[gitg] Call libgitg init method from the startup



commit c1205431cda5c9608d7b8af157b2e5bd06385a95
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Wed Aug 26 13:58:13 2015 +0200

    Call libgitg init method from the startup
    
    This is to ensure that gtk is already inited since libgitg depends
    on gtk to i.e add the css style

 gitg/gitg-application.vala |   32 ++++++++++++++++++++++++++++++++
 gitg/gitg.vala             |   36 ------------------------------------
 2 files changed, 32 insertions(+), 36 deletions(-)
---
diff --git a/gitg/gitg-application.vala b/gitg/gitg-application.vala
index 6aac6d4..b0903d6 100644
--- a/gitg/gitg-application.vala
+++ b/gitg/gitg-application.vala
@@ -302,10 +302,42 @@ public class Application : Gtk.Application
                string[] accels;
        }
 
+       private void init_error(string msg)
+       {
+               var dlg = new Gtk.MessageDialog(null,
+                                               0,
+                                               Gtk.MessageType.ERROR,
+                                               Gtk.ButtonsType.CLOSE,
+                                               "%s",
+                                               msg);
+
+               dlg.window_position = Gtk.WindowPosition.CENTER;
+
+               dlg.response.connect(() => { Gtk.main_quit(); });
+               dlg.show();
+       }
+
        protected override void startup()
        {
                base.startup();
 
+               try
+               {
+                       Gitg.init();
+               }
+               catch (Error e)
+               {
+                       if (e is Gitg.InitError.THREADS_UNSAFE)
+                       {
+                               var errmsg = _("We are terribly sorry, but gitg requires libgit2 (a library 
on which gitg depends) to be compiled with threading support.\n\nIf you manually compiled libgit2, then 
please configure libgit2 with -DTHREADSAFE:BOOL=ON.\n\nOtherwise, report a bug in your distributions' bug 
reporting system for providing libgit2 without threading support.");
+
+                               init_error(errmsg);
+                               error("%s", errmsg);
+                       }
+
+                       return;
+               }
+
                // Handle the state setting in the application
                d_state_settings = new Settings("org.gnome.gitg.state.window");
                d_state_settings.delay();
diff --git a/gitg/gitg.vala b/gitg/gitg.vala
index 09d587a..e5fde1f 100644
--- a/gitg/gitg.vala
+++ b/gitg/gitg.vala
@@ -24,25 +24,6 @@ private const string version = Config.VERSION;
 
 public class Main
 {
-       private static void init_error(string[] args, string msg)
-       {
-               Gtk.init(ref args);
-
-               var dlg = new Gtk.MessageDialog(null,
-                                               0,
-                                               Gtk.MessageType.ERROR,
-                                               Gtk.ButtonsType.CLOSE,
-                                               "%s",
-                                               msg);
-
-               dlg.window_position = Gtk.WindowPosition.CENTER;
-
-               dlg.response.connect(() => { Gtk.main_quit(); });
-               dlg.show();
-
-               Gtk.main();
-       }
-
        public static int main(string[] args)
        {
                Gtk.disable_setlocale();
@@ -57,23 +38,6 @@ public class Main
                Environment.set_prgname("gitg");
                Environment.set_application_name(_("gitg"));
 
-               try
-               {
-                       Gitg.init();
-               }
-               catch (Error e)
-               {
-                       if (e is Gitg.InitError.THREADS_UNSAFE)
-                       {
-                               var errmsg = _("We are terribly sorry, but gitg requires libgit2 (a library 
on which gitg depends) to be compiled with threading support.\n\nIf you manually compiled libgit2, then 
please configure libgit2 with -DTHREADSAFE:BOOL=ON.\n\nOtherwise, report a bug in your distributions' bug 
reporting system for providing libgit2 without threading support.");
-
-                               init_error(args, errmsg);
-                               error("%s", errmsg);
-                       }
-
-                       Process.exit(1);
-               }
-
                // Make sure to pull in gd symbols since libgd gets linked statically
                Gd.ensure_types();
 


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