summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorVincent Sanders <vince@netsurf-browser.org>2011-09-24 09:24:13 +0000
committerVincent Sanders <vince@netsurf-browser.org>2011-09-24 09:24:13 +0000
commit7334ec404e2ff3b3e502bb366afac376b7e6262e (patch)
tree6913e5444fca07e116679232dc769d5666963540 /gtk
parent9854ad631326d19fed5243b51716b3606fb2484c (diff)
downloadnetsurf-7334ec404e2ff3b3e502bb366afac376b7e6262e.tar.gz
netsurf-7334ec404e2ff3b3e502bb366afac376b7e6262e.tar.bz2
reduce to a single global structure for glade file locations
svn path=/trunk/netsurf/; revision=12872
Diffstat (limited to 'gtk')
-rw-r--r--gtk/dialogs/options.c2
-rw-r--r--gtk/gui.c59
-rw-r--r--gtk/gui.h23
-rw-r--r--gtk/login.c2
-rw-r--r--gtk/scaffolding.c2
-rw-r--r--gtk/toolbar.c2
-rw-r--r--gtk/window.c3
7 files changed, 47 insertions, 46 deletions
diff --git a/gtk/dialogs/options.c b/gtk/dialogs/options.c
index 380b767c4..6a015b44b 100644
--- a/gtk/dialogs/options.c
+++ b/gtk/dialogs/options.c
@@ -139,7 +139,7 @@ DECLARE(setDefaultExportOptions);
GtkDialog* nsgtk_options_init(struct browser_window *bw, GtkWindow *parent)
{
- gladeFile = glade_xml_new(glade_options_file_location, NULL, NULL);
+ gladeFile = glade_xml_new(glade_file_location->options, NULL, NULL);
if (gladeFile == NULL)
return NULL;
diff --git a/gtk/gui.c b/gtk/gui.c
index 94e68b84a..271eb2890 100644
--- a/gtk/gui.c
+++ b/gtk/gui.c
@@ -90,18 +90,7 @@ char *res_dir_location;
char *print_options_file_location;
char *languages_file_location;
-char *glade_netsurf_file_location;
-char *glade_password_file_location;
-char *glade_warning_file_location;
-char *glade_login_file_location;
-char *glade_ssl_file_location;
-char *glade_toolbar_file_location;
-char *glade_options_file_location;
-
-static char *glade_downloads_file_location;
-static char *glade_history_file_location;
-static char *glade_hotlist_file_location;
-static char *glade_cookies_file_location;
+struct glade_file_location_s *glade_file_location;
static GtkWindow *nsgtk_warning_window;
GtkWidget *widWarning;
@@ -226,18 +215,23 @@ nsgtk_init_glade(char **respath)
glade_init();
- glade_netsurf_file_location = nsgtk_new_glade(respath, "netsurf", NULL);
- glade_password_file_location = nsgtk_new_glade(respath, "password", NULL);
- glade_login_file_location = nsgtk_new_glade(respath, "login", NULL);
- glade_ssl_file_location = nsgtk_new_glade(respath, "ssl", NULL);
- glade_toolbar_file_location = nsgtk_new_glade(respath, "toolbar", NULL);
- glade_downloads_file_location = nsgtk_new_glade(respath, "downloads", NULL);
- glade_history_file_location = nsgtk_new_glade(respath, "history", NULL);
- glade_options_file_location = nsgtk_new_glade(respath, "options", NULL);
- glade_hotlist_file_location = nsgtk_new_glade(respath, "hotlist", NULL);
- glade_cookies_file_location = nsgtk_new_glade(respath, "cookies", NULL);
-
- glade_warning_file_location = nsgtk_new_glade(respath, "warning", &gladeWarning);
+ glade_file_location = calloc(1, sizeof(struct glade_file_location_s));
+ if (glade_file_location == NULL) {
+ die("Unable to allocate glade file locations");
+ }
+
+ glade_file_location->netsurf = nsgtk_new_glade(respath, "netsurf", NULL);
+ glade_file_location->password = nsgtk_new_glade(respath, "password", NULL);
+ glade_file_location->login = nsgtk_new_glade(respath, "login", NULL);
+ glade_file_location->ssl = nsgtk_new_glade(respath, "ssl", NULL);
+ glade_file_location->toolbar = nsgtk_new_glade(respath, "toolbar", NULL);
+ glade_file_location->downloads = nsgtk_new_glade(respath, "downloads", NULL);
+ glade_file_location->history = nsgtk_new_glade(respath, "history", NULL);
+ glade_file_location->options = nsgtk_new_glade(respath, "options", NULL);
+ glade_file_location->hotlist = nsgtk_new_glade(respath, "hotlist", NULL);
+ glade_file_location->cookies = nsgtk_new_glade(respath, "cookies", NULL);
+
+ glade_file_location->warning = nsgtk_new_glade(respath, "warning", &gladeWarning);
nsgtk_warning_window = GTK_WINDOW(glade_xml_get_widget(gladeWarning, "wndWarning"));
widWarning = glade_xml_get_widget(gladeWarning, "labelWarning");
}
@@ -418,21 +412,22 @@ static void gui_init(int argc, char** argv, char **respath)
gdk_screen_get_default()));
LOG(("Set CSS DPI to %f", FIXTOFLT(nscss_screen_dpi)));
- if (nsgtk_history_init(glade_history_file_location) == false)
+ if (nsgtk_history_init(glade_file_location->history) == false)
die("Unable to initialise history window.\n");
- if (nsgtk_download_init(glade_downloads_file_location) == false)
+ if (nsgtk_download_init(glade_file_location->downloads) == false)
die("Unable to initialise download window.\n");
- if (nsgtk_cookies_init(glade_cookies_file_location) == false)
+ if (nsgtk_cookies_init(glade_file_location->cookies) == false)
die("Unable to initialise cookies window.\n");
- if (nsgtk_hotlist_init(glade_hotlist_file_location) == false)
+ if (nsgtk_hotlist_init(glade_file_location->hotlist) == false)
die("Unable to initialise hotlist window.\n");
sslcert_init(tree_content_icon_name);
- if (option_homepage_url != NULL && option_homepage_url[0] != '\0')
+ if ((option_homepage_url != NULL) &&
+ (option_homepage_url[0] != '\0'))
addr = option_homepage_url;
if (2 <= argc)
@@ -592,10 +587,6 @@ void gui_quit(void)
-
-
-
-
static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
gpointer user_data)
{
@@ -682,7 +673,7 @@ void gui_cert_verify(const char *url, const struct ssl_cert_info *certs,
{
static struct nsgtk_treeview *ssl_window;
struct sslcert_session_data *data;
- GladeXML *x = glade_xml_new(glade_ssl_file_location, NULL, NULL);
+ GladeXML *x = glade_xml_new(glade_file_location->ssl, NULL, NULL);
GtkButton *accept, *reject;
void **session = calloc(sizeof(void *), 3);
GtkWindow *window;
diff --git a/gtk/gui.h b/gtk/gui.h
index 9035d8873..40f41a078 100644
--- a/gtk/gui.h
+++ b/gtk/gui.h
@@ -31,13 +31,22 @@
#include <gtk/gtk.h>
#include <glade/glade.h>
-extern char *glade_netsurf_file_location;
-extern char *glade_password_file_location;
-extern char *glade_warning_file_location;
-extern char *glade_login_file_location;
-extern char *glade_ssl_file_location;
-extern char *glade_toolbar_file_location;
-extern char *glade_options_file_location;
+struct glade_file_location_s {
+ char *netsurf;
+ char *password;
+ char *warning;
+ char *login;
+ char *ssl;
+ char *toolbar;
+ char *options;
+ char *downloads;
+ char *history;
+ char *hotlist;
+ char *cookies;
+};
+
+/** location of all glade files. */
+extern struct glade_file_location_s *glade_file_location;
extern char *languages_file_location;
extern char *toolbar_indices_file_location;
diff --git a/gtk/login.c b/gtk/login.c
index 44ef399af..daf9e9644 100644
--- a/gtk/login.c
+++ b/gtk/login.c
@@ -78,7 +78,7 @@ void create_login_window(const char *url, const char *host, const char *realm,
* the widgets we're interested in.
*/
- GladeXML *x = glade_xml_new(glade_login_file_location, NULL, NULL);
+ GladeXML *x = glade_xml_new(glade_file_location->login, NULL, NULL);
GtkWindow *wnd = GTK_WINDOW(glade_xml_get_widget(x, "wndLogin"));
GtkLabel *lhost, *lrealm;
GtkEntry *euser, *epass;
diff --git a/gtk/scaffolding.c b/gtk/scaffolding.c
index fd076616f..2b345b156 100644
--- a/gtk/scaffolding.c
+++ b/gtk/scaffolding.c
@@ -1644,7 +1644,7 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
/* load the window template from the glade xml file, and extract
* widget references from it for later use.
*/
- g->xml = glade_xml_new(glade_netsurf_file_location,
+ g->xml = glade_xml_new(glade_file_location->netsurf,
"wndBrowser", NULL);
glade_xml_signal_autoconnect(g->xml);
g->window = GTK_WINDOW(GET_WIDGET("wndBrowser"));
diff --git a/gtk/toolbar.c b/gtk/toolbar.c
index 09c309f04..a6b6b283e 100644
--- a/gtk/toolbar.c
+++ b/gtk/toolbar.c
@@ -193,7 +193,7 @@ void nsgtk_toolbar_window_open(nsgtk_scaffolding *g)
nsgtk_toolbar_cancel_clicked(NULL, g);
return;
}
- window->glade = glade_xml_new(glade_toolbar_file_location,
+ window->glade = glade_xml_new(glade_file_location->toolbar,
"toolbarwindow", NULL);
if (window->glade == NULL) {
warn_user(messages_get("NoMemory"), 0);
diff --git a/gtk/window.c b/gtk/window.c
index 4c85afa6a..088fa28ae 100644
--- a/gtk/window.c
+++ b/gtk/window.c
@@ -522,7 +522,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
/* Construct our primary elements */
/* top-level document (not a frame) => create a new tab */
- GladeXML *xml = glade_xml_new(glade_netsurf_file_location, "tabContents", NULL);
+ GladeXML *xml = glade_xml_new(glade_file_location->netsurf,
+ "tabContents", NULL);
if (!xml) {
warn_user("MiscError", "Failed to create tab contents");
free(g);