4 #include <glib/gi18n.h>
6 #include "Common/Common.h"
12 #include <Gtk2/DasherAppSettings.h>
13 #include <Gtk2/dasher_editor_internal.h>
19 // TODO: This shouldn't need to be here
20 #if (defined GNOME_SPEECH || defined GNOME_A11Y)
21 #include <libbonobo.h>
29 #include "dasher_main.h"
32 #include "gpesettings_store.h"
36 //extern const gchar *filename;
38 DasherMain
*g_pDasherMain
;
41 // Stuff imported from dasher.cc
44 osso_context_t
*osso_context
;
49 //static GtkWidget *vbox; // Main vbox (top level under main window)
50 // GdkPixbuf *p; // Hmm... descriptive names
54 // GtkWidget *dasher_menu_bar;
55 // GtkWidget *open_filesel;
56 // GtkWidget *save_filesel;
57 // GtkWidget *save_and_quit_filesel;
58 // GtkWidget *import_filesel;
59 // GtkWidget *append_filesel;
60 // GtkWidget *g_pHiddenWindow;
61 // GtkWidget *file_selector;
62 //GtkWidget *g_pEditPane = 0;
63 //GtkWidget *g_pActionPane = 0;
66 Window g_xOldIMWindow
;
69 //DasherAction *g_pAction = 0;
71 // const gchar *filename = NULL; // Filename of file currently being edited
73 //static DasherEditor *g_pEditor = 0;
76 // Apparently not obsolete, but should be sorted out
78 // gboolean file_modified = FALSE; // Have unsaved changes been made to the current file
79 // gint outputcharacters;
81 // const char *g_szAccessibleContext = 0;
82 // int g_iExpectedPosition = -1;
83 // int g_iOldPosition = -1;
89 // "member" variables for main window "class"
91 // int g_bOnTop = true; // Whether the window should always be on top
92 // int g_bDock = true; // Whether to dock the window
93 // int g_iDockType; // Ignored for now - will determine how the window is docked to the side of the screen
94 // double g_dXFraction = 0.25; // Fraction of the width of the screen to use;
95 // double g_dYFraction = 0.25; // Fraction of the height of the screen to use;
99 /// Old stuff from edit.cc
101 // DasherEditor *g_pEditor = 0;
103 // GtkWidget *the_text_view;
104 // GtkTextBuffer *the_text_buffer;
106 // KeySym *origkeymap;
107 // int modifiedkey = 0;
112 void sigint_handler(int iSigNum
);
115 // TODO: reimplement command line parsing - should just be a way of
116 // temporarily overriding parameters
118 // GOption command line parsing variables
119 // gboolean timedata = FALSE;
120 // gboolean preferences = FALSE;
121 // gboolean textentry = FALSE;
122 // gboolean stdoutpipe = FALSE;
125 // TODO: Do we actually need this - gtk should in theory have
126 // functions to prevent windows from taking focus, but maybe they
127 // don't work which is why this is here.
129 // GdkFilterReturn dasher_discard_take_focus_filter(GdkXEvent *xevent, GdkEvent *event, gpointer data) {
130 // XEvent *xev = (XEvent *) xevent;
131 // if(xev->xany.type == ClientMessage && (Atom) xev->xclient.data.l[0] == gdk_x11_atom_to_xatom(gdk_atom_intern("WM_TAKE_FOCUS", False))) {
132 // return GDK_FILTER_REMOVE;
135 // return GDK_FILTER_CONTINUE;
140 extern "C" gint
main_key_snooper(GtkWidget
*pWidget
, GdkEventKey
*pEvent
, gpointer pUserData
);
143 int main(int argc
, char *argv
[]) {
145 // DasherAppSettings *g_pDasherAppSettings;
146 // GtkWidget *window; // Main window
148 signal(2, sigint_handler
);
150 bindtextdomain(PACKAGE
, LOCALEDIR
);
151 bind_textdomain_codeset(PACKAGE
, "UTF-8");
154 // gchar *szOptionAppstyle = NULL;
156 SCommandLine sCommandLine
;
158 sCommandLine
.szFilename
= NULL
;
159 sCommandLine
.szAppStyle
= NULL
;
160 sCommandLine
.szOptions
= NULL
;
162 gboolean do_option_help
= false;
163 static const GOptionEntry options
[] = {
164 // {"timedata", 'w', 0, G_OPTION_ARG_NONE, &timedata, "Write basic timing information to stdout", NULL},
165 // {"preferences", 'p', 0, G_OPTION_ARG_NONE, &preferences, "Show preferences window only", NULL},
166 // {"textentry", 'o', 0, G_OPTION_ARG_NONE, &textentry, "Onscreen text entry mode", NULL},
167 // {"pipe", 's', 0, G_OPTION_ARG_NONE, &stdoutpipe, "Pipe text to stdout", NULL},
168 /* 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. */
169 {"appstyle", 'a', 0, G_OPTION_ARG_STRING
, &(sCommandLine
.szAppStyle
), N_("Application style (traditional, direct, compose or fullscreen)"), "traditional"},
170 // Note to translators: This is the help string for "--options"
171 {"options", 'o', 0, G_OPTION_ARG_STRING
, &(sCommandLine
.szOptions
), N_("Override stored options"), NULL
},
172 // Note to translators: This is the help string for "--help-options"
173 {"help-options", 0, 0, G_OPTION_ARG_NONE
, &do_option_help
, N_("Describe \"--options\"."), NULL
},
177 //parse command line options
178 GOptionContext
*goptcontext
;
179 // Note to translators: This is the "--help" description of dasher.
180 goptcontext
= g_option_context_new(_("- A text input application honouring accessibility"));
181 g_option_context_add_main_entries(goptcontext
, options
, GETTEXT_PACKAGE
);
182 g_option_context_add_group(goptcontext
, gtk_get_option_group (TRUE
));
183 g_option_context_parse(goptcontext
, &argc
, &argv
, NULL
);
185 // TODO: Check what happens here when goption has done its stuff
188 sCommandLine
.szFilename
= g_strdup(argv
[1]);
189 //later GnomeProgram will call g_option_context_free() when we unref it
197 gpe_application_init(&argc
, &argv
);
200 gtk_init(&argc
, &argv
);
204 osso_context
= osso_initialize("dasher", PACKAGE_VERSION
, TRUE
, NULL
);
207 #if (defined GNOME_SPEECH || defined GNOME_A11Y)
208 if(!bonobo_is_initialized()) {
209 if(!bonobo_init(&argc
, argv
)) {
210 g_error("Can't initialize Bonobo...\n");
216 g_set_application_name("Dasher");
218 gtk_window_set_default_icon_name("dasher");
222 g_pDasherMain
= dasher_main_new(&argc
, &argv
, &sCommandLine
);
224 g_free(sCommandLine
.szFilename
);
225 g_free(sCommandLine
.szAppStyle
);
226 g_free(sCommandLine
.szOptions
);
228 if (g_pDasherMain
== 0)
231 dasher_main_show(g_pDasherMain
);
233 // This call is just to force the linker to export the following symbol.
234 dasher_editor_internal_get_type();
247 osso_deinitialize(osso_context
);
250 /* TODO: check that this really does the right thing with the references counting */
252 g_object_unref(G_OBJECT(g_pDasherMain
));
255 void sigint_handler(int iSigNum
) {
256 if(gtk_main_level() > 0) {
260 // This implies that we haven't got as far as setting up the main loop yet