[latexila] app: refactor code wrt connecting GApplication signals



commit 96028b1954dac6afccb0835466255e93555f0ea4
Author: Sébastien Wilmet <swilmet gnome org>
Date:   Fri Dec 18 17:50:40 2015 +0100

    app: refactor code wrt connecting GApplication signals
    
    Prefer regular functions when the code is bigger.

 src/latexila_app.vala |   81 +++++++++++++++++++++++-------------------------
 1 files changed, 39 insertions(+), 42 deletions(-)
---
diff --git a/src/latexila_app.vala b/src/latexila_app.vala
index 0aba0c9..7b0b4e6 100644
--- a/src/latexila_app.vala
+++ b/src/latexila_app.vala
@@ -28,12 +28,7 @@ public class LatexilaApp : Gtk.Application
         Object (application_id: "org.gnome.latexila");
         Environment.set_application_name (Config.PACKAGE_NAME);
 
-        connect_signals ();
-    }
-
-    private void connect_signals ()
-    {
-        startup.connect (init_primary_instance);
+        startup.connect (startup_cb);
 
         activate.connect (() =>
         {
@@ -42,28 +37,47 @@ public class LatexilaApp : Gtk.Application
             release ();
         });
 
-        shutdown.connect (() =>
-        {
-            hold ();
+        shutdown.connect (shutdown_cb);
+    }
 
-            Projects.get_default ().save ();
-            MostUsedSymbols.get_default ().save ();
+    private void startup_cb ()
+    {
+        hold ();
+        add_actions ();
+        set_application_icons ();
+        Latexila.utils_register_icons ();
+        StockIcons.register_stock_icons ();
+        setup_theme_extensions ();
 
-            /* Save accel file */
-            string accel_filename = get_accel_filename ();
-            File accel_file = File.new_for_path (accel_filename);
-            try
-            {
-                Latexila.utils_create_parent_directories (accel_file);
-                Gtk.AccelMap.save (accel_filename);
-            }
-            catch (Error error)
-            {
-                warning ("Error when saving accel file: %s", error.message);
-            }
+        AppSettings.get_default ();
+        create_window ();
+        reopen_files ();
+        Gtk.AccelMap.load (get_accel_filename ());
+        support_backward_search ();
+        release ();
+    }
 
-            release ();
-        });
+    private void shutdown_cb ()
+    {
+        hold ();
+
+        Projects.get_default ().save ();
+        MostUsedSymbols.get_default ().save ();
+
+        /* Save accel file */
+        string accel_filename = get_accel_filename ();
+        File accel_file = File.new_for_path (accel_filename);
+        try
+        {
+            Latexila.utils_create_parent_directories (accel_file);
+            Gtk.AccelMap.save (accel_filename);
+        }
+        catch (Error error)
+        {
+            warning ("Error when saving accel file: %s", error.message);
+        }
+
+        release ();
     }
 
     private void add_actions ()
@@ -258,23 +272,6 @@ public class LatexilaApp : Gtk.Application
         return GLib.Application.get_default () as LatexilaApp;
     }
 
-    private void init_primary_instance ()
-    {
-        hold ();
-        add_actions ();
-        set_application_icons ();
-        Latexila.utils_register_icons ();
-        StockIcons.register_stock_icons ();
-        setup_theme_extensions ();
-
-        AppSettings.get_default ();
-        create_window ();
-        reopen_files ();
-        Gtk.AccelMap.load (get_accel_filename ());
-        support_backward_search ();
-        release ();
-    }
-
     private void set_application_icons ()
     {
         string[] sizes = {"16x16", "22x22", "24x24", "32x32", "48x48"};


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