[network-manager-applet/dcbw/indicator-cleanups: 6/7] applet: add --indicator to switch between indicator and status icon at runtime



commit b648b4bfcecabd68b64b1079069e8b7f388d9044
Author: Dan Williams <dcbw redhat com>
Date:   Tue Mar 15 15:28:01 2016 -0500

    applet: add --indicator to switch between indicator and status icon at runtime

 src/applet.c |   17 ++++++++++-------
 src/main.c   |   16 +++++++++++-----
 2 files changed, 21 insertions(+), 12 deletions(-)
---
diff --git a/src/applet.c b/src/applet.c
index 761f92c..bab980b 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -54,6 +54,7 @@
 
 extern gboolean shell_debug;
 extern gboolean with_agent;
+extern gboolean with_appindicator;
 
 #ifdef WITH_APPINDICATOR
 #define INDICATOR_ENABLED(a) ((a)->app_indicator)
@@ -3094,13 +3095,15 @@ static gboolean
 setup_widgets (NMApplet *applet)
 {
 #ifdef WITH_APPINDICATOR
-       applet->app_indicator = app_indicator_new
-                               ("nm-applet", "nm-no-connection",
-                                APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
-       if (!applet->app_indicator)
-               return FALSE;
-       app_indicator_set_title(applet->app_indicator, _("Network"));
-       applet_schedule_update_menu (applet);
+       if (with_appindicator) {
+               applet->app_indicator = app_indicator_new ("nm-applet",
+                                                          "nm-no-connection",
+                                                          APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+               if (!applet->app_indicator)
+                       return FALSE;
+               app_indicator_set_title(applet->app_indicator, _("Network"));
+               applet_schedule_update_menu (applet);
+       }
 #endif  /* WITH_APPINDICATOR */
 
        /* Fall back to status icon if indicator isn't enabled or built */
diff --git a/src/main.c b/src/main.c
index ee3de68..d2d3f37 100644
--- a/src/main.c
+++ b/src/main.c
@@ -31,19 +31,18 @@
 
 gboolean shell_debug = FALSE;
 gboolean with_agent = TRUE;
+gboolean with_appindicator = FALSE;
 
 static void
 usage (const char *progname)
 {
-       char *foo;
+       gs_free char *basename = g_path_get_basename (progname);
 
-       foo = g_path_get_basename (progname);
        fprintf (stdout, "%s %s\n\n%s\n%s\n\n",
                         _("Usage:"),
-                        foo,
+                        basename,
                         _("This program is a component of NetworkManager 
(https://wiki.gnome.org/Projects/NetworkManager/)."),
                         _("It is not intended for command-line interaction but instead runs in the GNOME 
desktop environment."));
-       g_free (foo);
 }
 
 int main (int argc, char *argv[])
@@ -60,8 +59,15 @@ int main (int argc, char *argv[])
                }
                if (!strcmp (argv[i], "--shell-debug"))
                        shell_debug = TRUE;
-               if (!strcmp (argv[i], "--no-agent"))
+               else if (!strcmp (argv[i], "--no-agent"))
                        with_agent = FALSE;
+               else if (!strcmp (argv[i], "--indicator")) {
+#ifdef WITH_APPINDICATOR
+                       with_appindicator = TRUE;
+#else
+                       g_error ("Error: --indicator requested but indicator support not available");
+#endif
+               }
        }
 
        bindtextdomain (GETTEXT_PACKAGE, NMALOCALEDIR);


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