summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryetist <[email protected]>2018-05-08 13:14:22 +0800
committerraveit65 <[email protected]>2018-06-06 17:41:02 +0200
commit5e688bfb146b9731496650eb8dcaf5ef9ba778ad (patch)
tree2aba3bc21b438926171a575a6e533692dca55c46 /src
parent6fd50ad6440bb348e78f7206deb2be8f8b047e67 (diff)
downloadmate-notification-daemon-5e688bfb146b9731496650eb8dcaf5ef9ba778ad.tar.bz2
mate-notification-daemon-5e688bfb146b9731496650eb8dcaf5ef9ba778ad.tar.xz
Add new file
Diffstat (limited to 'src')
-rw-r--r--src/daemon/mnd-daemon.c93
1 files changed, 93 insertions, 0 deletions
diff --git a/src/daemon/mnd-daemon.c b/src/daemon/mnd-daemon.c
new file mode 100644
index 0000000..bcb28af
--- /dev/null
+++ b/src/daemon/mnd-daemon.c
@@ -0,0 +1,93 @@
+/* vi: set sw=4 ts=4 wrap ai: */
+/*
+ * mnd-daemon.c: This file is part of mate-notification-daemon
+ *
+ * Copyright (C) 2018 Wu Xiaotian <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gtk/gtk.h>
+#include <stdlib.h>
+
+#include "daemon.h"
+
+static gboolean debug = FALSE;
+static gboolean replace = FALSE;
+
+static GOptionEntry entries[] =
+{
+ {
+ "debug", 0, G_OPTION_FLAG_NONE,
+ G_OPTION_ARG_NONE, &debug,
+ "Enable debugging code",
+ NULL
+ },
+ {
+ "replace", 'r', G_OPTION_FLAG_NONE,
+ G_OPTION_ARG_NONE, &replace,
+ "Replace a currently running application",
+ NULL
+ },
+ {
+ NULL
+ }
+};
+
+static gboolean parse_arguments (int *argc, char ***argv)
+{
+ GOptionContext *context;
+ GError *error;
+
+ context = g_option_context_new (NULL);
+
+ g_option_context_add_main_entries (context, entries, NULL);
+
+ error = NULL;
+ if (g_option_context_parse (context, argc, argv, &error) == FALSE)
+ {
+ g_warning ("Failed to parse command line arguments: %s", error->message);
+ g_error_free (error);
+
+ return FALSE;
+ }
+
+ if (debug)
+ g_setenv ("G_MESSAGES_DEBUG", "all", FALSE);
+
+ return TRUE;
+}
+
+int main (int argc, char *argv[])
+{
+ NotifyDaemon *daemon;
+
+ gtk_init(&argc, &argv);
+
+ if (!parse_arguments (&argc, &argv))
+ return EXIT_FAILURE;
+
+ daemon = notify_daemon_new (replace);
+
+ gtk_main();
+
+ g_object_unref (daemon);
+
+ return EXIT_SUCCESS;
+}