diff options
| author | Victor Kareh <[email protected]> | 2026-03-20 20:55:49 -0400 |
|---|---|---|
| committer | Luke from DC <[email protected]> | 2026-04-02 18:50:26 +0000 |
| commit | 465e5a19136f7d37d27f8f33a7459c5989037b5e (patch) | |
| tree | 5930eed408fb55261f7f060b043b5dabe7a83fde | |
| parent | 482c096f7e7e3e021b8f5088d6e5a8fd47f32edf (diff) | |
| download | mate-notification-daemon-465e5a19136f7d37d27f8f33a7459c5989037b5e.tar.bz2 mate-notification-daemon-465e5a19136f7d37d27f8f33a7459c5989037b5e.tar.xz | |
Add version flag to daemon and properties dialog
The mate-notification-properties binary had no command-line option
parsing, making it hard to know the installed version.
This adds the version flag to both mate-notification-properties and
mate-notification-daemon.
Fixes #228
| -rw-r--r-- | src/capplet/mate-notification-properties.c | 28 | ||||
| -rw-r--r-- | src/daemon/mnd-daemon.c | 13 |
2 files changed, 40 insertions, 1 deletions
diff --git a/src/capplet/mate-notification-properties.c b/src/capplet/mate-notification-properties.c index a12ff20..a27eb91 100644 --- a/src/capplet/mate-notification-properties.c +++ b/src/capplet/mate-notification-properties.c @@ -565,6 +565,14 @@ static void notification_properties_dialog_finalize(NotificationAppletDialog* di int main(int argc, char** argv) { NotificationAppletDialog *dialog; + static gboolean show_version = FALSE; + GOptionContext *option_context; + GError *error = NULL; + + static GOptionEntry option_entries[] = { + { "version", 'v', 0, G_OPTION_ARG_NONE, &show_version, N_("Version of this application"), NULL }, + { NULL } + }; #ifdef ENABLE_NLS bindtextdomain(GETTEXT_PACKAGE, NOTIFICATION_LOCALEDIR); @@ -572,7 +580,25 @@ int main(int argc, char** argv) textdomain(GETTEXT_PACKAGE); #endif /* ENABLE_NLS */ - gtk_init(&argc, &argv); + option_context = g_option_context_new (NULL); + g_option_context_add_main_entries (option_context, option_entries, GETTEXT_PACKAGE); + g_option_context_add_group (option_context, gtk_get_option_group (TRUE)); + + if (!g_option_context_parse (option_context, &argc, &argv, &error)) + { + g_warning ("%s", error->message); + g_error_free (error); + g_option_context_free (option_context); + return 1; + } + + g_option_context_free (option_context); + + if (show_version) + { + g_print ("%s %s\n", PACKAGE, VERSION); + return 0; + } notify_init("mate-notification-properties"); diff --git a/src/daemon/mnd-daemon.c b/src/daemon/mnd-daemon.c index 59921c7..cfaedfd 100644 --- a/src/daemon/mnd-daemon.c +++ b/src/daemon/mnd-daemon.c @@ -32,6 +32,7 @@ static gboolean debug = FALSE; static gboolean replace = FALSE; static gboolean idle_exit = FALSE; +static gboolean show_version = FALSE; static GOptionEntry entries[] = { @@ -54,6 +55,12 @@ static GOptionEntry entries[] = NULL }, { + "version", 'v', G_OPTION_FLAG_NONE, + G_OPTION_ARG_NONE, &show_version, + "Version of this application", + NULL + }, + { NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL } }; @@ -102,6 +109,12 @@ int main (int argc, char *argv[]) if (!parse_arguments (&argc, &argv)) return EXIT_FAILURE; + if (show_version) + { + g_print ("%s %s\n", PACKAGE, VERSION); + return EXIT_SUCCESS; + } + daemon = notify_daemon_new (replace, idle_exit); gtk_main(); |
