[latexila] MainWindow: connect to notify::active-tab at the end of initialization



commit d8aa577597824ca92ac6db404826e29b0bf835df
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Aug 14 20:15:30 2017 +0200

    MainWindow: connect to notify::active-tab at the end of initialization
    
    When the signal is sent, all latexila widgets/objects must have been
    created (at least those used in the signal handler). To be sure that all
    objects are created, connect to the signal at the end of the MainWindow
    initialization. And set_tab_group() after connecting to the signals, so
    if the notebook already contains a tab, the signal handlers will be
    called.
    
    This commit has normally no visible effect in latexila, it is just to
    have safer and more future-proof code.

 src/main_window.vala |   60 +++++++++++++++++++++++++------------------------
 1 files changed, 31 insertions(+), 29 deletions(-)
---
diff --git a/src/main_window.vala b/src/main_window.vala
index db2ab4a..59141a3 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -154,37 +154,10 @@ public class MainWindow : ApplicationWindow
         Object (application: app);
         this.title = "LaTeXila";
 
-        /* TeplApplicationWindow */
-
+        // Init TeplApplicationWindow GActions.
         Tepl.ApplicationWindow tepl_window =
             Tepl.ApplicationWindow.get_from_gtk_application_window (this);
 
-        tepl_window.notify["active-tab"].connect (() =>
-        {
-            update_file_actions_sensitivity ();
-            update_config_project_sensitivity ();
-            update_cursor_position_statusbar ();
-            my_set_title ();
-
-            if (this.active_tab == null)
-            {
-                _goto_line.hide ();
-                _search_and_replace.hide ();
-            }
-
-            this.notify_property ("active-tab");
-        });
-
-        tepl_window.notify["active-view"].connect (() =>
-        {
-            this.notify_property ("active-view");
-        });
-
-        tepl_window.notify["active-buffer"].connect (() =>
-        {
-            this.notify_property ("active-document");
-        });
-
         /* GtkUIManager */
 
         initialize_ui_manager ();
@@ -262,7 +235,6 @@ public class MainWindow : ApplicationWindow
         // Documents panel
         init_documents_panel ();
         docs_vgrid.add (_documents_panel);
-        tepl_window.set_tab_group (_documents_panel);
 
         // Goto Line
         _goto_line = new GotoLine (this);
@@ -289,6 +261,36 @@ public class MainWindow : ApplicationWindow
 
         _tip_message_cid = _statusbar.get_context_id ("tip_message");
 
+        /* TeplApplicationWindow */
+
+        tepl_window.notify["active-tab"].connect (() =>
+        {
+            update_file_actions_sensitivity ();
+            update_config_project_sensitivity ();
+            update_cursor_position_statusbar ();
+            my_set_title ();
+
+            if (this.active_tab == null)
+            {
+                _goto_line.hide ();
+                _search_and_replace.hide ();
+            }
+
+            this.notify_property ("active-tab");
+        });
+
+        tepl_window.notify["active-view"].connect (() =>
+        {
+            this.notify_property ("active-view");
+        });
+
+        tepl_window.notify["active-buffer"].connect (() =>
+        {
+            this.notify_property ("active-document");
+        });
+
+        tepl_window.set_tab_group (_documents_panel);
+
         /* Other misc stuff */
 
         support_drag_and_drop ();


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