diff --git a/Makefile b/Makefile index c7429f9e..24e8d2fa 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ CPPLIB = -lstdc++ CFLAGS = -I ~/include -O3 $(WARNS) $(LIBS) `pkg-config --cflags glib-2.0` OBJS = log.o windows.o title_bar.o status_bar.o input_win.o jabber.o \ profanity.o util.o command.o history.o contact_list.o prof_history.o \ - contact.o main.o + contact.o preferences.o main.o TESTOBJS = test_contact_list.o contact_list.o contact.o \ test_util.o test_prof_history.o prof_history.o util.o @@ -20,13 +20,14 @@ title_bar.o: windows.h status_bar.o: windows.h util.h input_win.o: windows.h jabber.o: jabber.h log.h windows.h contact_list.h -profanity.o: log.h windows.h jabber.h command.h +profanity.o: log.h windows.h jabber.h command.h preferences.h util.o: util.h command.o: command.h util.h history.h contact_list.h history.o: history.h prof_history.h contact_list.o: contact_list.h contact.h prof_history.o: prof_history.h contact.o: contact.h +preferences.o: preferences.h windows.h main.o: profanity.h test_contact_list.o: contact_list.h contact.h diff --git a/preferences.c b/preferences.c new file mode 100644 index 00000000..f5e5284a --- /dev/null +++ b/preferences.c @@ -0,0 +1,44 @@ +/* + * preferences.c + * + * Copyright (C) 2012 James Booth + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see . + * + */ + +#include + +#include "windows.h" + +void prefs_load(void) +{ + GKeyFile *g_prefs = g_key_file_new(); + + g_key_file_load_from_file(g_prefs, "/home/james/.profanity", + G_KEY_FILE_NONE, NULL); + + gboolean beep = g_key_file_get_boolean(g_prefs, "settings", "beep", NULL); + gboolean flash = g_key_file_get_boolean(g_prefs, "settings", "flash", NULL); + + win_set_beep(beep); + status_bar_set_flash(flash); + +// g_key_file_set_string(g_prefs, "settings", "somekey2", "someothervalue"); +// gsize g_data_len; +// char *g_prefs_data = g_key_file_to_data(g_prefs, &g_data_len, NULL); +// g_file_set_contents("/home/james/.profanity", g_prefs_data, g_data_len, NULL); +} diff --git a/preferences.h b/preferences.h new file mode 100644 index 00000000..a1349592 --- /dev/null +++ b/preferences.h @@ -0,0 +1,28 @@ +/* + * preferences.h + * + * Copyright (C) 2012 James Booth + * + * This file is part of Profanity. + * + * Profanity is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Profanity is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Profanity. If not, see . + * + */ + +#ifndef PREFERENCES_H +#define PREFERENCES_H + +void prefs_load(void); + +#endif diff --git a/profanity.c b/profanity.c index f87fca6a..ad914567 100644 --- a/profanity.c +++ b/profanity.c @@ -29,6 +29,7 @@ #include "windows.h" #include "jabber.h" #include "command.h" +#include "preferences.h" static void _profanity_shutdown(void); @@ -67,6 +68,7 @@ void profanity_init(const int disable_tls) gui_init(); jabber_init(disable_tls); command_init(); + prefs_load(); atexit(_profanity_shutdown); } diff --git a/windows.c b/windows.c index eeb2a5ab..6462a790 100644 --- a/windows.c +++ b/windows.c @@ -50,7 +50,7 @@ static int dirty; static int max_cols = 0; // allow beep? -static int do_beep = TRUE; +static int do_beep = FALSE; static void _create_windows(void); static int _find_prof_win_index(const char * const contact);