mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added preferences
This commit is contained in:
parent
d7cee5bec9
commit
6d5d41b33a
5
Makefile
5
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
|
||||
|
44
preferences.c
Normal file
44
preferences.c
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* preferences.c
|
||||
*
|
||||
* Copyright (C) 2012 James Booth <boothj5@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#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);
|
||||
}
|
28
preferences.h
Normal file
28
preferences.h
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
* preferences.h
|
||||
*
|
||||
* Copyright (C) 2012 James Booth <boothj5@gmail.com>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PREFERENCES_H
|
||||
#define PREFERENCES_H
|
||||
|
||||
void prefs_load(void);
|
||||
|
||||
#endif
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user