[gnome-software] Add a command line argument to be able to startup the UI in a specific mode



commit 64856b17c511eab168040dbf0a99956b562100be
Author: Richard Hughes <richard hughsie com>
Date:   Fri Aug 16 11:16:23 2013 +0100

    Add a command line argument to be able to startup the UI in a specific mode
    
    We need this for the g-s-d notification bubble.

 src/gs-main.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
---
diff --git a/src/gs-main.c b/src/gs-main.c
index cd07cc6..791ae00 100644
--- a/src/gs-main.c
+++ b/src/gs-main.c
@@ -49,6 +49,7 @@ enum {
 typedef struct {
        GCancellable            *cancellable;
        GsMainMode               mode;
+       GsMainMode               app_startup_mode;
        GtkApplication          *application;
        GtkBuilder              *builder;
        PkTask                  *task;
@@ -1672,7 +1673,7 @@ gs_main_startup_cb (GApplication *application, GsMainPrivate *priv)
 
        /* show main UI */
        gtk_widget_show (main_window);
-       gs_main_set_overview_mode (priv, GS_MAIN_MODE_INSTALLED, NULL, NULL);
+       gs_main_set_overview_mode (priv, priv->app_startup_mode, NULL, NULL);
 out:
        if (data != NULL)
                g_bytes_unref (data);
@@ -1685,12 +1686,15 @@ int
 main (int argc, char **argv)
 {
        gboolean ret;
+       gchar *mode = NULL;
        GError *error = NULL;
        GOptionContext *context;
        GsMainPrivate *priv = NULL;
        int status = 0;
 
        const GOptionEntry options[] = {
+               { "mode", '\0', 0, G_OPTION_ARG_STRING, &mode,
+                 _("Start up mode, either 'updates', 'installed' or 'new'"), NULL },
                { NULL}
        };
 
@@ -1730,6 +1734,21 @@ main (int argc, char **argv)
                      "background", FALSE,
                      NULL);
 
+       /* specified what page to open */
+       if (mode != NULL) {
+               if (g_strcmp0 (mode, "updates") == 0) {
+                       priv->app_startup_mode = GS_MAIN_MODE_UPDATES;
+               } else if (g_strcmp0 (mode, "installed") == 0) {
+                       priv->app_startup_mode = GS_MAIN_MODE_INSTALLED;
+               } else if (g_strcmp0 (mode, "new") == 0) {
+                       priv->app_startup_mode = GS_MAIN_MODE_NEW;
+               } else {
+                       g_warning ("Mode '%s' not recognised", mode);
+               }
+       } else {
+               priv->app_startup_mode = GS_MAIN_MODE_INSTALLED;
+       }
+
        /* load the plugins */
        priv->plugin_loader = gs_plugin_loader_new ();
        gs_plugin_loader_set_location (priv->plugin_loader, NULL);
@@ -1754,6 +1773,7 @@ main (int argc, char **argv)
        /* wait */
        status = g_application_run (G_APPLICATION (priv->application), argc, argv);
 out:
+       g_free (mode);
        if (priv != NULL) {
                g_object_unref (priv->plugin_loader);
                g_object_unref (priv->task);


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