2 * This file is part of maemopad+
5 * This software is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public License
7 * as published by the Free Software Foundation; either version 2.1 of
8 * the License, or (at your option) any later version.
10 * This software is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this software; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 #include <ui/interface.h>
23 #include <ui/callbacks.h>
27 #include <gtk/gtkmain.h>
28 #include <hildon/hildon-program.h>
29 #include <hildon/hildon-note.h>
34 #define _(String) gettext(String)
42 AppData
* app_data
= g_new0(AppData
, 1);
44 app_data
->app
= HILDON_PROGRAM(hildon_program_get_instance());
45 g_assert(app_data
->app
);
46 app_data
->osso
= osso_initialize("maepad", VERSION
, FALSE
, NULL
);
47 g_assert(app_data
->osso
);
48 app_data
->gconf
= gconf_client_get_default();
49 g_assert(app_data
->gconf
);
55 app_data_destroy(AppData
* app_data
)
57 osso_deinitialize(app_data
->osso
);
58 g_object_unref(app_data
->gconf
);
63 int main(int argc
, char *argv
[])
68 /* Initialise the locale stuff */
69 setlocale(LC_ALL
, "");
70 bindtextdomain(GETTEXT_PACKAGE
, LOCALEDIR
);
71 bind_textdomain_codeset(GETTEXT_PACKAGE
, "UTF-8");
72 textdomain(GETTEXT_PACKAGE
);
74 /* Init the gtk - must be called before any hildon stuff */
75 gtk_init(&argc
, &argv
);
77 /* Create the hildon application and setup the title */
78 g_set_application_name ("MæPad");
80 /* Create the data and views for our application */
81 app_data
= app_data_new();
82 main_view
= interface_main_view_new(app_data
);
84 /* Add handler for hardware D-BUS messages */
85 g_assert(osso_hw_set_event_cb(app_data
->osso
, NULL
, hw_event_handler
, (gpointer
)main_view
) == OSSO_OK
);
87 /* Check if we can directly open the last document */
88 gchar
* last_document
= gconf_client_get_string(app_data
->gconf
, MAEPAD_GCONF_LAST_DOCUMENT
, NULL
);
90 if (last_document
!= NULL
) {
91 open_file(last_document
, main_view
);
92 g_free(last_document
);
95 gboolean do_quit
= FALSE
;
96 while (main_view
->file_name
== NULL
&& !do_quit
) {
97 switch (interface_initial_setup(main_view
)) {
98 case RESPONSE_CREATE_NEW
:
99 callback_file_new(NULL
, main_view
);
101 case RESPONSE_OPEN_FILE
:
102 callback_file_open(NULL
, main_view
);
110 if (main_view
->file_name
!= NULL
) {
111 /* Ready to begin the main loop */
114 /* Remember last filename on close */
115 if (main_view
->file_name
!= NULL
) {
116 gconf_client_set_string(app_data
->gconf
, MAEPAD_GCONF_LAST_DOCUMENT
, main_view
->file_name
, NULL
);
120 /* Clean-up the interface and app data objects */
121 interface_main_view_destroy(main_view
);
122 app_data_destroy(app_data
);