[latexila] Show/hide the side panel by binding properties



commit 952d03c764c12fb1db57ae3e23f6a257b844e992
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Tue Jul 10 03:57:39 2012 +0200

    Show/hide the side panel by binding properties

 src/main_window.vala |   19 ++++---------------
 src/side_panel.vala  |    8 +-------
 2 files changed, 5 insertions(+), 22 deletions(-)
---
diff --git a/src/main_window.vala b/src/main_window.vala
index 30e4b24..eb9dc80 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -171,7 +171,7 @@ public class MainWindow : Window
         { "ViewEditToolbar", null, N_("_Edit Toolbar"), null,
             N_("Show or hide the edit toolbar"), on_show_edit_toolbar },
         { "ViewSidePanel", null, N_("_Side panel"), "<Release>F12",
-            N_("Show or hide the side panel"), on_show_side_panel },
+            N_("Show or hide the side panel"), null },
         { "ViewBottomPanel", null, N_("_Bottom panel"), null,
             N_("Show or hide the bottom panel"), null },
         { "BuildShowWarnings", Stock.DIALOG_WARNING, N_("Show _Warnings"), null,
@@ -315,7 +315,8 @@ public class MainWindow : Window
         ToggleAction action_view_side_panel =
             action_group.get_action ("ViewSidePanel") as ToggleAction;
 
-        _side_panel.closed.connect (() => action_view_side_panel.active = false);
+        _side_panel.bind_property ("visible", action_view_side_panel, "active",
+            BindingFlags.BIDIRECTIONAL);
 
         _symbols = new SymbolsView (this);
         _side_panel.add_component (_("Symbols"), "symbol_greek", _symbols);
@@ -665,10 +666,7 @@ public class MainWindow : Window
         /* side panel */
         show = settings.get_boolean ("side-panel-visible");
 
-        if (! show)
-            _side_panel.hide ();
-
-        action = (ToggleAction) action_group.get_action ("ViewSidePanel");
+        action = action_group.get_action ("ViewSidePanel") as ToggleAction;
         action.set_active (show);
 
         /* bottom panel */
@@ -1669,15 +1667,6 @@ public class MainWindow : Window
 
     /* View */
 
-    public void on_show_side_panel (Gtk.Action action)
-    {
-        bool show = (action as ToggleAction).active;
-        if (show)
-            _side_panel.show ();
-        else
-            _side_panel.hide ();
-    }
-
     public void on_show_main_toolbar (Gtk.Action action)
     {
         bool show = (action as ToggleAction).active;
diff --git a/src/side_panel.vala b/src/side_panel.vala
index 37faecb..970ff3c 100644
--- a/src/side_panel.vala
+++ b/src/side_panel.vala
@@ -34,8 +34,6 @@ public class SidePanel : Grid
     private ListStore _list_store;
     private int _current_component = -1;
 
-    public signal void closed ();
-
     public SidePanel ()
     {
         _settings = new GLib.Settings ("org.gnome.latexila.preferences.ui");
@@ -87,11 +85,7 @@ public class SidePanel : Grid
         close_button.tooltip_text = _("Hide panel");
         close_button.add (new Image.from_stock (Stock.CLOSE, IconSize.MENU));
 
-        close_button.clicked.connect (() =>
-        {
-            this.hide ();
-            closed ();
-        });
+        close_button.clicked.connect (() => this.hide ());
 
         return close_button;
     }



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