aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c116
1 files changed, 97 insertions, 19 deletions
diff --git a/src/main.c b/src/main.c
index 238db98c..1aaa13e6 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,47 +1,125 @@
1/* 1/*
2 * Initial main.c file generated by Glade. Edit as required. 2 This file is part of GNUnet.
3 * Glade will not overwrite this file. 3 (C) 2005 Christian Grothoff (and other contributing authors)
4 */ 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*/
5 20
6#ifdef HAVE_CONFIG_H 21#ifdef HAVE_CONFIG_H
7# include <config.h> 22# include <config.h>
8#endif 23#endif
9 24
25#include "gettext.h"
26
10#include <gtk/gtk.h> 27#include <gtk/gtk.h>
11 28
29#include <GNUnet/gnunet_util.h>
30#include <GNUnet/gnunet_ecrs_lib.h>
31
12#include "interface.h" 32#include "interface.h"
13#include "support.h" 33#include "support.h"
14 34
35
36
37/**
38 * Prints the usage information for this command if the user errs.
39 * Aborts the program.
40 */
41static void printhelp() {
42 static Help help[] = {
43 HELP_CONFIG,
44 HELP_HELP,
45 HELP_HOSTNAME,
46 HELP_LOGLEVEL,
47 HELP_VERSION,
48 HELP_END,
49 };
50 formatHelp("gnunet-gtk [OPTIONS]",
51 _("GNUnet GTK user interface."),
52 help);
53}
54
55/**
56 * Parse the options, set the timeout.
57 * @param argc the number of options
58 * @param argv the option list (including keywords)
59 * @return SYSERR if we should exit, OK otherwise
60 */
61static int parseOptions(int argc,
62 char ** argv) {
63 int c;
64
65 while (1) {
66 int option_index = 0;
67 static struct GNoption long_options[] = {
68 LONG_DEFAULT_OPTIONS,
69 { 0,0,0,0 }
70 };
71 c = GNgetopt_long(argc,
72 argv,
73 "c:dhH:L:v",
74 long_options,
75 &option_index);
76 if (c == -1)
77 break; /* No more flags to process */
78 if (YES == parseDefaultOptions(c, GNoptarg))
79 continue;
80 switch(c) {
81 case 'h':
82 printhelp();
83 return SYSERR;
84 case 'v':
85 printf("GNUnet v%s, gnunet-gtk v%s\n",
86 VERSION,
87 AFS_VERSION);
88 return SYSERR;
89 default:
90 LOG(LOG_FAILURE,
91 _("Use --help to get a list of options.\n"));
92 return SYSERR;
93 } /* end of parsing commandline */
94 } /* while (1) */
95 setConfigurationStringList(&argv[GNoptind],
96 argc-GNoptind);
97 return OK;
98}
99
100
15int 101int
16main (int argc, char *argv[]) 102main (int argc, char *argv[])
17{ 103{
18 GtkWidget *mainWindow; 104 GtkWidget * mainWindow;
19 GtkWidget *metadatadialog; 105 GtkWidget * metaDataDialog;
20 GtkWidget *metaDisplayDialog; 106 GtkWidget * metaDisplayDialog;
21 107
22#ifdef ENABLE_NLS 108#ifdef ENABLE_NLS
23 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR); 109 bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
110 bind_textdomain_codeset (PACKAGE, "UTF-8");
24 textdomain (PACKAGE); 111 textdomain (PACKAGE);
25#endif 112#endif
26 113
27 gtk_set_locale (); 114 gtk_set_locale ();
28 gtk_init (&argc, &argv); 115 gtk_init(&argc, &argv);
29 116 if (SYSERR == initUtil(argc, argv, &parseOptions))
117 return 0; /* parse error, --help, etc. */
118
30 add_pixmap_directory (PACKAGE_DATA_DIR "/pixmaps"); 119 add_pixmap_directory (PACKAGE_DATA_DIR "/pixmaps");
31 add_pixmap_directory (PACKAGE_SOURCE_DIR "/pixmaps");
32 120
33 /*
34 * The following code was added by Glade to create one of each component
35 * (except popup menus), just so that you see something after building
36 * the project. Delete any components that you don't want shown initially.
37 */
38 mainWindow = create_mainWindow (); 121 mainWindow = create_mainWindow ();
39 gtk_widget_show (mainWindow); 122 gtk_widget_show (mainWindow);
40 metadatadialog = create_metadatadialog ();
41 gtk_widget_show (metadatadialog);
42 metaDisplayDialog = create_metaDisplayDialog ();
43 gtk_widget_show (metaDisplayDialog);
44
45 gtk_main (); 123 gtk_main ();
46 return 0; 124 return 0;
47} 125}