1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
/***************************************************************************
* gui.c
*
* Copyright 2005 Ian McIntosh
* ian_mcintosh@linuxadvocate.org
****************************************************************************/
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <glade/glade.h>
#include <gtk/gtk.h>
#include "main.h"
#include "gui.h"
#include "db.h"
#include "mainwindow.h"
#include "gotowindow.h"
#include "importwindow.h"
#include "searchwindow.h"
#include "mapinfowindow.h"
#include "locationeditwindow.h"
#ifdef ENABLE_TEST_MODULES
#include "test_poly.h"
#endif
void gui_init(void)
{
GladeXML* pGladeXML = gui_load_xml(GLADE_FILE_NAME, NULL);
glade_xml_signal_autoconnect(pGladeXML);
// init all windows/dialogs
g_print("- initializing mapinfowindow\n");
mapinfowindow_init(pGladeXML);
g_print("- initializing mainwindow\n");
mainwindow_init(pGladeXML);
g_print("- initializing searchwindow\n");
searchwindow_init(pGladeXML);
g_print("- initializing gotowindow\n");
gotowindow_init(pGladeXML);
g_print("- initializing importwindow\n");
importwindow_init(pGladeXML);
#ifdef ENABLE_TEST_MODULES
g_print("- initializing test_poly\n");
test_poly_init(pGladeXML);
#endif
//datasetwindow_init(pGladeXML);
g_print("- initializing locationeditwindow\n");
locationeditwindow_init(pGladeXML);
}
GladeXML* gui_load_xml(gchar* pszFileName, gchar* pszXMLTreeRoot)
{
GladeXML *pGladeXML;
gchar* pszPath;
// Load glade UI definition file and connect to callback functions
// try source directory first (good for development)
pszPath = g_strdup_printf(PACKAGE_SOURCE_DIR"/data/%s", pszFileName);
pGladeXML = glade_xml_new(pszPath, pszXMLTreeRoot, NULL);
g_free(pszPath);
if(pGladeXML == NULL) {
pszPath = g_strdup_printf(PACKAGE_DATA_DIR"/data/%s", pszFileName);
pGladeXML = glade_xml_new(pszPath, pszXMLTreeRoot, NULL);
g_free(pszPath);
if(pGladeXML == NULL) {
g_message("cannot find glade file '%s'\n", pszFileName);
gtk_main_quit();
}
}
return pGladeXML;
}
void gui_run()
{
mainwindow_show();
gtk_main();
}
void gui_exit()
{
// Hide first, then quit (makes the UI feel snappier)
mainwindow_hide();
gotowindow_hide();
importwindow_hide();
locationeditwindow_hide();
gtk_main_quit();
}
|