Combining changes from various places
[dasher.git] / Src / Gtk2 / dasher.cc
blobba6a821c887acf06522318ac4f0d73246c5d3ce9
1 /*! \file dasher.cc
2 \brief The core of the Dasher application
4 Core routines for the Dasher application
5 */
7 // System headers
9 #include "../Common/Common.h"
11 #include <sys/types.h>
12 #include <sys/time.h>
13 #include <sys/stat.h>
14 #include <stdlib.h>
15 #include <libintl.h>
16 #include <locale.h>
17 #include <string>
18 #include <vector>
19 #include <stdio.h>
20 #include <time.h>
21 #include <dirent.h>
22 #include <X11/Xlib.h>
23 #include <X11/Xatom.h>
24 #include "Output.h"
26 // C++ STL headers (ideally minimise the use of C++ outside of the control)
28 #include <iostream>
30 // GTK/GDK headers and friends
32 #include <gtk/gtk.h>
33 #include <gdk/gdk.h>
34 #include <gdk/gdkx.h>
36 #ifdef GNOME_LIBS
37 #include <libgnomeui/libgnomeui.h>
38 #include <libgnome/libgnome.h>
39 #endif
41 #ifdef WITH_GPE
42 #include "gpesettings_store.h"
43 #endif
45 // Other Dasher components
47 #include "dasher.h"
48 #include "edit.h"
49 #include "fileops.h"
50 #include "Preferences.h"
51 #include "FontDialogues.h"
52 #include "Menu.h"
53 #include "AppSettings.h"
54 #include "../DasherCore/Parameters.h"
55 #include "accessibility.h"
56 #include "dasher_lock_dialogue.h"
58 // We shouldn't need this - the functions which reference it are obsolete
59 //#include "../DasherCore/Event.h"
61 #include "GtkDasherControl.h"
63 // Pointers to various GTK widgets
65 // GladeXML *widgets;
67 GtkWidget *vbox;
68 GdkPixbuf *p; // Hmm... descriptive names
69 GtkWidget *pw;
70 GtkStyle *style;
71 GtkAccelGroup *dasher_accel;
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 *window;
79 GtkWidget *g_pHiddenWindow;
80 GtkWidget *file_selector;
82 GtkWidget *pDasherWidget = NULL;
83 //GtkWidget *g_pEditPane = 0;
84 //GtkWidget *g_pActionPane = 0;
86 #ifdef WITH_MAEMO
87 Window g_xOldIMWindow;
88 #endif
90 //DasherAction *g_pAction = 0;
92 const gchar *filename = NULL; // Filename of file currently being edited
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;
103 // 'Private' methods
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 /// Initialise the main window and child components
118 /// This is actually closer to 'initialise application', so name
119 /// should really be changed to reflect this
122 void InitialiseMainWindow(int argc, char **argv) {
123 GladeXML *pGladeXML;
124 pGladeXML = dasher_main_get_glade(g_pDasherMain);
126 dasher_accel = gtk_accel_group_new(); //?
128 // widgets = pGladeXML; // obsolete? NO - used later in this file, but should be
129 // Grab some pointers to important GTK widgets from the Glade XML
130 // FIXME - do we actually need all of these?
132 window = glade_xml_get_widget(pGladeXML, "window");
134 vbox = glade_xml_get_widget(pGladeXML, "vbox1");
135 dasher_menu_bar = glade_xml_get_widget(pGladeXML, "dasher_menu_bar");
136 pDasherWidget = glade_xml_get_widget(pGladeXML, "DasherControl");
138 dasher_lock_dialogue_new(pGladeXML, GTK_WINDOW(window));
141 // Initialise the various components
143 initialise_edit(pGladeXML);
144 #ifndef WITH_MAEMO
145 PopulateMenus(pGladeXML);
146 #endif
148 g_pPreferencesDialogue = dasher_preferences_dialogue_new(pGladeXML);
150 InitialiseFontDialogues(pGladeXML);