summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--frontends/gtk/gui.c7
-rw-r--r--frontends/gtk/options.h9
-rw-r--r--frontends/gtk/res/toolbar.gtk2.ui3
-rw-r--r--frontends/gtk/scaffolding.c85
-rw-r--r--frontends/gtk/scaffolding.h6
-rw-r--r--frontends/gtk/tabs.c5
-rw-r--r--frontends/gtk/toolbar.c581
-rw-r--r--frontends/gtk/toolbar.h9
-rw-r--r--frontends/gtk/toolbar_items.h17
-rw-r--r--frontends/gtk/window.c42
-rw-r--r--frontends/gtk/window.h18
11 files changed, 509 insertions, 273 deletions
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index a87ef7281..f14c7bd92 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -249,6 +249,13 @@ static nserror set_defaults(struct nsoption_s *defaults)
break;
}
+ /* set default items in toolbar */
+ nsoption_set_charp(toolbar_items,
+ strdup("back/history/forward/reloadstop/url_bar/websearch/openmenu"));
+
+ /* set default for menu and tool bar visibility */
+ nsoption_set_charp(bar_show, strdup("tool"));
+
return NSERROR_OK;
}
diff --git a/frontends/gtk/options.h b/frontends/gtk/options.h
index 018a448be..dad17f059 100644
--- a/frontends/gtk/options.h
+++ b/frontends/gtk/options.h
@@ -16,8 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _NETSURF_GTK_OPTIONS_H_
-#define _NETSURF_GTK_OPTIONS_H_
+#ifndef NETSURF_GTK_OPTIONS_H_
+#define NETSURF_GTK_OPTIONS_H_
/* currently nothing here */
@@ -72,4 +72,7 @@ NSOPTION_INTEGER(developer_view, 0)
NSOPTION_INTEGER(position_tab, 0)
/* Toolbar customisation */
-NSOPTION_STRING(toolbar_order, NULL)
+NSOPTION_STRING(toolbar_items, NULL)
+
+/* The menu and tool bars that are shown */
+NSOPTION_STRING(bar_show, NULL)
diff --git a/frontends/gtk/res/toolbar.gtk2.ui b/frontends/gtk/res/toolbar.gtk2.ui
index 22889717f..61723065b 100644
--- a/frontends/gtk/res/toolbar.gtk2.ui
+++ b/frontends/gtk/res/toolbar.gtk2.ui
@@ -25,8 +25,9 @@
<property name="label" translatable="yes">gtkCustomizeToolbarInstructions</property>
</object>
<packing>
- <property name="expand">True</property>
+ <property name="expand">False</property>
<property name="fill">True</property>
+ <property name="padding">6</property>
<property name="position">1</property>
</packing>
</child>
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 5a50d8101..526c0be83 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -48,7 +48,10 @@ struct nsgtk_menu {
GtkWidget *main; /* main menu entry */
GtkWidget *burger; /* right click menu */
GtkWidget *popup; /* popup menu entry */
- void *mhandler; /* menu item handler */
+ /**
+ * menu item handler
+ */
+ gboolean (*mhandler)(GtkMenuItem *widget, gpointer data);
const char *iconname; /* name of the icon to use */
bool sensitivity; /* menu item is sensitive */
};
@@ -589,6 +592,55 @@ static gboolean nsgtk_on_find_activate_menu(GtkMenuItem *widget, gpointer data)
return TRUE;
}
+static nserror get_bar_show(bool *menu, bool *tool)
+{
+ const char *cur_bar_show;
+
+ *menu = false;
+ *tool = false;
+
+ cur_bar_show = nsoption_charp(bar_show);
+ if (cur_bar_show != NULL) {
+ if (strcmp(cur_bar_show, "menu/tool") == 0) {
+ *menu = true;
+ *tool = true;
+ } else if (strcmp(cur_bar_show, "menu") == 0) {
+ *menu = true;
+ } else if (strcmp(cur_bar_show, "tool") == 0) {
+ *tool = true;
+ }
+ }
+
+ return NSERROR_OK;
+}
+
+static nserror set_bar_show(const char *bar, bool show)
+{
+ bool menu;
+ bool tool;
+ const char *new_bar_show;
+
+ get_bar_show(&menu, &tool);
+
+ if (strcmp(bar, "menu") == 0) {
+ menu = show;
+ } else if (strcmp(bar, "tool") == 0) {
+ tool = show;
+ }
+
+ if ((menu == true) && (tool == true)) {
+ new_bar_show = "menu/tool";
+ } else if (menu == true) {
+ new_bar_show = "menu";
+ } else if (tool == true) {
+ new_bar_show = "tool";
+ } else {
+ new_bar_show = "none";
+ }
+ nsoption_set_charp(bar_show, strdup(new_bar_show));
+
+ return NSERROR_OK;
+}
static gboolean
nsgtk_on_menubar_activate_menu(GtkMenuItem *widget, gpointer data)
@@ -617,7 +669,7 @@ nsgtk_on_menubar_activate_menu(GtkMenuItem *widget, gpointer data)
}
gtk_widget_show(GTK_WIDGET(gs->menu_bar->bar_menu));
-
+ set_bar_show("menu", true);
} else {
if (gtk_check_menu_item_get_active(bmcmi) == TRUE) {
gtk_check_menu_item_set_active(bmcmi, FALSE);
@@ -632,6 +684,7 @@ nsgtk_on_menubar_activate_menu(GtkMenuItem *widget, gpointer data)
}
gtk_widget_hide(GTK_WIDGET(gs->menu_bar->bar_menu));
+ set_bar_show("menu", false);
}
return TRUE;
}
@@ -664,6 +717,7 @@ nsgtk_on_toolbar_activate_menu(GtkMenuItem *widget, gpointer data)
}
nsgtk_window_toolbar_show(gs, true);
+ set_bar_show("tool", true);
} else {
if (gtk_check_menu_item_get_active(bmcmi) == TRUE) {
gtk_check_menu_item_set_active(bmcmi, FALSE);
@@ -678,6 +732,7 @@ nsgtk_on_toolbar_activate_menu(GtkMenuItem *widget, gpointer data)
}
nsgtk_window_toolbar_show(gs, false);
+ set_bar_show("tool", false);
}
return TRUE;
}
@@ -792,6 +847,7 @@ create_scaffolding_burger_menu(struct nsgtk_scaffolding *gs,
return nmenu;
}
+
/**
* Create and connect handlers to popup menu.
*
@@ -800,7 +856,8 @@ create_scaffolding_burger_menu(struct nsgtk_scaffolding *gs,
* \return menu structure on success or NULL on error.
*/
static struct nsgtk_popup_menu *
-create_scaffolding_popup_menu(struct nsgtk_scaffolding *gs, GtkAccelGroup *group)
+create_scaffolding_popup_menu(struct nsgtk_scaffolding *gs,
+ GtkAccelGroup *group)
{
struct nsgtk_popup_menu *nmenu;
@@ -1013,6 +1070,7 @@ static void nsgtk_menu_set_sensitivity(struct nsgtk_scaffolding *g)
}
}
+
/* set menu items to have icons */
static void nsgtk_menu_set_icons(struct nsgtk_scaffolding *g)
{
@@ -1041,6 +1099,7 @@ static void nsgtk_menu_set_icons(struct nsgtk_scaffolding *g)
}
}
+
/**
* create and initialise menus
*
@@ -1103,10 +1162,6 @@ static nserror nsgtk_menus_create(struct nsgtk_scaffolding *gs)
}
-
-
-
-
/* exported function documented in gtk/scaffolding.h */
void nsgtk_scaffolding_set_title(struct gui_window *gw, const char *title)
{
@@ -1189,12 +1244,6 @@ GtkNotebook* nsgtk_scaffolding_notebook(struct nsgtk_scaffolding *g)
return g->notebook;
}
-/* exported interface documented in gtk/scaffolding.h */
-GtkWidget *nsgtk_scaffolding_urlbar(struct nsgtk_scaffolding *g)
-{
- return NULL;//g->url_bar;
-}
-
/* exported interface documented in gtk/scaffolding.h */
GtkMenuBar *nsgtk_scaffolding_menu_bar(struct nsgtk_scaffolding *gs)
@@ -1373,6 +1422,8 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
{
nserror res;
struct nsgtk_scaffolding *gs;
+ bool menu;
+ bool tool;
gs = calloc(1, sizeof(*gs));
if (gs == NULL) {
@@ -1457,6 +1508,14 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
gs->prev = NULL;
scaf_list = gs;
+ /* set menu and tool bar visibility */
+ get_bar_show(&menu, &tool);
+ if (menu) {
+ gtk_widget_show(GTK_WIDGET(gs->menu_bar->bar_menu));
+ } else {
+ gtk_widget_hide(GTK_WIDGET(gs->menu_bar->bar_menu));
+ }
+
/* finally, show the window. */
gtk_widget_show(GTK_WIDGET(gs->window));
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index c30c58534..1fae00394 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -79,12 +79,6 @@ GtkWindow *nsgtk_scaffolding_window(struct nsgtk_scaffolding *g);
*/
GtkNotebook *nsgtk_scaffolding_notebook(struct nsgtk_scaffolding *g);
-/**
- * Get the gtk url bar from a scaffold.
- */
-GtkWidget *nsgtk_scaffolding_urlbar(struct nsgtk_scaffolding *g);
-
-
struct gtk_search *nsgtk_scaffolding_search(struct nsgtk_scaffolding *g);
GtkMenuBar *nsgtk_scaffolding_menu_bar(struct nsgtk_scaffolding *g);
diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c
index 6f4b22b0e..ae07c167f 100644
--- a/frontends/gtk/tabs.c
+++ b/frontends/gtk/tabs.c
@@ -287,6 +287,7 @@ nsgtk_tab_add_newtab(GtkNotebook *notebook)
tabcontents = nsgtk_hbox_new(FALSE, 1);
add = gtk_image_new_from_icon_name(NSGTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
+ gtk_widget_set_tooltip_text(add, "New Tab");
gtk_box_pack_start(GTK_BOX(tablabel), add, FALSE, FALSE, 0);
@@ -424,10 +425,6 @@ void nsgtk_tab_add(struct gui_window *gw,
nsgtk_tab_add_page(notebook, tab_contents, background, title, icon_pixbuf);
-#if 0
- gtk_widget_grab_focus(GTK_WIDGET(nsgtk_scaffolding_urlbar(
- nsgtk_get_scaffold(gw))));
-#endif
}
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 0d868a0ba..8eba86718 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -106,17 +106,41 @@
* toolbar item context
*/
struct nsgtk_toolbar_item {
+
+ /**
+ * GTK widget in the toolbar
+ */
GtkToolItem *button;
- int location; /* in toolbar */
+
+ /**
+ * location index in toolbar
+ */
+ int location;
+
+ /**
+ * if the item is currently sensitive in the toolbar
+ */
bool sensitivity;
/**
- * button clicked handler
+ * textural name used in serialising items
*/
- gboolean (*bhandler)(GtkWidget *widget, gpointer data);
+ const char *name;
- void *dataplus; /* customisation -> toolbar */
- void *dataminus; /* customisation -> store */
+ /**
+ * button clicked on toolbar handler
+ */
+ gboolean (*clicked)(GtkWidget *widget, gpointer data);
+
+ /**
+ * handler when dragging from customisation toolbox to toolbar
+ */
+ void *dataplus;
+
+ /**
+ * handler when dragging from toolbar to customisation toolbox
+ */
+ void *dataminus;
};
@@ -138,13 +162,14 @@ struct nsgtk_toolbar {
*/
struct nsgtk_toolbar_item items[PLACEHOLDER_BUTTON];
- /** entry widget holding the url of the current displayed page */
- GtkWidget *url_bar;
-
- /** Current frame of throbber animation */
+ /**
+ * Current frame of throbber animation
+ */
int throb_frame;
- /** Web search widget */
+ /**
+ * Web search widget
+ */
GtkWidget *webSearchEntry;
/**
@@ -196,8 +221,6 @@ struct nsgtk_toolbar_customisation {
};
-static bool edit_mode = false;
-
/* forward declaration */
static nserror toolbar_item_create(nsgtk_toolbar_button id,
struct nsgtk_toolbar_item *item_out);
@@ -237,7 +260,7 @@ static char *remove_underscores(const char *s, bool replacespace)
* create a gtk entry widget with a completion attached
*/
static GtkToolItem *
-make_toolbar_item_throbber(bool sensitivity)
+make_toolbar_item_throbber(bool sensitivity, bool edit)
{
nserror res;
GtkToolItem *item;
@@ -249,7 +272,7 @@ make_toolbar_item_throbber(bool sensitivity)
return NULL;
}
- if (edit_mode) {
+ if (edit) {
const char *msg;
msg = messages_get("ToolThrob");
item = gtk_tool_button_new(
@@ -280,7 +303,7 @@ make_toolbar_item_throbber(bool sensitivity)
* create a gtk entry widget with a completion attached
*/
static GtkToolItem *
-make_toolbar_item_url_bar(bool sensitivity)
+make_toolbar_item_url_bar(bool sensitivity, bool edit)
{
GtkToolItem *item;
GtkWidget *entry;
@@ -292,7 +315,7 @@ make_toolbar_item_url_bar(bool sensitivity)
return NULL;
}
- if (edit_mode) {
+ if (edit) {
gtk_entry_set_width_chars(GTK_ENTRY(entry), 9);
item = gtk_tool_button_new(NULL, "URL");
@@ -323,7 +346,7 @@ make_toolbar_item_url_bar(bool sensitivity)
* create web search toolbar item widget
*/
static GtkToolItem *
-make_toolbar_item_websearch(bool sensitivity)
+make_toolbar_item_websearch(bool sensitivity, bool edit)
{
GtkToolItem *item;
nserror res;
@@ -353,7 +376,7 @@ make_toolbar_item_websearch(bool sensitivity)
NSGTK_STOCK_INFO);
}
- if (edit_mode) {
+ if (edit) {
gtk_entry_set_width_chars(GTK_ENTRY(entry), 9);
item = gtk_tool_button_new(NULL, "Web Search");
@@ -380,13 +403,13 @@ make_toolbar_item_websearch(bool sensitivity)
* create local history toolbar item widget
*/
static GtkToolItem *
-make_toolbar_item_history(bool sensitivity)
+make_toolbar_item_history(bool sensitivity, bool edit)
{
GtkToolItem *item;
const char *msg = "H";
char *label = NULL;
- if (edit_mode) {
+ if (edit) {
msg = messages_get("gtkLocalHistory");
}
label = remove_underscores(msg, false);
@@ -410,7 +433,8 @@ make_toolbar_item_history(bool sensitivity)
static GtkToolItem *
make_toolbar_item_button(const char *labelmsg,
const char *iconname,
- bool sensitivity)
+ bool sensitivity,
+ bool edit)
{
GtkToolItem *item;
char *label = NULL;
@@ -426,7 +450,7 @@ make_toolbar_item_button(const char *labelmsg,
gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(item), iconname);
gtk_widget_set_sensitive(GTK_WIDGET(item), sensitivity);
- if (edit_mode) {
+ if (edit) {
nsgtk_widget_set_margins(GTK_WIDGET(item), 0, 0);
}
}
@@ -443,42 +467,105 @@ make_toolbar_item_button(const char *labelmsg,
* \return gtk widget
*/
static GtkToolItem *
-make_toolbar_item(nsgtk_toolbar_button itemid,
- bool sensitivity)
+make_toolbar_item(nsgtk_toolbar_button itemid, bool sensitivity)
+{
+ GtkToolItem *toolitem = NULL;
+
+ switch(itemid) {
+#define TOOLBAR_ITEM_y(identifier, label, iconame)
+#define TOOLBAR_ITEM_n(identifier, label, iconame)
+#define TOOLBAR_ITEM_t(identifier, label, iconame) \
+ case identifier: \
+ toolitem = make_toolbar_item_button(#label, iconame, sensitivity, false); \
+ break;
+#define TOOLBAR_ITEM_b(identifier, label, iconame) \
+ case identifier: \
+ toolitem = make_toolbar_item_button(#label, iconame, sensitivity, false); \
+ break;
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, label, iconame) \
+ TOOLBAR_ITEM_ ## clicked(identifier, label, iconame)
+
+#include "gtk/toolbar_items.h"
+
+#undef TOOLBAR_ITEM_t
+#undef TOOLBAR_ITEM_b
+#undef TOOLBAR_ITEM_n
+#undef TOOLBAR_ITEM_y
+#undef TOOLBAR_ITEM
+
+ case HISTORY_BUTTON:
+ toolitem = make_toolbar_item_history(sensitivity, false);
+ break;
+
+ case URL_BAR_ITEM:
+ toolitem = make_toolbar_item_url_bar(sensitivity, false);
+ break;
+
+ case THROBBER_ITEM:
+ toolitem = make_toolbar_item_throbber(sensitivity, false);
+ break;
+
+ case WEBSEARCH_ITEM:
+ toolitem = make_toolbar_item_websearch(sensitivity, false);
+ break;
+
+ default:
+ break;
+
+ }
+ return toolitem;
+}
+
+
+/**
+ * widget factory for creation of toolbar item widgets for the toolbox
+ *
+ * \param itemid the id of the widget
+ * \return gtk tool item widget
+ */
+static GtkToolItem *
+make_toolbox_item(nsgtk_toolbar_button itemid, bool bar)
{
GtkToolItem *toolitem = NULL;
switch(itemid) {
#define TOOLBAR_ITEM_y(identifier, label, iconame)
#define TOOLBAR_ITEM_n(identifier, label, iconame)
+#define TOOLBAR_ITEM_t(identifier, label, iconame) \
+ case identifier: \
+ if (bar) { \
+ toolitem = make_toolbar_item_button(#label, iconame, true, true); \
+ } \
+ break;
#define TOOLBAR_ITEM_b(identifier, label, iconame) \
case identifier: \
- toolitem = make_toolbar_item_button(#label, iconame, sensitivity);\
+ toolitem = make_toolbar_item_button(#label, iconame, true, true); \
break;
#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, label, iconame) \
TOOLBAR_ITEM_ ## clicked(identifier, label, iconame)
#include "gtk/toolbar_items.h"
+#undef TOOLBAR_ITEM_t
#undef TOOLBAR_ITEM_b
#undef TOOLBAR_ITEM_n
#undef TOOLBAR_ITEM_y
#undef TOOLBAR_ITEM
case HISTORY_BUTTON:
- toolitem = make_toolbar_item_history(sensitivity);
+ toolitem = make_toolbar_item_history(true, true);
break;
case URL_BAR_ITEM:
- toolitem = make_toolbar_item_url_bar(sensitivity);
+ toolitem = make_toolbar_item_url_bar(false, true);
break;
case THROBBER_ITEM:
- toolitem = make_toolbar_item_throbber(sensitivity);
+ toolitem = make_toolbar_item_throbber(true, true);
break;
case WEBSEARCH_ITEM:
- toolitem = make_toolbar_item_websearch(sensitivity);
+ toolitem = make_toolbar_item_websearch(false, true);
break;
default:
@@ -488,6 +575,7 @@ make_toolbar_item(nsgtk_toolbar_button itemid,
return toolitem;
}
+
/**
* target entry for drag source
*/
@@ -499,43 +587,79 @@ static GtkTargetEntry target_entry = {
/**
+ * find the toolbar item with a given location.
+ *
+ * \param tb the toolbar instance
+ * \param locaction the location to search for
+ * \return the item id for a location
+ */
+static nsgtk_toolbar_button
+itemid_from_location(struct nsgtk_toolbar *tb, int location)
+{
+ int iidx;
+ for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
+ if (tb->items[iidx].location == location) {
+ break;
+ }
+ }
+ return iidx;
+}
+
+
+/**
* save toolbar settings to file
*/
static nserror
-nsgtk_toolbar_customisation_save(struct nsgtk_toolbar_customisation *tbc)
+nsgtk_toolbar_customisation_save(struct nsgtk_toolbar *tb)
{
+ int iidx; /* item index */
+ char *order; /* item ordering */
+ char *start; /* start of next item name to be output */
+ int orderlen = 0; /* length of item ordering */
+ nsgtk_toolbar_button itemid;
+ int location;
char *choices = NULL;
- char *order;
- int order_len;
- int tbidx;
- char *cur;
- int plen;
- order_len = PLACEHOLDER_BUTTON * 12; /* length of order buffer */
- order = malloc(order_len);
+ for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
+ if (tb->items[iidx].location != INACTIVE_LOCATION) {
+ orderlen += strlen(tb->items[iidx].name);
+ orderlen++; /* allow for separator */
+ }
+ }
+
+ /* ensure there are some items to store */
+ if (orderlen == 0) {
+ return NSERROR_INVALID;
+ }
+ order = malloc(orderlen);
if (order == NULL) {
return NSERROR_NOMEM;
}
- cur = order;
- for (tbidx = BACK_BUTTON; tbidx < PLACEHOLDER_BUTTON; tbidx++) {
- plen = snprintf(cur,
- order_len,
- "%d;%d|",
- tbidx,
- tbc->toolbar.items[tbidx].location);
- if (plen == order_len) {
- /* ran out of space, bail early */
- NSLOG(netsurf, INFO,
- "toolbar ordering exceeded available space");
+ start = order;
+
+ for (location = BACK_BUTTON;
+ location < PLACEHOLDER_BUTTON;
+ location++) {
+ itemid = itemid_from_location(tb, location);
+ if (itemid == PLACEHOLDER_BUTTON) {
+ /* no more filled locations */
+ break;
+ }
+ start += snprintf(start,
+ orderlen - (start - order),
+ "%s/",
+ tb->items[itemid].name);
+
+ if ((start - order) >= orderlen) {
break;
}
- cur += plen;
- order_len -= plen;
}
- nsoption_set_charp(toolbar_order, order);
+ order[orderlen - 1] = 0;
+
+ nsoption_set_charp(toolbar_items, order);
/* ensure choices are saved */
netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
@@ -549,26 +673,6 @@ nsgtk_toolbar_customisation_save(struct nsgtk_toolbar_customisation *tbc)
/**
- * find the toolbar item with a given location.
- *
- * \param tb the toolbar instance
- * \param locaction the location to search for
- * \return the item id for a location
- */
-static nsgtk_toolbar_button
-itemid_from_location(struct nsgtk_toolbar *tb, int location)
-{
- int iidx;
- for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
- if (tb->items[iidx].location == location) {
- break;
- }
- }
- return iidx;
-}
-
-
-/**
* connect signals to a toolbar item in a customisation toolbar
*
* \param tb The toolbar
@@ -712,10 +816,7 @@ customisation_toolbar_drag_drop_cb(GtkWidget *widget,
}
- edit_mode = true;
- dragitem->button = make_toolbar_item(tbc->dragitem,
- tbc->toolbar.items[tbc->dragitem].sensitivity);
- edit_mode = false;
+ dragitem->button = make_toolbox_item(tbc->dragitem, true);
if (dragitem->button == NULL) {
nsgtk_warning("NoMemory", 0);
@@ -846,8 +947,6 @@ nsgtk_browser_window_create(struct browser_window *bw, bool intab)
}
-
-
/**
* Apply the user toolbar button settings from configuration
*
@@ -860,106 +959,116 @@ nsgtk_browser_window_create(struct browser_window *bw, bool intab)
static nserror
apply_user_button_customisation(struct nsgtk_toolbar *tb)
{
- int i, ii;
- char *buffer;
- char *buffer1, *subbuffer, *ptr = NULL, *pter = NULL;
+ const char *tbitems; /* item order user config */
+ const char *start;
+ const char *end;
+ int iidx; /* item index */
+ int location = 0; /* location index */
/* set all button locations to inactive */
- for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- tb->items[i].location = INACTIVE_LOCATION;
+ for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
+ tb->items[iidx].location = INACTIVE_LOCATION;
}
- /* if no user config is present apply the defaults */
- if (nsoption_charp(toolbar_order) == NULL) {
- tb->items[BACK_BUTTON].location = 0;
- tb->items[HISTORY_BUTTON].location = 1;
- tb->items[FORWARD_BUTTON].location = 2;
- tb->items[STOP_BUTTON].location = 3;
- tb->items[RELOAD_BUTTON].location = 4;
- tb->items[URL_BAR_ITEM].location = 5;
- tb->items[WEBSEARCH_ITEM].location = 6;
- tb->items[THROBBER_ITEM].location = 7;
-
- return NSERROR_OK;
+ tbitems = nsoption_charp(toolbar_items);
+ if (tbitems == NULL) {
+ tbitems = "";
}
- buffer = strdup(nsoption_charp(toolbar_order));
- if (buffer == NULL) {
- return NSERROR_NOMEM;
- }
+ end = tbitems;
+ while (*end != 0) {
+ start = end;
+ while ((*end != 0) && (*end !='/')) {
+ end++;
+ }
- i = BACK_BUTTON;
- ii = BACK_BUTTON;
- buffer1 = strtok_r(buffer, "|", &ptr);
- while (buffer1 != NULL) {
- subbuffer = strtok_r(buffer1, ";", &pter);
- if (subbuffer != NULL) {
- i = atoi(subbuffer);
- subbuffer = strtok_r(NULL, ";", &pter);
- if (subbuffer != NULL) {
- ii = atoi(subbuffer);
- if ((i >= BACK_BUTTON) &&
- (i < PLACEHOLDER_BUTTON) &&
- (ii >= -1) &&
- (ii < PLACEHOLDER_BUTTON)) {
- tb->items[i].location = ii;
- }
+ for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
+ if (((ssize_t)strlen(tb->items[iidx].name) == (end - start)) &&
+ (strncmp(tb->items[iidx].name, start, end - start) == 0)) {
+ tb->items[iidx].location = location++;
+ break;
}
}
- buffer1 = strtok_r(NULL, "|", &ptr);
+
+ if (*end == '/') {
+ end++;
+ }
}
- free(buffer);
+ if (location == 0) {
+ /* completely failed to create any buttons so use defaults */
+ tb->items[BACK_BUTTON].location = location++;
+ tb->items[HISTORY_BUTTON].location = location++;
+ tb->items[FORWARD_BUTTON].location = location++;
+ tb->items[RELOADSTOP_BUTTON].location = location++;
+ tb->items[URL_BAR_ITEM].location = location++;
+ tb->items[WEBSEARCH_ITEM].location = location++;
+ tb->items[OPENMENU_BUTTON].location = location++;
+ tb->items[THROBBER_ITEM].location = location++;
+ }
+
+
return NSERROR_OK;
}
/**
- * append item to gtk toolbar container
+ * callback function to remove a widget from a container
+ */
+static void container_remove_widget(GtkWidget *widget, gpointer data)
+{
+ GtkContainer *container = GTK_CONTAINER(data);
+ gtk_container_remove(container, widget);
+}
+
+
+/**
+ * populates a toolbar with widgets in correct order
*
* \param tb toolbar
- * \param theme in use
- * \param location item location being appended
* \return NSERROR_OK on success else error code.
*/
-static nserror
-add_item_to_toolbar(struct nsgtk_toolbar *tb, int location)
+static nserror populate_gtk_toolbar_widget(struct nsgtk_toolbar *tb)
{
- int bidx; /* button index */
-
- for (bidx = BACK_BUTTON; bidx < PLACEHOLDER_BUTTON; bidx++) {
-
- if (tb->items[bidx].location == location) {
+ int location; /* location index */
+ int itemid;
- tb->items[bidx].button = make_toolbar_item(
- bidx, tb->items[bidx].sensitivity);
+ /* clear the toolbar container of all widgets */
+ gtk_container_foreach(GTK_CONTAINER(tb->widget),
+ container_remove_widget,
+ tb->widget);
- gtk_toolbar_insert(tb->widget,
- tb->items[bidx].button,
- location);
+ /* add widgets to toolbar */
+ for (location = 0; location < PLACEHOLDER_BUTTON; location++) {
+ itemid = itemid_from_location(tb, location);
+ if (itemid == PLACEHOLDER_BUTTON) {
break;
}
+ tb->items[itemid].button =
+ make_toolbar_item(itemid,
+ tb->items[itemid].sensitivity);
+
+ gtk_toolbar_insert(tb->widget,
+ tb->items[itemid].button,
+ location);
}
- return NSERROR_OK;
-}
+ gtk_widget_show_all(GTK_WIDGET(tb->widget));
-/**
- * callback function to remove a widget from a container
- */
-static void container_remove_widget(GtkWidget *widget, gpointer data)
-{
- GtkContainer *container = GTK_CONTAINER(data);
- gtk_container_remove(container, widget);
+ return NSERROR_OK;
}
/**
- * populates the gtk toolbar container with widgets in correct order
+ * populates the customization toolbar with widgets in correct order
+ *
+ * \param tb toolbar
+ * \return NSERROR_OK on success else error code.
*/
-static nserror populate_gtk_toolbar_widget(struct nsgtk_toolbar *tb)
+static nserror customisation_toolbar_populate(struct nsgtk_toolbar *tb)
{
- int lidx; /* location index */
+ int location; /* location index */
+ int itemid;
/* clear the toolbar container of all widgets */
gtk_container_foreach(GTK_CONTAINER(tb->widget),
@@ -967,8 +1076,16 @@ static nserror populate_gtk_toolbar_widget(struct nsgtk_toolbar *tb)
tb->widget);
/* add widgets to toolbar */
- for (lidx = 0; lidx < PLACEHOLDER_BUTTON; lidx++) {
- add_item_to_toolbar(tb, lidx);
+ for (location = 0; location < PLACEHOLDER_BUTTON; location++) {
+ itemid = itemid_from_location(tb, location);
+ if (itemid == PLACEHOLDER_BUTTON) {
+ break;
+ }
+ tb->items[itemid].button = make_toolbox_item(itemid, true);
+
+ gtk_toolbar_insert(tb->widget,
+ tb->items[itemid].button,
+ location);
}
gtk_widget_show_all(GTK_WIDGET(tb->widget));
@@ -1021,6 +1138,56 @@ set_item_sensitivity(struct nsgtk_toolbar_item *item, bool sensitivity)
/**
+ * set an item to its alternative action
+ *
+ * this is currently only used for the stop/reload button where we
+ * also reuse the item sensitivity for the state indicator.
+ *
+ * \param tb the toolbar instance
+ */
+static nserror set_item_action(struct nsgtk_toolbar *tb, int itemid, bool alt)
+{
+ const char *iconname;
+ char *label = NULL;
+
+ if (itemid != RELOADSTOP_BUTTON) {
+ return NSERROR_INVALID;
+ }
+ if (tb->items[itemid].location == -1) {
+ return NSERROR_OK;
+ }
+ tb->items[itemid].sensitivity = alt;
+
+ if (tb->items[itemid].button == NULL) {
+ return NSERROR_INVALID;
+ }
+
+ if (tb->items[itemid].sensitivity) {
+ iconname = NSGTK_STOCK_REFRESH;
+ label = remove_underscores(messages_get("Reload"), false);
+
+ } else {
+ iconname = NSGTK_STOCK_STOP;
+ label = remove_underscores(messages_get("gtkStop"), false);
+
+ }
+ gtk_tool_button_set_label(GTK_TOOL_BUTTON(tb->items[itemid].button),
+ label);
+
+ gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(tb->items[itemid].button),
+ iconname);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(tb->items[itemid].button), TRUE);
+
+ if (label != NULL) {
+ free(label);
+ }
+
+ return NSERROR_OK;
+}
+
+
+/**
* cause the toolbar browsing context to navigate to a new url.
*
* \param tb the toolbar context.
@@ -1255,7 +1422,6 @@ toolbar_customisation_create_toolbox(struct nsgtk_toolbar_customisation *tbc,
columns = NSGTK_MIN_STORE_COLUMNS;
}
- edit_mode = true;
curcol = 0;
for (iidx = startidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
if (curcol >= columns) {
@@ -1263,8 +1429,7 @@ toolbar_customisation_create_toolbox(struct nsgtk_toolbar_customisation *tbc,
curcol = 0;
startidx = iidx;
}
- tbc->items[iidx] = make_toolbar_item(iidx,
- tbc->toolbar.items[iidx].sensitivity);
+ tbc->items[iidx] = make_toolbox_item(iidx, false);
if (tbc->items[iidx] != NULL) {
curcol++;
}
@@ -1272,7 +1437,6 @@ toolbar_customisation_create_toolbox(struct nsgtk_toolbar_customisation *tbc,
if (curcol > 0) {
add_toolbox_row(tbc, startidx, iidx);
}
- edit_mode = false;
return NSERROR_OK;
}
@@ -1292,12 +1456,10 @@ customisation_toolbar_update(struct nsgtk_toolbar_customisation *tbc)
}
/* populate toolbar widget */
- edit_mode = true;
- res = populate_gtk_toolbar_widget(&tbc->toolbar);
+ res = customisation_toolbar_populate(&tbc->toolbar);
if (res != NSERROR_OK) {
return res;
}
- edit_mode = false;
/* ensure icon sizes and text labels on toolbar are set */
res = nsgtk_toolbar_restyle(&tbc->toolbar);
@@ -1327,7 +1489,7 @@ customisation_apply_clicked_cb(GtkWidget *widget, gpointer data)
tbc = (struct nsgtk_toolbar_customisation *)data;
/* save state to file, update toolbars for all windows */
- nsgtk_toolbar_customisation_save(tbc);
+ nsgtk_toolbar_customisation_save(&tbc->toolbar);
nsgtk_window_toolbar_update();
gtk_widget_destroy(tbc->container);
@@ -1353,19 +1515,14 @@ customisation_reset_clicked_cb(GtkWidget *widget, gpointer data)
/**
- * customisation container delete handler
+ * customisation container destroy handler
*/
-static gboolean
-customisation_container_delete_cb(GtkWidget *widget,
- GdkEvent *event,
- gpointer data)
+static void customisation_container_destroy_cb(GtkWidget *widget, gpointer data)
{
struct nsgtk_toolbar_customisation *tbc;
tbc = (struct nsgtk_toolbar_customisation *)data;
free(tbc);
-
- return FALSE;
}
/*
@@ -1440,11 +1597,6 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
if (res != NSERROR_OK) {
goto cutomize_button_clicked_cb_error;
}
- if ((iidx == URL_BAR_ITEM) || (iidx == WEBSEARCH_ITEM)) {
- tbc->toolbar.items[iidx].sensitivity = false;
- } else {
- tbc->toolbar.items[iidx].sensitivity = true;
- }
}
res = customisation_toolbar_update(tbc);
@@ -1487,8 +1639,8 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
/* close and cleanup on delete signal */
g_signal_connect(tbc->container,
- "delete-event",
- G_CALLBACK(customisation_container_delete_cb),
+ "destroy",
+ G_CALLBACK(customisation_container_destroy_cb),
tbc);
@@ -1682,6 +1834,34 @@ reload_button_clicked_cb(GtkWidget *widget, gpointer data)
/**
+ * handler for reload/stop tool bar item clicked signal
+ *
+ * \param widget The widget the signal is being delivered to.
+ * \param data The toolbar context passed when the signal was connected
+ * \return TRUE
+ */
+static gboolean
+reloadstop_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+
+ bw = tb->get_bw(tb->get_ctx);
+
+ /* clear potential search effects */
+ browser_window_search_clear(bw);
+
+ if (tb->items[RELOADSTOP_BUTTON].sensitivity) {
+ browser_window_reload(bw, true);
+ } else {
+ browser_window_stop(tb->get_bw(tb->get_ctx));
+ }
+
+ return TRUE;
+}
+
+
+/**
* handler for home tool bar item clicked signal
*
* \param widget The widget the signal is being delivered to.
@@ -2972,20 +3152,26 @@ toolbar_item_create(nsgtk_toolbar_button id, struct nsgtk_toolbar_item *item)
/* set item defaults from macro */
switch (id) {
+#define TOOLBAR_ITEM_t(name) \
+ item->clicked = name##_button_clicked_cb;
#define TOOLBAR_ITEM_b(name) \
- item->bhandler = name##_button_clicked_cb;
+ item->clicked = name##_button_clicked_cb;
#define TOOLBAR_ITEM_y(name) \
- item->bhandler = name##_button_clicked_cb;
+ item->clicked = name##_button_clicked_cb;
#define TOOLBAR_ITEM_n(name) \
- item->bhandler = NULL;
-#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, label, iconame) \
+ item->clicked = NULL;
+#define TOOLBAR_ITEM(identifier, iname, snstvty, clicked, activate, label, iconame) \
case identifier: \
+ item->name = #iname; \
item->sensitivity = snstvty; \
- item->dataplus = nsgtk_toolbar_##name##_data_plus; \
- item->dataminus = nsgtk_toolbar_##name##_data_minus; \
- TOOLBAR_ITEM_ ## clicked(name) \
+ item->dataplus = nsgtk_toolbar_##iname##_data_plus; \
+ item->dataminus = nsgtk_toolbar_##iname##_data_minus; \
+ TOOLBAR_ITEM_ ## clicked(iname) \
break;
+
#include "gtk/toolbar_items.h"
+
+#undef TOOLBAR_ITEM_t
#undef TOOLBAR_ITEM_y
#undef TOOLBAR_ITEM_n
#undef TOOLBAR_ITEM
@@ -3111,10 +3297,10 @@ toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
break;
default:
- if ((item->bhandler != NULL) && (item->button != NULL)) {
+ if ((item->clicked != NULL) && (item->button != NULL)) {
g_signal_connect(item->button,
"clicked",
- G_CALLBACK(item->bhandler),
+ G_CALLBACK(item->clicked),
tb);
}
break;
@@ -3175,6 +3361,22 @@ toolbar_popup_context_menu_cb(GtkToolbar *toolbar,
return TRUE;
}
+
+/**
+ * toolbar delete signal handler
+ */
+static void toolbar_destroy_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb;
+ tb = (struct nsgtk_toolbar *)data;
+
+ /* ensure any throbber scheduled is stopped */
+ nsgtk_schedule(-1, next_throbber_frame, tb);
+
+ free(tb);
+}
+
+
/* exported interface documented in toolbar.h */
nserror
nsgtk_toolbar_create(GtkBuilder *builder,
@@ -3204,18 +3406,22 @@ nsgtk_toolbar_create(GtkBuilder *builder,
G_CALLBACK(toolbar_popup_context_menu_cb),
tb);
+ /* close and cleanup on delete signal */
+ g_signal_connect(tb->widget,
+ "destroy",
+ G_CALLBACK(toolbar_destroy_cb),
+ tb);
+
/* allocate button contexts */
for (bidx = BACK_BUTTON; bidx < PLACEHOLDER_BUTTON; bidx++) {
res = toolbar_item_create(bidx, &tb->items[bidx]);
if (res != NSERROR_OK) {
- free(tb);
return res;
}
}
res = nsgtk_toolbar_update(tb);
if (res != NSERROR_OK) {
- free(tb);
return res;
}
@@ -3225,14 +3431,6 @@ nsgtk_toolbar_create(GtkBuilder *builder,
/* exported interface documented in toolbar.h */
-nserror nsgtk_toolbar_destroy(struct nsgtk_toolbar *tb)
-{
- /** \todo free buttons and destroy toolbar container (and widgets) */
- free(tb);
- return NSERROR_OK;
-}
-
-/* exported interface documented in toolbar.h */
nserror nsgtk_toolbar_restyle(struct nsgtk_toolbar *tb)
{
/*
@@ -3283,14 +3481,13 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active)
nserror res;
struct browser_window *bw;
- bw = tb->get_bw(tb->get_ctx);
-
/* when activating the throbber simply schedule the next frame update */
if (active) {
nsgtk_schedule(THROBBER_FRAME_TIME, next_throbber_frame, tb);
set_item_sensitivity(&tb->items[STOP_BUTTON], true);
set_item_sensitivity(&tb->items[RELOAD_BUTTON], false);
+ set_item_action(tb, RELOADSTOP_BUTTON, false);
return NSERROR_OK;
}
@@ -3301,9 +3498,12 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active)
res = set_throbber_frame(tb->items[THROBBER_ITEM].button,
tb->throb_frame);
+ bw = tb->get_bw(tb->get_ctx);
+
/* adjust sensitivity of other items */
set_item_sensitivity(&tb->items[STOP_BUTTON], false);
set_item_sensitivity(&tb->items[RELOAD_BUTTON], true);
+ set_item_action(tb, RELOADSTOP_BUTTON, true);
set_item_sensitivity(&tb->items[BACK_BUTTON],
browser_window_history_back_available(bw));
set_item_sensitivity(&tb->items[FORWARD_BUTTON],
@@ -3387,7 +3587,7 @@ nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb,
return NSERROR_BAD_PARAMETER;
}
- if (tb->items[itemid].bhandler == NULL) {
+ if (tb->items[itemid].clicked == NULL) {
return NSERROR_INVALID;
}
@@ -3401,7 +3601,7 @@ nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb,
widget = GTK_WIDGET(tb->widget);
}
- tb->items[itemid].bhandler(widget, tb);
+ tb->items[itemid].clicked(widget, tb);
return NSERROR_OK;
}
@@ -3414,7 +3614,6 @@ nserror nsgtk_toolbar_show(struct nsgtk_toolbar *tb, bool show)
gtk_widget_show(GTK_WIDGET(tb->widget));
} else {
gtk_widget_hide(GTK_WIDGET(tb->widget));
-
}
return NSERROR_OK;
}
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index e895d0b13..6be45b030 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -36,15 +36,6 @@ nserror nsgtk_toolbar_create(GtkBuilder *builder, struct browser_window *(*get_b
/**
- * Destroy toolbar previously created
- *
- * \param toolbar A toolbar returned from a creation
- * \return NSERROR_OK on success
- */
-nserror nsgtk_toolbar_destroy(struct nsgtk_toolbar *toolbar);
-
-
-/**
* Update the toolbar items being shown based on current settings
*
* \param toolbar A toolbar returned from a creation
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 344c09771..b4bed371f 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -23,11 +23,13 @@ typedef enum {
BACK_BUTTON = 0,
HISTORY_BUTTON,
FORWARD_BUTTON,
+ RELOADSTOP_BUTTON,
+ URL_BAR_ITEM,
+ WEBSEARCH_ITEM,
+ OPENMENU_BUTTON,
STOP_BUTTON,
RELOAD_BUTTON,
HOME_BUTTON,
- URL_BAR_ITEM,
- WEBSEARCH_ITEM,
THROBBER_ITEM,
NEWWINDOW_BUTTON,
NEWTAB_BUTTON,
@@ -71,7 +73,6 @@ typedef enum {
GUIDE_BUTTON,
INFO_BUTTON,
ABOUT_BUTTON,
- OPENMENU_BUTTON,
CUSTOMIZE_BUTTON,
PLACEHOLDER_BUTTON /* size indicator; array maximum indices */
} nsgtk_toolbar_button; /* PLACEHOLDER_BUTTON - 1 */
@@ -84,9 +85,10 @@ typedef enum {
* - name (identifier)
* - initial sensitivity (true/false)
* - if there is a toolbar click signal handler (y/n) and it is available in
- * the toolbar as a button (b, implies y)
+ * the toolbar and toolbox as a button (b, implies y) if the item is
+ * available as a button but not placed in the toolbox (t, implies y)
* - if there is a menu activate signal handler (y/n) and it calls the
- toolbar click handler directly. (p, implies y)
+ * toolbar click handler directly. (p, implies y)
* - item label as a netsurf message (identifier)
* - icon image name ("string")
*/
@@ -99,8 +101,8 @@ typedef enum {
TOOLBAR_ITEM(BACK_BUTTON, back, false, b, p, gtkBack, "go-previous")
TOOLBAR_ITEM(HISTORY_BUTTON, history, true, y, n, , "local-history")
TOOLBAR_ITEM(FORWARD_BUTTON, forward, false, b, p, gtkForward, "go-next")
-TOOLBAR_ITEM(STOP_BUTTON, stop, false, b, p, gtkStop, NSGTK_STOCK_STOP)
-TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, b, p, Reload, NSGTK_STOCK_REFRESH)
+TOOLBAR_ITEM(STOP_BUTTON, stop, false, t, p, gtkStop, NSGTK_STOCK_STOP)
+TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, t, p, Reload, NSGTK_STOCK_REFRESH)
TOOLBAR_ITEM(HOME_BUTTON, home, true, b, p, gtkHome, NSGTK_STOCK_HOME)
TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true, n, n, , NULL)
TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true, n, n, , NULL)
@@ -149,6 +151,7 @@ TOOLBAR_ITEM(INFO_BUTTON, info, true, y, p, gtkUserInformation, "dialog-informat
TOOLBAR_ITEM(ABOUT_BUTTON, about, true, b, p, gtkAbout, "help-about")
TOOLBAR_ITEM(OPENMENU_BUTTON, openmenu, true, b, n, gtkOpenMenu, NSGTK_STOCK_OPEN_MENU)
TOOLBAR_ITEM(CUSTOMIZE_BUTTON, cutomize, true, y, p, , NULL)
+TOOLBAR_ITEM(RELOADSTOP_BUTTON, reloadstop, true, b, n, Reload, NSGTK_STOCK_REFRESH)
#ifdef TOOLBAR_ITEM_SET
#undef TOOLBAR_ITEM
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index a26c76c5e..a5defcfce 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -121,9 +121,6 @@ struct gui_window {
/** has the status pane had its first size operation yet? */
bool paned_sized;
- /** to allow disactivation / resume of normal window behaviour */
- gulong signalhandler[NSGTK_WINDOW_SIGNAL_COUNT];
-
/** The icon this window should have */
GdkPixbuf *icon;
@@ -710,6 +707,22 @@ static struct browser_window *bw_from_gw(void *data)
}
+static bool get_tool_bar_show(void)
+{
+ const char *cur_bar_show;
+
+ cur_bar_show = nsoption_charp(bar_show);
+ if (cur_bar_show != NULL) {
+ if (strcmp(cur_bar_show, "menu/tool") == 0) {
+ return true;
+ } else if (strcmp(cur_bar_show, "tool") == 0) {
+ return true;
+ }
+ }
+ return false;
+}
+
+
/**
* Create and open a gtk container (window or tab) for a browsing context.
*
@@ -831,8 +844,7 @@ gui_window_create(struct browser_window *bw,
GTK_STATE_NORMAL,
0, 0xffff, 0xffff, 0xffff);
- g->signalhandler[NSGTK_WINDOW_SIGNAL_REDRAW] =
- nsgtk_connect_draw_event(GTK_WIDGET(g->layout),
+ nsgtk_connect_draw_event(GTK_WIDGET(g->layout),
G_CALLBACK(nsgtk_window_draw_event), g);
/* helper macro to conect signals to callbacks */
@@ -842,8 +854,7 @@ gui_window_create(struct browser_window *bw,
/* layout signals */
CONNECT(g->layout, "motion-notify-event",
nsgtk_window_motion_notify_event, g);
- g->signalhandler[NSGTK_WINDOW_SIGNAL_CLICK] =
- CONNECT(g->layout, "button-press-event",
+ CONNECT(g->layout, "button-press-event",
nsgtk_window_button_press_event, g);
CONNECT(g->layout, "button-release-event",
nsgtk_window_button_release_event, g);
@@ -892,6 +903,9 @@ gui_window_create(struct browser_window *bw,
/* initialy should not be visible */
nsgtk_search_toggle_visibility(g->search);
+ /* set toolbar visibility from user option */
+ nsgtk_toolbar_show(g->toolbar, get_tool_bar_show());
+
/* safe to drop the reference to the tab_builder as the container is
* referenced by the notebook now.
*/
@@ -1480,13 +1494,6 @@ struct nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g)
/* exported interface documented in window.h */
-struct gtk_search *nsgtk_window_get_search(struct gui_window *gw)
-{
- return gw->search;
-}
-
-
-/* exported interface documented in window.h */
struct browser_window *nsgtk_get_browser_window(struct gui_window *g)
{
return g->bw;
@@ -1494,13 +1501,6 @@ struct browser_window *nsgtk_get_browser_window(struct gui_window *g)
/* exported interface documented in window.h */
-unsigned long nsgtk_window_get_signalhandler(struct gui_window *g, int i)
-{
- return g->signalhandler[i];
-}
-
-
-/* exported interface documented in window.h */
GtkLayout *nsgtk_window_get_layout(struct gui_window *g)
{
return g->layout;
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index 69b1cdc68..728c653a8 100644
--- a/frontends/gtk/window.h
+++ b/frontends/gtk/window.h
@@ -22,12 +22,6 @@
extern struct gui_window_table *nsgtk_window_table;
extern struct gui_search_web_table *nsgtk_search_web_table;
-typedef enum nsgtk_window_signals {
- NSGTK_WINDOW_SIGNAL_CLICK,
- NSGTK_WINDOW_SIGNAL_REDRAW,
- NSGTK_WINDOW_SIGNAL_COUNT
-} nsgtk_window_signal;
-
extern struct gui_window *window_list;
extern int temp_open_background;
@@ -78,13 +72,6 @@ int nsgtk_gui_window_update_targets(struct gui_window *gw);
*/
void nsgtk_window_destroy_browser(struct gui_window *gw);
-/**
- * set signal handler
- *
- * \param gw gui window handle
- */
-unsigned long nsgtk_window_get_signalhandler(struct gui_window *gw, int i);
-
/**
* toggle search visibility
@@ -102,11 +89,6 @@ GtkLayout *nsgtk_window_get_layout(struct gui_window *gw);
/**
- * get search from window handle
- */
-struct gtk_search *nsgtk_window_get_search(struct gui_window *gw);
-
-/**
* activate the handler for a item in a toolbar of a gui window
*
* \param gw The gui window handle