Diff of /cbrpager-maemo/branches/MAEMO_0_9_20/src/conf.c [r19] .. [r20] Maximize Restore

  Switch to side-by-side view

--- a/cbrpager-maemo/branches/MAEMO_0_9_20/src/conf.c
+++ b/cbrpager-maemo/branches/MAEMO_0_9_20/src/conf.c
@@ -12,10 +12,12 @@
 #    define DEFAULT_WIDTH 700
 #    define DEFAULT_HEIGHT 480
 #    define DEFAULT_BUFFER_SIZE (10*1024)
+#    define GCONF_DIR "/apps/Maemo/" prog_name "/"
 #else
 #    define DEFAULT_WIDTH 480
 #    define DEFAULT_HEIGHT 640
 #    define DEFAULT_BUFFER_SIZE (1024*1024)
+#    define GCONF_DIR "/apps/" prog_name "/"
 #endif
 
 GtkListStore	*accel_store = NULL;
@@ -53,8 +55,9 @@
   {N_("Scroll up"),     "scroll_up",      0, 0},
   {N_("Scroll right"),  "scroll_right",   0, 0},
   {N_("Scroll left"),   "scroll_left",    0, 0},
+  {N_("Page up"),       "page_up",        0, HILDON_HARDKEY_LEFT},
   {N_("Page down"),     "page_down",      0, HILDON_HARDKEY_RIGHT},
-  {N_("Page up"),       "page_up",        0, HILDON_HARDKEY_LEFT},
+  {N_("Goto page"),     "goto_page",      0, GDK_g},
 };
 
 key_assignment key_asg1[] = {
@@ -76,8 +79,9 @@
   {N_("Scroll up"),     "scroll_up",      0, HILDON_HARDKEY_UP},
   {N_("Scroll right"),  "scroll_right",   0, HILDON_HARDKEY_RIGHT},
   {N_("Scroll left"),   "scroll_left",    0, HILDON_HARDKEY_LEFT},
+  {N_("Page up"),       "page_up",        0, 0},
   {N_("Page down"),     "page_down",      0, 0},
-  {N_("Page up"),       "page_up",        0, 0},
+  {N_("Goto page"),     "goto_page",      0, GDK_g},
 };
 
 key_assignment* key_asg = key_asg0;
@@ -102,8 +106,9 @@
   {N_("Scroll up"),     "scroll_up",      0, GDK_Up},
   {N_("Scroll right"),  "scroll_right",   0, GDK_Right},
   {N_("Scroll left"),   "scroll_left",    0, GDK_Left},
+  {N_("Page up"),       "page_up",        GDK_SHIFT_MASK, GDK_Up},
   {N_("Page down"),     "page_down",      GDK_SHIFT_MASK, GDK_Down},
-  {N_("Page up"),       "page_up",        GDK_SHIFT_MASK, GDK_Up},
+  {N_("Goto page"),     "goto_page",      0, GDK_g},
 };
 
 key_assignment* key_asg = key_asg0;
@@ -115,10 +120,10 @@
   ""
 };
 
-#define KEY_FMT "/%s/accel/%s_key"
-#define MODS_FMT "/%s/accel/%s_mods"
-#define KEY_FMT_ALT "/%s/accel/%s_key_alt"
-#define MODS_FMT_ALT "/%s/accel/%s_mods_alt"
+#define KEY_FMT "%saccel/%s_key"
+#define MODS_FMT "%saccel/%s_mods"
+#define KEY_FMT_ALT "%saccel/%s_key_alt"
+#define MODS_FMT_ALT "%saccel/%s_mods_alt"
 
 static void
 save_accels(GConfClient* client, 
@@ -130,9 +135,9 @@
   int ka;
   
   for (ka = 0; ka < nr_keys_assigned; ka++) {
-    g_sprintf(path, mod_fmt, prog_name, keys[ka].widget);
+    g_sprintf(path, mod_fmt, GCONF_DIR, keys[ka].widget);
     gconf_client_set_int(client, path, keys[ka].mods, NULL);
-    g_sprintf(path, key_fmt, prog_name, keys[ka].widget);
+    g_sprintf(path, key_fmt, GCONF_DIR, keys[ka].widget);
     gconf_client_set_int(client, path, keys[ka].accel, NULL);
   }
 }
@@ -146,59 +151,26 @@
 
   client = gconf_client_get_default();
 
-  g_sprintf(path, "/%s/global/lastbook", prog_name);
-  gconf_client_set_string(client, path, pref.lastbook, NULL);
-
-  g_sprintf(path, "/%s/global/fixed_dir", prog_name);
-  gconf_client_set_string(client, path, pref.fixeddir, NULL);
-
-  g_sprintf(path, "/%s/global/nextpage", prog_name);
-  gconf_client_set_int(client, path, pref.nextpage, NULL);
-
-  g_sprintf(path, "/%s/global/prevpage", prog_name);
-  gconf_client_set_int(client, path, pref.prevpage, NULL);
-
-  g_sprintf(path, "/%s/global/nrpages", prog_name);
-  gconf_client_set_int(client, path, pref.nrpages, NULL);
-
-  g_sprintf(path, "/%s/startup/width", prog_name);
-  gconf_client_set_int(client, path, pref.initwidth, NULL);
-
-  g_sprintf(path, "/%s/startup/height", prog_name);
-  gconf_client_set_int(client, path, pref.initheight, NULL);
-
-  g_sprintf(path, "/%s/global/nav_pos", prog_name);
-  gconf_client_set_int(client, path, pref.nav_pos, NULL);
-
-  g_sprintf(path, "/%s/global/nav_hor", prog_name);
-  gconf_client_set_int(client, path, pref.nav_hor, NULL);
-
-  g_sprintf(path, "/%s/global/dirmode", prog_name);
-  gconf_client_set_int(client, path, pref.dirmode, NULL);
-
-  g_sprintf(path, "/%s/global/nav_hidden", prog_name);
-  gconf_client_set_int(client, path, pref.nav_hidden, NULL);
-
-  g_sprintf(path, "/%s/global/pagenumber", prog_name);
-  gconf_client_set_int(client, path, pref.pagenumber, NULL);
-
-  g_sprintf(path, "/%s/global/manga_mode", prog_name);
-  gconf_client_set_int(client, path, pref.manga_mode, NULL);
-
-  g_sprintf(path, "/%s/global/auto_rotate", prog_name);
-  gconf_client_set_int(client, path, pref.auto_rotate, NULL);
-
-  g_sprintf(path, "/%s/global/zone_size", prog_name);
-  gconf_client_set_int(client, path, pref.zone_size, NULL);
-
-  g_sprintf(path, "/%s/global/buffer_size", prog_name);
-  gconf_client_set_int(client, path, pref.buffer_size, NULL);
-
-  g_sprintf(path, "/%s/global/scrollbars_fullscreen", prog_name);
-  gconf_client_set_int(client, path, pref.scrollbars_fullscreen, NULL);
-
-  g_sprintf(path, "/%s/global/rotate_ccw", prog_name);
-  gconf_client_set_int(client, path, pref.rotate_ccw, NULL);
+  gconf_client_set_string(client, GCONF_DIR "global/lastbook", pref.lastbook, NULL);
+  gconf_client_set_string(client, GCONF_DIR "global/fixed_dir", pref.fixeddir, NULL);
+
+  gconf_client_set_int(client, GCONF_DIR "global/nextpage", pref.nextpage, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/prevpage", pref.prevpage, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/nrpages", pref.nrpages, NULL);
+  gconf_client_set_int(client, GCONF_DIR "startup/width", pref.initwidth, NULL);
+  gconf_client_set_int(client, GCONF_DIR "startup/height", pref.initheight, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/nav_pos", pref.nav_pos, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/nav_hor", pref.nav_hor, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/dirmode", pref.dirmode, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/nav_hidden", pref.nav_hidden, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/pagenumber", pref.pagenumber, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/manga_mode", pref.manga_mode, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/auto_rotate", pref.auto_rotate, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/zone_size", pref.zone_size, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/buffer_size", pref.buffer_size, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/scrollbars_fullscreen", pref.scrollbars_fullscreen, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/rotate_ccw", pref.rotate_ccw, NULL);
+  gconf_client_set_int(client, GCONF_DIR "global/sort_order", pref.sort_order, NULL);
 
   save_accels(client, KEY_FMT, MODS_FMT, key_asg0);
 #if USE_HILDON
@@ -235,9 +207,9 @@
   gchar path[120];
   int ka;
   for (ka = 0; ka < nr_keys_assigned; ka++) {
-    g_sprintf(path, mod_fmt, prog_name, keys[ka].widget);
+    g_sprintf(path, mod_fmt, GCONF_DIR, keys[ka].widget);
     keys[ka].mods = gconf_client_get_int_with_default(client, path, keys[ka].mods);
-    g_sprintf(path, key_fmt, prog_name, keys[ka].widget);
+    g_sprintf(path, key_fmt, GCONF_DIR, keys[ka].widget);
     keys[ka].accel = gconf_client_get_int_with_default(client, path, keys[ka].accel);
   }
 }
@@ -252,62 +224,31 @@
   client = gconf_client_get_default();
   gconf_client_suggest_sync(client, NULL);
 
-  g_sprintf(path, "/%s/global/lastbook", prog_name);
-  strcpy(pref.lastbook, p = gconf_client_get_string_with_default(client, path, ""));
+  strcpy(pref.lastbook, 
+	 p = gconf_client_get_string_with_default(client, GCONF_DIR "global/lastbook", ""));
   g_free(p);
 
-  g_sprintf(path, "/%s/global/fixed_dir", prog_name);
-  strcpy(pref.fixeddir, p = gconf_client_get_string_with_default(client, path, ""));
+  strcpy(pref.fixeddir, 
+	 p = gconf_client_get_string_with_default(client, GCONF_DIR "global/fixed_dir", ""));
   g_free(p);
 
-  g_sprintf(path, "/%s/global/nextpage", prog_name);
-  pref.nextpage = gconf_client_get_int_with_default(client, path, 0);
-
-  g_sprintf(path, "/%s/global/prevpage", prog_name);
-  pref.prevpage = gconf_client_get_int_with_default(client, path, 0);
-
-  g_sprintf(path, "/%s/global/nrpages", prog_name);
-  pref.nrpages = gconf_client_get_int_with_default(client, path, 1);
-    
-  g_sprintf(path, "/%s/startup/width", prog_name);
-  pref.initwidth = gconf_client_get_int_with_default(client, path, DEFAULT_WIDTH);
-
-  g_sprintf(path, "/%s/startup/height", prog_name);
-  pref.initheight = gconf_client_get_int_with_default(client, path, DEFAULT_HEIGHT);
-
-  g_sprintf(path, "/%s/global/nav_pos", prog_name);
-  pref.nav_pos = gconf_client_get_int_with_default(client, path, NAV_SE);
-
-  g_sprintf(path, "/%s/global/nav_hor", prog_name);
-  pref.nav_hor = gconf_client_get_int_with_default(client, path, FALSE);
-
-  g_sprintf(path, "/%s/global/dirmode", prog_name);
-  pref.dirmode = gconf_client_get_int_with_default(client, path, 0);
-
-  g_sprintf(path, "/%s/global/nav_hidden", prog_name);
-  pref.nav_hidden = gconf_client_get_int_with_default(client, path, 0);
-
-  g_sprintf(path, "/%s/global/pagenumber", prog_name);
-  pref.pagenumber = gconf_client_get_int_with_default(client, path, 0);
-  
-  g_sprintf(path, "/%s/global/manga_mode", prog_name);
-  pref.manga_mode = gconf_client_get_int_with_default(client, path, 0);
-
-  g_sprintf(path, "/%s/global/auto_rotate", prog_name);
-  pref.auto_rotate = gconf_client_get_int_with_default(client, path, 0);
-
-  g_sprintf(path, "/%s/global/zone_size", prog_name);
-  pref.zone_size = gconf_client_get_int_with_default(client, path, DEFAULT_ZONE_SIZE);
-  
-  g_sprintf(path, "/%s/global/buffer_size", prog_name);
-  pref.buffer_size = gconf_client_get_int_with_default(client, path, DEFAULT_BUFFER_SIZE);
-
-  g_sprintf(path, "/%s/global/scrollbars_fullscreen", prog_name);
-  pref.scrollbars_fullscreen = gconf_client_get_int_with_default(client, path, 1);
-
-  g_sprintf(path, "/%s/global/rotate_ccw", prog_name);
-  pref.rotate_ccw = gconf_client_get_int_with_default(client, path, 0);
-
+  pref.nextpage = gconf_client_get_int_with_default(client, GCONF_DIR "global/nextpage", 0);
+  pref.prevpage = gconf_client_get_int_with_default(client, GCONF_DIR "global/prevpage", 0);
+  pref.nrpages = gconf_client_get_int_with_default(client, GCONF_DIR "global/nrpages", 1);
+  pref.initwidth = gconf_client_get_int_with_default(client, GCONF_DIR "startup/width", DEFAULT_WIDTH);
+  pref.initheight = gconf_client_get_int_with_default(client, GCONF_DIR "startup/height", DEFAULT_HEIGHT);
+  pref.nav_pos = gconf_client_get_int_with_default(client, GCONF_DIR "global/nav_pos", NAV_SE);
+  pref.nav_hor = gconf_client_get_int_with_default(client, GCONF_DIR "global/nav_hor", FALSE);
+  pref.dirmode = gconf_client_get_int_with_default(client, GCONF_DIR "global/dirmode", 0);
+  pref.nav_hidden = gconf_client_get_int_with_default(client, GCONF_DIR "global/nav_hidden", 0);
+  pref.pagenumber = gconf_client_get_int_with_default(client, GCONF_DIR "global/pagenumber", 0);
+  pref.manga_mode = gconf_client_get_int_with_default(client, GCONF_DIR "global/manga_mode", 0);
+  pref.auto_rotate = gconf_client_get_int_with_default(client, GCONF_DIR "global/auto_rotate", 0);
+  pref.zone_size = gconf_client_get_int_with_default(client, GCONF_DIR "global/zone_size", DEFAULT_ZONE_SIZE);
+  pref.buffer_size = gconf_client_get_int_with_default(client, GCONF_DIR "global/buffer_size", DEFAULT_BUFFER_SIZE);
+  pref.scrollbars_fullscreen = gconf_client_get_int_with_default(client, GCONF_DIR "global/scrollbars_fullscreen", 1);
+  pref.rotate_ccw = gconf_client_get_int_with_default(client, GCONF_DIR "global/rotate_ccw", 0);
+  pref.sort_order = gconf_client_get_int_with_default(client, GCONF_DIR "global/sort_order", 0);
 
   load_accels(client, KEY_FMT, MODS_FMT, key_asg0);
 #if USE_HILDON
@@ -369,7 +310,8 @@
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), pref.scrollbars_fullscreen ? TRUE : FALSE);
   w = lookup_widget(ref, "rotate_ccw");
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), pref.rotate_ccw ? TRUE : FALSE);
-
+  w = lookup_widget(ref, "sort_order");
+  gtk_combo_box_set_active(GTK_COMBO_BOX(w), pref.sort_order);
 
 #if !USE_HILDON
   switch (pref.nav_pos) {
@@ -480,6 +422,11 @@
 
   w = lookup_widget(ref, "rotate_ccw");
   pref.rotate_ccw = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
+
+  w = lookup_widget(ref, "sort_order");
+  pref.sort_order = gtk_combo_box_get_active(GTK_COMBO_BOX(w));
+  if(pref.sort_order == -1)
+    pref.sort_order = 0;
 
 #if !USE_HILDON
   w = lookup_widget(ref, "conf_nav_nw_rbtn");