diff options
author | Vincent Sanders <vince@kyllikki.org> | 2016-07-25 21:55:03 +0100 |
---|---|---|
committer | Vincent Sanders <vince@kyllikki.org> | 2016-07-25 21:59:17 +0100 |
commit | 2d41d6c933cec1a0660bc71aaa115b41dcfdfbed (patch) | |
tree | a6f8091e9742b0a9672ac2be44d505e460440aed /frontends/gtk/cookies.c | |
parent | 0c7649d030d980755d9659574214f104368fc6a0 (diff) | |
download | netsurf-2d41d6c933cec1a0660bc71aaa115b41dcfdfbed.tar.gz netsurf-2d41d6c933cec1a0660bc71aaa115b41dcfdfbed.tar.bz2 |
cleanup gtk cookie interface
use gtk_window_present instead of gdk_window_raise and reduce exposed
variables and interfaces.
Diffstat (limited to 'frontends/gtk/cookies.c')
-rw-r--r-- | frontends/gtk/cookies.c | 51 |
1 files changed, 37 insertions, 14 deletions
diff --git a/frontends/gtk/cookies.c b/frontends/gtk/cookies.c index 76894fab4..f252e6b3c 100644 --- a/frontends/gtk/cookies.c +++ b/frontends/gtk/cookies.c @@ -35,7 +35,11 @@ #include "gtk/treeview.h" #include "gtk/resources.h" -#define MENUPROTO(x) static gboolean nsgtk_on_##x##_activate( \ +static struct nsgtk_treeview *cookies_treeview; +static GtkBuilder *cookie_builder; +static GtkWindow *wndCookies = NULL; + +#define MENUPROTO(x) static gboolean nsgtk_on_##x##_activate( \ GtkMenuItem *widget, gpointer g) #define MENUEVENT(x) { #x, G_CALLBACK(nsgtk_on_##x##_activate) } #define MENUHANDLER(x) gboolean nsgtk_on_##x##_activate(GtkMenuItem *widget, \ @@ -80,9 +84,7 @@ static struct menu_events menu_events[] = { {NULL, NULL} }; -static struct nsgtk_treeview *cookies_treeview; -static GtkBuilder *cookie_builder; -GtkWindow *wndCookies; + /** * Connects menu events in the cookies window. @@ -102,13 +104,21 @@ static void nsgtk_cookies_init_menu(void) } } -/* exported interface documented in gtk/cookies.h */ -nserror nsgtk_cookies_init(void) +/** + * Creates the window for the cookies tree. + * + * \return NSERROR_OK on success else appropriate error code on faliure. + */ +static nserror nsgtk_cookies_init(void) { GtkScrolledWindow *scrolled; GtkDrawingArea *drawing_area; nserror res; + if (wndCookies != NULL) { + return NSERROR_OK; + } + res = nsgtk_builder_new_from_resname("cookies", &cookie_builder); if (res != NSERROR_OK) { LOG("Cookie UI builder init failed"); @@ -147,14 +157,6 @@ nserror nsgtk_cookies_init(void) } -/** - * Destroys the cookies window and performs any other necessary cleanup actions. - */ -void nsgtk_cookies_destroy(void) -{ - /** \todo what about cookie_builder? */ - nsgtk_treeview_destroy(cookies_treeview); -} /* edit menu */ @@ -219,3 +221,24 @@ MENUHANDLER(collapse_cookies) cookie_manager_contract(false); return TRUE; } + +/* exported function documented gtk/cookies.h */ +nserror nsgtk_cookies_present(void) +{ + nserror res; + + res = nsgtk_cookies_init(); + if (res == NSERROR_OK) { + gtk_window_present(wndCookies); + } + return res; +} + +/* exported function documented gtk/cookies.h */ +void nsgtk_cookies_destroy(void) +{ + /** \todo what about cookie_builder? */ + if (wndCookies != NULL) { + nsgtk_treeview_destroy(cookies_treeview); + } +} |