Skip to content

Commit 5e688bf

Browse files
yetistraveit65
authored andcommitted
Add new file
1 parent 6fd50ad commit 5e688bf

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

src/daemon/mnd-daemon.c

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/* vi: set sw=4 ts=4 wrap ai: */
2+
/*
3+
* mnd-daemon.c: This file is part of mate-notification-daemon
4+
*
5+
* Copyright (C) 2018 Wu Xiaotian <yetist@gmail.com>
6+
*
7+
* This program is free software; you can redistribute it and/or modify
8+
* it under the terms of the GNU General Public License as published by
9+
* the Free Software Foundation; either version 2 of the License, or
10+
* (at your option) any later version.
11+
*
12+
* This program is distributed in the hope that it will be useful,
13+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
* GNU General Public License for more details.
16+
*
17+
* You should have received a copy of the GNU General Public License along
18+
* with this program; if not, write to the Free Software Foundation, Inc.,
19+
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20+
* */
21+
22+
#ifdef HAVE_CONFIG_H
23+
#include "config.h"
24+
#endif
25+
26+
#include <gtk/gtk.h>
27+
#include <stdlib.h>
28+
29+
#include "daemon.h"
30+
31+
static gboolean debug = FALSE;
32+
static gboolean replace = FALSE;
33+
34+
static GOptionEntry entries[] =
35+
{
36+
{
37+
"debug", 0, G_OPTION_FLAG_NONE,
38+
G_OPTION_ARG_NONE, &debug,
39+
"Enable debugging code",
40+
NULL
41+
},
42+
{
43+
"replace", 'r', G_OPTION_FLAG_NONE,
44+
G_OPTION_ARG_NONE, &replace,
45+
"Replace a currently running application",
46+
NULL
47+
},
48+
{
49+
NULL
50+
}
51+
};
52+
53+
static gboolean parse_arguments (int *argc, char ***argv)
54+
{
55+
GOptionContext *context;
56+
GError *error;
57+
58+
context = g_option_context_new (NULL);
59+
60+
g_option_context_add_main_entries (context, entries, NULL);
61+
62+
error = NULL;
63+
if (g_option_context_parse (context, argc, argv, &error) == FALSE)
64+
{
65+
g_warning ("Failed to parse command line arguments: %s", error->message);
66+
g_error_free (error);
67+
68+
return FALSE;
69+
}
70+
71+
if (debug)
72+
g_setenv ("G_MESSAGES_DEBUG", "all", FALSE);
73+
74+
return TRUE;
75+
}
76+
77+
int main (int argc, char *argv[])
78+
{
79+
NotifyDaemon *daemon;
80+
81+
gtk_init(&argc, &argv);
82+
83+
if (!parse_arguments (&argc, &argv))
84+
return EXIT_FAILURE;
85+
86+
daemon = notify_daemon_new (replace);
87+
88+
gtk_main();
89+
90+
g_object_unref (daemon);
91+
92+
return EXIT_SUCCESS;
93+
}

0 commit comments

Comments
 (0)