2 * This file is part of MaePad
3 * Copyright (c) 2010 Thomas Perl <thp.io/about>
4 * http://thp.io/2010/maepad/
7 * Copyright (c) 2006-2008 Kemal Hadimli
8 * Copyright (c) 2008 Thomas Perl
10 * This software is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public License
12 * as published by the Free Software Foundation; either version 2.1 of
13 * the License, or (at your option) any later version.
15 * This software is distributed in the hope that it will be useful, but
16 * WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 * Lesser General Public License for more details.
20 * You should have received a copy of the GNU Lesser General Public
21 * License along with this software; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
27 #include <ui/interface.h>
28 #include <ui/callbacks.h>
32 #include <gtk/gtkmain.h>
33 #include <hildon/hildon-program.h>
34 #include <hildon/hildon-note.h>
39 #define _(String) gettext(String)
47 AppData
* app_data
= g_new0(AppData
, 1);
49 app_data
->app
= HILDON_PROGRAM(hildon_program_get_instance());
50 g_assert(app_data
->app
);
51 app_data
->osso
= osso_initialize("org.maemo.maepad", VERSION
, FALSE
, NULL
);
52 g_assert(app_data
->osso
);
53 app_data
->gconf
= gconf_client_get_default();
54 g_assert(app_data
->gconf
);
60 app_data_destroy(AppData
* app_data
)
62 osso_deinitialize(app_data
->osso
);
63 g_object_unref(app_data
->gconf
);
68 int main(int argc
, char *argv
[])
73 /* Initialise the locale stuff */
74 setlocale(LC_ALL
, "");
75 bindtextdomain(GETTEXT_PACKAGE
, LOCALEDIR
);
76 bind_textdomain_codeset(GETTEXT_PACKAGE
, "UTF-8");
77 textdomain(GETTEXT_PACKAGE
);
79 /* Init the gtk - must be called before any hildon stuff */
80 gtk_init(&argc
, &argv
);
82 /* Create the hildon application and setup the title */
83 g_set_application_name ("MæPad");
85 /* Create the data and views for our application */
86 app_data
= app_data_new();
87 main_view
= interface_main_view_new(app_data
);
89 /* Check if we can directly open the last document */
90 gchar
* last_document
= gconf_client_get_string(app_data
->gconf
, MAEPAD_GCONF_LAST_DOCUMENT
, NULL
);
92 if (last_document
!= NULL
) {
93 open_file(last_document
, main_view
);
94 g_free(last_document
);
97 gboolean do_quit
= FALSE
;
98 while (main_view
->file_name
== NULL
&& !do_quit
) {
99 switch (interface_initial_setup(main_view
)) {
100 case RESPONSE_CREATE_NEW
:
101 callback_file_new(NULL
, main_view
);
103 case RESPONSE_OPEN_FILE
:
104 callback_file_open(NULL
, main_view
);
112 if (main_view
->file_name
!= NULL
) {
113 /* Ready to begin the main loop */
116 /* Remember last filename on close */
117 if (main_view
->file_name
!= NULL
) {
118 gconf_client_set_string(app_data
->gconf
, MAEPAD_GCONF_LAST_DOCUMENT
, main_view
->file_name
, NULL
);
122 /* Clean-up the interface and app data objects */
123 interface_main_view_destroy(main_view
);
124 app_data_destroy(app_data
);