4 #include <glib/gi18n.h>
6 #include "Common/Common.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>
20 // TODO: This shouldn't need to be here
21 #if (defined GNOME_SPEECH || defined GNOME_A11Y)
22 #include <libbonobo.h>
30 #include "dasher_main.h"
33 #include "gpesettings_store.h"
37 //extern const gchar *filename;
39 DasherMain
*g_pDasherMain
;
42 // Stuff imported from dasher.cc
45 osso_context_t
*osso_context
;
50 //static GtkWidget *vbox; // Main vbox (top level under main window)
51 // GdkPixbuf *p; // Hmm... descriptive names
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;
67 Window g_xOldIMWindow
;
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;
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;
98 /// Old stuff from edit.cc
100 // GtkWidget *the_text_view;
101 // GtkTextBuffer *the_text_buffer;
103 // KeySym *origkeymap;
104 // int modifiedkey = 0;
109 void sigint_handler(int iSigNum
);
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;
132 // return GDK_FILTER_CONTINUE;
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");
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
},
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
185 sCommandLine
.szFilename
= g_strdup(argv
[1]);
186 //later GnomeProgram will call g_option_context_free() when we unref it
194 gpe_application_init(&argc
, &argv
);
197 gtk_init(&argc
, &argv
);
201 osso_context
= osso_initialize("dasher", PACKAGE_VERSION
, TRUE
, NULL
);
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");
213 g_set_application_name("Dasher");
215 gtk_window_set_default_icon_name("dasher");
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)
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();
244 osso_deinitialize(osso_context
);
247 /* TODO: check that this really does the right thing with the references counting */
249 g_object_unref(G_OBJECT(g_pDasherMain
));
252 void sigint_handler(int iSigNum
) {
253 if(gtk_main_level() > 0) {
257 // This implies that we haven't got as far as setting up the main loop yet