5 #include <glib/gi18n.h>
8 #include "Common/Common.h"
13 #include <glade/glade.h>
15 #if GLIB_CHECK_VERSION(2,6,0)
16 #include <Gtk2/DasherAppSettings.h>
23 // TODO: This shouldn't need to be here
24 #if (defined GNOME_SPEECH || defined GNOME_A11Y)
26 #include <libbonobo.h>
34 #include <libgnome/libgnome.h>
35 #include <libgnomeui/libgnomeui.h>
38 // #include <libintl.h>
39 // #include <locale.h>
41 // #include <stdlib.h>
42 // #include <iostream>
45 //#include "DasherControl.h"
46 #include "dasher_lock_dialogue.h"
47 #include "dasher_main.h"
50 #include "gpesettings_store.h"
54 //extern const gchar *filename;
56 DasherMain
*g_pDasherMain
;
59 // Stuff imported from dasher.cc
62 osso_context_t
*osso_context
;
67 //static GtkWidget *vbox; // Main vbox (top level under main window)
68 // GdkPixbuf *p; // Hmm... descriptive names
72 // GtkWidget *dasher_menu_bar;
73 // GtkWidget *open_filesel;
74 // GtkWidget *save_filesel;
75 // GtkWidget *save_and_quit_filesel;
76 // GtkWidget *import_filesel;
77 // GtkWidget *append_filesel;
78 // GtkWidget *g_pHiddenWindow;
79 // GtkWidget *file_selector;
80 //GtkWidget *g_pEditPane = 0;
81 //GtkWidget *g_pActionPane = 0;
84 Window g_xOldIMWindow
;
87 //DasherAction *g_pAction = 0;
89 // const gchar *filename = NULL; // Filename of file currently being edited
91 //static DasherEditor *g_pEditor = 0;
94 // Apparently not obsolete, but should be sorted out
96 // gboolean file_modified = FALSE; // Have unsaved changes been made to the current file
97 // gint outputcharacters;
99 // const char *g_szAccessibleContext = 0;
100 // int g_iExpectedPosition = -1;
101 // int g_iOldPosition = -1;
107 // "member" variables for main window "class"
109 // int g_bOnTop = true; // Whether the window should always be on top
110 // int g_bDock = true; // Whether to dock the window
111 // int g_iDockType; // Ignored for now - will determine how the window is docked to the side of the screen
112 // double g_dXFraction = 0.25; // Fraction of the width of the screen to use;
113 // double g_dYFraction = 0.25; // Fraction of the height of the screen to use;
117 /// Old stuff from edit.cc
119 // DasherEditor *g_pEditor = 0;
121 // GtkWidget *the_text_view;
122 // GtkTextBuffer *the_text_buffer;
124 // KeySym *origkeymap;
125 // int modifiedkey = 0;
130 void sigint_handler(int iSigNum
);
133 // TODO: reimplement command line parsing - should just be a way of
134 // temporarily overriding parameters
136 // GOption command line parsing variables
137 // gboolean timedata = FALSE;
138 // gboolean preferences = FALSE;
139 // gboolean textentry = FALSE;
140 // gboolean stdoutpipe = FALSE;
143 // TODO: Do we actually need this - gtk should in theory have
144 // functions to prevent windows from taking focus, but maybe they
145 // don't work which is why this is here.
147 // GdkFilterReturn dasher_discard_take_focus_filter(GdkXEvent *xevent, GdkEvent *event, gpointer data) {
148 // XEvent *xev = (XEvent *) xevent;
149 // if(xev->xany.type == ClientMessage && (Atom) xev->xclient.data.l[0] == gdk_x11_atom_to_xatom(gdk_atom_intern("WM_TAKE_FOCUS", False))) {
150 // return GDK_FILTER_REMOVE;
153 // return GDK_FILTER_CONTINUE;
158 extern "C" gint
main_key_snooper(GtkWidget
*pWidget
, GdkEventKey
*pEvent
, gpointer pUserData
);
161 int main(int argc
, char *argv
[]) {
163 // DasherAppSettings *g_pDasherAppSettings;
164 // GtkWidget *window; // Main window
166 signal(2, sigint_handler
);
168 bindtextdomain(PACKAGE
, LOCALEDIR
);
169 bind_textdomain_codeset(PACKAGE
, "UTF-8");
172 // gchar *szOptionAppstyle = NULL;
174 SCommandLine sCommandLine
;
176 sCommandLine
.szFilename
= NULL
;
177 sCommandLine
.szAppStyle
= NULL
;
178 sCommandLine
.szOptions
= NULL
;
180 // TODO: It would be nice to have command line parsing in version prior to goption (eg in Solaris 10)...
181 #if GLIB_CHECK_VERSION(2,6,0)
182 gboolean do_option_help
= false;
183 static const GOptionEntry options
[] = {
184 // {"timedata", 'w', 0, G_OPTION_ARG_NONE, &timedata, "Write basic timing information to stdout", NULL},
185 // {"preferences", 'p', 0, G_OPTION_ARG_NONE, &preferences, "Show preferences window only", NULL},
186 // {"textentry", 'o', 0, G_OPTION_ARG_NONE, &textentry, "Onscreen text entry mode", NULL},
187 // {"pipe", 's', 0, G_OPTION_ARG_NONE, &stdoutpipe, "Pipe text to stdout", NULL},
188 /* 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. */
189 {"appstyle", 'a', 0, G_OPTION_ARG_STRING
, &(sCommandLine
.szAppStyle
), N_("Application style (traditional, direct, compose or fullscreen)"), "traditional"},
190 // Note to translators: This is the help string for "--options"
191 {"options", 'o', 0, G_OPTION_ARG_STRING
, &(sCommandLine
.szOptions
), N_("Override stored options"), NULL
},
192 // Note to translators: This is the help string for "--help-options"
193 {"help-options", 0, 0, G_OPTION_ARG_NONE
, &do_option_help
, N_("Describe \"--options\"."), NULL
},
197 //parse command line options
198 GOptionContext
*goptcontext
;
199 // Note to translators: This is the "--help" description of dasher.
200 goptcontext
= g_option_context_new(_("- A text input application honouring accessibility"));
201 g_option_context_add_main_entries(goptcontext
, options
, GETTEXT_PACKAGE
);
202 g_option_context_add_group(goptcontext
, gtk_get_option_group (TRUE
));
203 g_option_context_parse(goptcontext
, &argc
, &argv
, NULL
);
205 // TODO: Check what happens here when goption has done its stuff
208 sCommandLine
.szFilename
= g_strdup(argv
[1]);
209 //later GnomeProgram will call g_option_context_free() when we unref it
218 gpe_application_init(&argc
, &argv
);
221 gtk_init(&argc
, &argv
);
225 osso_context
= osso_initialize("dasher", PACKAGE_VERSION
, TRUE
, NULL
);
229 GnomeProgram
*program
= 0;
230 #if GLIB_CHECK_VERSION(2,14,0)
231 program
= gnome_program_init
232 (argv
[0], PACKAGE_VERSION
, LIBGNOMEUI_MODULE
,
234 GNOME_PARAM_GOPTION_CONTEXT
, goptcontext
, GNOME_PARAM_NONE
);
236 program
= gnome_program_init
237 (argv
[0], PACKAGE_VERSION
, LIBGNOMEUI_MODULE
,
241 #endif /* GNOME_LIBS */
243 #if (defined GNOME_SPEECH || defined GNOME_A11Y)
244 if(!bonobo_is_initialized()) {
245 if(!bonobo_init(&argc
, argv
)) {
246 g_error("Can't initialize Bonobo...\n");
252 g_set_application_name("Dasher");
253 #if (!defined WITH_MAEMO) && GTK_CHECK_VERSION(2,6,0)
254 gtk_window_set_default_icon_name("dasher");
258 g_pDasherMain
= dasher_main_new(&argc
, &argv
, &sCommandLine
);
260 g_free(sCommandLine
.szFilename
);
261 g_free(sCommandLine
.szAppStyle
);
262 g_free(sCommandLine
.szOptions
);
264 if (g_pDasherMain
== 0)
267 dasher_main_show(g_pDasherMain
);
280 osso_deinitialize(osso_context
);
283 /* TODO: check that this really does the right thing with the references counting */
285 g_object_unref(G_OBJECT(g_pDasherMain
));
288 void sigint_handler(int iSigNum
) {
289 if(gtk_main_level() > 0) {
293 // This implies that we haven't got as far as setting up the main loop yet