[gnome-todo/gnome-3-26] Merge branch 'wip/sadiq' into 'master'



commit 00745268e1cb767941c2e84e4f81e39809b94e04
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Thu Oct 26 14:21:25 2017 +0000

    Merge branch 'wip/sadiq' into 'master'
    
    application: Add --quit commandline argument
    
    Closes #94
    
    See merge request GNOME/gnome-todo!3
    
    (cherry picked from commit 41afc2a95429ecc51bb4b485293636a9c25d8142)
    
    995c8fde application: Add --quit commandline argument

 src/gtd-application.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)
---
diff --git a/src/gtd-application.c b/src/gtd-application.c
index 4e57cbc..4b0c779 100644
--- a/src/gtd-application.c
+++ b/src/gtd-application.c
@@ -72,6 +72,10 @@ static void           gtd_application_quit                        (GSimpleAction
 
 G_DEFINE_TYPE_WITH_PRIVATE (GtdApplication, gtd_application, GTK_TYPE_APPLICATION)
 
+static GOptionEntry cmd_options[] = {
+  { "quit", 'q', 0, G_OPTION_ARG_NONE, NULL, N_("Quit GNOME ToDo"), NULL }
+};
+
 static const GActionEntry gtd_application_entries[] = {
   { "activate", gtd_application_activate_action },
   { "start-client", gtd_application_start_client },
@@ -179,7 +183,7 @@ gtd_application_new (void)
 
   return g_object_new (GTD_TYPE_APPLICATION,
                        "application-id", "org.gnome.Todo",
-                       "flags", G_APPLICATION_FLAGS_NONE,
+                       "flags", G_APPLICATION_HANDLES_COMMAND_LINE,
                        "resource-base-path", "/org/gnome/todo",
                        NULL);
 }
@@ -302,6 +306,25 @@ gtd_application_startup (GApplication *application)
   gtd_manager_load_plugins (priv->manager);
 }
 
+static gint
+gtd_application_command_line (GApplication            *app,
+                              GApplicationCommandLine *command_line)
+{
+  GVariantDict *options;
+
+  options = g_application_command_line_get_options_dict (command_line);
+
+  if (g_variant_dict_contains (options, "quit"))
+    {
+      g_application_quit (app);
+      return 0;
+    }
+
+  g_application_activate (app);
+
+  return 0;
+}
+
 static gboolean
 gtd_application_local_command_line (GApplication   *application,
                                     gchar        ***arguments,
@@ -324,6 +347,7 @@ gtd_application_class_init (GtdApplicationClass *klass)
 
   application_class->activate = gtd_application_activate;
   application_class->startup = gtd_application_startup;
+  application_class->command_line = gtd_application_command_line;
   application_class->local_command_line = gtd_application_local_command_line;
 }
 
@@ -333,6 +357,8 @@ gtd_application_init (GtdApplication *self)
   GtdApplicationPrivate *priv = gtd_application_get_instance_private (self);
 
   self->priv = priv;
+
+  g_application_add_main_option_entries (G_APPLICATION (self), cmd_options);
 }
 
 GtdManager*


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