[latexila] MainWindow: bind TeplTabGroup properties



commit a32abc5063295315bd290ee6e93c9fb3088d21ee
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Mon Aug 14 19:44:19 2017 +0200

    MainWindow: bind TeplTabGroup properties

 src/main_window.vala |   51 ++++++++++++++++++++++++++++++-------------------
 1 files changed, 31 insertions(+), 20 deletions(-)
---
diff --git a/src/main_window.vala b/src/main_window.vala
index 0ee86d4..4b2c89e 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -113,16 +113,16 @@ public class MainWindow : ApplicationWindow
     {
         get
         {
-            if (_documents_panel == null)
-                return null;
-            return (DocumentTab?) _documents_panel.active_tab;
+            Tepl.ApplicationWindow tepl_window =
+                Tepl.ApplicationWindow.get_from_gtk_application_window (this);
+            return tepl_window.get_active_tab () as DocumentTab?;
         }
 
         set
         {
-            int n = _documents_panel.page_num (value);
-            if (n != -1)
-                _documents_panel.set_current_page (n);
+            Tepl.ApplicationWindow tepl_window =
+                Tepl.ApplicationWindow.get_from_gtk_application_window (this);
+            tepl_window.set_active_tab (value);
         }
     }
 
@@ -130,9 +130,9 @@ public class MainWindow : ApplicationWindow
     {
         get
         {
-            if (active_tab == null)
-                return null;
-            return active_tab.document_view;
+            Tepl.ApplicationWindow tepl_window =
+                Tepl.ApplicationWindow.get_from_gtk_application_window (this);
+            return tepl_window.get_active_view () as DocumentView?;
         }
     }
 
@@ -140,9 +140,9 @@ public class MainWindow : ApplicationWindow
     {
         get
         {
-            if (active_tab == null)
-                return null;
-            return active_tab.document;
+            Tepl.ApplicationWindow tepl_window =
+                Tepl.ApplicationWindow.get_from_gtk_application_window (this);
+            return tepl_window.get_active_buffer () as Document?;
         }
     }
 
@@ -154,9 +154,28 @@ public class MainWindow : ApplicationWindow
         Object (application: app);
         this.title = "LaTeXila";
 
+        /* TeplApplicationWindow */
+
         Tepl.ApplicationWindow tepl_window =
             Tepl.ApplicationWindow.get_from_gtk_application_window (this);
 
+        tepl_window.notify["active-tab"].connect (() =>
+        {
+            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 ();
 
         _main_window_file = new MainWindowFile (this, _ui_manager);
@@ -466,10 +485,6 @@ public class MainWindow : ApplicationWindow
                 set_file_actions_sensitivity (false);
                 _goto_line.hide ();
                 _search_and_replace.hide ();
-
-                notify_property ("active-tab");
-                notify_property ("active-document");
-                notify_property ("active-view");
             }
 
             my_set_title ();
@@ -483,10 +498,6 @@ public class MainWindow : ApplicationWindow
             update_config_project_sensitivity ();
             my_set_title ();
             update_cursor_position_statusbar ();
-
-            notify_property ("active-tab");
-            notify_property ("active-document");
-            notify_property ("active-view");
         });
     }
 


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