[l10n] Updated German doc translation
[dasher.git] / Src / main.cc
blob1f81354acd66d0190ee14edc6568497f7bc3d6bc
1 #ifdef HAVE_CONFIG_H
2 #include <config.h>
3 #endif
4 #include <glib/gi18n.h>
6 #include "Common/Common.h"
8 #include <gdk/gdk.h>
9 #include <gtk/gtk.h>
10 #include <gdk/gdkx.h>
11 #include <signal.h>
12 #include <Gtk2/DasherAppSettings.h>
13 /* Just to make sure the symbols for the editor are visible. */
14 #include <Gtk2/dasher_editor_internal.h>
16 #ifdef WITH_MAEMO
17 #include <libosso.h>
18 #endif
20 // TODO: This shouldn't need to be here
21 #if (defined GNOME_SPEECH || defined GNOME_A11Y)
22 #include <libbonobo.h>
23 #endif
25 #ifdef WITH_GPE
26 #include <gpe/init.h>
27 #endif
29 #include "dasher.h"
30 #include "dasher_main.h"
32 #ifdef WITH_GPE
33 #include "gpesettings_store.h"
34 #endif
36 //extern int optind;
37 //extern const gchar *filename;
39 DasherMain *g_pDasherMain;
42 // Stuff imported from dasher.cc
44 #ifdef WITH_MAEMO
45 osso_context_t *osso_context;
46 #endif
50 //static GtkWidget *vbox; // Main vbox (top level under main window)
51 // GdkPixbuf *p; // Hmm... descriptive names
52 // GtkWidget *pw;
53 // GtkStyle *style;
55 // GtkWidget *dasher_menu_bar;
56 // GtkWidget *open_filesel;
57 // GtkWidget *save_filesel;
58 // GtkWidget *save_and_quit_filesel;
59 // GtkWidget *import_filesel;
60 // GtkWidget *append_filesel;
61 // GtkWidget *g_pHiddenWindow;
62 // GtkWidget *file_selector;
63 //GtkWidget *g_pEditPane = 0;
64 //GtkWidget *g_pActionPane = 0;
66 #ifdef WITH_MAEMO
67 Window g_xOldIMWindow;
68 #endif
70 //DasherAction *g_pAction = 0;
72 // const gchar *filename = NULL; // Filename of file currently being edited
75 // Apparently not obsolete, but should be sorted out
77 // gboolean file_modified = FALSE; // Have unsaved changes been made to the current file
78 // gint outputcharacters;
80 // const char *g_szAccessibleContext = 0;
81 // int g_iExpectedPosition = -1;
82 // int g_iOldPosition = -1;
84 // 'Private' methods
88 // "member" variables for main window "class"
90 // int g_bOnTop = true; // Whether the window should always be on top
91 // int g_bDock = true; // Whether to dock the window
92 // int g_iDockType; // Ignored for now - will determine how the window is docked to the side of the screen
93 // double g_dXFraction = 0.25; // Fraction of the width of the screen to use;
94 // double g_dYFraction = 0.25; // Fraction of the height of the screen to use;
96 /// ---
98 /// Old stuff from edit.cc
100 // GtkWidget *the_text_view;
101 // GtkTextBuffer *the_text_buffer;
103 // KeySym *origkeymap;
104 // int modifiedkey = 0;
105 // int numcodes;
107 /// ---
109 void sigint_handler(int iSigNum);
110 void clean_up();
112 // TODO: reimplement command line parsing - should just be a way of
113 // temporarily overriding parameters
115 // GOption command line parsing variables
116 // gboolean timedata = FALSE;
117 // gboolean preferences = FALSE;
118 // gboolean textentry = FALSE;
119 // gboolean stdoutpipe = FALSE;
122 // TODO: Do we actually need this - gtk should in theory have
123 // functions to prevent windows from taking focus, but maybe they
124 // don't work which is why this is here.
126 // GdkFilterReturn dasher_discard_take_focus_filter(GdkXEvent *xevent, GdkEvent *event, gpointer data) {
127 // XEvent *xev = (XEvent *) xevent;
128 // if(xev->xany.type == ClientMessage && (Atom) xev->xclient.data.l[0] == gdk_x11_atom_to_xatom(gdk_atom_intern("WM_TAKE_FOCUS", False))) {
129 // return GDK_FILTER_REMOVE;
130 // }
131 // else {
132 // return GDK_FILTER_CONTINUE;
133 // }
134 // }
137 extern "C" gint main_key_snooper(GtkWidget *pWidget, GdkEventKey *pEvent, gpointer pUserData);
140 int main(int argc, char *argv[]) {
142 // DasherAppSettings *g_pDasherAppSettings;
143 // GtkWidget *window; // Main window
145 signal(2, sigint_handler);
147 bindtextdomain(PACKAGE, LOCALEDIR);
148 bind_textdomain_codeset(PACKAGE, "UTF-8");
149 textdomain(PACKAGE);
151 // gchar *szOptionAppstyle = NULL;
153 SCommandLine sCommandLine;
155 sCommandLine.szFilename = NULL;
156 sCommandLine.szAppStyle = NULL;
157 sCommandLine.szOptions = NULL;
159 gboolean do_option_help = false;
160 static const GOptionEntry options[] = {
161 // {"timedata", 'w', 0, G_OPTION_ARG_NONE, &timedata, "Write basic timing information to stdout", NULL},
162 // {"preferences", 'p', 0, G_OPTION_ARG_NONE, &preferences, "Show preferences window only", NULL},
163 // {"textentry", 'o', 0, G_OPTION_ARG_NONE, &textentry, "Onscreen text entry mode", NULL},
164 // {"pipe", 's', 0, G_OPTION_ARG_NONE, &stdoutpipe, "Pipe text to stdout", NULL},
165 /* Note to translators: This is the help string for "--appstyle". The four options in brackets MUST either NOT be translated or at least it MUST be clear that they must be used in english. Otherwise a user running a non-english system will receive an error message when using the translated one instead of the english one and has no chance to find out the correct option. */
166 {"appstyle", 'a', 0, G_OPTION_ARG_STRING, &(sCommandLine.szAppStyle), N_("Application style (traditional, direct, compose or fullscreen)"), "traditional"},
167 // Note to translators: This is the help string for "--options"
168 {"options", 'o', 0, G_OPTION_ARG_STRING, &(sCommandLine.szOptions), N_("Override stored options"), NULL},
169 // Note to translators: This is the help string for "--help-options"
170 {"help-options", 0, 0, G_OPTION_ARG_NONE, &do_option_help, N_("Describe \"--options\"."), NULL},
171 {NULL}
174 //parse command line options
175 GOptionContext *goptcontext;
176 // Note to translators: This is the "--help" description of dasher.
177 goptcontext = g_option_context_new(_("- A text input application honouring accessibility"));
178 g_option_context_add_main_entries(goptcontext, options, GETTEXT_PACKAGE);
179 g_option_context_add_group(goptcontext, gtk_get_option_group (TRUE));
180 g_option_context_parse(goptcontext, &argc, &argv, NULL);
182 // TODO: Check what happens here when goption has done its stuff
184 if(argc > 1)
185 sCommandLine.szFilename = g_strdup(argv[1]);
186 //later GnomeProgram will call g_option_context_free() when we unref it
187 if (do_option_help)
189 option_help();
190 return 0;
193 #ifdef WITH_GPE
194 gpe_application_init(&argc, &argv);
195 init_xsettings();
196 #else
197 gtk_init(&argc, &argv);
198 #endif
200 #ifdef WITH_MAEMO
201 osso_context = osso_initialize("dasher", PACKAGE_VERSION, TRUE, NULL);
202 #endif
204 #if (defined GNOME_SPEECH || defined GNOME_A11Y)
205 if(!bonobo_is_initialized()) {
206 if(!bonobo_init(&argc, argv)) {
207 g_error("Can't initialize Bonobo...\n");
209 bonobo_activate();
211 #endif
213 g_set_application_name("Dasher");
214 #ifndef WITH_MAEMO
215 gtk_window_set_default_icon_name("dasher");
216 #endif
219 g_pDasherMain = dasher_main_new(&argc, &argv, &sCommandLine);
221 g_free(sCommandLine.szFilename);
222 g_free(sCommandLine.szAppStyle);
223 g_free(sCommandLine.szOptions);
225 if (g_pDasherMain == 0)
226 return 1;
228 dasher_main_show(g_pDasherMain);
230 // This call is just to force the linker to export the following symbols.
231 dasher_editor_internal_get_type();
233 // 10.
234 gtk_main();
236 // 11.
237 clean_up();
239 return 0;
242 void clean_up() {
243 #ifdef WITH_MAEMO
244 osso_deinitialize(osso_context);
245 #endif
247 /* TODO: check that this really does the right thing with the references counting */
248 if(g_pDasherMain)
249 g_object_unref(G_OBJECT(g_pDasherMain));
252 void sigint_handler(int iSigNum) {
253 if(gtk_main_level() > 0) {
254 gtk_main_quit();
256 else {
257 // This implies that we haven't got as far as setting up the main loop yet
258 clean_up();
259 exit(0);