[network-manager-applet/dcbw/indicator-cleanups: 6/6] applet: add --indicator to switch between indicator and status icon at runtime
- From: Dan Williams <dcbw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/dcbw/indicator-cleanups: 6/6] applet: add --indicator to switch between indicator and status icon at runtime
- Date: Tue, 15 Mar 2016 20:31:35 +0000 (UTC)
commit e539fbb2e5f59bf7318ff7095761e2fd5a011507
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 4b45e15..4aa0e89 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -54,6 +54,7 @@
extern gboolean shell_debug;
extern gboolean with_agent;
+extern gboolean with_indicator;
#ifdef WITH_INDICATOR
#define INDICATOR_ENABLED(a) (a->app_indicator)
@@ -3095,13 +3096,15 @@ static gboolean
setup_widgets (NMApplet *applet)
{
#ifdef WITH_INDICATOR
- 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_indicator) {
+ 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_INDICATOR */
/* Fall back to status icon if indicator isn't enabled or built */
diff --git a/src/main.c b/src/main.c
index ee3de68..4184100 100644
--- a/src/main.c
+++ b/src/main.c
@@ -31,19 +31,18 @@
gboolean shell_debug = FALSE;
gboolean with_agent = TRUE;
+gboolean with_indicator = 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_INDICATOR
+ with_indicator = 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]