[latexila] Use the new GtkApplication:active-window property



commit 91bc3fa7805762e374e8a17e6642e9b61de2d724
Author: SÃbastien Wilmet <swilmet gnome org>
Date:   Fri Jan 25 18:20:11 2013 +0100

    Use the new GtkApplication:active-window property
    
    And bump version requirements.

 configure.ac        |    4 ++--
 src/completion.vala |    2 +-
 src/latexila.vala   |   38 ++++++++++++--------------------------
 src/synctex.vala    |    4 ++--
 4 files changed, 17 insertions(+), 31 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 8d766db..ae2cd2d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -25,9 +25,9 @@ LT_INIT
 
 # Required dependencies versions
 GLIB_REQUIRED_VERSION="2.32"
-GTK_REQUIRED_VERSION="3.4.3"
+GTK_REQUIRED_VERSION="3.6.0"
 GTKSOURCEVIEW_REQUIRED_VERSION="3.4.1"
-VALA_REQUIRED_VERSION="0.17.3.1"
+VALA_REQUIRED_VERSION="0.18"
 
 AC_SUBST([GLIB_REQUIRED_VERSION])
 AC_SUBST([GTK_REQUIRED_VERSION])
diff --git a/src/completion.vala b/src/completion.vala
index e1480d7..5c0fe31 100644
--- a/src/completion.vala
+++ b/src/completion.vala
@@ -329,7 +329,7 @@ public class CompletionProvider : GLib.Object, SourceCompletionProvider
 
         _calltip_window_label.set_markup (markup);
 
-        MainWindow window = Latexila.get_instance ().active_window;
+        MainWindow window = Latexila.get_instance ().active_window as MainWindow;
         _calltip_window.set_transient_for (window);
         _calltip_window.set_attached_to (window.active_view);
 
diff --git a/src/latexila.vala b/src/latexila.vala
index e49064f..3d5ef6a 100644
--- a/src/latexila.vala
+++ b/src/latexila.vala
@@ -21,8 +21,6 @@
 
 public class Latexila : Gtk.Application
 {
-    public MainWindow active_window { get; private set; }
-
     public Latexila ()
     {
         Object (application_id: "org.gnome.latexila");
@@ -51,16 +49,6 @@ public class Latexila : Gtk.Application
             MostUsedSymbols.get_default ().save ();
             release ();
         });
-
-        window_removed.connect (() =>
-        {
-            hold ();
-            unowned List<weak Gtk.Window> windows = get_windows ();
-            if (0 < windows.length ())
-                active_window = windows.data as MainWindow;
-
-            release ();
-        });
     }
 
     private void add_actions ()
@@ -72,7 +60,8 @@ public class Latexila : Gtk.Application
         new_document_action.activate.connect (() =>
         {
             hold ();
-            active_window.create_tab (true);
+            MainWindow window = active_window as MainWindow;
+            window.create_tab (true);
             release ();
         });
 
@@ -199,20 +188,16 @@ public class Latexila : Gtk.Application
     public MainWindow create_window ()
     {
         if (active_window != null)
-            active_window.save_state ();
-
-        MainWindow window = new MainWindow ();
-        add_window (window);
-        active_window = window;
-
-        window.focus_in_event.connect (() =>
         {
-            active_window = window;
-            return false;
-        });
+            MainWindow window = active_window as MainWindow;
+            window.save_state ();
+        }
+
+        MainWindow new_window = new MainWindow ();
+        add_window (new_window);
+        new_window.show ();
 
-        window.show ();
-        return window;
+        return new_window;
     }
 
     public void open_documents (File[] files)
@@ -220,7 +205,8 @@ public class Latexila : Gtk.Application
         bool jump_to = true;
         foreach (File file in files)
         {
-            active_window.open_document (file, jump_to);
+            MainWindow window = active_window as MainWindow;
+            window.open_document (file, jump_to);
             jump_to = false;
         }
     }
diff --git a/src/synctex.vala b/src/synctex.vala
index 380980c..eeceea5 100644
--- a/src/synctex.vala
+++ b/src/synctex.vala
@@ -116,7 +116,7 @@ public class Synctex : Object
 
     private void show_warning (string message)
     {
-        MainWindow main_window = Latexila.get_instance ().active_window;
+        MainWindow main_window = Latexila.get_instance ().active_window as MainWindow;
 
         MessageDialog dialog = new MessageDialog (main_window,
             DialogFlags.DESTROY_WITH_PARENT,
@@ -256,7 +256,7 @@ public class Synctex : Object
                 return;
             }
 
-            MainWindow main_window = Latexila.get_instance ().active_window;
+            MainWindow main_window = Latexila.get_instance ().active_window as MainWindow;
             main_window.jump_to_file_position (tex_file, pos.line - 1, pos.line);
             main_window.present_with_time (timestamp);
         });



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