aboutsummaryrefslogtreecommitdiff
path: root/src/gns/gnunet-gns-gtk.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gns/gnunet-gns-gtk.c')
-rw-r--r--src/gns/gnunet-gns-gtk.c141
1 files changed, 141 insertions, 0 deletions
diff --git a/src/gns/gnunet-gns-gtk.c b/src/gns/gnunet-gns-gtk.c
new file mode 100644
index 00000000..e18aea4a
--- /dev/null
+++ b/src/gns/gnunet-gns-gtk.c
@@ -0,0 +1,141 @@
1/*
2 This file is part of GNUnet.
3 (C) 2012 Christian Grothoff (and other contributing authors)
4
5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published
7 by the Free Software Foundation; either version 2, or (at your
8 option) any later version.
9
10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with GNUnet; see the file COPYING. If not, write to the
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19*/
20
21/**
22 * @file src/gns/gnunet-gns-gtk.c
23 * @brief Main function of gnunet-gns-gtk
24 * @author Christian Grothoff
25 */
26#include "gnunet_gtk.h"
27
28/**
29 * Handle to our main loop.
30 */
31static struct GNUNET_GTK_MainLoop *ml;
32
33/**
34 * Should gnunet-gns-gtk start in tray mode?
35 */
36static int tray_only;
37
38
39/**
40 * Get cfg.
41 */
42static const struct GNUNET_CONFIGURATION_Handle *
43get_configuration ()
44{
45 return GNUNET_GTK_main_loop_get_configuration (ml);
46}
47
48
49/**
50 * Get an object from the main window.
51 *
52 * @param name name of the object
53 * @return NULL on error
54 */
55static GObject *
56get_object (const char *name)
57{
58 return GNUNET_GTK_main_loop_get_object (ml, name);
59}
60
61
62/**
63 * Task run on shutdown.
64 *
65 * @param cls unused
66 * @param tc scheduler context, unused
67 */
68static void
69shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
70{
71}
72
73
74/**
75 * Callback invoked if the application is supposed to exit.
76 */
77void
78GNUNET_GNS_GTK_quit_cb (GObject * object, gpointer user_data)
79{
80 GNUNET_GTK_tray_icon_destroy ();
81 GNUNET_GTK_main_loop_quit (ml);
82 GNUNET_SCHEDULER_add_now (&shutdown_task, NULL);
83}
84
85
86/**
87 * Actual main function run right after GNUnet's scheduler
88 * is initialized. Initializes up GTK and Glade.
89 */
90static void
91run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
92{
93 GtkWidget *main_window;
94
95 ml = cls;
96
97 if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL))
98 {
99 return;
100 }
101
102 GNUNET_GTK_set_icon_search_path ();
103 GNUNET_GTK_setup_nls ();
104 /* setup main window */
105 main_window = GTK_WIDGET (get_object ("GNUNET_GNS_GTK_main_window"));
106 gtk_window_maximize (GTK_WINDOW (main_window));
107 GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window),
108 "gnunet-gtk" /* FIXME: different icon? */ ,
109 "gnunet-gns-gtk");
110
111 /* make GUI visible */
112 if (!tray_only)
113 {
114 gtk_widget_show (main_window);
115 gtk_window_present (GTK_WINDOW (main_window));
116 }
117}
118
119
120int
121main (int argc, char *const *argv)
122{
123 static struct GNUNET_GETOPT_CommandLineOption options[] = {
124 {'t', "tray", NULL,
125 gettext_noop ("start in tray mode"), 0,
126 &GNUNET_GETOPT_set_one, &tray_only},
127 GNUNET_GETOPT_OPTION_END
128 };
129
130 if (GNUNET_OK !=
131 GNUNET_GTK_main_loop_start ("gnunet-gns-gtk",
132 "GTK GUI for editing our zone", argc,
133 argv, options,
134 "gnunet_gns_gtk_main_window.glade",
135 &run))
136 return 1;
137 return 0;
138}
139
140
141/* end of gnunet-gns-gtk.c */