[devhelp: 19/36] preferences: Connect new 'group by language' option with the configuration
- From: Aleksander Morgado <aleksm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp: 19/36] preferences: Connect new 'group by language' option with the configuration
- Date: Mon, 20 Dec 2010 14:33:01 +0000 (UTC)
commit ca78226d886dd18f12ff57cc91b4e1b13b5695ad
Author: Aleksander Morgado <aleksander lanedo com>
Date: Thu Dec 9 16:15:08 2010 +0100
preferences: Connect new 'group by language' option with the configuration
data/devhelp.schemas.in | 14 +++++++++++++-
src/dh-preferences.c | 40 ++++++++++++++++++++++++++++++----------
src/dh-util.c | 23 +++++++++++++++++++++++
src/dh-util.h | 3 +++
4 files changed, 69 insertions(+), 11 deletions(-)
---
diff --git a/data/devhelp.schemas.in b/data/devhelp.schemas.in
index 38bb62b..a2e9d84 100644
--- a/data/devhelp.schemas.in
+++ b/data/devhelp.schemas.in
@@ -24,7 +24,7 @@
<long>The width of the main window.</long>
</locale>
</schema>
-
+
<schema>
<key>/schemas/apps/devhelp/state/main/window/height</key>
<applyto>/apps/devhelp/state/main/window/height</applyto>
@@ -126,6 +126,7 @@
<long>Which of the tabs is selected: "content" or "search".</long>
</locale>
</schema>
+
<schema>
<key>/schemas/apps/devhelp/state/main/contents/books_disabled</key>
<applyto>/apps/devhelp/state/main/contents/books_disabled</applyto>
@@ -138,6 +139,17 @@
<long>List of books disabled by the user.</long>
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/devhelp/state/main/contents/group_books_by_language</key>
+ <applyto>/apps/devhelp/state/main/contents/group_books_by_language</applyto>
+ <owner>devhelp</owner>
+ <type>bool</type>
+ <default>false</default>
+ <locale name="C">
+ <short>Group by language</short>
+ <long>Whether books should be grouped by language in the UI</long>
+ </locale>
+ </schema>
<schema>
<key>/schemas/apps/devhelp/ui/use_system_fonts</key>
diff --git a/src/dh-preferences.c b/src/dh-preferences.c
index 98ba531..eea5196 100644
--- a/src/dh-preferences.c
+++ b/src/dh-preferences.c
@@ -45,6 +45,7 @@ typedef struct {
DhBookManager *book_manager;
GtkTreeView *booklist_treeview;
GtkListStore *booklist_store;
+ GtkWidget *group_by_language_button;
} DhPreferences;
/* Fonts-tab related */
@@ -69,16 +70,18 @@ static void preferences_fonts_get_font_names (gboolean u
gchar **fixed);
/* Bookshelf-tab related */
-static void preferences_bookshelf_tree_selection_toggled_cb (GtkCellRendererToggle *cell_renderer,
- gchar *path,
- gpointer user_data);
-static void preferences_bookshelf_populate_store (void);
-static void preferences_bookshelf_book_created_cb (DhBookManager *book_manager,
- GObject *book_object,
- gpointer user_data);
-static void preferences_bookshelf_book_deleted_cb (DhBookManager *book_manager,
- GObject *book_object,
- gpointer user_data);
+static void preferences_bookshelf_tree_selection_toggled_cb (GtkCellRendererToggle *cell_renderer,
+ gchar *path,
+ gpointer user_data);
+static void preferences_bookshelf_populate_store (void);
+static void preferences_bookshelf_book_created_cb (DhBookManager *book_manager,
+ GObject *book_object,
+ gpointer user_data);
+static void preferences_bookshelf_book_deleted_cb (DhBookManager *book_manager,
+ GObject *book_object,
+ gpointer user_data);
+static void preferences_bookshelf_group_by_language_toggled_cb (GtkToggleButton *button,
+ gpointer user_data);
#define DH_CONF_PATH "/apps/devhelp"
#define DH_CONF_USE_SYSTEM_FONTS DH_CONF_PATH "/ui/use_system_fonts"
@@ -86,6 +89,7 @@ static void preferences_bookshelf_book_deleted_cb (DhBookManager
#define DH_CONF_FIXED_FONT DH_CONF_PATH "/ui/fixed_font"
#define DH_CONF_SYSTEM_VARIABLE_FONT "/desktop/gnome/interface/font_name"
#define DH_CONF_SYSTEM_FIXED_FONT "/desktop/gnome/interface/monospace_font_name"
+#define DH_CONF_GROUP_BY_LANGUAGE DH_CONF_PATH "/ui/use_system_fonts"
/* Book list store columns... */
#define LTCOLUMN_ENABLED 0
@@ -451,6 +455,18 @@ preferences_dialog_response (GtkDialog *dialog,
preferences_shutdown ();
}
+static void
+preferences_bookshelf_group_by_language_toggled_cb (GtkToggleButton *button,
+ gpointer user_data)
+{
+ DhPreferences *prefs = user_data;
+ gboolean active;
+
+ active = gtk_toggle_button_get_active (button);
+
+ dh_util_state_store_group_books_by_language (active);
+}
+
void
dh_preferences_show_dialog (GtkWindow *parent)
{
@@ -480,6 +496,7 @@ dh_preferences_show_dialog (GtkWindow *parent)
"fixed_font_button", &prefs->fixed_font_button,
"book_manager_store", &prefs->booklist_store,
"book_manager_treeview", &prefs->booklist_treeview,
+ "group_by_language_button", &prefs->group_by_language_button,
NULL);
g_free (path);
@@ -490,6 +507,7 @@ dh_preferences_show_dialog (GtkWindow *parent)
"fixed_font_button", "font_set", preferences_fonts_font_set_cb,
"system_fonts_button", "toggled", preferences_fonts_system_fonts_toggled_cb,
"book_manager_toggle", "toggled", preferences_bookshelf_tree_selection_toggled_cb,
+ "group_by_language_button", "toggled", preferences_bookshelf_group_by_language_toggled_cb,
NULL);
ige_conf_get_bool (ige_conf_get (),
@@ -513,6 +531,8 @@ dh_preferences_show_dialog (GtkWindow *parent)
g_free (fixed_font_name);
}
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs->group_by_language_button),
+ dh_util_state_load_group_books_by_language ());
preferences_bookshelf_populate_store ();
g_object_unref (builder);
diff --git a/src/dh-util.c b/src/dh-util.c
index c9ce206..bf5d4c7 100644
--- a/src/dh-util.c
+++ b/src/dh-util.c
@@ -487,6 +487,29 @@ dh_util_state_store_books_disabled (GSList *books_disabled)
g_free (key);
}
+gboolean
+dh_util_state_load_group_books_by_language (void)
+{
+ gchar *key;
+ gboolean group_books_by_language = FALSE;
+
+ key = util_state_get_key ("main/contents", "group_books_by_language");
+ ige_conf_get_bool (ige_conf_get (), key, &group_books_by_language);
+ g_free (key);
+
+ return group_books_by_language;
+}
+
+void
+dh_util_state_store_group_books_by_language (gboolean group_books_by_language)
+{
+ gchar *key;
+
+ key = util_state_get_key ("main/contents", "group_books_by_language");
+ ige_conf_set_bool (ige_conf_get (), key, group_books_by_language);
+ g_free (key);
+}
+
static gboolean
util_state_notebook_timeout_cb (gpointer notebook)
{
diff --git a/src/dh-util.h b/src/dh-util.h
index 6f126d5..d595e01 100644
--- a/src/dh-util.h
+++ b/src/dh-util.h
@@ -52,6 +52,9 @@ const gchar *dh_util_state_get_notebook_page_name (GtkWidget *page);
GSList * dh_util_state_load_books_disabled (void);
void dh_util_state_store_books_disabled (GSList *books_disabled);
+gboolean dh_util_state_load_group_books_by_language (void);
+void dh_util_state_store_group_books_by_language (gboolean group_books_by_language);
+
void dh_util_font_get_variable (gchar **name,
gdouble *size,
gboolean use_system_font);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]