[latexila] SidePanel: emit closed signal



commit 44ff7003acf13276b13bda087f0ad6d36c7b2d20
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Thu Apr 5 06:20:47 2012 +0200

    SidePanel: emit closed signal
    
    It's cleaner than passing a ToggleAction as a parameter.

 src/main_window.vala |    5 ++++-
 src/side_panel.vala  |   10 ++++++----
 2 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/src/main_window.vala b/src/main_window.vala
index ce4811e..0406d3d 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -305,9 +305,12 @@ public class MainWindow : Window
         build_view = new BuildView (this, build_toolbar, action_view_bottom_panel);
 
         // side panel
+        _side_panel = new SidePanel ();
+
         ToggleAction action_view_side_panel =
             action_group.get_action ("ViewSidePanel") as ToggleAction;
-        _side_panel = new SidePanel (action_view_side_panel);
+
+        _side_panel.closed.connect (() => action_view_side_panel.active = false);
 
         symbols = new Symbols (this);
         _side_panel.add_component (_("Symbols"), "symbol_alpha", symbols);
diff --git a/src/side_panel.vala b/src/side_panel.vala
index 510dbff..37faecb 100644
--- a/src/side_panel.vala
+++ b/src/side_panel.vala
@@ -34,7 +34,9 @@ public class SidePanel : Grid
     private ListStore _list_store;
     private int _current_component = -1;
 
-    public SidePanel (ToggleAction action_view_side_panel)
+    public signal void closed ();
+
+    public SidePanel ()
     {
         _settings = new GLib.Settings ("org.gnome.latexila.preferences.ui");
         _components = new Gee.ArrayList<Grid?> ();
@@ -45,7 +47,7 @@ public class SidePanel : Grid
         row_spacing = 3;
 
         init_combo_box ();
-        Button close_button = get_close_button (action_view_side_panel);
+        Button close_button = get_close_button ();
 
         attach (_combo_box, 0, 0, 1, 1);
         attach (close_button, 1, 0, 1, 1);
@@ -77,7 +79,7 @@ public class SidePanel : Grid
         _combo_box.changed.connect (show_active_component);
     }
 
-    private Button get_close_button (ToggleAction action_view_side_panel)
+    private Button get_close_button ()
     {
         Button close_button = new Button ();
         close_button.relief = ReliefStyle.NONE;
@@ -88,7 +90,7 @@ public class SidePanel : Grid
         close_button.clicked.connect (() =>
         {
             this.hide ();
-            action_view_side_panel.active = false;
+            closed ();
         });
 
         return close_button;



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