From b0a6ee649521bde987095bf9def2841e791936c5 Mon Sep 17 00:00:00 2001
From: Jannis Pohlmann <jannis@xfce.org>
Date: Mon, 10 Nov 2008 13:10:52 +0000
Subject: [PATCH] Fix the /general/click_to_focus radio button synchronization
 with xfconf. The two radio buttons are now properly updated when the
 /general/click_to_focus property is changed outside of the dialog.

(Old svn revision: 28712)
---
 settings-dialogs/xfwm4-dialog.glade | 13 +++-----
 settings-dialogs/xfwm4-settings.c   | 47 ++++++++++++++++++++++++++---
 2 files changed, 48 insertions(+), 12 deletions(-)

diff --git a/settings-dialogs/xfwm4-dialog.glade b/settings-dialogs/xfwm4-dialog.glade
index 4fab73c18..e6f615431 100644
--- a/settings-dialogs/xfwm4-dialog.glade
+++ b/settings-dialogs/xfwm4-dialog.glade
@@ -1,10 +1,10 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Fri Oct 31 11:06:00 2008 -->
+<!--Generated with glade3 3.4.5 on Mon Nov 10 13:50:52 2008 -->
 <glade-interface>
   <requires lib="xfce4"/>
   <widget class="XfceTitledDialog" id="main-dialog">
-    <property name="title" translatable="yes">Window Manager</property>
+    <property name="title">Window Manager</property>
     <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
     <property name="icon_name">xfwm4</property>
     <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
@@ -431,7 +431,6 @@
                               <widget class="GtkTreeView" id="shortcuts_treeview">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
-                                <property name="headers_clickable">True</property>
                               </widget>
                             </child>
                           </widget>
@@ -531,26 +530,24 @@
                                 <property name="spacing">12</property>
                                 <property name="homogeneous">True</property>
                                 <child>
-                                  <widget class="GtkRadioButton" id="click_to_focus_mode">
+                                  <widget class="GtkRadioButton" id="click_to_focus_radio">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="label" translatable="yes">Clic_k to focus</property>
                                     <property name="use_underline">True</property>
                                     <property name="response_id">0</property>
-                                    <property name="active">True</property>
                                     <property name="draw_indicator">True</property>
                                   </widget>
                                 </child>
                                 <child>
-                                  <widget class="GtkRadioButton" id="radiobutton2">
+                                  <widget class="GtkRadioButton" id="focus_follows_mouse_radio">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="label" translatable="yes">Focus follows _mouse</property>
                                     <property name="use_underline">True</property>
                                     <property name="response_id">0</property>
-                                    <property name="active">True</property>
                                     <property name="draw_indicator">True</property>
-                                    <property name="group">click_to_focus_mode</property>
+                                    <property name="group">click_to_focus_radio</property>
                                   </widget>
                                   <packing>
                                     <property name="position">1</property>
diff --git a/settings-dialogs/xfwm4-settings.c b/settings-dialogs/xfwm4-settings.c
index a2ef5642b..2b234db7e 100644
--- a/settings-dialogs/xfwm4-settings.c
+++ b/settings-dialogs/xfwm4-settings.c
@@ -164,6 +164,10 @@ static void       xfwm_settings_double_click_action_property_changed (XfconfChan
                                                                       const gchar           *property,
                                                                       const GValue          *value,
                                                                       XfwmSettings          *settings);
+static void       xfwm_settings_click_to_focus_property_changed      (XfconfChannel         *channel,
+                                                                      const gchar           *property,
+                                                                      const GValue          *value,
+                                                                      XfwmSettings          *settings);
 static void       xfwm_settings_initialize_shortcuts                 (XfwmSettings          *settings);
 static void       xfwm_settings_reload_shortcuts                     (XfwmSettings          *settings);
 static void       xfwm_settings_shortcut_added                       (XfceShortcutsProvider *provider,
@@ -414,7 +418,7 @@ xfwm_settings_constructed (GObject *object)
   GtkWidget          *shortcuts_clear_button;
   GtkWidget          *shortcuts_reset_button;
   GtkWidget          *focus_delay_scale;
-  GtkWidget          *click_to_focus_mode;
+  GtkWidget          *click_to_focus_radio;
   GtkWidget          *raise_on_click_check;
   GtkWidget          *raise_on_focus_check;
   GtkWidget          *focus_new_check;
@@ -626,13 +630,10 @@ xfwm_settings_constructed (GObject *object)
   focus_new_check = glade_xml_get_widget (settings->priv->glade_xml, "focus_new_check");
   raise_on_focus_check = glade_xml_get_widget (settings->priv->glade_xml, "raise_on_focus_check");
   raise_on_click_check = glade_xml_get_widget (settings->priv->glade_xml, "raise_on_click_check");
-  click_to_focus_mode = glade_xml_get_widget (settings->priv->glade_xml, "click_to_focus_mode");
 
   /* Focus tab */
   xfconf_g_property_bind (settings->priv->wm_channel, "/general/focus_delay", G_TYPE_INT,
                           gtk_range_get_adjustment (GTK_RANGE (focus_delay_scale)), "value");
-  xfconf_g_property_bind (settings->priv->wm_channel, "/general/click_to_focus", G_TYPE_BOOLEAN,
-                          click_to_focus_mode, "active");
   xfconf_g_property_bind (settings->priv->wm_channel, "/general/raise_on_click", G_TYPE_BOOLEAN,
                           raise_on_click_check, "active");
   xfconf_g_property_bind (settings->priv->wm_channel, "/general/raise_on_focus", G_TYPE_BOOLEAN,
@@ -640,6 +641,14 @@ xfwm_settings_constructed (GObject *object)
   xfconf_g_property_bind (settings->priv->wm_channel, "/general/focus_new", G_TYPE_BOOLEAN,
                           focus_new_check, "active");
 
+  g_signal_connect (settings->priv->wm_channel, "property-changed::/general/click_to_focus", 
+                    G_CALLBACK (xfwm_settings_click_to_focus_property_changed), settings);
+  
+  xfconf_channel_get_property (settings->priv->wm_channel, "/general/click_to_focus", &value);
+  xfwm_settings_click_to_focus_property_changed (settings->priv->wm_channel, 
+                                                 "/general/click_to_focus", &value, settings);
+  g_value_unset (&value);
+
   /* Advanced tab widgets */
   box_move_check = glade_xml_get_widget (settings->priv->glade_xml, "box_move_check");
   box_resize_check = glade_xml_get_widget (settings->priv->glade_xml, "box_resize_check");
@@ -1582,6 +1591,36 @@ xfwm_settings_double_click_action_property_changed (XfconfChannel *channel,
 
 
 
+static void
+xfwm_settings_click_to_focus_property_changed (XfconfChannel *channel,
+                                               const gchar   *property,
+                                               const GValue  *value,
+                                               XfwmSettings  *settings)
+{
+  GtkWidget *click_to_focus_radio;
+  GtkWidget *focus_follows_mouse_radio;
+
+  g_return_if_fail (XFWM_IS_SETTINGS (settings));
+  g_return_if_fail (GLADE_IS_XML (settings->priv->glade_xml));
+
+  click_to_focus_radio = glade_xml_get_widget (settings->priv->glade_xml, 
+                                               "click_to_focus_radio");
+  focus_follows_mouse_radio = glade_xml_get_widget (settings->priv->glade_xml, 
+                                                    "focus_follows_mouse_radio");
+
+  if (G_UNLIKELY (G_VALUE_TYPE (value) != G_TYPE_BOOLEAN))
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (click_to_focus_radio), TRUE);
+  else 
+    {
+      if (g_value_get_boolean (value))
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (click_to_focus_radio), TRUE);
+      else
+        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (focus_follows_mouse_radio), TRUE);
+    }
+}
+
+
+
 static void
 xfwm_settings_initialize_shortcuts (XfwmSettings *settings)
 {
-- 
GitLab