[gthumb: 3/3] added ability to change click policy from the preferences dialog



commit a77fb752efd970ef08f2c6431d7e78c75558e989
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Thu Dec 24 11:47:45 2015 +0100

    added ability to change click policy from the preferences dialog

 data/org.gnome.gthumb.gschema.xml.in |    6 +-
 data/ui/browser-preferences.ui       |   87 ++++++++++++++++++++++++++++++++--
 gthumb/dlg-preferences-browser.c     |   25 ++++++++++
 gthumb/gth-browser.c                 |   18 +++++++-
 gthumb/gth-preferences.h             |    2 +-
 5 files changed, 129 insertions(+), 9 deletions(-)
---
diff --git a/data/org.gnome.gthumb.gschema.xml.in b/data/org.gnome.gthumb.gschema.xml.in
index 3677594..ba2f272 100644
--- a/data/org.gnome.gthumb.gschema.xml.in
+++ b/data/org.gnome.gthumb.gschema.xml.in
@@ -80,6 +80,9 @@
     <key name="thumbnail-caption" type="s">
       <default>'comment::note,comment::time'</default>
     </key>
+    <key name="single-click-activation" type="b">
+      <default>true</default>
+    </key>
     <key name="sort-type" type="s">
       <default>'file::mtime'</default>
     </key>
@@ -95,9 +98,6 @@
     <key name="maximized" type="b">
       <default>false</default>
     </key>
-    <key name="image-pane-visible" type="b">
-      <default>true</default>
-    </key>
     <key name="statusbar-visible" type="b">
       <default>true</default>
     </key>
diff --git a/data/ui/browser-preferences.ui b/data/ui/browser-preferences.ui
index 2157ded..e085d64 100644
--- a/data/ui/browser-preferences.ui
+++ b/data/ui/browser-preferences.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.19.0 -->
 <interface>
   <requires lib="gtk+" version="3.12"/>
   <object class="GtkBox" id="browser_page">
@@ -17,9 +17,9 @@
           <object class="GtkLabel" id="label4">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="xalign">0</property>
             <property name="label" translatable="yes">Caption</property>
             <property name="use_markup">True</property>
+            <property name="xalign">0</property>
             <attributes>
               <attribute name="weight" value="bold"/>
             </attributes>
@@ -60,6 +60,85 @@
       </packing>
     </child>
     <child>
+      <object class="GtkBox" id="box4">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="spacing">6</property>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="label" translatable="yes">Behavior</property>
+            <property name="use_markup">True</property>
+            <property name="xalign">0</property>
+            <attributes>
+              <attribute name="weight" value="bold"/>
+            </attributes>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="box5">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin_left">12</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkRadioButton" id="single_click_radiobutton">
+                <property name="label" translatable="yes">_Single click to open files</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_underline">True</property>
+                <property name="xalign">0</property>
+                <property name="active">True</property>
+                <property name="draw_indicator">True</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">0</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkRadioButton" id="double_click_radiobutton">
+                <property name="label" translatable="yes">_Double click to open files</property>
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <property name="use_underline">True</property>
+                <property name="xalign">0</property>
+                <property name="active">True</property>
+                <property name="draw_indicator">True</property>
+                <property name="group">single_click_radiobutton</property>
+              </object>
+              <packing>
+                <property name="expand">False</property>
+                <property name="fill">True</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="fill">True</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+    <child>
       <object class="GtkBox" id="box3">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
@@ -69,9 +148,9 @@
           <object class="GtkLabel" id="label8">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="xalign">0</property>
             <property name="label" translatable="yes">Other</property>
             <property name="use_markup">True</property>
+            <property name="xalign">0</property>
             <attributes>
               <attribute name="weight" value="bold"/>
             </attributes>
@@ -182,7 +261,7 @@
       <packing>
         <property name="expand">False</property>
         <property name="fill">True</property>
-        <property name="position">1</property>
+        <property name="position">2</property>
       </packing>
     </child>
   </object>
diff --git a/gthumb/dlg-preferences-browser.c b/gthumb/dlg-preferences-browser.c
index b2dfc35..46c9485 100644
--- a/gthumb/dlg-preferences-browser.c
+++ b/gthumb/dlg-preferences-browser.c
@@ -98,6 +98,14 @@ thumbnail_caption_chooser_changed_cb (GthMetadataChooser *chooser,
 }
 
 
+static void
+click_behavior_changed_cb (GtkToggleButton *button,
+                          BrowserData     *data)
+{
+       g_settings_set_boolean (data->browser_settings, PREF_BROWSER_SINGLE_CLICK_ACTIVATION, 
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_click_radiobutton"))));
+}
+
+
 void
 browser__dlg_preferences_construct_cb (GtkWidget  *dialog,
                                       GthBrowser *browser,
@@ -125,6 +133,15 @@ browser__dlg_preferences_construct_cb (GtkWidget  *dialog,
        gth_metadata_chooser_set_selection (GTH_METADATA_CHOOSER (data->thumbnail_caption_chooser), 
current_caption);
        g_free (current_caption);
 
+       /* behavior */
+
+       if (g_settings_get_boolean (data->browser_settings, PREF_BROWSER_SINGLE_CLICK_ACTIVATION))
+               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_click_radiobutton")), 
TRUE);
+       else
+               gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("double_click_radiobutton")), 
TRUE);
+
+       /* other */
+
        gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("thumbnail_size_combobox")),
                                  get_idx_from_size (g_settings_get_int (data->browser_settings, 
PREF_BROWSER_THUMBNAIL_SIZE)));
        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("slow_mime_type_checkbutton")),
@@ -140,6 +157,14 @@ browser__dlg_preferences_construct_cb (GtkWidget  *dialog,
                          "toggled",
                          G_CALLBACK (fast_file_type_toggled_cb),
                          data);
+       g_signal_connect (G_OBJECT (GET_WIDGET ("single_click_radiobutton")),
+                         "toggled",
+                         G_CALLBACK (click_behavior_changed_cb),
+                         data);
+       g_signal_connect (G_OBJECT (GET_WIDGET ("double_click_radiobutton")),
+                         "toggled",
+                         G_CALLBACK (click_behavior_changed_cb),
+                         data);
        g_signal_connect (G_OBJECT (data->thumbnail_caption_chooser),
                          "changed",
                          G_CALLBACK (thumbnail_caption_chooser_changed_cb),
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index e77dfa4..a5ee3e3 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -4155,6 +4155,18 @@ pref_thumbnail_caption_changed (GSettings  *settings,
 }
 
 
+static void
+pref_single_click_activation_changed (GSettings  *settings,
+                                     const char *key,
+                                     gpointer    user_data)
+{
+       GthBrowser *browser = user_data;
+       gboolean    single_click = g_settings_get_boolean (settings, key);
+
+       gth_file_view_set_activate_on_single_click (GTH_FILE_VIEW (gth_file_list_get_view (GTH_FILE_LIST 
(browser->priv->file_list))), single_click);
+}
+
+
 static gboolean
 _gth_browser_realize (GtkWidget *browser,
                      gpointer  *data)
@@ -4766,7 +4778,7 @@ gth_browser_init (GthBrowser *browser)
                                      g_settings_get_int (browser->priv->browser_settings, 
PREF_BROWSER_THUMBNAIL_SIZE));
        caption = g_settings_get_string (browser->priv->browser_settings, PREF_BROWSER_THUMBNAIL_CAPTION);
        gth_file_list_set_caption (GTH_FILE_LIST (browser->priv->file_list), caption);
-       gth_file_view_set_activate_on_single_click (GTH_FILE_VIEW (gth_file_list_get_view (GTH_FILE_LIST 
(browser->priv->file_list))), FALSE);
+       gth_file_view_set_activate_on_single_click (GTH_FILE_VIEW (gth_file_list_get_view (GTH_FILE_LIST 
(browser->priv->file_list))), g_settings_get_boolean (browser->priv->browser_settings, 
PREF_BROWSER_SINGLE_CLICK_ACTIVATION));
 
        g_free (caption);
        g_free (sort_type);
@@ -4987,6 +4999,10 @@ gth_browser_init (GthBrowser *browser)
                          "changed::" PREF_BROWSER_THUMBNAIL_CAPTION,
                          G_CALLBACK (pref_thumbnail_caption_changed),
                          browser);
+       g_signal_connect (browser->priv->browser_settings,
+                         "changed::" PREF_BROWSER_SINGLE_CLICK_ACTIVATION,
+                         G_CALLBACK (pref_single_click_activation_changed),
+                         browser);
 
        browser->priv->constructed = TRUE;
 }
diff --git a/gthumb/gth-preferences.h b/gthumb/gth-preferences.h
index 26799bd..d28937c 100644
--- a/gthumb/gth-preferences.h
+++ b/gthumb/gth-preferences.h
@@ -61,7 +61,7 @@ G_BEGIN_DECLS
 #define PREF_BROWSER_THUMBNAIL_SIZE           "thumbnail-size"
 #define PREF_BROWSER_THUMBNAIL_LIMIT          "thumbnail-limit"
 #define PREF_BROWSER_THUMBNAIL_CAPTION        "thumbnail-caption"
-#define PREF_BROWSER_CLICK_POLICY             "click-policy"
+#define PREF_BROWSER_SINGLE_CLICK_ACTIVATION  "single-click-activation"
 #define PREF_BROWSER_SORT_TYPE                "sort-type"
 #define PREF_BROWSER_SORT_INVERSE             "sort-inverse"
 #define PREF_BROWSER_WINDOW_WIDTH             "window-width"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]