2 * Copyright (C) 2008 Liam Girdwood
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330,
17 * Boston, MA 02111-1307, USA.
26 #include <glade/glade.h>
40 static struct ui_glade ui
[] = {
41 /* {"/splash.glade", "Splash", NULL, NULL},*/
42 {"/date-time-dlg.glade", "DateTimeDialog", NULL
, NULL
},
43 {"/observer-dlg.glade", "ObserverDialog", NULL
, NULL
},
44 {"/sky-catalog-dlg.glade", "SkyCatalogDialog", NULL
, NULL
},
45 {"/sky-deep-dlg.glade", "SkyDeepDialog", NULL
, NULL
},
46 {"/sky-near-dlg.glade", "SkyNearDialog", NULL
, NULL
},
47 {"/sky-markers-dlg.glade", "SkyMarkersDialog", NULL
, NULL
},
48 {"/sky-proj-dlg.glade", "SkyProjectionDialog", NULL
, NULL
},
51 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
57 for (i
= 0; i
< ARRAY_SIZE(ui
); i
++) {
58 GString
*interface
= NULL
;
63 interface
= g_string_new(NOVA_GLADE_DIR
);
64 interface
= g_string_append(interface
, ui
[i
].glade_file
);
66 g_print("%s: loading %s\n", __func__
, interface
->str
);
67 ui
[i
].xml
= glade_xml_new(interface
->str
, ui
[i
].name
, NULL
);
69 g_string_free(interface
, TRUE
);
72 g_critical("%s: failed to load\n", __func__
);
76 glade_xml_signal_autoconnect(ui
[i
].xml
);
77 ui
[i
].widget
= glade_xml_get_widget(ui
[i
].xml
, ui
[i
].name
);
80 g_critical("%s: failed to get widget %s\n", __func__
,
89 GtkWidget
* ui_get_dialog(gchar
* name
)
94 g_critical("%s: can't load glade UI files", __func__
);
98 for (i
= 0; i
< ARRAY_SIZE(ui
); i
++) {
99 if (!strcmp(name
, ui
[i
].name
))
103 g_critical("%s: can't find glade UI %s", __func__
, name
);
107 void ui_put_dialog(gchar
* name
)
111 for (i
= 0; i
< ARRAY_SIZE(ui
); i
++) {
112 if (!strcmp(name
, ui
[i
].name
)) {
114 g_object_unref(ui
[i
].xml
);
118 g_critical("%s: can't find glade UI %s", __func__
, name
);