[gnome-builder/document-manager] editor-view: keep split state in sync with toggle button



commit b5c65e77bd8155e93109101aa95a72395c310cad
Author: Christian Hergert <christian hergert me>
Date:   Mon Dec 8 16:47:40 2014 -0800

    editor-view: keep split state in sync with toggle button

 src/editor/gb-editor-view.c        |   20 +++++++++++++++++++-
 src/resources/ui/gb-editor-view.ui |    1 -
 2 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/src/editor/gb-editor-view.c b/src/editor/gb-editor-view.c
index cb301fe..af2d64b 100644
--- a/src/editor/gb-editor-view.c
+++ b/src/editor/gb-editor-view.c
@@ -145,15 +145,27 @@ gb_editor_view_toggle_split (GbEditorView *view)
 }
 
 static void
+gb_editor_view_split_button_toggled (GbEditorView    *view,
+                                     GtkToggleButton *button)
+{
+  g_return_if_fail (GB_IS_EDITOR_VIEW (view));
+
+  gb_editor_view_toggle_split (view);
+}
+
+
+static void
 gb_editor_view_toggle_split_activate (GSimpleAction *action,
                                       GVariant      *parameter,
                                       gpointer       user_data)
 {
   GbEditorView *view = user_data;
+  gboolean active;
 
   g_return_if_fail (GB_IS_EDITOR_VIEW (view));
 
-  gb_editor_view_toggle_split (view);
+  active = gtk_toggle_button_get_active (view->priv->split_button);
+  gtk_toggle_button_set_active (view->priv->split_button, !active);
 }
 
 static void
@@ -263,4 +275,10 @@ gb_editor_view_init (GbEditorView *self)
   gtk_widget_insert_action_group (GTK_WIDGET (self), "editor-view",
                                   G_ACTION_GROUP (actions));
   g_object_unref (actions);
+
+  g_signal_connect_object (self->priv->split_button,
+                           "toggled",
+                           G_CALLBACK (gb_editor_view_split_button_toggled),
+                           self,
+                           G_CONNECT_SWAPPED);
 }
diff --git a/src/resources/ui/gb-editor-view.ui b/src/resources/ui/gb-editor-view.ui
index 31db980..ff47a36 100644
--- a/src/resources/ui/gb-editor-view.ui
+++ b/src/resources/ui/gb-editor-view.ui
@@ -11,7 +11,6 @@
         <child>
           <object class="GtkToggleButton" id="split_button">
             <property name="visible">true</property>
-            <property name="action_name">editor-view.toggle-split</property>
             <style>
               <class name="image-button"/>
               <class name="tab-control-first"/>


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