netsurf: branch master updated. release/3.9-244-g6c47067
by NetSurf Browser Project
Gitweb links:
...log http://git.netsurf-browser.org/netsurf.git/shortlog/6c470679ee23f85ff291a...
...commit http://git.netsurf-browser.org/netsurf.git/commit/6c470679ee23f85ff291a1a...
...tree http://git.netsurf-browser.org/netsurf.git/tree/6c470679ee23f85ff291a1a68...
The branch, master has been updated
via 6c470679ee23f85ff291a1a68319289fbd807696 (commit)
via 9dd936ae7c1380061d35a763a728f5ad2bded798 (commit)
via 9d3112a643d2ff1c6055133485273d5e5a358d24 (commit)
via e14416d43fea0da0aca91a3373ed3c67a28af183 (commit)
via bebb883d5a8165aab90153a227f37e55de8f267b (commit)
via cbb818aa64b21e20954d06a4c5374a065d61088f (commit)
via 9b03d6ba6372298ad4df171003d35d54fe0c772c (commit)
via 4efb1d34c3b5cbce0fdac1eca45da88600e7f3c7 (commit)
via f6f8102ecb4e0281e5f0373464481185d2fa3b04 (commit)
via 25581133a11800600ad290fa84fc3ca11927116c (commit)
via 2bed178a339a5dfb05159f6efed2f283a2c2eb2d (commit)
via 12cca32059cc871245571f59af5e09816fbea094 (commit)
via d94afaa0e1bc2d50c68d562f4b5751cd469fa4cb (commit)
via e9b5b56ba61283901b8d04c0f84929664ee29bb3 (commit)
via a013a24d5f489ee5295aa1ce0bfe68c9c27e327f (commit)
via a20fe23ce611a156ba7f10d555436b3ad9f8b72f (commit)
via 9bbc7eb9cbde19ff594ce5901fdf7bf1faac2874 (commit)
via 541acda906e6d725468aa31bcc95f43d1cca23d4 (commit)
via 11aa682154af6e0d4c7920bb2983df5a6ded126f (commit)
via 9cd9a403e6ee69c78a575872bd399c633862d5aa (commit)
via 3df34e7dec892632851aa2774bab41f2dc708574 (commit)
via a8e186f120617a2f29a0673947734b65fad7995f (commit)
via 7b63f36a4f748d0a265c50c933181e1582484b77 (commit)
via db558f862bdf3c4a6392ab3b3b5bcacaf87b29bd (commit)
via c7ad2553d8a001d1dfc492a816b7b507836e05e9 (commit)
via dbc5b5df6af05e2218de3d07fcc602ae88520b57 (commit)
via df398ed886a020c5044239f43b0d73faa323545e (commit)
via 778c05a1949b61fbe37b06313e5b1e3c0f05f7e4 (commit)
via 608cc3cbbfae27498268442aa31ef791894e0789 (commit)
via 747f135de5785e2a43ff4b27e07559d3aacd3377 (commit)
via fc4ad51a66785979280b0609a39a3051dbc7d4a0 (commit)
via c7c89daff3f04d2ccc78905c128e7dfa938543d4 (commit)
via 46e1116aaa38793ff3a36fb5ff05e3be448df49f (commit)
via 65d5161558cfd749f58de89990b739865f2bccaa (commit)
via 635be1dfb88c01ab6a901f6e88eb3b7187d2c03b (commit)
via bcb2b7a2c4425ba888f6236890d35a8f2d037360 (commit)
via 11197074102a46cb85d108f0915fc2929e79b26a (commit)
via 5f5b94c2aee697e2da5ab6819b19a00b83f50390 (commit)
via 061499eef611ed39831a38384bba42d71d0e58c1 (commit)
via 64b2f355dc8b1779996f9cb981b1e9ddebd7d7cd (commit)
via ec62f346e11bc17c9d7c9955697503f309162fb3 (commit)
via f6a669464f67bbed442c80cb3b6d207eacf4fa9a (commit)
via 85b65921ed38b3ce0bd795e9455afbd53610b309 (commit)
via 2e8861dc05325c88cfb8130e7eddd0967e4d4b09 (commit)
via e84990bc891c7a75930fddd614516d3eb170cd75 (commit)
via e36338b6177df9617c89e2eae4f3fcb0a77d7b5b (commit)
via 08d7c55cc536211784a24df179719a802435ff0b (commit)
via 45bd456cd86bd300ea51285c969b88e6ae68bbb9 (commit)
via 7f115dc9268776a63084fe5e1cefa5852d6b2ff0 (commit)
via 8f0c0734eaf27429b4ca6c2c89517a3b5d476d87 (commit)
via 8eebe695f053abb390ddc9894415f595ad7f4177 (commit)
via b24b28e40eb84e1ed361224b172928582b471e10 (commit)
via ff64341ed33d8abf722795ca4d51d81ce02d7694 (commit)
via c297101c3a7b9b40ff08f120cb92c8a9b4237e5e (commit)
via b389dd4116fc5a313a015328a068a968223a4daf (commit)
via f3a68771e34511a07a42374c0c0a656ed8d47905 (commit)
via 305190fe730cf19e0556ff8e24cbf85e63566de0 (commit)
via 07a9d5b3fb1c8d956d453e998c5903527f99f5e4 (commit)
via 8b5100a97e302ea11b00c9780c5071703ddf2027 (commit)
via 869c16dae60b519013bde67c443ce737bbb20ccf (commit)
via bd90138b482c8561927c2d6a75c172415e583a16 (commit)
via dd767acfee416a65e67193a9740d2b636b868e11 (commit)
via 02c75d07900d4566a8b2f835fb07a4eff1ab8235 (commit)
via 89fb88f6dee5322beb3161497cab7a848cb9a4a8 (commit)
via 65d169da106d159d9fb53ceb55a5b5899cc0762f (commit)
via 1fc51d1f4482243cc7d2a10517f04dcc471cef8e (commit)
from 63fc84a25f97c811259dbf1af51fc045b95c5659 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=6c470679ee23f85ff29...
commit 6c470679ee23f85ff291a1a68319289fbd807696
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
fix menu signal handler prototype
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 459195f..526c0be 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 */
};
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9dd936ae7c1380061d3...
commit 9dd936ae7c1380061d35a763a728f5ad2bded798
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
fix toolbar customisation
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index aed35e7..8eba867 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -524,14 +524,19 @@ make_toolbar_item(nsgtk_toolbar_button itemid, bool sensitivity)
* \return gtk tool item widget
*/
static GtkToolItem *
-make_toolbox_item(nsgtk_toolbar_button itemid)
+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)
+#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, true, true); \
@@ -811,7 +816,7 @@ customisation_toolbar_drag_drop_cb(GtkWidget *widget,
}
- dragitem->button = make_toolbox_item(tbc->dragitem);
+ dragitem->button = make_toolbox_item(tbc->dragitem, true);
if (dragitem->button == NULL) {
nsgtk_warning("NoMemory", 0);
@@ -978,7 +983,8 @@ apply_user_button_customisation(struct nsgtk_toolbar *tb)
}
for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
- if (strncmp(tb->items[iidx].name, start, end - start) == 0) {
+ 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;
}
@@ -1038,12 +1044,12 @@ static nserror populate_gtk_toolbar_widget(struct nsgtk_toolbar *tb)
if (itemid == PLACEHOLDER_BUTTON) {
break;
}
- tb->items[location].button =
- make_toolbar_item(location,
- tb->items[location].sensitivity);
+ tb->items[itemid].button =
+ make_toolbar_item(itemid,
+ tb->items[itemid].sensitivity);
gtk_toolbar_insert(tb->widget,
- tb->items[location].button,
+ tb->items[itemid].button,
location);
}
@@ -1075,10 +1081,10 @@ static nserror customisation_toolbar_populate(struct nsgtk_toolbar *tb)
if (itemid == PLACEHOLDER_BUTTON) {
break;
}
- tb->items[location].button = make_toolbox_item(location);
+ tb->items[itemid].button = make_toolbox_item(itemid, true);
gtk_toolbar_insert(tb->widget,
- tb->items[location].button,
+ tb->items[itemid].button,
location);
}
@@ -1423,7 +1429,7 @@ toolbar_customisation_create_toolbox(struct nsgtk_toolbar_customisation *tbc,
curcol = 0;
startidx = iidx;
}
- tbc->items[iidx] = make_toolbox_item(iidx);
+ tbc->items[iidx] = make_toolbox_item(iidx, false);
if (tbc->items[iidx] != NULL) {
curcol++;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9d3112a643d2ff1c605...
commit 9d3112a643d2ff1c6055133485273d5e5a358d24
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
persist the menu and tool bar visibility as user settings
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index 21d146c..f14c7bd 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -251,7 +251,10 @@ static nserror set_defaults(struct nsoption_s *defaults)
/* set default items in toolbar */
nsoption_set_charp(toolbar_items,
- strdup("back/history/forward/reloadstop/url_bar/websearch/openmenu"));
+ 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 483a766..dad17f0 100644
--- a/frontends/gtk/options.h
+++ b/frontends/gtk/options.h
@@ -75,4 +75,4 @@ NSOPTION_INTEGER(position_tab, 0)
NSOPTION_STRING(toolbar_items, NULL)
/* The menu and tool bars that are shown */
-NSOPTION_STRING(toolbar_show, NULL)
+NSOPTION_STRING(bar_show, NULL)
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 5a50d81..459195f 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -589,6 +589,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 +666,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 +681,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 +714,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 +729,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 +844,7 @@ create_scaffolding_burger_menu(struct nsgtk_scaffolding *gs,
return nmenu;
}
+
/**
* Create and connect handlers to popup menu.
*
@@ -800,7 +853,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 +1067,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 +1096,7 @@ static void nsgtk_menu_set_icons(struct nsgtk_scaffolding *g)
}
}
+
/**
* create and initialise menus
*
@@ -1103,10 +1159,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 +1241,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 +1419,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 +1505,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 c30c585..1fae003 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/toolbar.c b/frontends/gtk/toolbar.c
index 243c0ce..aed35e7 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -3608,7 +3608,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/window.c b/frontends/gtk/window.c
index da904ea..a5defcf 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -707,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.
*
@@ -887,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.
*/
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e14416d43fea0da0aca...
commit e14416d43fea0da0aca91a3373ed3c67a28af183
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
fix gtk2 customisation window instruction box expansion
diff --git a/frontends/gtk/res/toolbar.gtk2.ui b/frontends/gtk/res/toolbar.gtk2.ui
index 2288971..6172306 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>
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=bebb883d5a8165aab90...
commit bebb883d5a8165aab90153a227f37e55de8f267b
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
remove global edit mode and make customisation toolbox construction simpler
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 007a8fe..243c0ce 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -221,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);
@@ -262,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;
@@ -274,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(
@@ -305,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;
@@ -317,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");
@@ -348,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;
@@ -378,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");
@@ -405,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);
@@ -435,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;
@@ -451,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);
}
}
@@ -468,42 +467,46 @@ 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);\
+ 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);
+ toolitem = make_toolbar_item_history(sensitivity, false);
break;
case URL_BAR_ITEM:
- toolitem = make_toolbar_item_url_bar(sensitivity);
+ toolitem = make_toolbar_item_url_bar(sensitivity, false);
break;
case THROBBER_ITEM:
- toolitem = make_toolbar_item_throbber(sensitivity);
+ toolitem = make_toolbar_item_throbber(sensitivity, false);
break;
case WEBSEARCH_ITEM:
- toolitem = make_toolbar_item_websearch(sensitivity);
+ toolitem = make_toolbar_item_websearch(sensitivity, false);
break;
default:
@@ -513,6 +516,61 @@ make_toolbar_item(nsgtk_toolbar_button itemid,
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)
+{
+ 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)
+#define TOOLBAR_ITEM_b(identifier, label, iconame) \
+ case identifier: \
+ 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(true, true);
+ break;
+
+ case URL_BAR_ITEM:
+ toolitem = make_toolbar_item_url_bar(false, true);
+ break;
+
+ case THROBBER_ITEM:
+ toolitem = make_toolbar_item_throbber(true, true);
+ break;
+
+ case WEBSEARCH_ITEM:
+ toolitem = make_toolbar_item_websearch(false, true);
+ break;
+
+ default:
+ break;
+
+ }
+ return toolitem;
+}
+
+
/**
* target entry for drag source
*/
@@ -753,10 +811,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);
if (dragitem->button == NULL) {
nsgtk_warning("NoMemory", 0);
@@ -887,8 +942,6 @@ nsgtk_browser_window_create(struct browser_window *bw, bool intab)
}
-
-
/**
* Apply the user toolbar button settings from configuration
*
@@ -954,51 +1007,62 @@ apply_user_button_customisation(struct nsgtk_toolbar *tb)
/**
- * 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[location].button =
+ make_toolbar_item(location,
+ tb->items[location].sensitivity);
+
+ gtk_toolbar_insert(tb->widget,
+ tb->items[location].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),
@@ -1006,8 +1070,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[location].button = make_toolbox_item(location);
+
+ gtk_toolbar_insert(tb->widget,
+ tb->items[location].button,
+ location);
}
gtk_widget_show_all(GTK_WIDGET(tb->widget));
@@ -1344,7 +1416,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) {
@@ -1352,8 +1423,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);
if (tbc->items[iidx] != NULL) {
curcol++;
}
@@ -1361,7 +1431,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;
}
@@ -1381,12 +1450,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);
@@ -1524,11 +1591,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);
@@ -3084,6 +3146,8 @@ 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->clicked = name##_button_clicked_cb;
#define TOOLBAR_ITEM_y(name) \
@@ -3098,7 +3162,10 @@ toolbar_item_create(nsgtk_toolbar_button id, struct nsgtk_toolbar_item *item)
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
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index df7347a..b4bed37 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,9 +73,7 @@ typedef enum {
GUIDE_BUTTON,
INFO_BUTTON,
ABOUT_BUTTON,
- OPENMENU_BUTTON,
CUSTOMIZE_BUTTON,
- RELOADSTOP_BUTTON,
PLACEHOLDER_BUTTON /* size indicator; array maximum indices */
} nsgtk_toolbar_button; /* PLACEHOLDER_BUTTON - 1 */
@@ -85,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")
*/
@@ -100,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)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=cbb818aa64b21e20954...
commit cbb818aa64b21e20954d06a4c5374a065d61088f
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
improve how toolbar contents customisation is stored in user options
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index a87ef72..21d146c 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -249,6 +249,10 @@ 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"));
+
return NSERROR_OK;
}
diff --git a/frontends/gtk/options.h b/frontends/gtk/options.h
index 018a448..483a766 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(toolbar_show, NULL)
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 5fa373b..007a8fe 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
+ */
+ const char *name;
+
+ /**
+ * button clicked on toolbar handler
+ */
+ gboolean (*clicked)(GtkWidget *widget, gpointer data);
+
+ /**
+ * handler when dragging from customisation toolbox to toolbar
*/
- gboolean (*bhandler)(GtkWidget *widget, gpointer data);
+ void *dataplus;
- void *dataplus; /* customisation -> toolbar */
- void *dataminus; /* customisation -> store */
+ /**
+ * handler when dragging from toolbar to customisation toolbox
+ */
+ void *dataminus;
};
@@ -500,43 +524,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");
@@ -550,26 +610,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
@@ -861,56 +901,54 @@ 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 (strncmp(tb->items[iidx].name, start, end - start) == 0) {
+ tb->items[iidx].location = location++;
+ break;
}
}
- buffer1 = strtok_r(NULL, "|", &ptr);
+
+ if (*end == '/') {
+ end++;
+ }
+ }
+
+ 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++;
}
- free(buffer);
+
return NSERROR_OK;
}
@@ -1378,7 +1416,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);
@@ -3047,17 +3085,18 @@ toolbar_item_create(nsgtk_toolbar_button id, struct nsgtk_toolbar_item *item)
/* set item defaults from macro */
switch (id) {
#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_y
@@ -3185,10 +3224,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;
@@ -3475,7 +3514,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;
}
@@ -3489,7 +3528,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;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9b03d6ba6372298ad4d...
commit 9b03d6ba6372298ad4df171003d35d54fe0c772c
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
add combined reload and stop button
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index af75b89..5fa373b 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -138,13 +138,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;
/**
@@ -1021,6 +1022,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.
@@ -1677,6 +1728,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.
@@ -3296,6 +3375,7 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active)
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;
}
@@ -3311,6 +3391,7 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active)
/* 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],
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 344c097..df7347a 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -73,6 +73,7 @@ typedef enum {
ABOUT_BUTTON,
OPENMENU_BUTTON,
CUSTOMIZE_BUTTON,
+ RELOADSTOP_BUTTON,
PLACEHOLDER_BUTTON /* size indicator; array maximum indices */
} nsgtk_toolbar_button; /* PLACEHOLDER_BUTTON - 1 */
@@ -149,6 +150,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
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=4efb1d34c3b5cbce0fd...
commit 4efb1d34c3b5cbce0fdac1eca45da88600e7f3c7
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
remove leftover sighandler code
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index b1c0b70..da904ea 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -1482,13 +1482,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;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f6f8102ecb4e0281e5f...
commit f6f8102ecb4e0281e5f0373464481185d2fa3b04
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
clean up tab focus setting
diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c
index 6f4b22b..ae07c16 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
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=25581133a11800600ad...
commit 25581133a11800600ad290fa84fc3ca11927116c
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
remove unused signal handler api
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index f4812bd..b1c0b70 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;
@@ -831,8 +828,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 +838,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);
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index 3c807c0..728c653 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
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=2bed178a339a5dfb051...
commit 2bed178a339a5dfb05159f6efed2f283a2c2eb2d
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
fix resource release and stopping throbber on toolbar widget destruction
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 0d868a0..af75b89 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -1353,19 +1353,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;
}
/*
@@ -1487,8 +1482,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);
@@ -3175,6 +3170,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 +3215,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 +3240,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,8 +3290,6 @@ 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);
@@ -3301,6 +3306,8 @@ 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);
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index e895d0b..6be45b0 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/window.c b/frontends/gtk/window.c
index a26c76c..f4812bd 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -1480,13 +1480,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;
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index 69b1cdc..3c807c0 100644
--- a/frontends/gtk/window.h
+++ b/frontends/gtk/window.h
@@ -102,11 +102,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
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=12cca32059cc8712455...
commit 12cca32059cc871245571f59af5e09816fbea094
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
fix core find in page behaviour when case sensitivity is toggled
diff --git a/content/handlers/html/html_interaction.c b/content/handlers/html/html_interaction.c
index 5f165e3..d31ad1d 100644
--- a/content/handlers/html/html_interaction.c
+++ b/content/handlers/html/html_interaction.c
@@ -1165,21 +1165,25 @@ bool html_keypress(struct content *c, uint32_t key)
/**
* Handle search.
*
- * \param c content of type HTML
- * \param context front end private data
- * \param flags search flags
- * \param string search string
+ * \param c content of type HTML
+ * \param context front end private data
+ * \param flags search flags
+ * \param string search string
*/
-void html_search(struct content *c, void *context,
- search_flags_t flags, const char *string)
+void
+html_search(struct content *c,
+ void *context,
+ search_flags_t flags,
+ const char *string)
{
html_content *html = (html_content *)c;
assert(c != NULL);
- if (string != NULL && html->search_string != NULL &&
- strcmp(string, html->search_string) == 0 &&
- html->search != NULL) {
+ if ((string != NULL) &&
+ (html->search_string != NULL) &&
+ (strcmp(string, html->search_string) == 0) &&
+ (html->search != NULL)) {
/* Continue prev. search */
search_step(html->search, flags, string);
diff --git a/content/handlers/html/search.c b/content/handlers/html/search.c
index e26510e..3599951 100644
--- a/content/handlers/html/search.c
+++ b/content/handlers/html/search.c
@@ -422,6 +422,49 @@ static bool find_occurrences_text(const char *pattern, int p_len,
/**
+ * Specifies whether all matches or just the current match should
+ * be highlighted in the search text.
+ */
+static void search_show_all(bool all, struct search_context *context)
+{
+ struct list_entry *a;
+
+ for (a = context->found->next; a; a = a->next) {
+ bool add = true;
+ if (!all && a != context->current) {
+ add = false;
+ if (a->sel) {
+ selection_clear(a->sel, true);
+ selection_destroy(a->sel);
+ a->sel = NULL;
+ }
+ }
+ if (add && !a->sel) {
+
+ if (context->is_html == true) {
+ html_content *html = (html_content *)context->c;
+ a->sel = selection_create(context->c, true);
+ if (!a->sel)
+ continue;
+
+ selection_init(a->sel, html->layout,
+ &html->len_ctx);
+ } else {
+ a->sel = selection_create(context->c, false);
+ if (!a->sel)
+ continue;
+
+ selection_init(a->sel, NULL, NULL);
+ }
+
+ selection_set_start(a->sel, a->start_idx);
+ selection_set_end(a->sel, a->end_idx);
+ }
+ }
+}
+
+
+/**
* Search for a string in the box tree
*
* \param string the string to search for
@@ -429,8 +472,11 @@ static bool find_occurrences_text(const char *pattern, int p_len,
* \param context The search context to add the entry to.
* \param flags flags to control the search.
*/
-static void search_text(const char *string, int string_len,
- struct search_context *context, search_flags_t flags)
+static void
+search_text(const char *string,
+ int string_len,
+ struct search_context *context,
+ search_flags_t flags)
{
struct rect bounds;
struct box *box = NULL;
@@ -456,7 +502,8 @@ static void search_text(const char *string, int string_len,
/* check if we need to start a new search or continue an old one */
- if (context->newsearch) {
+ if ((context->newsearch) ||
+ (context->prev_case_sens != case_sensitive)) {
bool res;
if (context->string != NULL)
@@ -543,16 +590,15 @@ static void search_text(const char *string, int string_len,
/* Exported function documented in search.h */
-void search_step(struct search_context *context, search_flags_t flags,
- const char *string)
+void
+search_step(struct search_context *context,
+ search_flags_t flags,
+ const char *string)
{
int string_len;
int i = 0;
- if (context == NULL) {
- guit->misc->warning("SearchError", 0);
- return;
- }
+ assert(context != NULL);
guit->search->add_recent(string, context->gui_p);
@@ -598,44 +644,6 @@ bool search_term_highlighted(struct content *c,
}
-/* Exported function documented in search.h */
-void search_show_all(bool all, struct search_context *context)
-{
- struct list_entry *a;
-
- for (a = context->found->next; a; a = a->next) {
- bool add = true;
- if (!all && a != context->current) {
- add = false;
- if (a->sel) {
- selection_clear(a->sel, true);
- selection_destroy(a->sel);
- a->sel = NULL;
- }
- }
- if (add && !a->sel) {
-
- if (context->is_html == true) {
- html_content *html = (html_content *)context->c;
- a->sel = selection_create(context->c, true);
- if (!a->sel)
- continue;
-
- selection_init(a->sel, html->layout,
- &html->len_ctx);
- } else {
- a->sel = selection_create(context->c, false);
- if (!a->sel)
- continue;
-
- selection_init(a->sel, NULL, NULL);
- }
-
- selection_set_start(a->sel, a->start_idx);
- selection_set_end(a->sel, a->end_idx);
- }
- }
-}
/* Exported function documented in search.h */
diff --git a/content/handlers/html/search.h b/content/handlers/html/search.h
index 5c9408e..dfb1afc 100644
--- a/content/handlers/html/search.h
+++ b/content/handlers/html/search.h
@@ -60,11 +60,6 @@ void search_destroy_context(struct search_context *context);
void search_step(struct search_context *context, search_flags_t flags,
const char * string);
-/**
- * Specifies whether all matches or just the current match should
- * be highlighted in the search text.
- */
-void search_show_all(bool all, struct search_context *context);
/**
* Determines whether any portion of the given text box should be
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=d94afaa0e1bc2d50c68...
commit d94afaa0e1bc2d50c68d562f4b5751cd469fa4cb
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
make the gtk_search structure private to teh gtk search object
diff --git a/content/handlers/html/search.c b/content/handlers/html/search.c
index 9ba2957..e26510e 100644
--- a/content/handlers/html/search.c
+++ b/content/handlers/html/search.c
@@ -75,8 +75,8 @@ struct search_context {
/* Exported function documented in search.h */
-struct search_context * search_create_context(struct content *c,
- content_type type, void *gui_data)
+struct search_context *
+search_create_context(struct content *c, content_type type, void *gui_data)
{
struct search_context *context;
struct list_entry *search_head;
diff --git a/frontends/gtk/res/tabcontents.gtk3.ui b/frontends/gtk/res/tabcontents.gtk3.ui
index 5d7a40b..b07cf92 100644
--- a/frontends/gtk/res/tabcontents.gtk3.ui
+++ b/frontends/gtk/res/tabcontents.gtk3.ui
@@ -87,7 +87,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkCheckButton" id="FindHightlightAll">
+ <object class="GtkCheckButton" id="FindHighlightAll">
<property name="label" translatable="yes">gtkFindHighlightAll</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
diff --git a/frontends/gtk/search.c b/frontends/gtk/search.c
index a7e343e..0686241 100644
--- a/frontends/gtk/search.c
+++ b/frontends/gtk/search.c
@@ -38,18 +38,26 @@
#include "gtk/search.h"
+struct gtk_search {
+ GtkToolbar *bar;
+ GtkEntry *entry;
+ GtkToolButton *back;
+ GtkToolButton *forward;
+ GtkToolButton *close;
+ GtkCheckButton *checkAll;
+ GtkCheckButton *caseSens;
+
+ struct browser_window *bw;
+};
+
/**
* activate search forwards button in gui.
*
* \param active activate/inactivate
- * \param gw The gui window in which to activite the search button in.
+ * \param search the gtk search context
*/
-static void nsgtk_search_set_forward_state(bool active, struct gui_window *gw)
+static void nsgtk_search_set_forward_state(bool active, struct gtk_search *search)
{
- struct gtk_search *search;
-
- search = nsgtk_window_get_search(gw);
-
gtk_widget_set_sensitive(GTK_WIDGET(search->forward), active);
}
@@ -58,14 +66,10 @@ static void nsgtk_search_set_forward_state(bool active, struct gui_window *gw)
* activate search back button in gui.
*
* \param active activate/inactivate
- * \param gw The gui window in which to activite the search button in.
+ * \param search the gtk search context
*/
-static void nsgtk_search_set_back_state(bool active, struct gui_window *gw)
+static void nsgtk_search_set_back_state(bool active, struct gtk_search *search)
{
- struct gtk_search *search;
-
- search = nsgtk_window_get_search(gw);
-
gtk_widget_set_sensitive(GTK_WIDGET(search->back), active);
}
@@ -77,13 +81,10 @@ static gboolean
nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data)
{
struct gtk_search *search;
- struct browser_window *bw;
search_flags_t flags;
search = (struct gtk_search *)data;
- bw = nsgtk_get_browser_window(search->gw);
-
flags = SEARCH_FLAG_FORWARDS;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->caseSens))) {
@@ -94,7 +95,8 @@ nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data)
flags |= SEARCH_FLAG_SHOWALL;
}
- browser_window_search(bw, search->gw, flags, gtk_entry_get_text(search->entry));
+ browser_window_search(search->bw, search, flags,
+ gtk_entry_get_text(search->entry));
return TRUE;
}
@@ -106,13 +108,10 @@ static gboolean
nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data)
{
struct gtk_search *search;
- struct browser_window *bw;
search_flags_t flags;
search = (struct gtk_search *)data;
- bw = nsgtk_get_browser_window(search->gw);
-
flags = 0;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->caseSens))) {
@@ -123,7 +122,8 @@ nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data)
flags |= SEARCH_FLAG_SHOWALL;
}
- browser_window_search(bw, search->gw, flags, gtk_entry_get_text(search->entry));
+ browser_window_search(search->bw, search, flags,
+ gtk_entry_get_text(search->entry));
return TRUE;
}
@@ -150,13 +150,10 @@ nsgtk_search_close_button_clicked(GtkWidget *widget, gpointer data)
static gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data)
{
struct gtk_search *search;
- struct browser_window *bw;
search_flags_t flags;
search = (struct gtk_search *)data;
- bw = nsgtk_get_browser_window(search->gw);
-
flags = 0;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->caseSens))) {
@@ -167,7 +164,8 @@ static gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data)
flags |= SEARCH_FLAG_SHOWALL;
}
- browser_window_search(bw, search->gw, flags, gtk_entry_get_text(search->entry));
+ browser_window_search(search->bw, search, flags,
+ gtk_entry_get_text(search->entry));
return TRUE;
}
@@ -178,16 +176,10 @@ static gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data)
static gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data)
{
struct gtk_search *search;
- struct browser_window *bw;
search_flags_t flags;
search = (struct gtk_search *)data;
- nsgtk_search_set_forward_state(true, search->gw);
- nsgtk_search_set_back_state(true, search->gw);
-
- bw = nsgtk_get_browser_window(search->gw);
-
flags = SEARCH_FLAG_FORWARDS;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->caseSens))) {
@@ -198,7 +190,8 @@ static gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data)
flags |= SEARCH_FLAG_SHOWALL;
}
- browser_window_search(bw, search->gw, flags, gtk_entry_get_text(search->entry));
+ browser_window_search(search->bw, search, flags,
+ gtk_entry_get_text(search->entry));
return FALSE;
}
@@ -232,7 +225,7 @@ nserror nsgtk_search_toggle_visibility(struct gtk_search *search)
{
gboolean vis;
- browser_window_search_clear(nsgtk_get_browser_window(search->gw));
+ browser_window_search_clear(search->bw);
g_object_get(G_OBJECT(search->bar), "visible", &vis, NULL);
if (vis) {
@@ -286,8 +279,8 @@ nserror nsgtk_search_restyle(struct gtk_search *search)
/* exported interface documented in gtk/search.h */
nserror
nsgtk_search_create(GtkBuilder *builder,
- struct gtk_search **search_out,
- struct gui_window *gw)
+ struct browser_window *bw,
+ struct gtk_search **search_out)
{
struct gtk_search *search;
@@ -296,7 +289,7 @@ nsgtk_search_create(GtkBuilder *builder,
return NSERROR_NOMEM;
}
- search->gw = gw;
+ search->bw = bw;
search->bar = GTK_TOOLBAR(gtk_builder_get_object(builder, "findbar"));
search->entry = GTK_ENTRY(gtk_builder_get_object(builder, "Find"));
diff --git a/frontends/gtk/search.h b/frontends/gtk/search.h
index b242c86..5eb0b35 100644
--- a/frontends/gtk/search.h
+++ b/frontends/gtk/search.h
@@ -18,7 +18,7 @@
/**
* \file
- * free text page search for gtk interfaces
+ * free text page search for gtk interface
*/
#ifndef NETSURF_GTK_SEARCH_H_
@@ -26,28 +26,17 @@
extern struct gui_search_table *nsgtk_search_table;
-struct nsgtk_scaffolding;
-
-struct gtk_search {
- GtkToolbar *bar;
- GtkEntry *entry;
- GtkToolButton *back;
- GtkToolButton *forward;
- GtkToolButton *close;
- GtkCheckButton *checkAll;
- GtkCheckButton *caseSens;
-
- struct gui_window *gw;
-};
+struct gtk_search;
/**
* create text search context
*
* \param builder the gtk builder containing the search toolbar
- * \param search_out search context result
+ * \param bw The browsing context to run the find operations against
+ * \param search search context result
* \return NSERROR_OK and search_out updated
*/
-nserror nsgtk_search_create(GtkBuilder *builder, struct gtk_search **search_out, struct gui_window *gw);
+nserror nsgtk_search_create(GtkBuilder *builder, struct browser_window *bw, struct gtk_search **search);
/**
* update search toolbar size and style
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 8a93f37..a26c76c 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -792,7 +792,7 @@ gui_window_create(struct browser_window *bw,
}
/* local page text search toolbar */
- res = nsgtk_search_create(tab_builder, &g->search, g);
+ res = nsgtk_search_create(tab_builder, g->bw, &g->search);
if (res != NSERROR_OK) {
free(g);
g_object_unref(tab_builder);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e9b5b56ba61283901b8...
commit e9b5b56ba61283901b8d04c0f84929664ee29bb3
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
fixup the gtk2 ui builders
diff --git a/frontends/gtk/res/netsurf.gtk2.ui b/frontends/gtk/res/netsurf.gtk2.ui
index 431eab4..adca540 100644
--- a/frontends/gtk/res/netsurf.gtk2.ui
+++ b/frontends/gtk/res/netsurf.gtk2.ui
@@ -1,156 +1,43 @@
-<?xml version="1.0"?>
-<!--Generated with glade3 3.4.5 on Wed Apr 7 17:10:28 2010 -->
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
+ <!-- interface-requires gtk+ 2.12 -->
+ <!-- interface-naming-policy toplevel-contextual -->
<object class="GtkAdjustment" id="adjustment1">
<property name="upper">100</property>
- <property name="lower">0</property>
- <property name="page_increment">10</property>
+ <property name="value">0.5357142857142857</property>
<property name="step_increment">26</property>
+ <property name="page_increment">10</property>
<property name="page_size">10</property>
- <property name="value">0.5357142857142857</property>
</object>
<object class="GtkAdjustment" id="adjustment2">
<property name="upper">100</property>
- <property name="lower">0</property>
- <property name="page_increment">10</property>
<property name="step_increment">26</property>
+ <property name="page_increment">10</property>
<property name="page_size">10</property>
- <property name="value">0</property>
- </object>
- <object class="GtkUIManager" id="uimanager1">
- <ui>
- <menubar name="menubar"/>
- </ui>
</object>
<object class="GtkWindow" id="wndBrowser">
+ <property name="can_focus">False</property>
<property name="title" translatable="yes">NetSurf</property>
- <property name="window_position">GTK_WIN_POS_CENTER</property>
+ <property name="window_position">center</property>
<child>
<object class="GtkVBox" id="vbox14">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkMenuBar" constructor="uimanager1" id="menubar">
+ <object class="GtkMenuBar" id="menubar">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolbar" id="searchbar">
- <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
- <child>
- <object class="GtkToolButton" id="closeSearchButton">
- <property name="visible">True</property>
- <property name="stock_id">gtk-close</property>
- </object>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolItem" id="searchLabelItem">
- <property name="visible">True</property>
- <child>
- <object class="GtkLabel" id="searchlabel">
- <property name="visible">True</property>
- <property name="xpad">4</property>
- <property name="label" translatable="yes">Match</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolItem" id="toolSearch">
- <property name="visible">True</property>
- <child>
- <object class="GtkEntry" id="searchEntry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="searchBackButton">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Search _Back</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-go-back</property>
- </object>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="searchForwardButton">
- <property name="visible">True</property>
- <property name="label" translatable="yes">Search _Forward</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-go-forward</property>
- </object>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolItem" id="checkAllSearchItem">
- <property name="visible">True</property>
- <child>
- <object class="GtkCheckButton" id="checkAllSearch">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="tooltip-text" translatable="yes">show all matches</property>
- <property name="label" translatable="yes">All </property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolItem" id="caseSensItem">
- <property name="visible">True</property>
- <child>
- <object class="GtkCheckButton" id="caseSensButton">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="tooltip-text" translatable="yes">Match case when searching</property>
- <property name="label" translatable="yes">Case</property>
- <property name="relief">GTK_RELIEF_NONE</property>
- <property name="use_underline">True</property>
- <property name="draw_indicator">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">False</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="show_tabs">False</property>
<property name="show_border">False</property>
<property name="scrollable">True</property>
@@ -192,7 +79,9 @@
</child>
</object>
<packing>
- <property name="position">2</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
diff --git a/frontends/gtk/res/tabcontents.gtk2.ui b/frontends/gtk/res/tabcontents.gtk2.ui
index cbd7759..c47e6a2 100644
--- a/frontends/gtk/res/tabcontents.gtk2.ui
+++ b/frontends/gtk/res/tabcontents.gtk2.ui
@@ -1,13 +1,27 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkAdjustment" id="layouthadjustment">
+ <property name="upper">100</property>
+ <property name="step_increment">30</property>
+ <property name="page_increment">10</property>
+ <property name="page_size">10</property>
+ </object>
+ <object class="GtkAdjustment" id="layoutvadjustment">
+ <property name="upper">100</property>
+ <property name="step_increment">30</property>
+ <property name="page_increment">10</property>
+ <property name="page_size">10</property>
+ </object>
<object class="GtkVBox" id="tabBox">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
<object class="GtkToolbar" id="toolbar">
<property name="visible">True</property>
- <property name="toolbar_style">GTK_TOOLBAR_BOTH_HORIZ</property>
+ <property name="can_focus">False</property>
+ <property name="toolbar_style">both-horiz</property>
</object>
<packing>
<property name="expand">False</property>
@@ -16,79 +30,65 @@
</packing>
</child>
<child>
- <object class="GtkToolbar" id="searchbar">
- <property name="toolbar_style">GTK_TOOLBAR_BOTH</property>
- <child>
- <object class="GtkToolButton" id="closeSearchButton">
- <property name="visible">True</property>
- <property name="stock_id">gtk-close</property>
- </object>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
+ <object class="GtkToolbar" id="findbar">
+ <property name="can_focus">False</property>
+ <property name="toolbar_style">both</property>
<child>
- <object class="GtkToolItem" id="searchLabelItem">
+ <object class="GtkToolItem" id="toolitemFind">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkLabel" id="searchlabel">
- <property name="visible">True</property>
- <property name="xpad">4</property>
- <property name="label" translatable="yes">Match</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolItem" id="toolSearch">
- <property name="visible">True</property>
- <child>
- <object class="GtkEntry" id="searchEntry">
+ <object class="GtkEntry" id="Find">
<property name="visible">True</property>
<property name="can_focus">True</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
</object>
</child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="homogeneous">False</property>
+ <property name="expand">True</property>
</packing>
</child>
<child>
- <object class="GtkToolButton" id="searchBackButton">
+ <object class="GtkToolButton" id="FindBack">
<property name="visible">True</property>
- <property name="label" translatable="yes">Search _Back</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">gtkFindBack</property>
<property name="use_underline">True</property>
- <property name="stock_id">gtk-go-back</property>
+ <property name="icon_name">go-up</property>
</object>
<packing>
<property name="expand">False</property>
+ <property name="homogeneous">True</property>
</packing>
</child>
<child>
- <object class="GtkToolButton" id="searchForwardButton">
+ <object class="GtkToolButton" id="FindForward">
<property name="visible">True</property>
- <property name="label" translatable="yes">Search _Forward</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">gtkFindForward</property>
<property name="use_underline">True</property>
- <property name="stock_id">gtk-go-forward</property>
+ <property name="icon_name">go-down</property>
</object>
<packing>
<property name="expand">False</property>
+ <property name="homogeneous">True</property>
</packing>
</child>
<child>
- <object class="GtkToolItem" id="checkAllSearchItem">
+ <object class="GtkToolItem" id="toolitemFindHighlightAll">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkCheckButton" id="checkAllSearch">
+ <object class="GtkCheckButton" id="FindHighlightAll">
+ <property name="label" translatable="yes">gtkFindHighlightAll</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="tooltip-text" translatable="yes">show all matches</property>
- <property name="label" translatable="yes">All </property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">show all matches</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
@@ -96,19 +96,20 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="homogeneous">False</property>
</packing>
</child>
<child>
- <object class="GtkToolItem" id="caseSensItem">
+ <object class="GtkToolItem" id="toolitemFindMatchCase">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<child>
- <object class="GtkCheckButton" id="caseSensButton">
+ <object class="GtkCheckButton" id="FindMatchCase">
+ <property name="label" translatable="yes">gtkFindMatchCase</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="tooltip-text" translatable="yes">Match case when searching</property>
- <property name="label" translatable="yes">Case</property>
- <property name="relief">GTK_RELIEF_NONE</property>
+ <property name="receives_default">False</property>
+ <property name="tooltip_text" translatable="yes">Match case when searching</property>
+ <property name="relief">none</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
@@ -116,7 +117,18 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="homogeneous">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkToolButton" id="FindClose">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">gtkFindClose</property>
+ <property name="icon_name">window-close</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
</packing>
</child>
</object>
@@ -129,12 +141,14 @@
<child>
<object class="GtkTable" id="tabContents">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<child>
<object class="GtkLayout" id="layout">
<property name="visible">True</property>
<property name="app_paintable">True</property>
+ <property name="can_focus">False</property>
<property name="events">GDK_EXPOSURE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_STRUCTURE_MASK | GDK_SCROLL_MASK</property>
<property name="hadjustment">layouthadjustment</property>
<property name="vadjustment">layoutvadjustment</property>
@@ -144,6 +158,7 @@
<object class="GtkStatusbar" id="resizer">
<property name="height_request">1</property>
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">2</property>
</object>
<packing>
@@ -163,6 +178,7 @@
<object class="GtkLabel" id="status_bar">
<property name="width_request">1</property>
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="xpad">4</property>
<property name="label" translatable="yes">Status</property>
@@ -175,6 +191,7 @@
<child>
<object class="GtkHScrollbar" id="hscrollbar">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="adjustment">layouthadjustment</property>
</object>
<packing>
@@ -192,31 +209,21 @@
<child>
<object class="GtkVScrollbar" id="vscrollbar">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
+ <property name="can_focus">False</property>
<property name="adjustment">layoutvadjustment</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="x_options"></property>
+ <property name="x_options"/>
</packing>
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
</object>
- <object class="GtkAdjustment" id="layouthadjustment">
- <property name="upper">100</property>
- <property name="step_increment">30</property>
- <property name="page_increment">10</property>
- <property name="page_size">10</property>
- </object>
- <object class="GtkAdjustment" id="layoutvadjustment">
- <property name="upper">100</property>
- <property name="step_increment">30</property>
- <property name="page_increment">10</property>
- <property name="page_size">10</property>
- </object>
</interface>
diff --git a/frontends/gtk/res/toolbar.gtk2.ui b/frontends/gtk/res/toolbar.gtk2.ui
index eb882f3..2288971 100644
--- a/frontends/gtk/res/toolbar.gtk2.ui
+++ b/frontends/gtk/res/toolbar.gtk2.ui
@@ -17,6 +17,20 @@
</packing>
</child>
<child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">0</property>
+ <property name="xpad">6</property>
+ <property name="label" translatable="yes">gtkCustomizeToolbarInstructions</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -44,7 +58,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -98,7 +112,7 @@
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">6</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
diff --git a/frontends/gtk/search.c b/frontends/gtk/search.c
index ead511f..a7e343e 100644
--- a/frontends/gtk/search.c
+++ b/frontends/gtk/search.c
@@ -307,7 +307,7 @@ nsgtk_search_create(GtkBuilder *builder,
search->close = GTK_TOOL_BUTTON(gtk_builder_get_object(builder,
"FindClose"));
search->checkAll = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
- "FindHightlightAll"));
+ "FindHighlightAll"));
search->caseSens = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
"FindMatchCase"));
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a013a24d5f489ee5295...
commit a013a24d5f489ee5295aa1ce0bfe68c9c27e327f
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
clean up find in page to operate nicely
diff --git a/frontends/gtk/res/netsurf.gtk3.ui b/frontends/gtk/res/netsurf.gtk3.ui
index ce47c63..6ea8f07 100644
--- a/frontends/gtk/res/netsurf.gtk3.ui
+++ b/frontends/gtk/res/netsurf.gtk3.ui
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
<interface>
- <!-- interface-requires gtk+ 3.0 -->
+ <requires lib="gtk+" version="3.0"/>
<object class="GtkWindow" id="wndBrowser">
<property name="can_focus">False</property>
<child>
+ <placeholder/>
+ </child>
+ <child>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -20,156 +24,6 @@
</packing>
</child>
<child>
- <object class="GtkToolbar" id="toolbar">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="toolbar_style">both</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolbar" id="searchbar">
- <property name="can_focus">False</property>
- <property name="toolbar_style">both</property>
- <child>
- <object class="GtkToolButton" id="closeSearchButton">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="label" translatable="yes">gtk-close</property>
- <property name="stock_id">gtk-close</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolItem" id="searchLabelItem">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <child>
- <object class="GtkLabel" id="searchlabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xpad">4</property>
- <property name="label" translatable="yes">Match</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolItem" id="toolSearch">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <child>
- <object class="GtkEntry" id="searchEntry">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">●</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="searchBackButton">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="label" translatable="yes">Search _Back</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-go-back</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolButton" id="searchForwardButton">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <property name="label" translatable="yes">Search _Forward</property>
- <property name="use_underline">True</property>
- <property name="stock_id">gtk-go-forward</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolItem" id="checkAllSearchItem">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <child>
- <object class="GtkCheckButton" id="checkAllSearch">
- <property name="label" translatable="yes">All</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolItem" id="caseSensItem">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
- <child>
- <object class="GtkCheckButton" id="caseSensButton">
- <property name="label" translatable="yes">Case</property>
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <property name="use_action_appearance">False</property>
- <property name="xalign">0</property>
- <property name="draw_indicator">True</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
diff --git a/frontends/gtk/res/tabcontents.gtk3.ui b/frontends/gtk/res/tabcontents.gtk3.ui
index 607d511..5d7a40b 100644
--- a/frontends/gtk/res/tabcontents.gtk3.ui
+++ b/frontends/gtk/res/tabcontents.gtk3.ui
@@ -29,67 +29,37 @@
</packing>
</child>
<child>
- <object class="GtkToolbar" id="searchbar">
+ <object class="GtkToolbar" id="findbar">
<property name="can_focus">False</property>
<property name="toolbar_style">both</property>
<child>
- <object class="GtkToolButton" id="closeSearchButton">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">gtk-close</property>
- <property name="stock_id">gtk-close</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolItem" id="searchLabelItem">
+ <object class="GtkToolItem">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkLabel" id="searchlabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="xpad">4</property>
- <property name="label" translatable="yes">Match</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">False</property>
- </packing>
- </child>
- <child>
- <object class="GtkToolItem" id="toolSearch">
- <property name="use_action_appearance">False</property>
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkEntry" id="searchEntry">
+ <object class="GtkEntry" id="Find">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">●</property>
+ <property name="placeholder_text" translatable="yes">gtkFindPlaceholder</property>
</object>
</child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="homogeneous">False</property>
</packing>
</child>
<child>
- <object class="GtkToolButton" id="searchBackButton">
+ <object class="GtkToolButton" id="FindBack">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Search _Back</property>
+ <property name="tooltip_text" translatable="yes">gtkFindBack</property>
+ <property name="label" translatable="yes">gtkFindBack</property>
<property name="use_underline">True</property>
- <property name="stock_id">gtk-go-back</property>
+ <property name="stock_id">gtk-go-up</property>
</object>
<packing>
<property name="expand">False</property>
@@ -97,13 +67,14 @@
</packing>
</child>
<child>
- <object class="GtkToolButton" id="searchForwardButton">
+ <object class="GtkToolButton" id="FindForward">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Search _Forward</property>
+ <property name="tooltip_text" translatable="yes">gtkFindForward</property>
+ <property name="label" translatable="yes">gtkFindForward</property>
<property name="use_underline">True</property>
- <property name="stock_id">gtk-go-forward</property>
+ <property name="stock_id">gtk-go-down</property>
</object>
<packing>
<property name="expand">False</property>
@@ -111,13 +82,13 @@
</packing>
</child>
<child>
- <object class="GtkToolItem" id="checkAllSearchItem">
+ <object class="GtkToolItem">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkCheckButton" id="checkAllSearch">
- <property name="label" translatable="yes">All</property>
+ <object class="GtkCheckButton" id="FindHightlightAll">
+ <property name="label" translatable="yes">gtkFindHighlightAll</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -133,13 +104,13 @@
</packing>
</child>
<child>
- <object class="GtkToolItem" id="caseSensItem">
+ <object class="GtkToolItem">
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
- <object class="GtkCheckButton" id="caseSensButton">
- <property name="label" translatable="yes">Case</property>
+ <object class="GtkCheckButton" id="FindMatchCase">
+ <property name="label" translatable="yes">gtkFindMatchCase</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -154,6 +125,20 @@
<property name="homogeneous">False</property>
</packing>
</child>
+ <child>
+ <object class="GtkToolButton" id="FindClose">
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">gtkFindClose</property>
+ <property name="label" translatable="yes">gtkFindClose</property>
+ <property name="stock_id">gtk-close</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="homogeneous">True</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index b86b914..5a50d81 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -1,6 +1,5 @@
/*
- * Copyright 2006 Rob Kendrick <rjek(a)rjek.com>
- * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ * Copyright 2019 Vincent Sanders <vince(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -18,26 +17,25 @@
*/
#include <gtk/gtk.h>
+#include <stdbool.h>
#include "utils/utils.h"
#include "utils/log.h"
-#include "utils/nsurl.h"
#include "utils/messages.h"
+#include "utils/nsurl.h"
#include "utils/nsoption.h"
#include "netsurf/browser_window.h"
#include "desktop/browser_history.h"
#include "desktop/hotlist.h"
#include "gtk/compat.h"
-#include "gtk/warn.h"
#include "gtk/toolbar_items.h"
-#include "gtk/toolbar.h"
#include "gtk/menu.h"
#include "gtk/local_history.h"
-#include "gtk/download.h"
#include "gtk/gui.h"
+#include "gtk/download.h"
#include "gtk/window.h"
-#include "gtk/completion.h"
+#include "gtk/warn.h"
#include "gtk/tabs.h"
#include "gtk/resources.h"
#include "gtk/scaffolding.h"
diff --git a/frontends/gtk/search.c b/frontends/gtk/search.c
index a75dc94..ead511f 100644
--- a/frontends/gtk/search.c
+++ b/frontends/gtk/search.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ * Copyright 2019 Vincent Sanders <vince(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -19,30 +19,24 @@
/**
* \file
- * Free text search (front component)
+ * find in page gtk frontend implementation
+ *
+ * \todo this whole thing should be named find rather than search as
+ * that generally means web search and is confusing.
*/
-#include <stdint.h>
-#include <ctype.h>
-#include <string.h>
-#include <gdk/gdkkeysyms.h>
+#include <stdbool.h>
+#include <gtk/gtk.h>
-#include "utils/config.h"
-#include "utils/log.h"
-#include "utils/messages.h"
-#include "utils/nsurl.h"
#include "utils/nsoption.h"
#include "netsurf/search.h"
-#include "netsurf/browser_window.h"
#include "desktop/search.h"
-#include "desktop/searchweb.h"
-#include "gtk/warn.h"
#include "gtk/compat.h"
-#include "gtk/search.h"
#include "gtk/toolbar_items.h"
-#include "gtk/scaffolding.h"
#include "gtk/window.h"
+#include "gtk/search.h"
+
/**
* activate search forwards button in gui.
@@ -161,12 +155,9 @@ static gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data)
search = (struct gtk_search *)data;
- nsgtk_search_set_forward_state(true, search->gw);
- nsgtk_search_set_back_state(true, search->gw);
-
bw = nsgtk_get_browser_window(search->gw);
- flags = SEARCH_FLAG_FORWARDS;
+ flags = 0;
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->caseSens))) {
flags |= SEARCH_FLAG_CASE_SENSITIVE;
@@ -241,14 +232,15 @@ nserror nsgtk_search_toggle_visibility(struct gtk_search *search)
{
gboolean vis;
+ browser_window_search_clear(nsgtk_get_browser_window(search->gw));
+
g_object_get(G_OBJECT(search->bar), "visible", &vis, NULL);
if (vis) {
- browser_window_search_clear(nsgtk_get_browser_window(search->gw));
-
gtk_widget_hide(GTK_WIDGET(search->bar));
} else {
gtk_widget_show(GTK_WIDGET(search->bar));
gtk_widget_grab_focus(GTK_WIDGET(search->entry));
+ nsgtk_search_entry_changed(GTK_WIDGET(search->entry), search);
}
return NSERROR_OK;
@@ -306,20 +298,18 @@ nsgtk_search_create(GtkBuilder *builder,
search->gw = gw;
- search->bar = GTK_TOOLBAR(gtk_builder_get_object(builder,
- "searchbar"));
- search->entry = GTK_ENTRY(gtk_builder_get_object(builder,
- "searchEntry"));
+ search->bar = GTK_TOOLBAR(gtk_builder_get_object(builder, "findbar"));
+ search->entry = GTK_ENTRY(gtk_builder_get_object(builder, "Find"));
search->back = GTK_TOOL_BUTTON(gtk_builder_get_object(builder,
- "searchBackButton"));
+ "FindBack"));
search->forward = GTK_TOOL_BUTTON(gtk_builder_get_object(builder,
- "searchForwardButton"));
+ "FindForward"));
search->close = GTK_TOOL_BUTTON(gtk_builder_get_object(builder,
- "closeSearchButton"));
+ "FindClose"));
search->checkAll = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
- "checkAllSearch"));
+ "FindHightlightAll"));
search->caseSens = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
- "caseSensButton"));
+ "FindMatchCase"));
g_signal_connect(search->forward,
"clicked",
@@ -356,8 +346,14 @@ nsgtk_search_create(GtkBuilder *builder,
G_CALLBACK(nsgtk_search_entry_changed),
search);
+ g_signal_connect(search->checkAll,
+ "toggled",
+ G_CALLBACK(nsgtk_search_entry_changed),
+ search);
+
nsgtk_search_restyle(search);
+
*search_out = search;
return NSERROR_OK;
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index a8badc4..8a93f37 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -889,8 +889,8 @@ gui_window_create(struct browser_window *bw,
}
nsgtk_tab_add(g, g->container, tempback, messages_get("NewTab"), g->icon);
- /* \todo move search bar properly */
- gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(tab_builder, "searchbar")));
+ /* initialy should not be visible */
+ nsgtk_search_toggle_visibility(g->search);
/* safe to drop the reference to the tab_builder as the container is
* referenced by the notebook now.
diff --git a/resources/FatMessages b/resources/FatMessages
index ee56dee..9125866 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -3301,6 +3301,15 @@ nl.gtk.gtkThemeAdd:Thema is succesvol toegevoegd
en.gtk.gtkCustomizeToolbarTitle:Customise Toolbar
en.gtk.gtkCustomizeToolbarInstructions:Drag toolbar items into and out of the toolbar.
+# GTK find in page
+
+en.gtk.gtkFindPlaceholder:Find in page
+en.gtk.gtkFindBack:Find Previous Occurrence
+en.gtk.gtkFindForward:Find _Next Occurrence
+en.gtk.gtkFindHighlightAll:Highlight All
+en.gtk.gtkFindMatchCase:Match Case
+en.gtk.gtkFindClose:Close Find Bar
+
# GTK preferences dialog
en.gtk.preferencesTitle:Netsurf Preferences
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a20fe23ce611a156ba7...
commit a20fe23ce611a156ba7f10d555436b3ad9f8b72f
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
move search toolbar to be per tab and move implementation to one place
diff --git a/frontends/gtk/compat.h b/frontends/gtk/compat.h
index 8ef2ed5..3b2f550 100644
--- a/frontends/gtk/compat.h
+++ b/frontends/gtk/compat.h
@@ -16,7 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/** \file
+/**
+ * \file
* Compatibility functions for older GTK versions (interface)
*/
@@ -40,9 +41,6 @@
#define NSGTK_STOCK_CANCEL "_Cancel"
#define NSGTK_STOCK_CLEAR "edit-clear"
#define NSGTK_STOCK_CLOSE "window-close"
-#define NSGTK_STOCK_FIND "edit-find"
-#define NSGTK_STOCK_GO_BACK "go-previous"
-#define NSGTK_STOCK_GO_FORWARD "go-next"
#define NSGTK_STOCK_HOME "go-home"
#define NSGTK_STOCK_INFO "dialog-information"
#define NSGTK_STOCK_REFRESH "view-refresh"
@@ -57,9 +55,6 @@
#define NSGTK_STOCK_CANCEL GTK_STOCK_CANCEL
#define NSGTK_STOCK_CLEAR GTK_STOCK_CLEAR
#define NSGTK_STOCK_CLOSE GTK_STOCK_CLOSE
-#define NSGTK_STOCK_FIND GTK_STOCK_FIND
-#define NSGTK_STOCK_GO_BACK GTK_STOCK_GO_BACK
-#define NSGTK_STOCK_GO_FORWARD GTK_STOCK_GO_FORWARD
#define NSGTK_STOCK_HOME GTK_STOCK_HOME
#define NSGTK_STOCK_INFO GTK_STOCK_INFO
#define NSGTK_STOCK_REFRESH GTK_STOCK_REFRESH
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index f0b4f9b..b86b914 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -27,7 +27,6 @@
#include "netsurf/browser_window.h"
#include "desktop/browser_history.h"
#include "desktop/hotlist.h"
-#include "desktop/search.h"
#include "gtk/compat.h"
#include "gtk/warn.h"
@@ -40,7 +39,6 @@
#include "gtk/window.h"
#include "gtk/completion.h"
#include "gtk/tabs.h"
-#include "gtk/search.h"
#include "gtk/resources.h"
#include "gtk/scaffolding.h"
@@ -76,9 +74,6 @@ struct nsgtk_scaffolding {
/** tab widget holding displayed pages */
GtkNotebook *notebook;
- /** In page text search context */
- struct gtk_search *search;
-
/** menu bar hierarchy */
struct nsgtk_bar_submenu *menu_bar;
@@ -591,7 +586,8 @@ static gboolean nsgtk_on_find_activate_menu(GtkMenuItem *widget, gpointer data)
{
struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_scaffolding_toggle_search_bar_visibility(g);
+ nsgtk_window_search_toggle(g->top_level);
+
return TRUE;
}
@@ -1081,7 +1077,7 @@ static nserror nsgtk_menus_create(struct nsgtk_scaffolding *gs)
gs->menu_bar = nsgtk_menu_bar_create(menushell, group);
- /* toolbar URL bar menu bar search bar signal handlers */
+ /* toolbar URL bar menu bar signal handlers */
g_signal_connect(gs->menu_bar->edit_submenu->edit,
"show",
G_CALLBACK(nsgtk_window_edit_menu_shown),
@@ -1109,119 +1105,8 @@ static nserror nsgtk_menus_create(struct nsgtk_scaffolding *gs)
}
-/**
- * update search toolbar size and style
- */
-static nserror nsgtk_search_update(struct gtk_search *search)
-{
- switch (nsoption_int(button_type)) {
-
- case 1: /* Small icons */
- gtk_toolbar_set_style(GTK_TOOLBAR(search->bar),
- GTK_TOOLBAR_ICONS);
- gtk_toolbar_set_icon_size(GTK_TOOLBAR(search->bar),
- GTK_ICON_SIZE_SMALL_TOOLBAR);
- break;
-
- case 2: /* Large icons */
- gtk_toolbar_set_style(GTK_TOOLBAR(search->bar),
- GTK_TOOLBAR_ICONS);
- gtk_toolbar_set_icon_size(GTK_TOOLBAR(search->bar),
- GTK_ICON_SIZE_LARGE_TOOLBAR);
- break;
-
- case 3: /* Large icons with text */
- gtk_toolbar_set_style(GTK_TOOLBAR(search->bar),
- GTK_TOOLBAR_BOTH);
- gtk_toolbar_set_icon_size(GTK_TOOLBAR(search->bar),
- GTK_ICON_SIZE_LARGE_TOOLBAR);
- break;
-
- case 4: /* Text icons only */
- gtk_toolbar_set_style(GTK_TOOLBAR(search->bar),
- GTK_TOOLBAR_TEXT);
- default:
- break;
- }
- return NSERROR_OK;
-}
-
-/**
- * create text search context
- */
-static nserror
-nsgtk_search_create(GtkBuilder *builder, struct gtk_search **search_out)
-{
- struct gtk_search *search;
-
- search = malloc(sizeof(struct gtk_search));
- if (search == NULL) {
- return NSERROR_NOMEM;
- }
-
- search->bar = GTK_TOOLBAR(gtk_builder_get_object(builder, "searchbar"));
- search->entry = GTK_ENTRY(gtk_builder_get_object(builder,"searchEntry"));
-
- search->buttons[0] = GTK_TOOL_BUTTON(gtk_builder_get_object(
- builder,"searchBackButton"));
- search->buttons[1] = GTK_TOOL_BUTTON(gtk_builder_get_object(
- builder,"searchForwardButton"));
- search->buttons[2] = GTK_TOOL_BUTTON(gtk_builder_get_object(
- builder,"closeSearchButton"));
- search->checkAll = GTK_CHECK_BUTTON(gtk_builder_get_object(
- builder,"checkAllSearch"));
- search->caseSens = GTK_CHECK_BUTTON(gtk_builder_get_object(
- builder,"caseSensButton"));
-
- nsgtk_search_update(search);
-
- *search_out = search;
-
- return NSERROR_OK;
-}
-
-/**
- * connect signals to search bar
- */
-static nserror nsgtk_search_connect_signals(struct nsgtk_scaffolding *gs)
-{
- g_signal_connect(gs->search->buttons[1],
- "clicked",
- G_CALLBACK(nsgtk_search_forward_button_clicked),
- gs);
-
- g_signal_connect(gs->search->buttons[0],
- "clicked",
- G_CALLBACK(nsgtk_search_back_button_clicked),
- gs);
- g_signal_connect(gs->search->entry,
- "changed",
- G_CALLBACK(nsgtk_search_entry_changed),
- gs);
- g_signal_connect(gs->search->entry,
- "activate",
- G_CALLBACK(nsgtk_search_entry_activate),
- gs);
-
- g_signal_connect(gs->search->entry,
- "key-press-event",
- G_CALLBACK(nsgtk_search_entry_key),
- gs);
-
- g_signal_connect(gs->search->buttons[2],
- "clicked",
- G_CALLBACK(nsgtk_search_close_button_clicked),
- gs);
-
- g_signal_connect(gs->search->caseSens,
- "toggled",
- G_CALLBACK(nsgtk_search_entry_changed),
- gs);
-
- return NSERROR_OK;
-}
/* exported function documented in gtk/scaffolding.h */
@@ -1314,12 +1199,6 @@ GtkWidget *nsgtk_scaffolding_urlbar(struct nsgtk_scaffolding *g)
/* exported interface documented in gtk/scaffolding.h */
-struct gtk_search *nsgtk_scaffolding_search(struct nsgtk_scaffolding *g)
-{
- return g->search;
-}
-
-/* exported interface documented in gtk/scaffolding.h */
GtkMenuBar *nsgtk_scaffolding_menu_bar(struct nsgtk_scaffolding *gs)
{
if (gs == NULL) {
@@ -1346,26 +1225,6 @@ struct gui_window *nsgtk_scaffolding_top_level(struct nsgtk_scaffolding *g)
/* exported interface documented in gtk/scaffolding.h */
-void nsgtk_scaffolding_toggle_search_bar_visibility(struct nsgtk_scaffolding *g)
-{
- gboolean vis;
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
-
- g_object_get(G_OBJECT(g->search->bar), "visible", &vis, NULL);
- if (vis) {
- if (bw != NULL) {
- browser_window_search_clear(bw);
- }
-
- gtk_widget_hide(GTK_WIDGET(g->search->bar));
- } else {
- gtk_widget_show(GTK_WIDGET(g->search->bar));
- gtk_widget_grab_focus(GTK_WIDGET(g->search->entry));
- }
-}
-
-
-/* exported interface documented in gtk/scaffolding.h */
void nsgtk_scaffolding_set_top_level(struct gui_window *gw)
{
struct browser_window *bw;
@@ -1387,9 +1246,6 @@ void nsgtk_scaffolding_set_top_level(struct gui_window *gw)
/* Synchronise the history (will also update the URL bar) */
scaffolding_update_context(sc);
- /* clear effects of potential searches */
- browser_window_search_clear(bw);
-
/* Ensure the window's title bar is updated */
nsgtk_scaffolding_set_title(gw, browser_window_get_title(bw));
}
@@ -1589,15 +1445,6 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
gs);
- /* local page text search */
- res = nsgtk_search_create(gs->builder, &gs->search);
- if (res != NSERROR_OK) {
- free(gs);
- return NULL;
- }
-
- nsgtk_search_connect_signals(gs);
-
res = nsgtk_menus_create(gs);
if (res != NSERROR_OK) {
free(gs);
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index 28fa6ec..c30c585 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -29,15 +29,6 @@ struct gui_search_web_table;
struct nsurl;
-struct gtk_search {
- GtkToolbar *bar;
- GtkEntry *entry;
- GtkToolButton *buttons[3]; /* back, forward, */
- GtkCheckButton *checkAll;
- GtkCheckButton *caseSens;
-};
-
-
/**
* create a new scaffolding for a window.
*
diff --git a/frontends/gtk/search.c b/frontends/gtk/search.c
index 6baf7f6..a75dc94 100644
--- a/frontends/gtk/search.c
+++ b/frontends/gtk/search.c
@@ -21,6 +21,7 @@
* \file
* Free text search (front component)
*/
+
#include <stdint.h>
#include <ctype.h>
#include <string.h>
@@ -30,6 +31,7 @@
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsurl.h"
+#include "utils/nsoption.h"
#include "netsurf/search.h"
#include "netsurf/browser_window.h"
#include "desktop/search.h"
@@ -50,14 +52,14 @@
*/
static void nsgtk_search_set_forward_state(bool active, struct gui_window *gw)
{
- if (gw != NULL && nsgtk_get_browser_window(gw) != NULL) {
- struct nsgtk_scaffolding *g = nsgtk_get_scaffold(gw);
- gtk_widget_set_sensitive(
- GTK_WIDGET(nsgtk_scaffolding_search(g)->buttons[1]),
- active);
- }
+ struct gtk_search *search;
+
+ search = nsgtk_window_get_search(gw);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(search->forward), active);
}
+
/**
* activate search back button in gui.
*
@@ -66,137 +68,297 @@ static void nsgtk_search_set_forward_state(bool active, struct gui_window *gw)
*/
static void nsgtk_search_set_back_state(bool active, struct gui_window *gw)
{
- if (gw != NULL && nsgtk_get_browser_window(gw) != NULL) {
- struct nsgtk_scaffolding *g = nsgtk_get_scaffold(gw);
- gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_search(
- g)->buttons[0]), active);
- }
+ struct gtk_search *search;
+
+ search = nsgtk_window_get_search(gw);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(search->back), active);
}
-/** connected to the search forward button */
-gboolean nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data)
+/**
+ * connected to the search forward button
+ */
+static gboolean
+nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data)
{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- struct gui_window *gw = nsgtk_scaffolding_top_level(g);
- struct browser_window *bw = nsgtk_get_browser_window(gw);
-
- assert(bw);
-
- search_flags_t flags = SEARCH_FLAG_FORWARDS |
- (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
- nsgtk_scaffolding_search(g)->caseSens)) ?
- SEARCH_FLAG_CASE_SENSITIVE : 0) |
- (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
- nsgtk_scaffolding_search(g)->checkAll)) ?
- SEARCH_FLAG_SHOWALL : 0);
-
- browser_window_search(bw, gw, flags,
- gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry));
+ struct gtk_search *search;
+ struct browser_window *bw;
+ search_flags_t flags;
+
+ search = (struct gtk_search *)data;
+
+ bw = nsgtk_get_browser_window(search->gw);
+
+ flags = SEARCH_FLAG_FORWARDS;
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->caseSens))) {
+ flags |= SEARCH_FLAG_CASE_SENSITIVE;
+ }
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->checkAll))) {
+ flags |= SEARCH_FLAG_SHOWALL;
+ }
+
+ browser_window_search(bw, search->gw, flags, gtk_entry_get_text(search->entry));
+
return TRUE;
}
-/** connected to the search back button */
-
-gboolean nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data)
+/**
+ * connected to the search back button
+ */
+static gboolean
+nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data)
{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- struct gui_window *gw = nsgtk_scaffolding_top_level(g);
- struct browser_window *bw = nsgtk_get_browser_window(gw);
-
- assert(bw);
-
- search_flags_t flags = 0 |(gtk_toggle_button_get_active(
- GTK_TOGGLE_BUTTON(
- nsgtk_scaffolding_search(g)->caseSens)) ?
- SEARCH_FLAG_CASE_SENSITIVE : 0) |
- (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
- nsgtk_scaffolding_search(g)->checkAll)) ?
- SEARCH_FLAG_SHOWALL : 0);
-
- browser_window_search(bw, gw, flags,
- gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry));
+ struct gtk_search *search;
+ struct browser_window *bw;
+ search_flags_t flags;
+
+ search = (struct gtk_search *)data;
+
+ bw = nsgtk_get_browser_window(search->gw);
+
+ flags = 0;
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->caseSens))) {
+ flags |= SEARCH_FLAG_CASE_SENSITIVE;
+ }
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->checkAll))) {
+ flags |= SEARCH_FLAG_SHOWALL;
+ }
+
+ browser_window_search(bw, search->gw, flags, gtk_entry_get_text(search->entry));
+
return TRUE;
}
-/** connected to the search close button */
-
-gboolean nsgtk_search_close_button_clicked(GtkWidget *widget, gpointer data)
+/**
+ * connected to the search close button
+ */
+static gboolean
+nsgtk_search_close_button_clicked(GtkWidget *widget, gpointer data)
{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_scaffolding_toggle_search_bar_visibility(g);
- return TRUE;
+ struct gtk_search *search;
+
+ search = (struct gtk_search *)data;
+
+ nsgtk_search_toggle_visibility(search);
+
+ return TRUE;
}
-/** connected to the search entry [typing] */
-gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data)
+/**
+ * connected to the search entry [typing]
+ */
+static gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data)
{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- struct gui_window *gw = nsgtk_scaffolding_top_level(g);
- struct browser_window *bw = nsgtk_get_browser_window(gw);
+ struct gtk_search *search;
+ struct browser_window *bw;
search_flags_t flags;
- assert(bw != NULL);
+ search = (struct gtk_search *)data;
- nsgtk_search_set_forward_state(true, gw);
- nsgtk_search_set_back_state(true, gw);
+ nsgtk_search_set_forward_state(true, search->gw);
+ nsgtk_search_set_back_state(true, search->gw);
- flags = SEARCH_FLAG_FORWARDS |
- (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
- nsgtk_scaffolding_search(g)->caseSens)) ?
- SEARCH_FLAG_CASE_SENSITIVE : 0) |
- (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
- nsgtk_scaffolding_search(g)->checkAll)) ?
- SEARCH_FLAG_SHOWALL : 0);
+ bw = nsgtk_get_browser_window(search->gw);
+
+ flags = SEARCH_FLAG_FORWARDS;
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->caseSens))) {
+ flags |= SEARCH_FLAG_CASE_SENSITIVE;
+ }
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->checkAll))) {
+ flags |= SEARCH_FLAG_SHOWALL;
+ }
+
+ browser_window_search(bw, search->gw, flags, gtk_entry_get_text(search->entry));
- browser_window_search(bw, gw, flags,
- gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry));
return TRUE;
}
-/** connected to the search entry [return key] */
-
-gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data)
+/**
+ * connected to the search entry [return key]
+ */
+static gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data)
{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- struct gui_window *gw = nsgtk_scaffolding_top_level(g);
- struct browser_window *bw = nsgtk_get_browser_window(gw);
+ struct gtk_search *search;
+ struct browser_window *bw;
search_flags_t flags;
- assert(bw);
+ search = (struct gtk_search *)data;
+
+ nsgtk_search_set_forward_state(true, search->gw);
+ nsgtk_search_set_back_state(true, search->gw);
+
+ bw = nsgtk_get_browser_window(search->gw);
- flags = SEARCH_FLAG_FORWARDS |
- (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
- nsgtk_scaffolding_search(g)->caseSens)) ?
- SEARCH_FLAG_CASE_SENSITIVE : 0) |
- (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(
- nsgtk_scaffolding_search(g)->checkAll)) ?
- SEARCH_FLAG_SHOWALL : 0);
+ flags = SEARCH_FLAG_FORWARDS;
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->caseSens))) {
+ flags |= SEARCH_FLAG_CASE_SENSITIVE;
+ }
+
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(search->checkAll))) {
+ flags |= SEARCH_FLAG_SHOWALL;
+ }
+
+ browser_window_search(bw, search->gw, flags, gtk_entry_get_text(search->entry));
- browser_window_search(bw, gw, flags,
- gtk_entry_get_text(nsgtk_scaffolding_search(g)->entry));
return FALSE;
}
-/** allows escape key to close search bar too */
-
-gboolean
+/**
+ * allows escape key to close search bar too
+ */
+static gboolean
nsgtk_search_entry_key(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
if (event->keyval == GDK_KEY(Escape)) {
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_scaffolding_toggle_search_bar_visibility(g);
+ struct gtk_search *search;
+ search = (struct gtk_search *)data;
+
+ nsgtk_search_toggle_visibility(search);
}
return FALSE;
}
-
-
static struct gui_search_table search_table = {
.forward_state = (void *)nsgtk_search_set_forward_state,
.back_state = (void *)nsgtk_search_set_back_state,
};
struct gui_search_table *nsgtk_search_table = &search_table;
+
+
+/* exported interface documented in gtk/scaffolding.h */
+nserror nsgtk_search_toggle_visibility(struct gtk_search *search)
+{
+ gboolean vis;
+
+ g_object_get(G_OBJECT(search->bar), "visible", &vis, NULL);
+ if (vis) {
+ browser_window_search_clear(nsgtk_get_browser_window(search->gw));
+
+ gtk_widget_hide(GTK_WIDGET(search->bar));
+ } else {
+ gtk_widget_show(GTK_WIDGET(search->bar));
+ gtk_widget_grab_focus(GTK_WIDGET(search->entry));
+ }
+
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in gtk/search.h */
+nserror nsgtk_search_restyle(struct gtk_search *search)
+{
+ switch (nsoption_int(button_type)) {
+
+ case 1: /* Small icons */
+ gtk_toolbar_set_style(GTK_TOOLBAR(search->bar),
+ GTK_TOOLBAR_ICONS);
+ gtk_toolbar_set_icon_size(GTK_TOOLBAR(search->bar),
+ GTK_ICON_SIZE_SMALL_TOOLBAR);
+ break;
+
+ case 2: /* Large icons */
+ gtk_toolbar_set_style(GTK_TOOLBAR(search->bar),
+ GTK_TOOLBAR_ICONS);
+ gtk_toolbar_set_icon_size(GTK_TOOLBAR(search->bar),
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
+ break;
+
+ case 3: /* Large icons with text */
+ gtk_toolbar_set_style(GTK_TOOLBAR(search->bar),
+ GTK_TOOLBAR_BOTH);
+ gtk_toolbar_set_icon_size(GTK_TOOLBAR(search->bar),
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
+ break;
+
+ case 4: /* Text icons only */
+ gtk_toolbar_set_style(GTK_TOOLBAR(search->bar),
+ GTK_TOOLBAR_TEXT);
+ default:
+ break;
+ }
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in gtk/search.h */
+nserror
+nsgtk_search_create(GtkBuilder *builder,
+ struct gtk_search **search_out,
+ struct gui_window *gw)
+{
+ struct gtk_search *search;
+
+ search = malloc(sizeof(struct gtk_search));
+ if (search == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ search->gw = gw;
+
+ search->bar = GTK_TOOLBAR(gtk_builder_get_object(builder,
+ "searchbar"));
+ search->entry = GTK_ENTRY(gtk_builder_get_object(builder,
+ "searchEntry"));
+ search->back = GTK_TOOL_BUTTON(gtk_builder_get_object(builder,
+ "searchBackButton"));
+ search->forward = GTK_TOOL_BUTTON(gtk_builder_get_object(builder,
+ "searchForwardButton"));
+ search->close = GTK_TOOL_BUTTON(gtk_builder_get_object(builder,
+ "closeSearchButton"));
+ search->checkAll = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
+ "checkAllSearch"));
+ search->caseSens = GTK_CHECK_BUTTON(gtk_builder_get_object(builder,
+ "caseSensButton"));
+
+ g_signal_connect(search->forward,
+ "clicked",
+ G_CALLBACK(nsgtk_search_forward_button_clicked),
+ search);
+
+ g_signal_connect(search->back,
+ "clicked",
+ G_CALLBACK(nsgtk_search_back_button_clicked),
+ search);
+
+ g_signal_connect(search->entry,
+ "changed",
+ G_CALLBACK(nsgtk_search_entry_changed),
+ search);
+
+ g_signal_connect(search->entry,
+ "activate",
+ G_CALLBACK(nsgtk_search_entry_activate),
+ search);
+
+ g_signal_connect(search->entry,
+ "key-press-event",
+ G_CALLBACK(nsgtk_search_entry_key),
+ search);
+
+ g_signal_connect(search->close,
+ "clicked",
+ G_CALLBACK(nsgtk_search_close_button_clicked),
+ search);
+
+ g_signal_connect(search->caseSens,
+ "toggled",
+ G_CALLBACK(nsgtk_search_entry_changed),
+ search);
+
+ nsgtk_search_restyle(search);
+
+ *search_out = search;
+
+ return NSERROR_OK;
+}
diff --git a/frontends/gtk/search.h b/frontends/gtk/search.h
index 716a60d..b242c86 100644
--- a/frontends/gtk/search.h
+++ b/frontends/gtk/search.h
@@ -16,25 +16,47 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _NETSURF_GTK_SEARCH_H_
-#define _NETSURF_GTK_SEARCH_H_
-
/**
* \file
* free text page search for gtk interfaces
*/
+#ifndef NETSURF_GTK_SEARCH_H_
+#define NETSURF_GTK_SEARCH_H_
+
extern struct gui_search_table *nsgtk_search_table;
struct nsgtk_scaffolding;
-void nsgtk_search_bar_toggle_visibility(struct nsgtk_scaffolding * g);
-gboolean nsgtk_search_entry_changed(GtkWidget *widget, gpointer data);
-gboolean nsgtk_search_entry_activate(GtkWidget *widget, gpointer data);
-gboolean nsgtk_search_entry_key(GtkWidget *widget, GdkEventKey *event, gpointer data);
-gboolean nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data);
-gboolean nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data);
-gboolean nsgtk_search_close_button_clicked(GtkWidget *widget, gpointer data);
+struct gtk_search {
+ GtkToolbar *bar;
+ GtkEntry *entry;
+ GtkToolButton *back;
+ GtkToolButton *forward;
+ GtkToolButton *close;
+ GtkCheckButton *checkAll;
+ GtkCheckButton *caseSens;
+
+ struct gui_window *gw;
+};
+
+/**
+ * create text search context
+ *
+ * \param builder the gtk builder containing the search toolbar
+ * \param search_out search context result
+ * \return NSERROR_OK and search_out updated
+ */
+nserror nsgtk_search_create(GtkBuilder *builder, struct gtk_search **search_out, struct gui_window *gw);
+
+/**
+ * update search toolbar size and style
+ */
+nserror nsgtk_search_restyle(struct gtk_search *search);
+
+/**
+ * toggle search bar visibility
+ */
+nserror nsgtk_search_toggle_visibility(struct gtk_search *search);
-
#endif
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 8d6c092..0d868a0 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2009 Mark Benjamin <netsurf-browser.org.MarkBenjamin(a)dfgh.net>
+ * Copyright 2019 Vincent Sanders <vince(a)netsurf-browser.org>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -18,7 +18,7 @@
/**
* \file
- * implementatio of toolbar to control browsing context
+ * implementation of toolbar to control browsing context
*/
#include <stdlib.h>
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 647f15f..a8badc4 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -62,6 +62,7 @@
#include "gtk/bitmap.h"
#include "gtk/gdk.h"
#include "gtk/resources.h"
+#include "gtk/search.h"
#include "gtk/window.h"
static GtkWidget *select_menu;
@@ -99,6 +100,9 @@ struct gui_window {
/** controls toolbar context */
struct nsgtk_toolbar *toolbar;
+ /** search toolbar context */
+ struct gtk_search *search;
+
/** The top level container (tabBox) */
GtkWidget *container;
@@ -779,6 +783,7 @@ gui_window_create(struct browser_window *bw,
g->input_method = gtk_im_multicontext_new();
+ /* create toolbar */
res = nsgtk_toolbar_create(tab_builder, bw_from_gw, g, &g->toolbar);
if (res != NSERROR_OK) {
free(g);
@@ -786,6 +791,13 @@ gui_window_create(struct browser_window *bw,
return NULL;
}
+ /* local page text search toolbar */
+ res = nsgtk_search_create(tab_builder, &g->search, g);
+ if (res != NSERROR_OK) {
+ free(g);
+ g_object_unref(tab_builder);
+ return NULL;
+ }
/* set a default favicon */
g_object_ref(favicon_pixbuf);
@@ -1468,6 +1480,13 @@ 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;
@@ -1490,6 +1509,14 @@ GtkLayout *nsgtk_window_get_layout(struct gui_window *g)
/* exported interface documented in window.h */
nserror
+nsgtk_window_search_toggle(struct gui_window *gw)
+{
+ return nsgtk_search_toggle_visibility(gw->search);
+}
+
+
+/* exported interface documented in window.h */
+nserror
nsgtk_window_item_activate(struct gui_window *gw, nsgtk_toolbar_button itemid)
{
return nsgtk_toolbar_item_activate(gw->toolbar, itemid);
@@ -1511,7 +1538,7 @@ nserror nsgtk_window_update_all(void)
for (gw = window_list; gw != NULL; gw = gw->next) {
nsgtk_tab_options_changed(nsgtk_scaffolding_notebook(gw->scaffold));
nsgtk_toolbar_restyle(gw->toolbar);
- /** \todo update search bar */
+ nsgtk_search_restyle(gw->search);
browser_window_schedule_reformat(gw->bw);
}
return NSERROR_OK;
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index 9d8d16e..69b1cdc 100644
--- a/frontends/gtk/window.h
+++ b/frontends/gtk/window.h
@@ -85,6 +85,14 @@ void nsgtk_window_destroy_browser(struct gui_window *gw);
*/
unsigned long nsgtk_window_get_signalhandler(struct gui_window *gw, int i);
+
+/**
+ * toggle search visibility
+ *
+ * \param gw gui window handle
+ */
+nserror nsgtk_window_search_toggle(struct gui_window *gw);
+
/**
* get gtk layout from gui handle
*
@@ -94,6 +102,11 @@ 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
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9bbc7eb9cbde19ff594...
commit 9bbc7eb9cbde19ff594ce5901fdf7bf1faac2874
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
ensure pixbuf references are updated correctly to avoid leaks
diff --git a/frontends/gtk/compat.c b/frontends/gtk/compat.c
index a8321d6..bd3f46e 100644
--- a/frontends/gtk/compat.c
+++ b/frontends/gtk/compat.c
@@ -635,7 +635,9 @@ void nsgtk_widget_set_margins(GtkWidget *widget, gint hmargin, gint vmargin)
gtk_widget_set_margin_top(widget, vmargin);
gtk_widget_set_margin_bottom(widget, vmargin);
#else
- gtk_misc_set_padding(GTK_MISC(widget), hmargin, vmargin);
+ if (GTK_IS_MISC(widget)) {
+ gtk_misc_set_padding(GTK_MISC(widget), hmargin, vmargin);
+ }
#endif
}
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index 205c548..a87ef72 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -258,10 +258,10 @@ static nserror set_defaults(struct nsoption_s *defaults)
*/
static nserror nsgtk_add_named_icons_to_theme(void)
{
- #if GTK_CHECK_VERSION(3,14,0)
+#if GTK_CHECK_VERSION(3,14,0)
gtk_icon_theme_add_resource_path(gtk_icon_theme_get_default(),
"/org/netsurf/icons");
- #else
+#else
GdkPixbuf *pixbuf;
nserror res;
diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c
index 04e90b9..6f4b22b 100644
--- a/frontends/gtk/tabs.c
+++ b/frontends/gtk/tabs.c
@@ -424,8 +424,10 @@ 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 f7a18e7..8d6c092 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -333,8 +333,7 @@ make_toolbar_item_websearch(bool sensitivity)
res = search_web_get_provider_bitmap(&bitmap);
if ((res == NSERROR_OK) && (bitmap != NULL)) {
- pixbuf = nsgdk_pixbuf_get_from_surface(bitmap->surface,
- 16, 16);
+ pixbuf = nsgdk_pixbuf_get_from_surface(bitmap->surface, 32, 32);
}
entry = nsgtk_entry_new();
@@ -347,6 +346,7 @@ make_toolbar_item_websearch(bool sensitivity)
nsgtk_entry_set_icon_from_pixbuf(entry,
GTK_ENTRY_ICON_PRIMARY,
pixbuf);
+ g_object_unref(pixbuf);
} else {
nsgtk_entry_set_icon_from_icon_name(entry,
GTK_ENTRY_ICON_PRIMARY,
@@ -1284,7 +1284,6 @@ toolbar_customisation_create_toolbox(struct nsgtk_toolbar_customisation *tbc,
static nserror
customisation_toolbar_update(struct nsgtk_toolbar_customisation *tbc)
{
- GtkEntry *entry;
nserror res;
res = apply_user_button_customisation(&tbc->toolbar);
@@ -1312,18 +1311,6 @@ customisation_toolbar_update(struct nsgtk_toolbar_customisation *tbc)
return res;
}
- if (tbc->toolbar.items[URL_BAR_ITEM].location != INACTIVE_LOCATION) {
- entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tbc->toolbar.items[URL_BAR_ITEM].button)));
-
- gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
- }
-
- if (tbc->toolbar.items[WEBSEARCH_ITEM].location != INACTIVE_LOCATION) {
- entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tbc->toolbar.items[WEBSEARCH_ITEM].button)));
-
- gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
- }
-
return NSERROR_OK;
}
@@ -1365,6 +1352,22 @@ customisation_reset_clicked_cb(GtkWidget *widget, gpointer data)
}
+/**
+ * customisation container delete handler
+ */
+static gboolean
+customisation_container_delete_cb(GtkWidget *widget,
+ GdkEvent *event,
+ gpointer data)
+{
+ struct nsgtk_toolbar_customisation *tbc;
+ tbc = (struct nsgtk_toolbar_customisation *)data;
+
+ free(tbc);
+
+ return FALSE;
+}
+
/*
* Toolbar button clicked handlers
*/
@@ -1482,16 +1485,13 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
G_CALLBACK(customisation_reset_clicked_cb),
tbc);
- /* close and cleanup on destroy signal */
-#if 0
-
+ /* close and cleanup on delete signal */
g_signal_connect(tbc->container,
"delete-event",
- G_CALLBACK(nsgtk_toolbar_delete),
- g);
+ G_CALLBACK(customisation_container_delete_cb),
+ tbc);
-#endif
g_signal_connect(tbc->container,
"drag-drop",
G_CALLBACK(customisation_container_drag_drop_cb),
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 9368d70..647f15f 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -1408,13 +1408,17 @@ gui_search_web_provider_update(const char *name, struct bitmap *bitmap)
GdkPixbuf *pixbuf = NULL;
if (bitmap != NULL) {
- pixbuf = nsgdk_pixbuf_get_from_surface(bitmap->surface, 16, 16);
+ pixbuf = nsgdk_pixbuf_get_from_surface(bitmap->surface, 32, 32);
}
for (gw = window_list; gw != NULL; gw = gw->next) {
nsgtk_toolbar_set_websearch_image(gw->toolbar, pixbuf);
}
+ if (pixbuf != NULL) {
+ g_object_unref(pixbuf);
+ }
+
return NSERROR_OK;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=541acda906e6d725468...
commit 541acda906e6d725468aa31bcc95f43d1cca23d4
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
add cookie icon and use it for show cookies toolbar button
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index 9b42ef9..205c548 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -270,7 +270,14 @@ static nserror nsgtk_add_named_icons_to_theme(void)
pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 8, 32);
}
gtk_icon_theme_add_builtin_icon("local-history", 32, pixbuf);
- #endif
+
+ res = nsgdk_pixbuf_new_from_resname("icons/show-cookie.png", &pixbuf);
+ if (res != NSERROR_OK) {
+ pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 24, 24);
+ }
+ gtk_icon_theme_add_builtin_icon("show-cookie", 24, pixbuf);
+
+#endif
return NSERROR_OK;
}
diff --git a/frontends/gtk/res/netsurf.gresource.xml b/frontends/gtk/res/netsurf.gresource.xml
index b475dc5..d9aa921 100644
--- a/frontends/gtk/res/netsurf.gresource.xml
+++ b/frontends/gtk/res/netsurf.gresource.xml
@@ -57,6 +57,7 @@
<file>quirks.css</file>
<file>netsurf.png</file>
<file>default.ico</file>
+ <file>icons/show-cookie.png</file>
<file>icons/local-history.png</file>
<file>icons/arrow-l.png</file>
<file>icons/content.png</file>
diff --git a/frontends/gtk/resources.c b/frontends/gtk/resources.c
index 9fd7116..f48ddb4 100644
--- a/frontends/gtk/resources.c
+++ b/frontends/gtk/resources.c
@@ -96,6 +96,7 @@ static struct nsgtk_resource_s pixbuf_resource[] = {
RES_ENTRY("netsurf.xpm"),
RES_ENTRY("menu_cursor.png"),
RES_ENTRY("icons/local-history.png"),
+ RES_ENTRY("icons/show-cookie.png"),
RES_ENTRY("throbber/throbber0.png"),
RES_ENTRY("throbber/throbber1.png"),
RES_ENTRY("throbber/throbber2.png"),
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 7a35112..344c097 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -139,7 +139,7 @@ TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true, y, p, , NULL)
TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, y, p, gtkGlobalHistory, NULL)
TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, y, p, gtkAddBookMarks, NULL)
TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true, b, p, gtkShowBookMarks, "user-bookmarks")
-TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, y, p, gtkShowCookies, NULL)
+TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, b, p, gtkShowCookies, "show-cookie")
TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true, y, p, gtkOpenLocation, NULL)
TOOLBAR_ITEM(NEXTTAB_BUTTON, nexttab, false, n, y, gtkNextTab, "media-skip-forward")
TOOLBAR_ITEM(PREVTAB_BUTTON, prevtab, false, n, y, gtkPrevTab, "media-skip-backward")
diff --git a/resources/icons/show-cookie.png b/resources/icons/show-cookie.png
new file mode 100644
index 0000000..8e44972
Binary files /dev/null and b/resources/icons/show-cookie.png differ
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=11aa682154af6e0d4c7...
commit 11aa682154af6e0d4c7920bb2983df5a6ded126f
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
construct all toolbar items from data table
This changes toolbar item constuction to use toolbar_items.h
instead of explicit macros.
Additionally all remenants of old stock item themeing are done
away with and GTK icon names are used instead.
diff --git a/frontends/gtk/compat.c b/frontends/gtk/compat.c
index a75fdaf..a8321d6 100644
--- a/frontends/gtk/compat.c
+++ b/frontends/gtk/compat.c
@@ -170,18 +170,18 @@ void nsgtk_entry_set_icon_from_pixbuf(GtkWidget *entry,
/* exported interface documented in gtk/compat.h */
-void nsgtk_entry_set_icon_from_stock(GtkWidget *entry,
- GtkEntryIconPosition icon_pos,
- const gchar *id)
+void nsgtk_entry_set_icon_from_icon_name(GtkWidget *entry,
+ GtkEntryIconPosition icon_pos,
+ const gchar *id)
{
#ifdef NSGTK_USE_ICON_NAME
gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), icon_pos, id);
#else
#if GTK_CHECK_VERSION(2,16,0)
- gtk_entry_set_icon_from_stock(GTK_ENTRY(entry), icon_pos, id);
+ gtk_entry_set_icon_from_icon_name(GTK_ENTRY(entry), icon_pos, id);
#else
- GtkImage *image = GTK_IMAGE(gtk_image_new_from_stock(id,
- GTK_ICON_SIZE_LARGE_TOOLBAR));
+ GtkImage *image;
+ image = GTK_IMAGE(gtk_image_new_from_stock(id, GTK_ICON_SIZE_LARGE_TOOLBAR));
if (image != NULL) {
sexy_icon_entry_set_icon(SEXY_ICON_ENTRY(entry),
diff --git a/frontends/gtk/compat.h b/frontends/gtk/compat.h
index feb0abe..8ef2ed5 100644
--- a/frontends/gtk/compat.h
+++ b/frontends/gtk/compat.h
@@ -178,16 +178,16 @@ enum {
/**
- * Sets the icon shown in the entry at the specified position from a
- * stock image.
+ * Sets the icon shown in the entry at the specified position from an
+ * icon name.
*
- * Compatability interface for original deprecated in GTK 3.10
+ * Compatability interface for original introduced in 2.16
*
* \param entry The entry widget to set the icon on.
* \param icon_pos The position of the icon.
* \param stock_id the name of the stock item.
*/
-void nsgtk_entry_set_icon_from_stock(GtkWidget *entry, GtkEntryIconPosition icon_pos, const gchar *stock_id);
+void nsgtk_entry_set_icon_from_icon_name(GtkWidget *entry, GtkEntryIconPosition icon_pos, const gchar *stock_id);
/**
* Creates a GtkImage displaying a stock icon.
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index d033a57..9b42ef9 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -81,7 +81,6 @@ char *nsgtk_config_home; /* exported global defined in gtk/gui.h */
GdkPixbuf *favicon_pixbuf; /** favicon default pixbuf */
GdkPixbuf *win_default_icon_pixbuf; /** default window icon pixbuf */
-GdkPixbuf *arrow_down_pixbuf; /** arrow down pixbuf */
GtkBuilder *warning_builder;
@@ -254,6 +253,26 @@ static nserror set_defaults(struct nsoption_s *defaults)
}
+/**
+ * adds named icons into gtk theme
+ */
+static nserror nsgtk_add_named_icons_to_theme(void)
+{
+ #if GTK_CHECK_VERSION(3,14,0)
+ gtk_icon_theme_add_resource_path(gtk_icon_theme_get_default(),
+ "/org/netsurf/icons");
+ #else
+ GdkPixbuf *pixbuf;
+ nserror res;
+
+ res = nsgdk_pixbuf_new_from_resname("icons/local-history.png", &pixbuf);
+ if (res != NSERROR_OK) {
+ pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, 8, 32);
+ }
+ gtk_icon_theme_add_builtin_icon("local-history", 32, pixbuf);
+ #endif
+ return NSERROR_OK;
+}
/**
@@ -313,12 +332,11 @@ static nserror nsgtk_init(int argc, char** argv, char **respath)
false, 8, 16, 16);
}
- /* arrow down icon */
- res = nsgdk_pixbuf_new_from_resname("arrow_down_8x32.png",
- &arrow_down_pixbuf);
+ /* add named icons to gtk theme */
+ res = nsgtk_add_named_icons_to_theme();
if (res != NSERROR_OK) {
- arrow_down_pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
- false, 8, 8, 32);
+ NSLOG(netsurf, INFO, "Unable to add named icons to GTK theme.");
+ return res;
}
/* initialise throbber */
diff --git a/frontends/gtk/gui.h b/frontends/gtk/gui.h
index 53e7324..ee82e7a 100644
--- a/frontends/gtk/gui.h
+++ b/frontends/gtk/gui.h
@@ -27,9 +27,6 @@ extern char *nsgtk_config_home;
/** favicon default pixbuf */
extern GdkPixbuf *favicon_pixbuf;
-/** arrow down pixbuf */
-extern GdkPixbuf *arrow_down_pixbuf;
-
/** resource search path vector */
extern char **respaths;
diff --git a/frontends/gtk/res/arrow_down_8x32.png b/frontends/gtk/res/arrow_down_8x32.png
deleted file mode 100644
index 475b4ff..0000000
Binary files a/frontends/gtk/res/arrow_down_8x32.png and /dev/null differ
diff --git a/frontends/gtk/res/netsurf.gresource.xml b/frontends/gtk/res/netsurf.gresource.xml
index c170df2..b475dc5 100644
--- a/frontends/gtk/res/netsurf.gresource.xml
+++ b/frontends/gtk/res/netsurf.gresource.xml
@@ -57,7 +57,7 @@
<file>quirks.css</file>
<file>netsurf.png</file>
<file>default.ico</file>
- <file>arrow_down_8x32.png</file>
+ <file>icons/local-history.png</file>
<file>icons/arrow-l.png</file>
<file>icons/content.png</file>
<file>icons/directory2.png</file>
diff --git a/frontends/gtk/resources.c b/frontends/gtk/resources.c
index 7aea43c..9fd7116 100644
--- a/frontends/gtk/resources.c
+++ b/frontends/gtk/resources.c
@@ -95,7 +95,7 @@ static struct nsgtk_resource_s pixbuf_resource[] = {
RES_ENTRY("favicon.png"),
RES_ENTRY("netsurf.xpm"),
RES_ENTRY("menu_cursor.png"),
- RES_ENTRY("arrow_down_8x32.png"),
+ RES_ENTRY("icons/local-history.png"),
RES_ENTRY("throbber/throbber0.png"),
RES_ENTRY("throbber/throbber1.png"),
RES_ENTRY("throbber/throbber2.png"),
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 6ace032..f0b4f9b 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -53,6 +53,7 @@ struct nsgtk_menu {
GtkWidget *burger; /* right click menu */
GtkWidget *popup; /* popup menu entry */
void *mhandler; /* menu item handler */
+ const char *iconname; /* name of the icon to use */
bool sensitivity; /* menu item is sensitive */
};
@@ -463,7 +464,7 @@ nsgtk_on_##name##_activate_menu(GtkMenuItem *widget, gpointer data) \
}
#define TOOLBAR_ITEM_y(identifier, name)
#define TOOLBAR_ITEM_n(identifier, name)
-#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate) \
+#define TOOLBAR_ITEM(identifier, name, sensitivity, clicked, activate, label, iconame) \
TOOLBAR_ITEM_ ## activate(identifier, name)
#include "gtk/toolbar_items.h"
#undef TOOLBAR_ITEM_y
@@ -888,15 +889,18 @@ create_scaffolding_link_menu(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
*/
static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
{
-#define TOOLBAR_ITEM_p(identifier, name) \
- g->menus[identifier].mhandler = nsgtk_on_##name##_activate_menu;
-#define TOOLBAR_ITEM_y(identifier, name) \
- g->menus[identifier].mhandler = nsgtk_on_##name##_activate_menu;
-#define TOOLBAR_ITEM_n(identifier, name) \
- g->menus[identifier].mhandler = NULL;
-#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate) \
+#define TOOLBAR_ITEM_p(identifier, name, iconame) \
+ g->menus[identifier].mhandler = nsgtk_on_##name##_activate_menu; \
+ g->menus[identifier].iconname = iconame;
+#define TOOLBAR_ITEM_y(identifier, name, iconame) \
+ g->menus[identifier].mhandler = nsgtk_on_##name##_activate_menu; \
+ g->menus[identifier].iconname = iconame;
+#define TOOLBAR_ITEM_n(identifier, name, iconame) \
+ g->menus[identifier].mhandler = NULL; \
+ g->menus[identifier].iconname = iconame;
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, label, iconame) \
g->menus[identifier].sensitivity = snstvty; \
- TOOLBAR_ITEM_ ## activate(identifier, name)
+ TOOLBAR_ITEM_ ## activate(identifier, name, iconame)
#include "gtk/toolbar_items.h"
#undef TOOLBAR_ITEM_y
#undef TOOLBAR_ITEM_n
@@ -1015,6 +1019,34 @@ 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)
+{
+ GtkWidget *img;
+ for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
+ /* ensure there is an icon name */
+ if (g->menus[i].iconname == NULL) {
+ continue;
+ }
+
+ if (g->menus[i].main != NULL) {
+ img = gtk_image_new_from_icon_name(g->menus[i].iconname,
+ GTK_ICON_SIZE_MENU);
+ nsgtk_image_menu_item_set_image(GTK_WIDGET(g->menus[i].main), img);
+ }
+ if (g->menus[i].burger != NULL) {
+ img = gtk_image_new_from_icon_name(g->menus[i].iconname,
+ GTK_ICON_SIZE_MENU);
+ nsgtk_image_menu_item_set_image(GTK_WIDGET(g->menus[i].burger), img);
+ }
+ if (g->menus[i].popup != NULL) {
+ img = gtk_image_new_from_icon_name(g->menus[i].iconname,
+ GTK_ICON_SIZE_MENU);
+ nsgtk_image_menu_item_set_image(GTK_WIDGET(g->menus[i].popup), img);
+ }
+ }
+}
+
/**
* create and initialise menus
*
@@ -1069,6 +1101,7 @@ static nserror nsgtk_menus_create(struct nsgtk_scaffolding *gs)
/* set up the menu signal handlers */
nsgtk_menu_initialise(gs);
+ nsgtk_menu_set_icons(gs);
nsgtk_menu_connect_signals(gs);
nsgtk_menu_set_sensitivity(gs);
@@ -1579,9 +1612,6 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
gs->prev = NULL;
scaf_list = gs;
- /* set icon images */
- nsgtk_theme_implement(gs);
-
/* finally, show the window. */
gtk_widget_show(GTK_WIDGET(gs->window));
diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c
index b9e6dad..04e90b9 100644
--- a/frontends/gtk/tabs.c
+++ b/frontends/gtk/tabs.c
@@ -286,7 +286,7 @@ nsgtk_tab_add_newtab(GtkNotebook *notebook)
tablabel = nsgtk_hbox_new(FALSE, 1);
tabcontents = nsgtk_hbox_new(FALSE, 1);
- add = nsgtk_image_new_from_stock(NSGTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
+ add = gtk_image_new_from_icon_name(NSGTK_STOCK_ADD, GTK_ICON_SIZE_MENU);
gtk_box_pack_start(GTK_BOX(tablabel), add, FALSE, FALSE, 0);
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 85c32e3..f7a18e7 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -82,6 +82,27 @@
#define THROBBER_FRAME_TIME (100)
/**
+ * the minimum number of columns in the tool store
+ */
+#define NSGTK_MIN_STORE_COLUMNS 4
+
+/**
+ * the 'standard' width of a button that makes sufficient of its label visible
+ */
+#define NSGTK_BUTTON_WIDTH 120
+
+/**
+ * the 'standard' height of a button that fits as many toolbars as
+ * possible into the store
+ */
+#define NSGTK_BUTTON_HEIGHT 70
+
+/**
+ * the 'normal' width of the websearch bar
+ */
+#define NSGTK_WEBSEARCH_WIDTH 150
+
+/**
* toolbar item context
*/
struct nsgtk_toolbar_item {
@@ -137,6 +158,7 @@ struct nsgtk_toolbar {
void *get_ctx;
};
+
/**
* toolbar cusomisation context
*/
@@ -176,336 +198,9 @@ struct nsgtk_toolbar_customisation {
static bool edit_mode = false;
-/* the number of items that fit in the width of the store window */
-#define NSGTK_STORE_WIDTH 6
-
-/* the 'standard' width of a button that makes sufficient of its label
-visible */
-#define NSGTK_BUTTON_WIDTH 120
-
-/* the 'standard' height of a button that fits as many toolbars as
-possible into the store */
-#define NSGTK_BUTTON_HEIGHT 70
-
-/* the 'normal' width of the websearch bar */
-#define NSGTK_WEBSEARCH_WIDTH 150
-
-
-enum image_sets {
- IMAGE_SET_MAIN_MENU = 0,
- IMAGE_SET_RCLICK_MENU,
- IMAGE_SET_POPUP_MENU,
- IMAGE_SET_BUTTONS,
- IMAGE_SET_COUNT
-};
-
-typedef enum search_buttons {
- SEARCH_BACK_BUTTON = 0,
- SEARCH_FORWARD_BUTTON,
- SEARCH_CLOSE_BUTTON,
- SEARCH_BUTTONS_COUNT
-} nsgtk_search_buttons;
-
-struct nsgtk_theme {
- GtkImage *image[PLACEHOLDER_BUTTON];
- GtkImage *searchimage[SEARCH_BUTTONS_COUNT];
-};
-
/* forward declaration */
-int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, struct nsgtk_scaffolding *g);
-static nserror toolbar_item_create(nsgtk_toolbar_button id, struct nsgtk_toolbar_item *item_out);
-
-
-/* define data plus and data minus handlers */
-#define TOOLBAR_ITEM(identifier, name, sensitivity, clicked, activate) \
-static gboolean \
-nsgtk_toolbar_##name##_data_plus(GtkWidget *widget, \
- GdkDragContext *cont, \
- GtkSelectionData *selection, \
- guint info, \
- guint time, \
- gpointer data) \
-{ \
- struct nsgtk_toolbar_customisation *tbc; \
- tbc = (struct nsgtk_toolbar_customisation *)data; \
- tbc->dragitem = identifier; \
- tbc->dragfrom = true; \
- return TRUE; \
-} \
-static gboolean \
-nsgtk_toolbar_##name##_data_minus(GtkWidget *widget, \
- GdkDragContext *cont, \
- GtkSelectionData *selection, \
- guint info, \
- guint time, \
- gpointer data) \
-{ \
- struct nsgtk_toolbar_customisation *tbc; \
- tbc = (struct nsgtk_toolbar_customisation *)data; \
- tbc->dragitem = identifier; \
- tbc->dragfrom = false; \
- return TRUE; \
-}
-
-#include "gtk/toolbar_items.h"
-
-#undef TOOLBAR_ITEM
-
-
-
-/**
- * get default image for buttons / menu items from gtk stock items.
- *
- * \param tbbutton button reference
- * \param iconsize The size of icons to select.
- * \param usedef Use the default image if not found.
- * \return default images.
- */
-static GtkImage *
-nsgtk_theme_image_default(nsgtk_toolbar_button tbbutton,
- GtkIconSize iconsize,
- bool usedef)
-{
- GtkImage *image; /* The GTK image to return */
-
- switch(tbbutton) {
-
-#define BUTTON_IMAGE(p, q) \
- case p##_BUTTON: \
- image = GTK_IMAGE(nsgtk_image_new_from_stock(q, iconsize)); \
- break
-
- BUTTON_IMAGE(BACK, NSGTK_STOCK_GO_BACK);
- BUTTON_IMAGE(FORWARD, NSGTK_STOCK_GO_FORWARD);
- BUTTON_IMAGE(STOP, NSGTK_STOCK_STOP);
- BUTTON_IMAGE(RELOAD, NSGTK_STOCK_REFRESH);
- BUTTON_IMAGE(HOME, NSGTK_STOCK_HOME);
- BUTTON_IMAGE(NEWWINDOW, "gtk-new");
- BUTTON_IMAGE(NEWTAB, "gtk-new");
- BUTTON_IMAGE(OPENFILE, NSGTK_STOCK_OPEN);
- BUTTON_IMAGE(CLOSETAB, NSGTK_STOCK_CLOSE);
- BUTTON_IMAGE(CLOSEWINDOW, NSGTK_STOCK_CLOSE);
- BUTTON_IMAGE(SAVEPAGE, NSGTK_STOCK_SAVE_AS);
- BUTTON_IMAGE(PRINTPREVIEW, "gtk-print-preview");
- BUTTON_IMAGE(PRINT, "gtk-print");
- BUTTON_IMAGE(QUIT, "gtk-quit");
- BUTTON_IMAGE(CUT, "gtk-cut");
- BUTTON_IMAGE(COPY, "gtk-copy");
- BUTTON_IMAGE(PASTE, "gtk-paste");
- BUTTON_IMAGE(DELETE, "gtk-delete");
- BUTTON_IMAGE(SELECTALL, "gtk-select-all");
- BUTTON_IMAGE(FIND, NSGTK_STOCK_FIND);
- BUTTON_IMAGE(PREFERENCES, "gtk-preferences");
- BUTTON_IMAGE(ZOOMPLUS, "gtk-zoom-in");
- BUTTON_IMAGE(ZOOMMINUS, "gtk-zoom-out");
- BUTTON_IMAGE(ZOOMNORMAL, "gtk-zoom-100");
- BUTTON_IMAGE(FULLSCREEN, "gtk-fullscreen");
- BUTTON_IMAGE(VIEWSOURCE, "gtk-index");
- BUTTON_IMAGE(CONTENTS, "gtk-help");
- BUTTON_IMAGE(ABOUT, "gtk-about");
- BUTTON_IMAGE(OPENMENU, NSGTK_STOCK_OPEN_MENU);
-#undef BUTTON_IMAGE
-
- case HISTORY_BUTTON:
- image = GTK_IMAGE(gtk_image_new_from_pixbuf(arrow_down_pixbuf));
- break;
-
- default:
- image = NULL;
- break;
-
- }
-
- if (usedef && (image == NULL)) {
- image = GTK_IMAGE(nsgtk_image_new_from_stock("gtk-missing-image", iconsize));
- }
-
- return image;
-}
-
-
-/**
- * Get default image for search buttons / menu items from gtk stock items
- *
- * \param tbbutton search button reference
- * \param iconsize The size of icons to select.
- * \param usedef Use the default image if not found.
- * \return default search image.
- */
-static GtkImage *
-nsgtk_theme_searchimage_default(nsgtk_search_buttons tbbutton,
- GtkIconSize iconsize,
- bool usedef)
-{
- GtkImage *image;
-
- switch (tbbutton) {
-
- case (SEARCH_BACK_BUTTON):
- image = GTK_IMAGE(nsgtk_image_new_from_stock(
- NSGTK_STOCK_GO_BACK, iconsize));
- break;
-
- case (SEARCH_FORWARD_BUTTON):
- image = GTK_IMAGE(nsgtk_image_new_from_stock(
- NSGTK_STOCK_GO_FORWARD, iconsize));
- break;
-
- case (SEARCH_CLOSE_BUTTON):
- image = GTK_IMAGE(nsgtk_image_new_from_stock(
- NSGTK_STOCK_CLOSE, iconsize));
- break;
-
- default:
- image = NULL;
- }
-
- if (usedef && (image == NULL)) {
- image = GTK_IMAGE(nsgtk_image_new_from_stock(
- "gtk-missing-image", iconsize));
- }
-
- return image;
-}
-
-/**
- * initialise a theme structure with gtk images
- *
- * \param iconsize The size of icon to load
- * \param usedef use the default gtk icon if unset
- */
-static struct nsgtk_theme *nsgtk_theme_load(GtkIconSize iconsize, bool usedef)
-{
- struct nsgtk_theme *theme;
- int btnloop;
-
- theme = malloc(sizeof(struct nsgtk_theme));
- if (theme == NULL) {
- return NULL;
- }
-
- for (btnloop = BACK_BUTTON;
- btnloop < PLACEHOLDER_BUTTON ;
- btnloop++) {
- theme->image[btnloop] = nsgtk_theme_image_default(btnloop,
- iconsize,
- usedef);
- }
-
- for (btnloop = SEARCH_BACK_BUTTON;
- btnloop < SEARCH_BUTTONS_COUNT;
- btnloop++) {
- theme->searchimage[btnloop] =
- nsgtk_theme_searchimage_default(btnloop,
- iconsize,
- usedef);
- }
- return theme;
-}
-
-static struct nsgtk_toolbar_item *
-nsgtk_scaffolding_button(struct nsgtk_scaffolding *g, int i)
-{
- return NULL;
-}
-
-/* exported function documented in gtk/toolbar.h */
-void nsgtk_theme_implement(struct nsgtk_scaffolding *g)
-{
- struct nsgtk_theme *theme[IMAGE_SET_COUNT];
- int i;
- struct nsgtk_toolbar_item *button;
- struct gtk_search *search;
-
- theme[IMAGE_SET_MAIN_MENU] = nsgtk_theme_load(GTK_ICON_SIZE_MENU, false);
- theme[IMAGE_SET_RCLICK_MENU] = nsgtk_theme_load(GTK_ICON_SIZE_MENU, false);
- theme[IMAGE_SET_POPUP_MENU] = nsgtk_theme_load(GTK_ICON_SIZE_MENU, false);
- theme[IMAGE_SET_BUTTONS] = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR, false);
-
- for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- if ((i == URL_BAR_ITEM) || (i == THROBBER_ITEM) ||
- (i == WEBSEARCH_ITEM))
- continue;
-
- button = nsgtk_scaffolding_button(g, i);
- if (button == NULL)
- continue;
-
- #if 0
- /* gtk_image_menu_item_set_image accepts NULL image */
- if ((button->main != NULL) &&
- (theme[IMAGE_SET_MAIN_MENU] != NULL)) {
- nsgtk_image_menu_item_set_image(
- GTK_WIDGET(button->main),
- GTK_WIDGET(theme[IMAGE_SET_MAIN_MENU]->image[i]));
- gtk_widget_show_all(GTK_WIDGET(button->main));
- }
- if ((button->rclick != NULL) &&
- (theme[IMAGE_SET_RCLICK_MENU] != NULL)) {
- nsgtk_image_menu_item_set_image(GTK_WIDGET(button->rclick),
- GTK_WIDGET(
- theme[IMAGE_SET_RCLICK_MENU]->
- image[i]));
- gtk_widget_show_all(GTK_WIDGET(button->rclick));
- }
- if ((button->popup != NULL) &&
- (theme[IMAGE_SET_POPUP_MENU] != NULL)) {
- nsgtk_image_menu_item_set_image(GTK_WIDGET(button->popup),
- GTK_WIDGET(
- theme[IMAGE_SET_POPUP_MENU]->
- image[i]));
- gtk_widget_show_all(GTK_WIDGET(button->popup));
- }
- #endif
- if ((button->location != -1) &&
- (button->button != NULL) &&
- (theme[IMAGE_SET_BUTTONS] != NULL)) {
- gtk_tool_button_set_icon_widget(
- GTK_TOOL_BUTTON(button->button),
- GTK_WIDGET(
- theme[IMAGE_SET_BUTTONS]->
- image[i]));
- gtk_widget_show_all(GTK_WIDGET(button->button));
- }
- }
-
- /* set search bar images */
- search = nsgtk_scaffolding_search(g);
- if ((search != NULL) && (theme[IMAGE_SET_MAIN_MENU] != NULL)) {
- /* gtk_tool_button_set_icon_widget accepts NULL image */
- if (search->buttons[SEARCH_BACK_BUTTON] != NULL) {
- gtk_tool_button_set_icon_widget(
- search->buttons[SEARCH_BACK_BUTTON],
- GTK_WIDGET(theme[IMAGE_SET_MAIN_MENU]->
- searchimage[SEARCH_BACK_BUTTON]));
- gtk_widget_show_all(GTK_WIDGET(
- search->buttons[SEARCH_BACK_BUTTON]));
- }
- if (search->buttons[SEARCH_FORWARD_BUTTON] != NULL) {
- gtk_tool_button_set_icon_widget(
- search->buttons[SEARCH_FORWARD_BUTTON],
- GTK_WIDGET(theme[IMAGE_SET_MAIN_MENU]->
- searchimage[SEARCH_FORWARD_BUTTON]));
- gtk_widget_show_all(GTK_WIDGET(
- search->buttons[
- SEARCH_FORWARD_BUTTON]));
- }
- if (search->buttons[SEARCH_CLOSE_BUTTON] != NULL) {
- gtk_tool_button_set_icon_widget(
- search->buttons[SEARCH_CLOSE_BUTTON],
- GTK_WIDGET(theme[IMAGE_SET_MAIN_MENU]->
- searchimage[SEARCH_CLOSE_BUTTON]));
- gtk_widget_show_all(GTK_WIDGET(
- search->buttons[SEARCH_CLOSE_BUTTON]));
- }
- }
-
- for (i = 0; i < IMAGE_SET_COUNT; i++) {
- if (theme[i] != NULL) {
- free(theme[i]);
- }
- }
-}
+static nserror toolbar_item_create(nsgtk_toolbar_button id,
+ struct nsgtk_toolbar_item *item_out);
/**
@@ -555,9 +250,11 @@ make_toolbar_item_throbber(bool sensitivity)
}
if (edit_mode) {
+ const char *msg;
+ msg = messages_get("ToolThrob");
item = gtk_tool_button_new(
GTK_WIDGET(gtk_image_new_from_pixbuf(pixbuf)),
- "[throbber]");
+ msg);
} else {
item = gtk_tool_item_new();
@@ -576,6 +273,7 @@ make_toolbar_item_throbber(bool sensitivity)
return item;
}
+
/**
* create url bar toolbar item widget
*
@@ -588,24 +286,34 @@ make_toolbar_item_url_bar(bool sensitivity)
GtkWidget *entry;
GtkEntryCompletion *completion;
- item = gtk_tool_item_new();
entry = nsgtk_entry_new();
- completion = gtk_entry_completion_new();
- if ((entry == NULL) || (completion == NULL) || (item == NULL)) {
+ if (entry == NULL) {
return NULL;
}
- gtk_widget_set_sensitive(GTK_WIDGET(item), sensitivity);
-
- gtk_container_add(GTK_CONTAINER(item), entry);
- gtk_tool_item_set_expand(item, TRUE);
-
if (edit_mode) {
- gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
+ gtk_entry_set_width_chars(GTK_ENTRY(entry), 9);
+
+ item = gtk_tool_button_new(NULL, "URL");
+ gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item), entry);
} else {
- gtk_entry_set_completion(GTK_ENTRY(entry), completion);
+ completion = gtk_entry_completion_new();
+ if (completion != NULL) {
+ gtk_entry_set_completion(GTK_ENTRY(entry), completion);
+ }
+
+ item = gtk_tool_item_new();
+ if (item == NULL) {
+ return NULL;
+ }
+
+ gtk_container_add(GTK_CONTAINER(item), entry);
+ gtk_tool_item_set_expand(item, TRUE);
+
}
+ gtk_widget_set_sensitive(GTK_WIDGET(item), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(entry), sensitivity);
return item;
}
@@ -623,37 +331,104 @@ make_toolbar_item_websearch(bool sensitivity)
struct bitmap *bitmap;
GdkPixbuf *pixbuf = NULL;
- entry = nsgtk_entry_new();
- item = gtk_tool_item_new();
-
- if ((entry == NULL) || (item == NULL)) {
- return NULL;
- }
-
- gtk_widget_set_sensitive(GTK_WIDGET(item), sensitivity);
-
- gtk_widget_set_size_request(entry, NSGTK_WEBSEARCH_WIDTH, -1);
-
res = search_web_get_provider_bitmap(&bitmap);
if ((res == NSERROR_OK) && (bitmap != NULL)) {
pixbuf = nsgdk_pixbuf_get_from_surface(bitmap->surface,
16, 16);
}
+ entry = nsgtk_entry_new();
+
+ if (entry == NULL) {
+ return NULL;
+ }
+
if (pixbuf != NULL) {
nsgtk_entry_set_icon_from_pixbuf(entry,
GTK_ENTRY_ICON_PRIMARY,
pixbuf);
} else {
- nsgtk_entry_set_icon_from_stock(entry,
- GTK_ENTRY_ICON_PRIMARY,
- NSGTK_STOCK_INFO);
+ nsgtk_entry_set_icon_from_icon_name(entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ NSGTK_STOCK_INFO);
}
- gtk_container_add(GTK_CONTAINER(item), entry);
+ if (edit_mode) {
+ gtk_entry_set_width_chars(GTK_ENTRY(entry), 9);
+
+ item = gtk_tool_button_new(NULL, "Web Search");
+ gtk_tool_button_set_icon_widget(GTK_TOOL_BUTTON(item),
+ entry);
+ } else {
+ gtk_widget_set_size_request(entry, NSGTK_WEBSEARCH_WIDTH, -1);
+
+ item = gtk_tool_item_new();
+ if (item == NULL) {
+ return NULL;
+ }
+
+ gtk_container_add(GTK_CONTAINER(item), entry);
+ }
+ gtk_widget_set_sensitive(GTK_WIDGET(item), TRUE);
+ gtk_widget_set_sensitive(GTK_WIDGET(entry), sensitivity);
+
+ return item;
+}
+
+
+/**
+ * create local history toolbar item widget
+ */
+static GtkToolItem *
+make_toolbar_item_history(bool sensitivity)
+{
+ GtkToolItem *item;
+ const char *msg = "H";
+ char *label = NULL;
if (edit_mode) {
- gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
+ msg = messages_get("gtkLocalHistory");
+ }
+ label = remove_underscores(msg, false);
+ item = gtk_tool_button_new(NULL, label);
+ if (label != NULL) {
+ free(label);
+ }
+ gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(item), "local-history");
+
+ /* set history widget minimum width */
+ gtk_widget_set_size_request(GTK_WIDGET(item), 20, -1);
+ gtk_widget_set_sensitive(GTK_WIDGET(item), sensitivity);
+
+ return item;
+}
+
+
+/**
+ * create generic button toolbar item widget
+ */
+static GtkToolItem *
+make_toolbar_item_button(const char *labelmsg,
+ const char *iconname,
+ bool sensitivity)
+{
+ GtkToolItem *item;
+ char *label = NULL;
+
+ label = remove_underscores(messages_get(labelmsg), false);
+
+ item = gtk_tool_button_new(NULL, label);
+ if (label != NULL) {
+ free(label);
+ }
+
+ if (item != NULL) {
+ gtk_tool_button_set_icon_name(GTK_TOOL_BUTTON(item), iconname);
+
+ gtk_widget_set_sensitive(GTK_WIDGET(item), sensitivity);
+ if (edit_mode) {
+ nsgtk_widget_set_margins(GTK_WIDGET(item), 0, 0);
+ }
}
return item;
@@ -669,104 +444,48 @@ make_toolbar_item_websearch(bool sensitivity)
*/
static GtkToolItem *
make_toolbar_item(nsgtk_toolbar_button itemid,
- struct nsgtk_theme *theme,
bool sensitivity)
{
- GtkToolItem *w = NULL;
+ GtkToolItem *toolitem = NULL;
switch(itemid) {
+#define TOOLBAR_ITEM_y(identifier, label, iconame)
+#define TOOLBAR_ITEM_n(identifier, label, iconame)
+#define TOOLBAR_ITEM_b(identifier, label, iconame) \
+ case identifier: \
+ toolitem = make_toolbar_item_button(#label, iconame, sensitivity);\
+ break;
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, label, iconame) \
+ TOOLBAR_ITEM_ ## clicked(identifier, label, iconame)
-/* gtk_tool_button_new accepts NULL args */
-#define MAKE_ITEM(p, q) \
- case p##_BUTTON: { \
- char *label = NULL; \
- label = remove_underscores(messages_get(#q), false); \
- w = gtk_tool_button_new(GTK_WIDGET(theme->image[p##_BUTTON]), \
- label); \
- gtk_widget_set_sensitive(GTK_WIDGET(w), sensitivity); \
- if (label != NULL) { \
- free(label); \
- } \
- break; \
- }
-
- MAKE_ITEM(HOME, gtkHome)
- MAKE_ITEM(BACK, gtkBack)
- MAKE_ITEM(FORWARD, gtkForward)
- MAKE_ITEM(STOP, Stop)
- MAKE_ITEM(RELOAD, Reload)
- MAKE_ITEM(NEWWINDOW, gtkNewWindow)
- MAKE_ITEM(NEWTAB, gtkNewTab)
- MAKE_ITEM(OPENFILE, gtkOpenFile)
- MAKE_ITEM(CLOSETAB, gtkCloseTab)
- MAKE_ITEM(CLOSEWINDOW, gtkCloseWindow)
- MAKE_ITEM(SAVEPAGE, gtkSavePage)
- MAKE_ITEM(PRINTPREVIEW, gtkPrintPreview)
- MAKE_ITEM(PRINT, gtkPrint)
- MAKE_ITEM(QUIT, gtkQuitMenu)
- MAKE_ITEM(CUT, gtkCut)
- MAKE_ITEM(COPY, gtkCopy)
- MAKE_ITEM(PASTE, gtkPaste)
- MAKE_ITEM(DELETE, gtkDelete)
- MAKE_ITEM(SELECTALL, gtkSelectAll)
- MAKE_ITEM(PREFERENCES, gtkPreferences)
- MAKE_ITEM(ZOOMPLUS, gtkZoomPlus)
- MAKE_ITEM(ZOOMMINUS, gtkZoomMinus)
- MAKE_ITEM(ZOOMNORMAL, gtkZoomNormal)
- MAKE_ITEM(FULLSCREEN, gtkFullScreen)
- MAKE_ITEM(VIEWSOURCE, gtkViewSource)
- MAKE_ITEM(CONTENTS, gtkContents)
- MAKE_ITEM(ABOUT, gtkAbout)
- MAKE_ITEM(PDF, gtkPDF)
- MAKE_ITEM(PLAINTEXT, gtkPlainText)
- MAKE_ITEM(DRAWFILE, gtkDrawFile)
- MAKE_ITEM(POSTSCRIPT, gtkPostScript)
- MAKE_ITEM(FIND, gtkFind)
- MAKE_ITEM(DOWNLOADS, gtkDownloads)
- MAKE_ITEM(SAVEWINDOWSIZE, gtkSaveWindowSize)
- MAKE_ITEM(TOGGLEDEBUGGING, gtkToggleDebugging)
- MAKE_ITEM(SAVEBOXTREE, gtkDebugBoxTree)
- MAKE_ITEM(SAVEDOMTREE, gtkDebugDomTree)
- MAKE_ITEM(LOCALHISTORY, gtkLocalHistory)
- MAKE_ITEM(GLOBALHISTORY, gtkGlobalHistory)
- MAKE_ITEM(ADDBOOKMARKS, gtkAddBookMarks)
- MAKE_ITEM(SHOWBOOKMARKS, gtkShowBookMarks)
- MAKE_ITEM(SHOWCOOKIES, gtkShowCookies)
- MAKE_ITEM(OPENLOCATION, gtkOpenLocation)
- MAKE_ITEM(NEXTTAB, gtkNextTab)
- MAKE_ITEM(PREVTAB, gtkPrevTab)
- MAKE_ITEM(GUIDE, gtkGuide)
- MAKE_ITEM(INFO, gtkUserInformation)
- MAKE_ITEM(OPENMENU, gtkOpenMenu)
-
-#undef MAKE_ITEM
+#include "gtk/toolbar_items.h"
+
+#undef TOOLBAR_ITEM_b
+#undef TOOLBAR_ITEM_n
+#undef TOOLBAR_ITEM_y
+#undef TOOLBAR_ITEM
case HISTORY_BUTTON:
- w = gtk_tool_button_new(GTK_WIDGET(
- theme->image[HISTORY_BUTTON]), "H");
- /* set history widget minimum width */
- gtk_widget_set_size_request(GTK_WIDGET(w), 20, -1);
- gtk_widget_set_sensitive(GTK_WIDGET(w), sensitivity);
+ toolitem = make_toolbar_item_history(sensitivity);
break;
case URL_BAR_ITEM:
- w = make_toolbar_item_url_bar(sensitivity);
+ toolitem = make_toolbar_item_url_bar(sensitivity);
break;
case THROBBER_ITEM:
- w = make_toolbar_item_throbber(sensitivity);
+ toolitem = make_toolbar_item_throbber(sensitivity);
break;
case WEBSEARCH_ITEM:
- w = make_toolbar_item_websearch(sensitivity);
+ toolitem = make_toolbar_item_websearch(sensitivity);
break;
default:
break;
}
-
- return w;
+ return toolitem;
}
/**
@@ -957,7 +676,6 @@ customisation_toolbar_drag_drop_cb(GtkWidget *widget,
struct nsgtk_toolbar_customisation *tbc;
tbc = (struct nsgtk_toolbar_customisation *)data;
gint position; /* drop position in toolbar */
- struct nsgtk_theme *theme;
int location;
int itemid;
struct nsgtk_toolbar_item *dragitem; /* toolbar item being dragged */
@@ -993,18 +711,12 @@ customisation_toolbar_drag_drop_cb(GtkWidget *widget,
GTK_WIDGET(dragitem->button));
}
- /* add dropped item into toolbar */
- theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR, false);
- if (theme == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- return TRUE;
- }
edit_mode = true;
- dragitem->button = make_toolbar_item(tbc->dragitem, theme, true);
+ dragitem->button = make_toolbar_item(tbc->dragitem,
+ tbc->toolbar.items[tbc->dragitem].sensitivity);
edit_mode = false;
- free(theme);
if (dragitem->button == NULL) {
nsgtk_warning("NoMemory", 0);
return TRUE;
@@ -1134,23 +846,6 @@ nsgtk_browser_window_create(struct browser_window *bw, bool intab)
}
-/**
- * \return toolbar item id when a widget is an element of the scaffolding
- * else -1
- */
-int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget,
- struct nsgtk_scaffolding *g)
-{
- int i;
- for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- if ((nsgtk_scaffolding_button(g, i)->location != -1)
- && (widget == GTK_WIDGET(
- nsgtk_scaffolding_button(g, i)->button))) {
- return i;
- }
- }
- return -1;
-}
/**
@@ -1228,9 +923,7 @@ apply_user_button_customisation(struct nsgtk_toolbar *tb)
* \return NSERROR_OK on success else error code.
*/
static nserror
-add_item_to_toolbar(struct nsgtk_toolbar *tb,
- struct nsgtk_theme *theme,
- int location)
+add_item_to_toolbar(struct nsgtk_toolbar *tb, int location)
{
int bidx; /* button index */
@@ -1239,7 +932,7 @@ add_item_to_toolbar(struct nsgtk_toolbar *tb,
if (tb->items[bidx].location == location) {
tb->items[bidx].button = make_toolbar_item(
- bidx, theme, tb->items[bidx].sensitivity);
+ bidx, tb->items[bidx].sensitivity);
gtk_toolbar_insert(tb->widget,
tb->items[bidx].button,
@@ -1266,14 +959,8 @@ static void container_remove_widget(GtkWidget *widget, gpointer data)
*/
static nserror populate_gtk_toolbar_widget(struct nsgtk_toolbar *tb)
{
- struct nsgtk_theme *theme; /* internal theme context */
int lidx; /* location index */
- theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR, false);
- if (theme == NULL) {
- return NSERROR_NOMEM;
- }
-
/* clear the toolbar container of all widgets */
gtk_container_foreach(GTK_CONTAINER(tb->widget),
container_remove_widget,
@@ -1281,11 +968,10 @@ static nserror populate_gtk_toolbar_widget(struct nsgtk_toolbar *tb)
/* add widgets to toolbar */
for (lidx = 0; lidx < PLACEHOLDER_BUTTON; lidx++) {
- add_item_to_toolbar(tb, theme, lidx);
+ add_item_to_toolbar(tb, lidx);
}
gtk_widget_show_all(GTK_WIDGET(tb->widget));
- free(theme);
return NSERROR_OK;
}
@@ -1490,7 +1176,6 @@ item_size_allocate_cb(GtkWidget *widget,
if (alloc->height > NSGTK_BUTTON_HEIGHT) {
alloc->height = NSGTK_BUTTON_HEIGHT;
}
- //NSLOG(netsurf, ERROR, "w:%d h:%d", alloc->width, alloc->height);
gtk_widget_set_allocation(widget, alloc);
}
@@ -1542,7 +1227,7 @@ add_toolbox_row(struct nsgtk_toolbar_customisation *tbc,
"size-allocate",
G_CALLBACK(item_size_allocate_cb),
NULL);
- gtk_toolbar_insert(rowbar, tbc->items[iidx], iidx - startitem);
+ gtk_toolbar_insert(rowbar, tbc->items[iidx], -1);
}
return NSERROR_OK;
}
@@ -1563,17 +1248,11 @@ toolbar_customisation_create_toolbox(struct nsgtk_toolbar_customisation *tbc,
int curcol; /* current column in creation */
int iidx; /* item index */
int startidx; /* index of item at start of row */
- struct nsgtk_theme *theme;
-
- theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR, true);
- if (theme == NULL) {
- return NSERROR_NOMEM;
- }
/* ensure there are a minimum number of items per row */
columns = width / NSGTK_BUTTON_WIDTH;
- if (columns < NSGTK_STORE_WIDTH) {
- columns = NSGTK_STORE_WIDTH;
+ if (columns < NSGTK_MIN_STORE_COLUMNS) {
+ columns = NSGTK_MIN_STORE_COLUMNS;
}
edit_mode = true;
@@ -1584,7 +1263,8 @@ toolbar_customisation_create_toolbox(struct nsgtk_toolbar_customisation *tbc,
curcol = 0;
startidx = iidx;
}
- tbc->items[iidx] = make_toolbar_item(iidx, theme, true);
+ tbc->items[iidx] = make_toolbar_item(iidx,
+ tbc->toolbar.items[iidx].sensitivity);
if (tbc->items[iidx] != NULL) {
curcol++;
}
@@ -1594,8 +1274,6 @@ toolbar_customisation_create_toolbox(struct nsgtk_toolbar_customisation *tbc,
}
edit_mode = false;
- free(theme);
-
return NSERROR_OK;
}
@@ -1615,10 +1293,12 @@ customisation_toolbar_update(struct nsgtk_toolbar_customisation *tbc)
}
/* populate toolbar widget */
+ edit_mode = true;
res = populate_gtk_toolbar_widget(&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);
@@ -1757,7 +1437,11 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
if (res != NSERROR_OK) {
goto cutomize_button_clicked_cb_error;
}
- tbc->toolbar.items[iidx].sensitivity = true;
+ 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);
@@ -3240,6 +2924,42 @@ static gboolean openmenu_button_clicked_cb(GtkWidget *widget, gpointer data)
}
+/* define data plus and data minus handlers */
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, label, iconame) \
+static gboolean \
+nsgtk_toolbar_##name##_data_plus(GtkWidget *widget, \
+ GdkDragContext *cont, \
+ GtkSelectionData *selection, \
+ guint info, \
+ guint time, \
+ gpointer data) \
+{ \
+ struct nsgtk_toolbar_customisation *tbc; \
+ tbc = (struct nsgtk_toolbar_customisation *)data; \
+ tbc->dragitem = identifier; \
+ tbc->dragfrom = true; \
+ return TRUE; \
+} \
+static gboolean \
+nsgtk_toolbar_##name##_data_minus(GtkWidget *widget, \
+ GdkDragContext *cont, \
+ GtkSelectionData *selection, \
+ guint info, \
+ guint time, \
+ gpointer data) \
+{ \
+ struct nsgtk_toolbar_customisation *tbc; \
+ tbc = (struct nsgtk_toolbar_customisation *)data; \
+ tbc->dragitem = identifier; \
+ tbc->dragfrom = false; \
+ return TRUE; \
+}
+
+#include "gtk/toolbar_items.h"
+
+#undef TOOLBAR_ITEM
+
+
/**
* create a toolbar item
*
@@ -3252,11 +2972,13 @@ toolbar_item_create(nsgtk_toolbar_button id, struct nsgtk_toolbar_item *item)
/* set item defaults from macro */
switch (id) {
-#define TOOLBAR_ITEM_y(name) \
+#define TOOLBAR_ITEM_b(name) \
+ item->bhandler = name##_button_clicked_cb;
+#define TOOLBAR_ITEM_y(name) \
item->bhandler = name##_button_clicked_cb;
-#define TOOLBAR_ITEM_n(name) \
+#define TOOLBAR_ITEM_n(name) \
item->bhandler = NULL;
-#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate) \
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, label, iconame) \
case identifier: \
item->sensitivity = snstvty; \
item->dataplus = nsgtk_toolbar_##name##_data_plus; \
@@ -3617,7 +3339,6 @@ nserror nsgtk_toolbar_set_url(struct nsgtk_toolbar *tb, nsurl *url)
}
gtk_entry_set_text(url_entry, url_text);
- //gtk_editable_set_position(GTK_EDITABLE(url_entry), -1);
if (idn_url_s != NULL) {
free(idn_url_s);
@@ -3645,9 +3366,9 @@ nsgtk_toolbar_set_websearch_image(struct nsgtk_toolbar *tb, GdkPixbuf *pixbuf)
GTK_ENTRY_ICON_PRIMARY,
pixbuf);
} else {
- nsgtk_entry_set_icon_from_stock(entry,
- GTK_ENTRY_ICON_PRIMARY,
- NSGTK_STOCK_INFO);
+ nsgtk_entry_set_icon_from_icon_name(entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ NSGTK_STOCK_INFO);
}
return NSERROR_OK;
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index b699898..e895d0b 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -43,6 +43,7 @@ nserror nsgtk_toolbar_create(GtkBuilder *builder, struct browser_window *(*get_b
*/
nserror nsgtk_toolbar_destroy(struct nsgtk_toolbar *toolbar);
+
/**
* Update the toolbar items being shown based on current settings
*
@@ -51,6 +52,7 @@ nserror nsgtk_toolbar_destroy(struct nsgtk_toolbar *toolbar);
*/
nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb);
+
/**
* Update toolbar style and size based on current settings
*
@@ -111,10 +113,6 @@ nserror nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb, nsgtk_toolbar_butt
*/
nserror nsgtk_toolbar_show(struct nsgtk_toolbar *tb, bool show);
-/**
- * sets up the images for scaffolding.
- */
-void nsgtk_theme_implement(struct nsgtk_scaffolding *g);
/**
* Initialise customization of toolbar entries
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 661cbef..7a35112 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -80,72 +80,75 @@ typedef enum {
/*
* Item fields are:
- * identifier enum
- * name
- * initial sensitivity
- * y/n - if there is a toolbar click signal handler
- * y/n/p - if there is a menu activate signal handler and if it calls the
- * toolbar click handler.
+ * - item identifier (enum value)
+ * - 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)
+ * - if there is a menu activate signal handler (y/n) and it calls the
+ toolbar click handler directly. (p, implies y)
+ * - item label as a netsurf message (identifier)
+ * - icon image name ("string")
*/
#ifndef TOOLBAR_ITEM
-#define TOOLBAR_ITEM(a, b, c, d, e)
+#define TOOLBAR_ITEM(a, b, c, d, e, f, g)
#define TOOLBAR_ITEM_SET
#endif
-TOOLBAR_ITEM(BACK_BUTTON, back, false, y, p)
-TOOLBAR_ITEM(HISTORY_BUTTON, history, true, y, n)
-TOOLBAR_ITEM(FORWARD_BUTTON, forward, false, y, p)
-TOOLBAR_ITEM(STOP_BUTTON, stop, false, y, p)
-TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, y, p)
-TOOLBAR_ITEM(HOME_BUTTON, home, true, y, p)
-TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true, n, n)
-TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true, n, n)
-TOOLBAR_ITEM(THROBBER_ITEM, throbber, true, n, n)
-TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true, y, p)
-TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true, y, p)
-TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, y, p)
-TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, n, y)
-TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, y, p)
-TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, y, p)
-TOOLBAR_ITEM(PDF_BUTTON, pdf, false, y, p)
-TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true, y, p)
-TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false, n, n)
-TOOLBAR_ITEM(POSTSCRIPT_BUTTON, postscript, false, n, n)
-TOOLBAR_ITEM(PRINTPREVIEW_BUTTON, printpreview, false, n, p)
-TOOLBAR_ITEM(PRINT_BUTTON, print, true, y, p)
-TOOLBAR_ITEM(QUIT_BUTTON, quit, true, y, p)
-TOOLBAR_ITEM(CUT_BUTTON, cut, true, y, p)
-TOOLBAR_ITEM(COPY_BUTTON, copy, true, y, p)
-TOOLBAR_ITEM(PASTE_BUTTON, paste, true, y, p)
-TOOLBAR_ITEM(DELETE_BUTTON, delete, false, y, p)
-TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true, y, p)
-TOOLBAR_ITEM(FIND_BUTTON, find, true, n, y)
-TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true, y, p)
-TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true, y, p)
-TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, y, p)
-TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, y, p)
-TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true, y, p)
-TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true, y, p)
-TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true, y, p)
-TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true, y, p)
-TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, y, p)
-TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true, y, p)
-TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true, y, p)
-TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true, y, p)
-TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, y, p)
-TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, y, p)
-TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true, y, p)
-TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, y, p)
-TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true, y, p)
-TOOLBAR_ITEM(NEXTTAB_BUTTON, nexttab, false, n, y)
-TOOLBAR_ITEM(PREVTAB_BUTTON, prevtab, false, n, y)
-TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true, y, p)
-TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, y, p)
-TOOLBAR_ITEM(INFO_BUTTON, info, true, y, p)
-TOOLBAR_ITEM(ABOUT_BUTTON, about, true, y, p)
-TOOLBAR_ITEM(OPENMENU_BUTTON, openmenu, true, y, n)
-TOOLBAR_ITEM(CUSTOMIZE_BUTTON, cutomize, true, y, p)
+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(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)
+TOOLBAR_ITEM(THROBBER_ITEM, throbber, true, n, n, , NULL)
+TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true, b, p, gtkNewWindow, "document-new")
+TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true, b, p, gtkNewTab, NSGTK_STOCK_ADD)
+TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, b, p, gtkOpenFile, "document-open")
+TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, n, y, , "window-close")
+TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, y, p, , "window-close")
+TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, b, p, gtkSavePage, "text-html")
+TOOLBAR_ITEM(PDF_BUTTON, pdf, false, y, p, , "x-office-document")
+TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true, b, p, gtkPlainText, "text-x-generic")
+TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false, n, n, , NULL)
+TOOLBAR_ITEM(POSTSCRIPT_BUTTON, postscript, false, n, n, , NULL)
+TOOLBAR_ITEM(PRINTPREVIEW_BUTTON, printpreview, false, n, p, gtkPrintPreview, "gtk-print-preview")
+TOOLBAR_ITEM(PRINT_BUTTON, print, true, b, p, gtkPrint, "document-print")
+TOOLBAR_ITEM(QUIT_BUTTON, quit, true, b, p, gtkQuitMenu, "application-exit")
+TOOLBAR_ITEM(CUT_BUTTON, cut, true, b, p, gtkCut, "edit-cut")
+TOOLBAR_ITEM(COPY_BUTTON, copy, true, b, p, gtkCopy, "edit-copy")
+TOOLBAR_ITEM(PASTE_BUTTON, paste, true, b, p, gtkPaste, "edit-paste")
+TOOLBAR_ITEM(DELETE_BUTTON, delete, false, b, p, gtkDelete, "edit-delete")
+TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true, b, p, gtkSelectAll, "edit-select-all")
+TOOLBAR_ITEM(FIND_BUTTON, find, true, n, y, gtkFind, "edit-find")
+TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true, b, p, gtkPreferences, "preferences-system")
+TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true, b, p, gtkZoomPlus, "gtk-zoom-in")
+TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, b, p, gtkZoomMinus, "gtk-zoom-out")
+TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, b, p, gtkZoomNormal, "gtk-zoom-100")
+TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true, b, p, gtkFullScreen, "gtk-fullscreen")
+TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true, b, p, gtkPageSource, "gtk-index")
+TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true, b, p, gtkDownloads, NSGTK_STOCK_SAVE_AS)
+TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true, y, p, gtkSaveWindowSize, NULL)
+TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, y, p, gtkToggleDebugging, NULL)
+TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true, y, p, gtkDebugBoxTree, NULL)
+TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true, y, p, gtkDebugDomTree, NULL)
+TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true, y, p, , NULL)
+TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, y, p, gtkGlobalHistory, NULL)
+TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, y, p, gtkAddBookMarks, NULL)
+TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true, b, p, gtkShowBookMarks, "user-bookmarks")
+TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, y, p, gtkShowCookies, NULL)
+TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true, y, p, gtkOpenLocation, NULL)
+TOOLBAR_ITEM(NEXTTAB_BUTTON, nexttab, false, n, y, gtkNextTab, "media-skip-forward")
+TOOLBAR_ITEM(PREVTAB_BUTTON, prevtab, false, n, y, gtkPrevTab, "media-skip-backward")
+TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true, y, p, gtkContents, "gtk-help")
+TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, y, p, gtkGuide, "gtk-help")
+TOOLBAR_ITEM(INFO_BUTTON, info, true, y, p, gtkUserInformation, "dialog-information")
+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)
#ifdef TOOLBAR_ITEM_SET
#undef TOOLBAR_ITEM
diff --git a/resources/FatMessages b/resources/FatMessages
index d42a4de..ee56dee 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -2906,6 +2906,8 @@ nl.gtk.gtkUnknownSize:onbekend
# gtk Menu / Button labels
#
+en.gtk.gtkOpenMenu:Open Menu
+
en.gtk.gtkFile:_File
de.gtk.gtkFile:_Datei
fr.gtk.gtkFile:_Fichier
@@ -3150,6 +3152,7 @@ fr.gtk.gtkDebugDomTree:Déboguer arbre _DOM
it.gtk.gtkDebugDomTree:Debug albero _DOM
nl.gtk.gtkDebugDomTree:_DOM-boom debuggen
+en.gtk.gtkStop:Stop
en.gtk.gtkBack:_Back
de.gtk.gtkBack:_Zurück
fr.gtk.gtkBack:_Précédent
diff --git a/resources/icons/local-history.png b/resources/icons/local-history.png
new file mode 100644
index 0000000..475b4ff
Binary files /dev/null and b/resources/icons/local-history.png differ
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=9cd9a403e6ee69c78a5...
commit 9cd9a403e6ee69c78a575872bd399c633862d5aa
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
do not allocate toolbar items individually
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index e137e82..85c32e3 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -115,7 +115,7 @@ struct nsgtk_toolbar {
/**
* Toolbar item contexts
*/
- struct nsgtk_toolbar_item *buttons[PLACEHOLDER_BUTTON];
+ struct nsgtk_toolbar_item items[PLACEHOLDER_BUTTON];
/** entry widget holding the url of the current displayed page */
GtkWidget *url_bar;
@@ -176,7 +176,7 @@ struct nsgtk_toolbar_customisation {
static bool edit_mode = false;
-/* the number of buttons that fit in the width of the store window */
+/* the number of items that fit in the width of the store window */
#define NSGTK_STORE_WIDTH 6
/* the 'standard' width of a button that makes sufficient of its label
@@ -213,7 +213,7 @@ struct nsgtk_theme {
/* forward declaration */
int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, struct nsgtk_scaffolding *g);
-static nserror toolbar_item_create(nsgtk_toolbar_button id, struct nsgtk_toolbar_item **item_out);
+static nserror toolbar_item_create(nsgtk_toolbar_button id, struct nsgtk_toolbar_item *item_out);
/* define data plus and data minus handlers */
@@ -805,7 +805,7 @@ nsgtk_toolbar_customisation_save(struct nsgtk_toolbar_customisation *tbc)
order_len,
"%d;%d|",
tbidx,
- tbc->toolbar.buttons[tbidx]->location);
+ tbc->toolbar.items[tbidx].location);
if (plen == order_len) {
/* ran out of space, bail early */
NSLOG(netsurf, INFO,
@@ -841,7 +841,7 @@ itemid_from_location(struct nsgtk_toolbar *tb, int location)
{
int iidx;
for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
- if (tb->buttons[iidx]->location == location) {
+ if (tb->items[iidx].location == location) {
break;
}
}
@@ -860,15 +860,15 @@ static nserror
toolbar_item_connect_signals(struct nsgtk_toolbar *tb, int itemid)
{
/* set toolbar items to be a drag source */
- gtk_tool_item_set_use_drag_window(tb->buttons[itemid]->button, TRUE);
- gtk_drag_source_set(GTK_WIDGET(tb->buttons[itemid]->button),
+ gtk_tool_item_set_use_drag_window(tb->items[itemid].button, TRUE);
+ gtk_drag_source_set(GTK_WIDGET(tb->items[itemid].button),
GDK_BUTTON1_MASK,
&target_entry,
1,
GDK_ACTION_COPY);
- g_signal_connect(tb->buttons[itemid]->button,
+ g_signal_connect(tb->items[itemid].button,
"drag-data-get",
- G_CALLBACK(tb->buttons[itemid]->dataminus),
+ G_CALLBACK(tb->items[itemid].dataminus),
tb);
return NSERROR_OK;
}
@@ -896,7 +896,7 @@ customisation_container_drag_drop_cb(GtkWidget *widget,
return FALSE;
}
- if (tbc->toolbar.buttons[tbc->dragitem]->location == INACTIVE_LOCATION) {
+ if (tbc->toolbar.items[tbc->dragitem].location == INACTIVE_LOCATION) {
tbc->dragitem = -1;
gtk_drag_finish(gdc, TRUE, TRUE, time);
return FALSE;
@@ -904,20 +904,20 @@ customisation_container_drag_drop_cb(GtkWidget *widget,
}
/* update the locations for all the subsequent toolbar items */
- for (location = tbc->toolbar.buttons[tbc->dragitem]->location;
+ for (location = tbc->toolbar.items[tbc->dragitem].location;
location < PLACEHOLDER_BUTTON;
location++) {
itemid = itemid_from_location(&tbc->toolbar, location);
if (itemid == PLACEHOLDER_BUTTON) {
break;
}
- tbc->toolbar.buttons[itemid]->location--;
+ tbc->toolbar.items[itemid].location--;
}
/* remove existing item */
- tbc->toolbar.buttons[tbc->dragitem]->location = -1;
+ tbc->toolbar.items[tbc->dragitem].location = -1;
gtk_container_remove(GTK_CONTAINER(tbc->toolbar.widget),
- GTK_WIDGET(tbc->toolbar.buttons[tbc->dragitem]->button));
+ GTK_WIDGET(tbc->toolbar.items[tbc->dragitem].button));
tbc->dragitem = -1;
gtk_drag_finish(gdc, TRUE, TRUE, time);
@@ -968,7 +968,7 @@ customisation_toolbar_drag_drop_cb(GtkWidget *widget,
}
/* pure conveiance variable */
- dragitem = tbc->toolbar.buttons[tbc->dragitem];
+ dragitem = &tbc->toolbar.items[tbc->dragitem];
/* deal with replacing existing item in toolbar */
if (dragitem->location != INACTIVE_LOCATION) {
@@ -984,7 +984,7 @@ customisation_toolbar_drag_drop_cb(GtkWidget *widget,
if (itemid == PLACEHOLDER_BUTTON) {
break;
}
- tbc->toolbar.buttons[itemid]->location--;
+ tbc->toolbar.items[itemid].location--;
}
/* remove existing item */
@@ -1014,7 +1014,7 @@ customisation_toolbar_drag_drop_cb(GtkWidget *widget,
for (location = PLACEHOLDER_BUTTON; location >= position; location--) {
itemid = itemid_from_location(&tbc->toolbar, location);
if (itemid != PLACEHOLDER_BUTTON) {
- tbc->toolbar.buttons[itemid]->location++;
+ tbc->toolbar.items[itemid].location++;
}
}
dragitem->location = position;
@@ -1171,19 +1171,19 @@ apply_user_button_customisation(struct nsgtk_toolbar *tb)
/* set all button locations to inactive */
for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- tb->buttons[i]->location = INACTIVE_LOCATION;
+ tb->items[i].location = INACTIVE_LOCATION;
}
/* if no user config is present apply the defaults */
if (nsoption_charp(toolbar_order) == NULL) {
- tb->buttons[BACK_BUTTON]->location = 0;
- tb->buttons[HISTORY_BUTTON]->location = 1;
- tb->buttons[FORWARD_BUTTON]->location = 2;
- tb->buttons[STOP_BUTTON]->location = 3;
- tb->buttons[RELOAD_BUTTON]->location = 4;
- tb->buttons[URL_BAR_ITEM]->location = 5;
- tb->buttons[WEBSEARCH_ITEM]->location = 6;
- tb->buttons[THROBBER_ITEM]->location = 7;
+ 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;
}
@@ -1207,7 +1207,7 @@ apply_user_button_customisation(struct nsgtk_toolbar *tb)
(i < PLACEHOLDER_BUTTON) &&
(ii >= -1) &&
(ii < PLACEHOLDER_BUTTON)) {
- tb->buttons[i]->location = ii;
+ tb->items[i].location = ii;
}
}
}
@@ -1236,13 +1236,13 @@ add_item_to_toolbar(struct nsgtk_toolbar *tb,
for (bidx = BACK_BUTTON; bidx < PLACEHOLDER_BUTTON; bidx++) {
- if (tb->buttons[bidx]->location == location) {
+ if (tb->items[bidx].location == location) {
- tb->buttons[bidx]->button = make_toolbar_item(
- bidx, theme, tb->buttons[bidx]->sensitivity);
+ tb->items[bidx].button = make_toolbar_item(
+ bidx, theme, tb->items[bidx].sensitivity);
gtk_toolbar_insert(tb->widget,
- tb->buttons[bidx]->button,
+ tb->items[bidx].button,
location);
break;
}
@@ -1303,8 +1303,8 @@ itemid_from_gtktoolitem(struct nsgtk_toolbar *tb, GtkToolItem *toolitem)
{
int iidx;
for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
- if ((tb->buttons[iidx]->location != INACTIVE_LOCATION) &&
- (tb->buttons[iidx]->button == toolitem)) {
+ if ((tb->items[iidx].location != INACTIVE_LOCATION) &&
+ (tb->items[iidx].button == toolitem)) {
break;
}
}
@@ -1445,7 +1445,7 @@ toolbar_customisation_connect_signals(struct nsgtk_toolbar *tb)
for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
/* skip inactive items in toolbar */
- if (tb->buttons[iidx]->location != INACTIVE_LOCATION) {
+ if (tb->items[iidx].location != INACTIVE_LOCATION) {
toolbar_item_connect_signals(tb, iidx);
}
}
@@ -1536,7 +1536,7 @@ add_toolbox_row(struct nsgtk_toolbar_customisation *tbc,
GDK_ACTION_COPY);
g_signal_connect(tbc->items[iidx],
"drag-data-get",
- G_CALLBACK(tbc->toolbar.buttons[iidx]->dataplus),
+ G_CALLBACK(tbc->toolbar.items[iidx].dataplus),
&tbc->toolbar);
g_signal_connect(tbc->items[iidx],
"size-allocate",
@@ -1632,14 +1632,14 @@ customisation_toolbar_update(struct nsgtk_toolbar_customisation *tbc)
return res;
}
- if (tbc->toolbar.buttons[URL_BAR_ITEM]->location != INACTIVE_LOCATION) {
- entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tbc->toolbar.buttons[URL_BAR_ITEM]->button)));
+ if (tbc->toolbar.items[URL_BAR_ITEM].location != INACTIVE_LOCATION) {
+ entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tbc->toolbar.items[URL_BAR_ITEM].button)));
gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
}
- if (tbc->toolbar.buttons[WEBSEARCH_ITEM]->location != INACTIVE_LOCATION) {
- entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tbc->toolbar.buttons[WEBSEARCH_ITEM]->button)));
+ if (tbc->toolbar.items[WEBSEARCH_ITEM].location != INACTIVE_LOCATION) {
+ entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tbc->toolbar.items[WEBSEARCH_ITEM].button)));
gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
}
@@ -1753,14 +1753,11 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
gtk_toolbar_set_show_arrow(tbc->toolbar.widget, TRUE);
for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
- res = toolbar_item_create(iidx, &tbc->toolbar.buttons[iidx]);
+ res = toolbar_item_create(iidx, &tbc->toolbar.items[iidx]);
if (res != NSERROR_OK) {
- for (iidx-- ; iidx >= BACK_BUTTON; iidx--) {
- free(tbc->toolbar.buttons[iidx]);
- }
goto cutomize_button_clicked_cb_error;
}
- tbc->toolbar.buttons[iidx]->sensitivity = true;
+ tbc->toolbar.items[iidx].sensitivity = true;
}
res = customisation_toolbar_update(tbc);
@@ -1864,7 +1861,7 @@ toolbar_item_size_allocate_cb(GtkWidget *widget,
itemid = itemid_from_gtktoolitem(tb, GTK_TOOL_ITEM(widget));
if ((tb->toolbarmem == alloc->x) ||
- (tb->buttons[itemid]->location < tb->buttons[HISTORY_BUTTON]->location)) {
+ (tb->items[itemid].location < tb->items[HISTORY_BUTTON].location)) {
/*
* no reallocation after first adjustment,
* no reallocation for buttons left of history button
@@ -1883,7 +1880,7 @@ toolbar_item_size_allocate_cb(GtkWidget *widget,
tb->offset = alloc->width - 20;
}
alloc->width = 20;
- } else if (tb->buttons[itemid]->location <= tb->buttons[URL_BAR_ITEM]->location) {
+ } else if (tb->items[itemid].location <= tb->items[URL_BAR_ITEM].location) {
alloc->x -= tb->offset;
if (itemid == URL_BAR_ITEM) {
alloc->width += tb->offset;
@@ -1916,9 +1913,9 @@ back_button_clicked_cb(GtkWidget *widget, gpointer data)
browser_window_history_back(bw, false);
- set_item_sensitivity(tb->buttons[BACK_BUTTON],
+ set_item_sensitivity(&tb->items[BACK_BUTTON],
browser_window_history_back_available(bw));
- set_item_sensitivity(tb->buttons[FORWARD_BUTTON],
+ set_item_sensitivity(&tb->items[FORWARD_BUTTON],
browser_window_history_forward_available(bw));
nsgtk_local_history_hide();
@@ -1948,9 +1945,9 @@ forward_button_clicked_cb(GtkWidget *widget, gpointer data)
browser_window_history_forward(bw, false);
- set_item_sensitivity(tb->buttons[BACK_BUTTON],
+ set_item_sensitivity(&tb->items[BACK_BUTTON],
browser_window_history_back_available(bw));
- set_item_sensitivity(tb->buttons[FORWARD_BUTTON],
+ set_item_sensitivity(&tb->items[FORWARD_BUTTON],
browser_window_history_forward_available(bw));
nsgtk_local_history_hide();
}
@@ -3128,7 +3125,7 @@ openlocation_button_clicked_cb(GtkWidget *widget, gpointer data)
struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
GtkToolItem *urltitem;
- urltitem = tb->buttons[URL_BAR_ITEM]->button;
+ urltitem = tb->items[URL_BAR_ITEM].button;
if (urltitem != NULL) {
GtkEntry *entry;
entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(urltitem)));
@@ -3249,14 +3246,8 @@ static gboolean openmenu_button_clicked_cb(GtkWidget *widget, gpointer data)
* create a toolbar item and set up its default handlers
*/
static nserror
-toolbar_item_create(nsgtk_toolbar_button id,
- struct nsgtk_toolbar_item **item_out)
+toolbar_item_create(nsgtk_toolbar_button id, struct nsgtk_toolbar_item *item)
{
- struct nsgtk_toolbar_item *item;
- item = calloc(1, sizeof(struct nsgtk_toolbar_item));
- if (item == NULL) {
- return NSERROR_NOMEM;
- }
item->location = INACTIVE_LOCATION;
/* set item defaults from macro */
@@ -3278,11 +3269,9 @@ toolbar_item_create(nsgtk_toolbar_button id,
#undef TOOLBAR_ITEM
case PLACEHOLDER_BUTTON:
- free(item);
return NSERROR_INVALID;
}
- *item_out = item;
return NSERROR_OK;
}
@@ -3334,11 +3323,11 @@ static void next_throbber_frame(void *p)
tb->throb_frame++; /* advance to next frame */
- res = set_throbber_frame(tb->buttons[THROBBER_ITEM]->button,
+ res = set_throbber_frame(tb->items[THROBBER_ITEM].button,
tb->throb_frame);
if (res == NSERROR_BAD_SIZE) {
tb->throb_frame = 1;
- res = set_throbber_frame(tb->buttons[THROBBER_ITEM]->button,
+ res = set_throbber_frame(tb->items[THROBBER_ITEM].button,
tb->throb_frame);
}
@@ -3358,7 +3347,7 @@ toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
struct nsgtk_toolbar_item *item;
GtkEntry *entry;
- item = tb->buttons[itemid];
+ item = &tb->items[itemid];
if (item->button != NULL) {
g_signal_connect(item->button,
@@ -3495,11 +3484,8 @@ nsgtk_toolbar_create(GtkBuilder *builder,
/* allocate button contexts */
for (bidx = BACK_BUTTON; bidx < PLACEHOLDER_BUTTON; bidx++) {
- res = toolbar_item_create(bidx, &tb->buttons[bidx]);
+ res = toolbar_item_create(bidx, &tb->items[bidx]);
if (res != NSERROR_OK) {
- for (bidx-- ; bidx >= BACK_BUTTON; bidx--) {
- free(tb->buttons[bidx]);
- }
free(tb);
return res;
}
@@ -3581,8 +3567,8 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active)
if (active) {
nsgtk_schedule(THROBBER_FRAME_TIME, next_throbber_frame, tb);
- set_item_sensitivity(tb->buttons[STOP_BUTTON], true);
- set_item_sensitivity(tb->buttons[RELOAD_BUTTON], false);
+ set_item_sensitivity(&tb->items[STOP_BUTTON], true);
+ set_item_sensitivity(&tb->items[RELOAD_BUTTON], false);
return NSERROR_OK;
}
@@ -3590,15 +3576,15 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active)
/* stopping the throbber */
nsgtk_schedule(-1, next_throbber_frame, tb);
tb->throb_frame = 0;
- res = set_throbber_frame(tb->buttons[THROBBER_ITEM]->button,
+ res = set_throbber_frame(tb->items[THROBBER_ITEM].button,
tb->throb_frame);
/* adjust sensitivity of other items */
- set_item_sensitivity(tb->buttons[STOP_BUTTON], false);
- set_item_sensitivity(tb->buttons[RELOAD_BUTTON], true);
- set_item_sensitivity(tb->buttons[BACK_BUTTON],
+ set_item_sensitivity(&tb->items[STOP_BUTTON], false);
+ set_item_sensitivity(&tb->items[RELOAD_BUTTON], true);
+ set_item_sensitivity(&tb->items[BACK_BUTTON],
browser_window_history_back_available(bw));
- set_item_sensitivity(tb->buttons[FORWARD_BUTTON],
+ set_item_sensitivity(&tb->items[FORWARD_BUTTON],
browser_window_history_forward_available(bw));
nsgtk_local_history_hide();
@@ -3614,11 +3600,11 @@ nserror nsgtk_toolbar_set_url(struct nsgtk_toolbar *tb, nsurl *url)
const char *url_text = NULL;
GtkEntry *url_entry;
- if (tb->buttons[URL_BAR_ITEM]->button == NULL) {
+ if (tb->items[URL_BAR_ITEM].button == NULL) {
/* no toolbar item */
return NSERROR_INVALID;
}
- url_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tb->buttons[URL_BAR_ITEM]->button)));
+ url_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tb->items[URL_BAR_ITEM].button)));
if (nsoption_bool(display_decoded_idn) == true) {
if (nsurl_get_utf8(url, &idn_url_s, &idn_url_l) != NSERROR_OK) {
@@ -3647,12 +3633,12 @@ nsgtk_toolbar_set_websearch_image(struct nsgtk_toolbar *tb, GdkPixbuf *pixbuf)
{
GtkWidget *entry;
- if (tb->buttons[WEBSEARCH_ITEM]->button == NULL) {
+ if (tb->items[WEBSEARCH_ITEM].button == NULL) {
/* no toolbar item */
return NSERROR_INVALID;
}
- entry = gtk_bin_get_child(GTK_BIN(tb->buttons[WEBSEARCH_ITEM]->button));
+ entry = gtk_bin_get_child(GTK_BIN(tb->items[WEBSEARCH_ITEM].button));
if (pixbuf != NULL) {
nsgtk_entry_set_icon_from_pixbuf(entry,
@@ -3680,7 +3666,7 @@ nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb,
return NSERROR_BAD_PARAMETER;
}
- if (tb->buttons[itemid]->bhandler == NULL) {
+ if (tb->items[itemid].bhandler == NULL) {
return NSERROR_INVALID;
}
@@ -3688,13 +3674,13 @@ nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb,
* if item has a widget in the current toolbar use that as the
* signal source otherwise use the toolbar widget itself.
*/
- if (tb->buttons[itemid]->button != NULL) {
- widget = GTK_WIDGET(tb->buttons[itemid]->button);
+ if (tb->items[itemid].button != NULL) {
+ widget = GTK_WIDGET(tb->items[itemid].button);
} else {
widget = GTK_WIDGET(tb->widget);
}
- tb->buttons[itemid]->bhandler(widget, tb);
+ tb->items[itemid].bhandler(widget, tb);
return NSERROR_OK;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=3df34e7dec892632851...
commit 3df34e7dec892632851aa2774bab41f2dc708574
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
cleanup some toolbar item creation bits
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 399db6c..e137e82 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -181,7 +181,7 @@ static bool edit_mode = false;
/* the 'standard' width of a button that makes sufficient of its label
visible */
-#define NSGTK_BUTTON_WIDTH 130
+#define NSGTK_BUTTON_WIDTH 120
/* the 'standard' height of a button that fits as many toolbars as
possible into the store */
@@ -542,7 +542,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(void)
+make_toolbar_item_throbber(bool sensitivity)
{
nserror res;
GtkToolItem *item;
@@ -571,6 +571,8 @@ make_toolbar_item_throbber(void)
gtk_container_add(GTK_CONTAINER(item), image);
}
}
+ gtk_widget_set_sensitive(GTK_WIDGET(item), sensitivity);
+
return item;
}
@@ -580,7 +582,7 @@ make_toolbar_item_throbber(void)
* create a gtk entry widget with a completion attached
*/
static GtkToolItem *
-make_toolbar_item_url_bar(void)
+make_toolbar_item_url_bar(bool sensitivity)
{
GtkToolItem *item;
GtkWidget *entry;
@@ -594,10 +596,17 @@ make_toolbar_item_url_bar(void)
return NULL;
}
- gtk_entry_set_completion(GTK_ENTRY(entry), completion);
+ gtk_widget_set_sensitive(GTK_WIDGET(item), sensitivity);
+
gtk_container_add(GTK_CONTAINER(item), entry);
gtk_tool_item_set_expand(item, TRUE);
+ if (edit_mode) {
+ gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
+ } else {
+ gtk_entry_set_completion(GTK_ENTRY(entry), completion);
+ }
+
return item;
}
@@ -606,48 +615,45 @@ make_toolbar_item_url_bar(void)
* create web search toolbar item widget
*/
static GtkToolItem *
-make_toolbar_item_websearch(void)
+make_toolbar_item_websearch(bool sensitivity)
{
GtkToolItem *item;
+ nserror res;
+ GtkWidget *entry;
+ struct bitmap *bitmap;
+ GdkPixbuf *pixbuf = NULL;
- if (edit_mode) {
- item = gtk_tool_button_new(
- GTK_WIDGET(nsgtk_image_new_from_stock(
- NSGTK_STOCK_FIND,
- GTK_ICON_SIZE_LARGE_TOOLBAR)),
- "[websearch]");
- } else {
- nserror res;
- GtkWidget *entry;
- struct bitmap *bitmap;
- GdkPixbuf *pixbuf = NULL;
+ entry = nsgtk_entry_new();
+ item = gtk_tool_item_new();
- entry = nsgtk_entry_new();
- item = gtk_tool_item_new();
+ if ((entry == NULL) || (item == NULL)) {
+ return NULL;
+ }
- if ((entry == NULL) || (item == NULL)) {
- return NULL;
- }
+ gtk_widget_set_sensitive(GTK_WIDGET(item), sensitivity);
- gtk_widget_set_size_request(entry, NSGTK_WEBSEARCH_WIDTH, -1);
+ gtk_widget_set_size_request(entry, NSGTK_WEBSEARCH_WIDTH, -1);
- res = search_web_get_provider_bitmap(&bitmap);
- if ((res == NSERROR_OK) && (bitmap != NULL)) {
- pixbuf = nsgdk_pixbuf_get_from_surface(bitmap->surface,
- 16, 16);
- }
+ res = search_web_get_provider_bitmap(&bitmap);
+ if ((res == NSERROR_OK) && (bitmap != NULL)) {
+ pixbuf = nsgdk_pixbuf_get_from_surface(bitmap->surface,
+ 16, 16);
+ }
- if (pixbuf != NULL) {
- nsgtk_entry_set_icon_from_pixbuf(entry,
- GTK_ENTRY_ICON_PRIMARY,
- pixbuf);
- } else {
- nsgtk_entry_set_icon_from_stock(entry,
- GTK_ENTRY_ICON_PRIMARY,
- NSGTK_STOCK_INFO);
- }
+ if (pixbuf != NULL) {
+ nsgtk_entry_set_icon_from_pixbuf(entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ pixbuf);
+ } else {
+ nsgtk_entry_set_icon_from_stock(entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ NSGTK_STOCK_INFO);
+ }
+
+ gtk_container_add(GTK_CONTAINER(item), entry);
- gtk_container_add(GTK_CONTAINER(item), entry);
+ if (edit_mode) {
+ gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
}
return item;
@@ -662,114 +668,97 @@ make_toolbar_item_websearch(void)
* \return gtk widget
*/
static GtkToolItem *
-make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
+make_toolbar_item(nsgtk_toolbar_button itemid,
+ struct nsgtk_theme *theme,
+ bool sensitivity)
{
GtkToolItem *w = NULL;
- switch(i) {
-
-/* gtk_tool_button_new() accepts NULL args */
-#define MAKE_STOCKBUTTON(p, q) \
- case p##_BUTTON: { \
- GtkStockItem item; \
- char *label = NULL; \
- if (nsgtk_stock_lookup(q, &item) && \
- (item.label != NULL) && \
- ((label = remove_underscores(item.label, false)) != NULL)) { \
- w = gtk_tool_button_new(GTK_WIDGET( \
- theme->image[p##_BUTTON]), label); \
- free(label); \
- } else { \
- w = gtk_tool_button_new(GTK_WIDGET( \
- theme->image[p##_BUTTON]), q); \
- } \
- break; \
- }
+ switch(itemid) {
/* gtk_tool_button_new accepts NULL args */
-#define MAKE_MENUBUTTON(p, q) \
+#define MAKE_ITEM(p, q) \
case p##_BUTTON: { \
char *label = NULL; \
label = remove_underscores(messages_get(#q), false); \
- w = gtk_tool_button_new( \
- GTK_WIDGET(theme->image[p##_BUTTON]), \
- label); \
+ w = gtk_tool_button_new(GTK_WIDGET(theme->image[p##_BUTTON]), \
+ label); \
+ gtk_widget_set_sensitive(GTK_WIDGET(w), sensitivity); \
if (label != NULL) { \
free(label); \
} \
break; \
}
- MAKE_STOCKBUTTON(HOME, NSGTK_STOCK_HOME)
- MAKE_STOCKBUTTON(BACK, NSGTK_STOCK_GO_BACK)
- MAKE_STOCKBUTTON(FORWARD, NSGTK_STOCK_GO_FORWARD)
- MAKE_STOCKBUTTON(STOP, NSGTK_STOCK_STOP)
- MAKE_STOCKBUTTON(RELOAD, NSGTK_STOCK_REFRESH)
-
- MAKE_MENUBUTTON(NEWWINDOW, gtkNewWindow)
- MAKE_MENUBUTTON(NEWTAB, gtkNewTab)
- MAKE_MENUBUTTON(OPENFILE, gtkOpenFile)
- MAKE_MENUBUTTON(CLOSETAB, gtkCloseTab)
- MAKE_MENUBUTTON(CLOSEWINDOW, gtkCloseWindow)
- MAKE_MENUBUTTON(SAVEPAGE, gtkSavePage)
- MAKE_MENUBUTTON(PRINTPREVIEW, gtkPrintPreview)
- MAKE_MENUBUTTON(PRINT, gtkPrint)
- MAKE_MENUBUTTON(QUIT, gtkQuitMenu)
- MAKE_MENUBUTTON(CUT, gtkCut)
- MAKE_MENUBUTTON(COPY, gtkCopy)
- MAKE_MENUBUTTON(PASTE, gtkPaste)
- MAKE_MENUBUTTON(DELETE, gtkDelete)
- MAKE_MENUBUTTON(SELECTALL, gtkSelectAll)
- MAKE_MENUBUTTON(PREFERENCES, gtkPreferences)
- MAKE_MENUBUTTON(ZOOMPLUS, gtkZoomPlus)
- MAKE_MENUBUTTON(ZOOMMINUS, gtkZoomMinus)
- MAKE_MENUBUTTON(ZOOMNORMAL, gtkZoomNormal)
- MAKE_MENUBUTTON(FULLSCREEN, gtkFullScreen)
- MAKE_MENUBUTTON(VIEWSOURCE, gtkViewSource)
- MAKE_MENUBUTTON(CONTENTS, gtkContents)
- MAKE_MENUBUTTON(ABOUT, gtkAbout)
- MAKE_MENUBUTTON(PDF, gtkPDF)
- MAKE_MENUBUTTON(PLAINTEXT, gtkPlainText)
- MAKE_MENUBUTTON(DRAWFILE, gtkDrawFile)
- MAKE_MENUBUTTON(POSTSCRIPT, gtkPostScript)
- MAKE_MENUBUTTON(FIND, gtkFind)
- MAKE_MENUBUTTON(DOWNLOADS, gtkDownloads)
- MAKE_MENUBUTTON(SAVEWINDOWSIZE, gtkSaveWindowSize)
- MAKE_MENUBUTTON(TOGGLEDEBUGGING, gtkToggleDebugging)
- MAKE_MENUBUTTON(SAVEBOXTREE, gtkDebugBoxTree)
- MAKE_MENUBUTTON(SAVEDOMTREE, gtkDebugDomTree)
- MAKE_MENUBUTTON(LOCALHISTORY, gtkLocalHistory)
- MAKE_MENUBUTTON(GLOBALHISTORY, gtkGlobalHistory)
- MAKE_MENUBUTTON(ADDBOOKMARKS, gtkAddBookMarks)
- MAKE_MENUBUTTON(SHOWBOOKMARKS, gtkShowBookMarks)
- MAKE_MENUBUTTON(SHOWCOOKIES, gtkShowCookies)
- MAKE_MENUBUTTON(OPENLOCATION, gtkOpenLocation)
- MAKE_MENUBUTTON(NEXTTAB, gtkNextTab)
- MAKE_MENUBUTTON(PREVTAB, gtkPrevTab)
- MAKE_MENUBUTTON(GUIDE, gtkGuide)
- MAKE_MENUBUTTON(INFO, gtkUserInformation)
- MAKE_MENUBUTTON(OPENMENU, gtkOpenMenu)
-
-#undef MAKE_STOCKBUTTON
-#undef MAKE_MENUBUTTON
+ MAKE_ITEM(HOME, gtkHome)
+ MAKE_ITEM(BACK, gtkBack)
+ MAKE_ITEM(FORWARD, gtkForward)
+ MAKE_ITEM(STOP, Stop)
+ MAKE_ITEM(RELOAD, Reload)
+ MAKE_ITEM(NEWWINDOW, gtkNewWindow)
+ MAKE_ITEM(NEWTAB, gtkNewTab)
+ MAKE_ITEM(OPENFILE, gtkOpenFile)
+ MAKE_ITEM(CLOSETAB, gtkCloseTab)
+ MAKE_ITEM(CLOSEWINDOW, gtkCloseWindow)
+ MAKE_ITEM(SAVEPAGE, gtkSavePage)
+ MAKE_ITEM(PRINTPREVIEW, gtkPrintPreview)
+ MAKE_ITEM(PRINT, gtkPrint)
+ MAKE_ITEM(QUIT, gtkQuitMenu)
+ MAKE_ITEM(CUT, gtkCut)
+ MAKE_ITEM(COPY, gtkCopy)
+ MAKE_ITEM(PASTE, gtkPaste)
+ MAKE_ITEM(DELETE, gtkDelete)
+ MAKE_ITEM(SELECTALL, gtkSelectAll)
+ MAKE_ITEM(PREFERENCES, gtkPreferences)
+ MAKE_ITEM(ZOOMPLUS, gtkZoomPlus)
+ MAKE_ITEM(ZOOMMINUS, gtkZoomMinus)
+ MAKE_ITEM(ZOOMNORMAL, gtkZoomNormal)
+ MAKE_ITEM(FULLSCREEN, gtkFullScreen)
+ MAKE_ITEM(VIEWSOURCE, gtkViewSource)
+ MAKE_ITEM(CONTENTS, gtkContents)
+ MAKE_ITEM(ABOUT, gtkAbout)
+ MAKE_ITEM(PDF, gtkPDF)
+ MAKE_ITEM(PLAINTEXT, gtkPlainText)
+ MAKE_ITEM(DRAWFILE, gtkDrawFile)
+ MAKE_ITEM(POSTSCRIPT, gtkPostScript)
+ MAKE_ITEM(FIND, gtkFind)
+ MAKE_ITEM(DOWNLOADS, gtkDownloads)
+ MAKE_ITEM(SAVEWINDOWSIZE, gtkSaveWindowSize)
+ MAKE_ITEM(TOGGLEDEBUGGING, gtkToggleDebugging)
+ MAKE_ITEM(SAVEBOXTREE, gtkDebugBoxTree)
+ MAKE_ITEM(SAVEDOMTREE, gtkDebugDomTree)
+ MAKE_ITEM(LOCALHISTORY, gtkLocalHistory)
+ MAKE_ITEM(GLOBALHISTORY, gtkGlobalHistory)
+ MAKE_ITEM(ADDBOOKMARKS, gtkAddBookMarks)
+ MAKE_ITEM(SHOWBOOKMARKS, gtkShowBookMarks)
+ MAKE_ITEM(SHOWCOOKIES, gtkShowCookies)
+ MAKE_ITEM(OPENLOCATION, gtkOpenLocation)
+ MAKE_ITEM(NEXTTAB, gtkNextTab)
+ MAKE_ITEM(PREVTAB, gtkPrevTab)
+ MAKE_ITEM(GUIDE, gtkGuide)
+ MAKE_ITEM(INFO, gtkUserInformation)
+ MAKE_ITEM(OPENMENU, gtkOpenMenu)
+
+#undef MAKE_ITEM
case HISTORY_BUTTON:
w = gtk_tool_button_new(GTK_WIDGET(
theme->image[HISTORY_BUTTON]), "H");
/* set history widget minimum width */
gtk_widget_set_size_request(GTK_WIDGET(w), 20, -1);
+ gtk_widget_set_sensitive(GTK_WIDGET(w), sensitivity);
break;
case URL_BAR_ITEM:
- w = make_toolbar_item_url_bar();
+ w = make_toolbar_item_url_bar(sensitivity);
break;
case THROBBER_ITEM:
- w = make_toolbar_item_throbber();
+ w = make_toolbar_item_throbber(sensitivity);
break;
case WEBSEARCH_ITEM:
- w = make_toolbar_item_websearch();
+ w = make_toolbar_item_websearch(sensitivity);
break;
default:
@@ -1011,7 +1000,9 @@ customisation_toolbar_drag_drop_cb(GtkWidget *widget,
return TRUE;
}
- dragitem->button = make_toolbar_item(tbc->dragitem, theme);
+ edit_mode = true;
+ dragitem->button = make_toolbar_item(tbc->dragitem, theme, true);
+ edit_mode = false;
free(theme);
if (dragitem->button == NULL) {
@@ -1247,12 +1238,8 @@ add_item_to_toolbar(struct nsgtk_toolbar *tb,
if (tb->buttons[bidx]->location == location) {
- tb->buttons[bidx]->button = make_toolbar_item(bidx,
- theme);
-
- /* set widgets initial sensitivity */
- gtk_widget_set_sensitive(GTK_WIDGET(tb->buttons[bidx]->button),
- tb->buttons[bidx]->sensitivity);
+ tb->buttons[bidx]->button = make_toolbar_item(
+ bidx, theme, tb->buttons[bidx]->sensitivity);
gtk_toolbar_insert(tb->widget,
tb->buttons[bidx]->button,
@@ -1492,12 +1479,28 @@ toolbar_customisation_connect_signals(struct nsgtk_toolbar *tb)
}
+static void
+item_size_allocate_cb(GtkWidget *widget,
+ GdkRectangle *alloc,
+ gpointer user_data)
+{
+ if (alloc->width > NSGTK_BUTTON_WIDTH) {
+ alloc->width = NSGTK_BUTTON_WIDTH;
+ }
+ if (alloc->height > NSGTK_BUTTON_HEIGHT) {
+ alloc->height = NSGTK_BUTTON_HEIGHT;
+ }
+ //NSLOG(netsurf, ERROR, "w:%d h:%d", alloc->width, alloc->height);
+ gtk_widget_set_allocation(widget, alloc);
+}
+
+
/**
* add a row to a toolbar customisation toolbox
*
* \param tbc The toolbar customisation context
* \param startitem The item index of the beginning of the row
- * \param enditem The item index of teh beginning of teh next row
+ * \param enditem The item index of the beginning of the next row
* \return NSERROR_OK on successs else error
*/
static nserror
@@ -1535,6 +1538,10 @@ add_toolbox_row(struct nsgtk_toolbar_customisation *tbc,
"drag-data-get",
G_CALLBACK(tbc->toolbar.buttons[iidx]->dataplus),
&tbc->toolbar);
+ g_signal_connect(tbc->items[iidx],
+ "size-allocate",
+ G_CALLBACK(item_size_allocate_cb),
+ NULL);
gtk_toolbar_insert(rowbar, tbc->items[iidx], iidx - startitem);
}
return NSERROR_OK;
@@ -1577,7 +1584,7 @@ toolbar_customisation_create_toolbox(struct nsgtk_toolbar_customisation *tbc,
curcol = 0;
startidx = iidx;
}
- tbc->items[iidx] = make_toolbar_item(iidx, theme);
+ tbc->items[iidx] = make_toolbar_item(iidx, theme, true);
if (tbc->items[iidx] != NULL) {
curcol++;
}
@@ -1594,26 +1601,6 @@ toolbar_customisation_create_toolbox(struct nsgtk_toolbar_customisation *tbc,
/**
- * customisation apply handler for clicked signal
- *
- * when 'save settings' button is clicked
- */
-static gboolean
-customisation_apply_clicked_cb(GtkWidget *widget, gpointer data)
-{
- struct nsgtk_toolbar_customisation *tbc;
- tbc = (struct nsgtk_toolbar_customisation *)data;
-
- /* save state to file, update toolbars for all windows */
- nsgtk_toolbar_customisation_save(tbc);
- nsgtk_window_toolbar_update();
- gtk_widget_destroy(tbc->container);
-
- return TRUE;
-}
-
-
-/**
* update toolbar in customisation to user settings
*/
static nserror
@@ -1660,6 +1647,27 @@ customisation_toolbar_update(struct nsgtk_toolbar_customisation *tbc)
return NSERROR_OK;
}
+
+/**
+ * customisation apply handler for clicked signal
+ *
+ * when 'save settings' button is clicked
+ */
+static gboolean
+customisation_apply_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar_customisation *tbc;
+ tbc = (struct nsgtk_toolbar_customisation *)data;
+
+ /* save state to file, update toolbars for all windows */
+ nsgtk_toolbar_customisation_save(tbc);
+ nsgtk_window_toolbar_update();
+ gtk_widget_destroy(tbc->container);
+
+ return TRUE;
+}
+
+
/**
* customisation reset handler for clicked signal
*
@@ -1752,6 +1760,7 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
}
goto cutomize_button_clicked_cb_error;
}
+ tbc->toolbar.buttons[iidx]->sensitivity = true;
}
res = customisation_toolbar_update(tbc);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=a8e186f120617a2f29a...
commit a8e186f120617a2f29a0673947734b65fad7995f
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
fix customisation toolbar reset and remove unused code
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 9c51b5b..399db6c 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -191,7 +191,6 @@ possible into the store */
#define NSGTK_WEBSEARCH_WIDTH 150
-
enum image_sets {
IMAGE_SET_MAIN_MENU = 0,
IMAGE_SET_RCLICK_MENU,
@@ -213,7 +212,6 @@ struct nsgtk_theme {
};
/* forward declaration */
-void nsgtk_toolbar_connect_all(struct nsgtk_scaffolding *g);
int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, struct nsgtk_scaffolding *g);
static nserror toolbar_item_create(nsgtk_toolbar_button id, struct nsgtk_toolbar_item **item_out);
@@ -325,6 +323,7 @@ nsgtk_theme_image_default(nsgtk_toolbar_button tbbutton,
return image;
}
+
/**
* Get default image for search buttons / menu items from gtk stock items
*
@@ -333,7 +332,6 @@ nsgtk_theme_image_default(nsgtk_toolbar_button tbbutton,
* \param usedef Use the default image if not found.
* \return default search image.
*/
-
static GtkImage *
nsgtk_theme_searchimage_default(nsgtk_search_buttons tbbutton,
GtkIconSize iconsize,
@@ -510,26 +508,6 @@ void nsgtk_theme_implement(struct nsgtk_scaffolding *g)
}
-
-/**
- * get scaffolding button index of button at location
- *
- * \return toolbar item id from location when there is an item at that logical
- * location; else -1
- */
-static nsgtk_toolbar_button
-nsgtk_toolbar_get_id_at_location(struct nsgtk_scaffolding *g, int i)
-{
- int q;
- for (q = BACK_BUTTON; q < PLACEHOLDER_BUTTON; q++) {
- if (nsgtk_scaffolding_button(g, q)->location == i) {
- return q;
- }
- }
- return -1;
-}
-
-
/**
* returns a string without its underscores
*
@@ -708,32 +686,6 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
break; \
}
- MAKE_STOCKBUTTON(HOME, NSGTK_STOCK_HOME)
- MAKE_STOCKBUTTON(BACK, NSGTK_STOCK_GO_BACK)
- MAKE_STOCKBUTTON(FORWARD, NSGTK_STOCK_GO_FORWARD)
- MAKE_STOCKBUTTON(STOP, NSGTK_STOCK_STOP)
- MAKE_STOCKBUTTON(RELOAD, NSGTK_STOCK_REFRESH)
-#undef MAKE_STOCKBUTTON
-
- case HISTORY_BUTTON:
- w = gtk_tool_button_new(GTK_WIDGET(
- theme->image[HISTORY_BUTTON]), "H");
- /* set history widget minimum width */
- gtk_widget_set_size_request(GTK_WIDGET(w), 20, -1);
- break;
-
- case URL_BAR_ITEM:
- w = make_toolbar_item_url_bar();
- break;
-
- case THROBBER_ITEM:
- w = make_toolbar_item_throbber();
- break;
-
- case WEBSEARCH_ITEM:
- w = make_toolbar_item_websearch();
- break;
-
/* gtk_tool_button_new accepts NULL args */
#define MAKE_MENUBUTTON(p, q) \
case p##_BUTTON: { \
@@ -748,6 +700,12 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
break; \
}
+ MAKE_STOCKBUTTON(HOME, NSGTK_STOCK_HOME)
+ MAKE_STOCKBUTTON(BACK, NSGTK_STOCK_GO_BACK)
+ MAKE_STOCKBUTTON(FORWARD, NSGTK_STOCK_GO_FORWARD)
+ MAKE_STOCKBUTTON(STOP, NSGTK_STOCK_STOP)
+ MAKE_STOCKBUTTON(RELOAD, NSGTK_STOCK_REFRESH)
+
MAKE_MENUBUTTON(NEWWINDOW, gtkNewWindow)
MAKE_MENUBUTTON(NEWTAB, gtkNewTab)
MAKE_MENUBUTTON(OPENFILE, gtkOpenFile)
@@ -791,8 +749,29 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
MAKE_MENUBUTTON(GUIDE, gtkGuide)
MAKE_MENUBUTTON(INFO, gtkUserInformation)
MAKE_MENUBUTTON(OPENMENU, gtkOpenMenu)
+
+#undef MAKE_STOCKBUTTON
#undef MAKE_MENUBUTTON
+ case HISTORY_BUTTON:
+ w = gtk_tool_button_new(GTK_WIDGET(
+ theme->image[HISTORY_BUTTON]), "H");
+ /* set history widget minimum width */
+ gtk_widget_set_size_request(GTK_WIDGET(w), 20, -1);
+ break;
+
+ case URL_BAR_ITEM:
+ w = make_toolbar_item_url_bar();
+ break;
+
+ case THROBBER_ITEM:
+ w = make_toolbar_item_throbber();
+ break;
+
+ case WEBSEARCH_ITEM:
+ w = make_toolbar_item_websearch();
+ break;
+
default:
break;
@@ -810,535 +789,6 @@ static GtkTargetEntry target_entry = {
0
};
-#if 0
-
-/**
- * toolbar customisation window context
- */
-struct nsgtk_toolbar_custom_store {
- GtkWidget *window;
- GtkWidget *store_buttons[PLACEHOLDER_BUTTON];
- GtkWidget *widgetvbox;
- GtkWidget *currentbar;
- char numberh; /* current horizontal location while adding */
- GtkBuilder *builder; /* button widgets to store */
- int buttonlocations[PLACEHOLDER_BUTTON];
- int currentbutton;
- bool fromstore;
-};
-static struct nsgtk_toolbar_custom_store store;
-static struct nsgtk_toolbar_custom_store *window = &store;
-
-/* exported interface documented in gtk/scaffolding.h */
-static GtkToolbar *nsgtk_scaffolding_toolbar(struct nsgtk_scaffolding *g)
-{
- return NULL;//g->tool_bar;
-}
-
-/**
- * callback function to iterate toolbar's widgets
- */
-static void nsgtk_toolbar_clear_toolbar(GtkWidget *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- gtk_container_remove(GTK_CONTAINER(nsgtk_scaffolding_toolbar(g)),
- widget);
-}
-
-/**
- * connect temporary handler for toolbar edit events
- *
- * \param g The scaffolding
- * \param bi The button index
- */
-static void nsgtk_toolbar_temp_connect(struct nsgtk_scaffolding *g,
- nsgtk_toolbar_button bi)
-{
- struct nsgtk_toolbar_item *bc;
-
- if (bi != URL_BAR_ITEM) {
- bc = nsgtk_scaffolding_button(g, bi);
- if ((bc->button != NULL) && (bc->dataminus != NULL)) {
- g_signal_connect(bc->button,
- "drag-data-get",
- G_CALLBACK(bc->dataminus),
- g);
- }
- }
-}
-
-/* exported interface documented in gtk/scaffolding.h */
-static void nsgtk_scaffolding_reset_offset(struct nsgtk_scaffolding *g)
-{
- //g->offset = 0;
-}
-
-
-
-/**
- * called when hovering an item above the toolbar
- */
-static gboolean
-nsgtk_toolbar_action(GtkWidget *widget, GdkDragContext *gdc, gint x,
- gint y, guint time, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- GtkToolItem *item = gtk_tool_button_new(NULL, NULL);
- if (item != NULL)
- gtk_toolbar_set_drop_highlight_item(
- nsgtk_scaffolding_toolbar(g),
- GTK_TOOL_ITEM(item),
- gtk_toolbar_get_drop_index(
- nsgtk_scaffolding_toolbar(g), x, y));
- return FALSE;
-}
-
-
-/**
- * add item to toolbar.
- *
- * the function should be called, when multiple items are being added,
- * in ascending order.
- *
- * \param g the scaffolding whose toolbar an item is added to.
- * \param i the location in the toolbar.
- * \param theme The theme in use.
- */
-static void
-nsgtk_toolbar_add_item_to_toolbar(struct nsgtk_scaffolding *g, int i,
- struct nsgtk_theme *theme)
-{
- int q;
- for (q = BACK_BUTTON; q < PLACEHOLDER_BUTTON; q++)
- if (nsgtk_scaffolding_button(g, q)->location == i) {
- nsgtk_scaffolding_button(g, q)->button = GTK_TOOL_ITEM(
- make_toolbar_item(q, theme));
- gtk_toolbar_insert(nsgtk_scaffolding_toolbar(g),
- nsgtk_scaffolding_button(g, q)->button,
- i);
- break;
- }
-}
-
-/**
- * cleanup code physical update of all toolbars; resensitize
- * \param g the 'front' scaffolding that called customize
- */
-static void nsgtk_toolbar_close(struct nsgtk_scaffolding *g)
-{
- int i;
-
- struct nsgtk_scaffolding *list;
- struct nsgtk_theme *theme;
-
- list = nsgtk_scaffolding_iterate(NULL);
- while (list) {
- theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR, false);
- if (theme == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- continue;
- }
- /* clear toolbar */
- gtk_container_foreach(GTK_CONTAINER(nsgtk_scaffolding_toolbar(
- list)), nsgtk_toolbar_clear_toolbar, list);
- /* then add items */
- for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- nsgtk_toolbar_add_item_to_toolbar(list, i, theme);
- }
- nsgtk_toolbar_connect_all(list);
- gtk_widget_show_all(GTK_WIDGET(nsgtk_scaffolding_toolbar(
- list)));
- nsgtk_scaffolding_set_sensitivity(list);
- nsgtk_widget_override_background_color(
- GTK_WIDGET(nsgtk_window_get_layout(nsgtk_scaffolding_top_level(list))),
- GTK_STATE_FLAG_NORMAL,
- 0, 0xFFFF, 0xFFFF, 0xFFFF);
- g_signal_handler_unblock(GTK_WIDGET(
- nsgtk_window_get_layout(
- nsgtk_scaffolding_top_level(list))),
- nsgtk_window_get_signalhandler(
- nsgtk_scaffolding_top_level(list),
- NSGTK_WINDOW_SIGNAL_CLICK));
- g_signal_handler_unblock(GTK_WIDGET(
- nsgtk_window_get_layout(
- nsgtk_scaffolding_top_level(list))),
- nsgtk_window_get_signalhandler(
- nsgtk_scaffolding_top_level(list),
- NSGTK_WINDOW_SIGNAL_REDRAW));
- browser_window_refresh_url_bar(
- nsgtk_get_browser_window(
- nsgtk_scaffolding_top_level(list)));
-
- if (list != g)
- gtk_widget_set_sensitive(GTK_WIDGET(
- nsgtk_scaffolding_window(list)), TRUE);
- free(theme);
- list = nsgtk_scaffolding_iterate(list);
- }
- gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_notebook(g)),
- TRUE);
- gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_menu_bar(g)),
- TRUE);
- /* update favicon etc */
- nsgtk_scaffolding_set_top_level(nsgtk_scaffolding_top_level(g));
-
- search_web_select_provider(-1);
-}
-
-
-/**
- * set toolbar logical -> physical; physically visible toolbar buttons are made
- * to correspond to the logically stored schema in terms of location
- * visibility etc
- */
-static void nsgtk_toolbar_set_physical(struct nsgtk_scaffolding *g)
-{
- int i;
- struct nsgtk_theme *theme;
-
- theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR, false);
- if (theme == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- return;
- }
- /* simplest is to clear the toolbar then reload it from memory */
- gtk_container_foreach(GTK_CONTAINER(nsgtk_scaffolding_toolbar(g)),
- nsgtk_toolbar_clear_toolbar, g);
- for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- nsgtk_toolbar_add_item_to_toolbar(g, i, theme);
- }
- gtk_widget_show_all(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)));
- free(theme);
-}
-
-
-/**
- * when cancel button is clicked
- */
-static gboolean nsgtk_toolbar_cancel_clicked(GtkWidget *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
-
- edit_mode = false;
- /* reset g->buttons->location */
- for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- nsgtk_scaffolding_button(g, i)->location =
- window->buttonlocations[i];
- }
- nsgtk_toolbar_set_physical(g);
- nsgtk_toolbar_connect_all(g);
- nsgtk_toolbar_close(g);
- nsgtk_scaffolding_set_sensitivity(g);
- gtk_widget_destroy(window->window);
- return TRUE;
-}
-
-/**
- * physically add widgets to store window
- */
-static bool nsgtk_toolbar_add_store_widget(GtkWidget *widget)
-{
- if (window->numberh >= NSGTK_STORE_WIDTH) {
- window->currentbar = gtk_toolbar_new();
- if (window->currentbar == NULL) {
- nsgtk_warning("NoMemory", 0);
- return false;
- }
- gtk_toolbar_set_style(GTK_TOOLBAR(window->currentbar),
- GTK_TOOLBAR_BOTH);
- gtk_toolbar_set_icon_size(GTK_TOOLBAR(window->currentbar),
- GTK_ICON_SIZE_LARGE_TOOLBAR);
- gtk_box_pack_start(GTK_BOX(window->widgetvbox),
- window->currentbar, FALSE, FALSE, 0);
- window->numberh = 0;
- }
- gtk_widget_set_size_request(widget, NSGTK_BUTTON_WIDTH,
- NSGTK_BUTTON_HEIGHT);
- gtk_toolbar_insert(GTK_TOOLBAR(window->currentbar), GTK_TOOL_ITEM(
- widget), window->numberh++);
- gtk_tool_item_set_use_drag_window(GTK_TOOL_ITEM(widget), TRUE);
- gtk_drag_source_set(widget, GDK_BUTTON1_MASK, &entry, 1,
- GDK_ACTION_COPY);
- gtk_widget_show_all(window->window);
- return true;
-}
-
-
-/**
- * cast toolbar settings to all scaffoldings referenced from the global linked
- * list of gui_windows
- */
-static void nsgtk_toolbar_cast(struct nsgtk_scaffolding *g)
-{
- int i;
- struct nsgtk_scaffolding *list;
-
- for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- window->buttonlocations[i] =
- ((nsgtk_scaffolding_button(g, i)->location
- >= -1) &&
- (nsgtk_scaffolding_button(g, i)->location
- < PLACEHOLDER_BUTTON)) ?
- nsgtk_scaffolding_button(g, i)->location : -1;
- }
-
- list = nsgtk_scaffolding_iterate(NULL);
- while (list) {
- if (list != g)
- for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++)
- nsgtk_scaffolding_button(list, i)->location =
- window->buttonlocations[i];
- list = nsgtk_scaffolding_iterate(list);
- }
-}
-
-
-
-
-
-
-
-/**
- * when 'reload defaults' button is clicked
- */
-static gboolean nsgtk_toolbar_reset(GtkWidget *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- int i;
- for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++)
- nsgtk_scaffolding_button(g, i)->location =
- (i <= THROBBER_ITEM) ? i : -1;
- nsgtk_toolbar_set_physical(g);
- for (i = BACK_BUTTON; i <= THROBBER_ITEM; i++) {
- if (i == URL_BAR_ITEM)
- continue;
- gtk_tool_item_set_use_drag_window(GTK_TOOL_ITEM(
- nsgtk_scaffolding_button(g, i)->button), TRUE);
- gtk_drag_source_set(GTK_WIDGET(
- nsgtk_scaffolding_button(g, i)->button),
- GDK_BUTTON1_MASK, &entry, 1, GDK_ACTION_COPY);
- nsgtk_toolbar_temp_connect(g, i);
- }
- return TRUE;
-}
-
-/**
- * when titlebar / alt-F4 window close event happens
- */
-static gboolean nsgtk_toolbar_delete(GtkWidget *widget, GdkEvent *event,
- gpointer data)
-{
- edit_mode = false;
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- /* reset g->buttons->location */
- for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- nsgtk_scaffolding_button(g, i)->location =
- window->buttonlocations[i];
- }
- nsgtk_toolbar_set_physical(g);
- nsgtk_toolbar_connect_all(g);
- nsgtk_toolbar_close(g);
- nsgtk_scaffolding_set_sensitivity(g);
- gtk_widget_destroy(window->window);
- return TRUE;
-}
-
-
-
-/**
- * create store window
- */
-static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g)
-{
- struct nsgtk_theme *theme;
- nserror res;
-
- theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR, true);
- if (theme == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- nsgtk_toolbar_cancel_clicked(NULL, g);
- return;
- }
-
- res = nsgtk_builder_new_from_resname("toolbar", &window->builder);
- if (res != NSERROR_OK) {
- NSLOG(netsurf, INFO, "Toolbar UI builder init failed");
- nsgtk_warning("Toolbar UI builder init failed", 0);
- nsgtk_toolbar_cancel_clicked(NULL, g);
- free(theme);
- return;
- }
-
- gtk_builder_connect_signals(window->builder, NULL);
-
- window->window = GTK_WIDGET(gtk_builder_get_object(
- window->builder, "dialogToolbar"));
- if (window->window == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- nsgtk_toolbar_cancel_clicked(NULL, g);
- free(theme);
- return;
- }
-
- gtk_window_set_transient_for(GTK_WINDOW(window->window),
- nsgtk_scaffolding_window(g));
-
- window->widgetvbox = GTK_WIDGET(gtk_builder_get_object(
- window->builder, "widgetvbox"));
- if (window->widgetvbox == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- nsgtk_toolbar_cancel_clicked(NULL, g);
- free(theme);
- return;
- }
-
- /* preset to width [in buttons] of */
- window->numberh = NSGTK_STORE_WIDTH;
-
- /* store to cause creation of a new toolbar */
- window->currentbutton = -1;
-
- /* load toolbuttons */
- /* add toolbuttons to window */
- /* set event handlers */
- for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- if (i == URL_BAR_ITEM)
- continue;
- window->store_buttons[i] =
- make_toolbar_item(i, theme);
- if (window->store_buttons[i] == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- continue;
- }
- nsgtk_toolbar_add_store_widget(window->store_buttons[i]);
- g_signal_connect(window->store_buttons[i], "drag-data-get",
- G_CALLBACK(
- nsgtk_scaffolding_button(g, i)->dataplus), g);
- }
- free(theme);
-
-
- gtk_window_set_accept_focus(GTK_WINDOW(window->window), FALSE);
-
- gtk_drag_dest_set(GTK_WIDGET(window->window), GTK_DEST_DEFAULT_MOTION |
- GTK_DEST_DEFAULT_DROP, &entry, 1, GDK_ACTION_COPY);
-
- g_signal_connect(GTK_WIDGET(gtk_builder_get_object(
- window->builder, "close")),
- "clicked",
- G_CALLBACK(nsgtk_toolbar_persist),
- g);
-
- g_signal_connect(GTK_WIDGET(gtk_builder_get_object(
- window->builder, "reset")),
- "clicked",
- G_CALLBACK(nsgtk_toolbar_reset),
- g);
-
- g_signal_connect(window->window, "delete-event",
- G_CALLBACK(nsgtk_toolbar_delete), g);
-
- g_signal_connect(window->window, "drag-drop",
- G_CALLBACK(nsgtk_toolbar_store_return), g);
-
- g_signal_connect(window->window, "drag-motion",
- G_CALLBACK(nsgtk_toolbar_store_action), g);
-
- gtk_widget_show_all(window->window);
-}
-
-/**
- * change behaviour of scaffoldings while editing toolbar
- *
- * All buttons as well as window clicks are desensitized; then buttons
- * in the front window are changed to movable buttons
- */
-void nsgtk_toolbar_customisation_init(struct nsgtk_scaffolding *g)
-{
- int i;
- struct nsgtk_scaffolding *list;
- edit_mode = true;
-
- list = nsgtk_scaffolding_iterate(NULL);
- while (list) {
- g_signal_handler_block(GTK_WIDGET(
- nsgtk_window_get_layout(
- nsgtk_scaffolding_top_level(list))),
- nsgtk_window_get_signalhandler(
- nsgtk_scaffolding_top_level(list),
- NSGTK_WINDOW_SIGNAL_CLICK));
- g_signal_handler_block(GTK_WIDGET(
- nsgtk_window_get_layout(
- nsgtk_scaffolding_top_level(list))),
- nsgtk_window_get_signalhandler(
- nsgtk_scaffolding_top_level(list),
- NSGTK_WINDOW_SIGNAL_REDRAW));
- nsgtk_widget_override_background_color(
- GTK_WIDGET(nsgtk_window_get_layout(
- nsgtk_scaffolding_top_level(list))),
- GTK_STATE_NORMAL, 0, 0xEEEE, 0xEEEE, 0xEEEE);
-
- if (list == g) {
- list = nsgtk_scaffolding_iterate(list);
- continue;
- }
- /* set sensitive for all gui_windows save g */
- gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_window(
- list)), FALSE);
- list = nsgtk_scaffolding_iterate(list);
- }
- /* set sensitive for all of g save toolbar */
- gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_menu_bar(g)),
- FALSE);
- gtk_widget_set_sensitive(GTK_WIDGET(nsgtk_scaffolding_notebook(g)),
- FALSE);
-
- /* set editable aspect for toolbar */
- gtk_container_foreach(GTK_CONTAINER(nsgtk_scaffolding_toolbar(g)),
- nsgtk_toolbar_clear_toolbar, g);
- nsgtk_toolbar_set_physical(g);
- /* memorize button locations, set editable */
- for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- window->buttonlocations[i] = nsgtk_scaffolding_button(g, i)
- ->location;
- if ((window->buttonlocations[i] == -1) || (i == URL_BAR_ITEM))
- continue;
- gtk_tool_item_set_use_drag_window(GTK_TOOL_ITEM(
- nsgtk_scaffolding_button(g, i)->button), TRUE);
- gtk_drag_source_set(GTK_WIDGET(nsgtk_scaffolding_button(
- g, i)->button), GDK_BUTTON1_MASK, &entry, 1,
- GDK_ACTION_COPY);
- nsgtk_toolbar_temp_connect(g, i);
- }
-
- /* add move button listeners */
- g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
- "drag-drop",
- G_CALLBACK(nsgtk_toolbar_data),
- g);
- g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
- "drag-data-received",
- G_CALLBACK(nsgtk_toolbar_move_complete),
- g);
- g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
- "drag-motion",
- G_CALLBACK(nsgtk_toolbar_action),
- g);
- g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
- "drag-leave",
- G_CALLBACK(nsgtk_toolbar_clear),
- g);
-
- /* set data types */
- gtk_drag_dest_set(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
- GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
- &entry, 1, GDK_ACTION_COPY);
-
- /* open toolbar window */
- nsgtk_toolbar_window_open(g);
-}
-#endif
-
/**
* save toolbar settings to file
@@ -1391,26 +841,6 @@ nsgtk_toolbar_customisation_save(struct nsgtk_toolbar_customisation *tbc)
/**
- * customisation apply handler for clicked signal
- *
- * when 'save settings' button is clicked
- */
-static gboolean
-customisation_apply_clicked_cb(GtkWidget *widget, gpointer data)
-{
- struct nsgtk_toolbar_customisation *tbc;
- tbc = (struct nsgtk_toolbar_customisation *)data;
-
- /* save state to file, update toolbars for all windows */
- nsgtk_toolbar_customisation_save(tbc);
- nsgtk_window_toolbar_update();
- gtk_widget_destroy(tbc->container);
-
- return TRUE;
-}
-
-
-/**
* find the toolbar item with a given location.
*
* \param tb the toolbar instance
@@ -1505,6 +935,7 @@ customisation_container_drag_drop_cb(GtkWidget *widget,
return FALSE;
}
+
/**
* customisation container handler for drag motion signal
*
@@ -1668,6 +1099,7 @@ customisation_toolbar_drag_leave_cb(GtkWidget *widget,
gtk_toolbar_set_drop_highlight_item(GTK_TOOLBAR(widget), NULL, 0);
}
+
/**
* create a new browser window
*
@@ -1730,22 +1162,6 @@ int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget,
}
-
-/**
- * connect 'normal' handlers to toolbar buttons
- */
-void nsgtk_toolbar_connect_all(struct nsgtk_scaffolding *g)
-{
- int q, i;
- for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- q = nsgtk_toolbar_get_id_at_location(g, i);
- if (q == -1)
- continue;
-
- }
-}
-
-
/**
* Apply the user toolbar button settings from configuration
*
@@ -1888,7 +1304,6 @@ static nserror populate_gtk_toolbar_widget(struct nsgtk_toolbar *tb)
}
-
/**
* find the toolbar item with a given gtk widget.
*
@@ -2177,6 +1592,91 @@ toolbar_customisation_create_toolbox(struct nsgtk_toolbar_customisation *tbc,
return NSERROR_OK;
}
+
+/**
+ * customisation apply handler for clicked signal
+ *
+ * when 'save settings' button is clicked
+ */
+static gboolean
+customisation_apply_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar_customisation *tbc;
+ tbc = (struct nsgtk_toolbar_customisation *)data;
+
+ /* save state to file, update toolbars for all windows */
+ nsgtk_toolbar_customisation_save(tbc);
+ nsgtk_window_toolbar_update();
+ gtk_widget_destroy(tbc->container);
+
+ return TRUE;
+}
+
+
+/**
+ * update toolbar in customisation to user settings
+ */
+static nserror
+customisation_toolbar_update(struct nsgtk_toolbar_customisation *tbc)
+{
+ GtkEntry *entry;
+ nserror res;
+
+ res = apply_user_button_customisation(&tbc->toolbar);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ /* populate toolbar widget */
+ res = populate_gtk_toolbar_widget(&tbc->toolbar);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ /* ensure icon sizes and text labels on toolbar are set */
+ res = nsgtk_toolbar_restyle(&tbc->toolbar);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ /* attach handlers to toolbar widgets */
+ res = toolbar_customisation_connect_signals(&tbc->toolbar);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ if (tbc->toolbar.buttons[URL_BAR_ITEM]->location != INACTIVE_LOCATION) {
+ entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tbc->toolbar.buttons[URL_BAR_ITEM]->button)));
+
+ gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
+ }
+
+ if (tbc->toolbar.buttons[WEBSEARCH_ITEM]->location != INACTIVE_LOCATION) {
+ entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tbc->toolbar.buttons[WEBSEARCH_ITEM]->button)));
+
+ gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
+ }
+
+ return NSERROR_OK;
+}
+
+/**
+ * customisation reset handler for clicked signal
+ *
+ * when 'reload defaults' button is clicked
+ */
+static gboolean
+customisation_reset_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar_customisation *tbc;
+ tbc = (struct nsgtk_toolbar_customisation *)data;
+
+ customisation_toolbar_update(tbc);
+
+ return TRUE;
+}
+
+
/*
* Toolbar button clicked handlers
*/
@@ -2254,45 +1754,12 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
}
}
- res = apply_user_button_customisation(&tbc->toolbar);
+ res = customisation_toolbar_update(tbc);
if (res != NSERROR_OK) {
goto cutomize_button_clicked_cb_error;
}
- /* populate toolbar widget */
- res = populate_gtk_toolbar_widget(&tbc->toolbar);
- if (res != NSERROR_OK) {
- goto cutomize_button_clicked_cb_error;
- }
-
- /* ensure icon sizes and text labels on toolbar are set */
- res = nsgtk_toolbar_restyle(&tbc->toolbar);
- if (res != NSERROR_OK) {
- goto cutomize_button_clicked_cb_error;
- }
-
- /* attach handlers to toolbar widgets */
- res = toolbar_customisation_connect_signals(&tbc->toolbar);
- if (res != NSERROR_OK) {
- goto cutomize_button_clicked_cb_error;
- }
-
- if (tbc->toolbar.buttons[URL_BAR_ITEM]->location != INACTIVE_LOCATION) {
- GtkEntry *entry;
- entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tbc->toolbar.buttons[URL_BAR_ITEM]->button)));
-
- gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
- }
-
- if (tbc->toolbar.buttons[WEBSEARCH_ITEM]->location != INACTIVE_LOCATION) {
- GtkEntry *entry;
- entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tbc->toolbar.buttons[WEBSEARCH_ITEM]->button)));
-
- gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
- }
-
/* use toolbox for widgets to drag to/from */
-
gtk_widget_get_allocation(GTK_WIDGET(notebook), ¬ebook_alloc);
res = toolbar_customisation_create_toolbox(tbc, notebook_alloc.width);
@@ -2300,11 +1767,6 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
goto cutomize_button_clicked_cb_error;
}
-
- /* save and update on apply button then discard */
- /* discard button causes destruction */
- /* close and cleanup on destroy signal */
-
/* configure the container */
gtk_drag_dest_set(GTK_WIDGET(tbc->container),
GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
@@ -2312,22 +1774,26 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
1,
GDK_ACTION_COPY);
+ /* discard button calls destroy */
g_signal_connect_swapped(GTK_WIDGET(gtk_builder_get_object(builder,
"discard")),
"clicked",
G_CALLBACK(gtk_widget_destroy),
tbc->container);
+ /* save and update on apply button */
g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "apply")),
"clicked",
G_CALLBACK(customisation_apply_clicked_cb),
tbc);
-#if 0
g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "reset")),
"clicked",
- G_CALLBACK(nsgtk_toolbar_reset),
- g);
+ G_CALLBACK(customisation_reset_clicked_cb),
+ tbc);
+
+ /* close and cleanup on destroy signal */
+#if 0
g_signal_connect(tbc->container,
"delete-event",
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=7b63f36a4f748d0a265...
commit 7b63f36a4f748d0a265c50c933181e1582484b77
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
toolbar customisation can now apply chnages
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index c3a95b9..9c51b5b 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -1095,72 +1095,10 @@ static void nsgtk_toolbar_cast(struct nsgtk_scaffolding *g)
-/**
- * save toolbar settings to file
- */
-static nserror nsgtk_toolbar_customisation_save(struct nsgtk_scaffolding *g)
-{
- char *choices = NULL;
- char *order;
- int order_len = PLACEHOLDER_BUTTON * 12; /* length of order buffer */
- int tbidx;
- char *cur;
- int plen;
- order = malloc(order_len);
-
- if (order == NULL) {
- return NSERROR_NOMEM;
- }
- cur = order;
-
- for (tbidx = BACK_BUTTON; tbidx < PLACEHOLDER_BUTTON; tbidx++) {
- plen = snprintf(cur,
- order_len,
- "%d;%d|",
- tbidx,
- nsgtk_scaffolding_button(g, tbidx)->location);
- if (plen == order_len) {
- /* ran out of space, bail early */
- NSLOG(netsurf, INFO,
- "toolbar ordering exceeded available space");
- break;
- }
- cur += plen;
- order_len -= plen;
- }
-
- nsoption_set_charp(toolbar_order, order);
-
- /* ensure choices are saved */
- netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
- if (choices != NULL) {
- nsoption_write(choices, NULL, NULL);
- free(choices);
- }
-
- return NSERROR_OK;
-}
/**
- * when 'save settings' button is clicked
- */
-static gboolean nsgtk_toolbar_persist(GtkWidget *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
-
- edit_mode = false;
- /* save state to file, update toolbars for all windows */
- nsgtk_toolbar_customisation_save(g);
- nsgtk_toolbar_cast(g);
- nsgtk_toolbar_set_physical(g);
- nsgtk_toolbar_close(g);
- gtk_widget_destroy(window->window);
- return TRUE;
-}
-
-/**
* when 'reload defaults' button is clicked
*/
static gboolean nsgtk_toolbar_reset(GtkWidget *widget, gpointer data)
@@ -1401,6 +1339,77 @@ void nsgtk_toolbar_customisation_init(struct nsgtk_scaffolding *g)
}
#endif
+
+/**
+ * save toolbar settings to file
+ */
+static nserror
+nsgtk_toolbar_customisation_save(struct nsgtk_toolbar_customisation *tbc)
+{
+ 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);
+
+ 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.buttons[tbidx]->location);
+ if (plen == order_len) {
+ /* ran out of space, bail early */
+ NSLOG(netsurf, INFO,
+ "toolbar ordering exceeded available space");
+ break;
+ }
+ cur += plen;
+ order_len -= plen;
+ }
+
+ nsoption_set_charp(toolbar_order, order);
+
+ /* ensure choices are saved */
+ netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
+ if (choices != NULL) {
+ nsoption_write(choices, NULL, NULL);
+ free(choices);
+ }
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * customisation apply handler for clicked signal
+ *
+ * when 'save settings' button is clicked
+ */
+static gboolean
+customisation_apply_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar_customisation *tbc;
+ tbc = (struct nsgtk_toolbar_customisation *)data;
+
+ /* save state to file, update toolbars for all windows */
+ nsgtk_toolbar_customisation_save(tbc);
+ nsgtk_window_toolbar_update();
+ gtk_widget_destroy(tbc->container);
+
+ return TRUE;
+}
+
+
/**
* find the toolbar item with a given location.
*
@@ -1654,7 +1663,7 @@ static void
customisation_toolbar_drag_leave_cb(GtkWidget *widget,
GdkDragContext *gdc,
guint time,
- gpointer data)
+ gpointer data)
{
gtk_toolbar_set_drop_highlight_item(GTK_TOOLBAR(widget), NULL, 0);
}
@@ -2257,7 +2266,7 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
}
/* ensure icon sizes and text labels on toolbar are set */
- res = nsgtk_toolbar_update(&tbc->toolbar);
+ res = nsgtk_toolbar_restyle(&tbc->toolbar);
if (res != NSERROR_OK) {
goto cutomize_button_clicked_cb_error;
}
@@ -2309,12 +2318,12 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
G_CALLBACK(gtk_widget_destroy),
tbc->container);
-#if 0
g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "apply")),
"clicked",
- G_CALLBACK(nsgtk_toolbar_persist),
- g);
+ G_CALLBACK(customisation_apply_clicked_cb),
+ tbc);
+#if 0
g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "reset")),
"clicked",
G_CALLBACK(nsgtk_toolbar_reset),
@@ -4021,30 +4030,12 @@ nsgtk_toolbar_create(GtkBuilder *builder,
}
}
- res = apply_user_button_customisation(tb);
- if (res != NSERROR_OK) {
- free(tb);
- return res;
- }
-
- res = populate_gtk_toolbar_widget(tb);
- if (res != NSERROR_OK) {
- free(tb);
- return res;
- }
-
res = nsgtk_toolbar_update(tb);
if (res != NSERROR_OK) {
free(tb);
return res;
}
- res = toolbar_connect_signals(tb);
- if (res != NSERROR_OK) {
- free(tb);
- return res;
- }
-
*tb_out = tb;
return NSERROR_OK;
}
@@ -4059,7 +4050,7 @@ nserror nsgtk_toolbar_destroy(struct nsgtk_toolbar *tb)
}
/* exported interface documented in toolbar.h */
-nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb)
+nserror nsgtk_toolbar_restyle(struct nsgtk_toolbar *tb)
{
/*
* reset toolbar size allocation so icon size change affects
@@ -4245,3 +4236,32 @@ nserror nsgtk_toolbar_show(struct nsgtk_toolbar *tb, bool show)
}
return NSERROR_OK;
}
+
+
+/* exported interface documented in toolbar.h */
+nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb)
+{
+ nserror res;
+
+ /* setup item locations based on user config */
+ res = apply_user_button_customisation(tb);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ /* populate toolbar widget */
+ res = populate_gtk_toolbar_widget(tb);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ /* ensure icon sizes and text labels on toolbar are set */
+ res = nsgtk_toolbar_restyle(tb);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ res = toolbar_connect_signals(tb);
+
+ return res;
+}
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index 75fb3ab..b699898 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -43,6 +43,13 @@ nserror nsgtk_toolbar_create(GtkBuilder *builder, struct browser_window *(*get_b
*/
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
+ * \return NSERROR_OK on success
+ */
+nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb);
/**
* Update toolbar style and size based on current settings
@@ -50,7 +57,7 @@ nserror nsgtk_toolbar_destroy(struct nsgtk_toolbar *toolbar);
* \param toolbar A toolbar returned from a creation
* \return NSERROR_OK on success
*/
-nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb);
+nserror nsgtk_toolbar_restyle(struct nsgtk_toolbar *tb);
/**
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 76e9863..9368d70 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -1506,7 +1506,7 @@ nserror nsgtk_window_update_all(void)
struct gui_window *gw;
for (gw = window_list; gw != NULL; gw = gw->next) {
nsgtk_tab_options_changed(nsgtk_scaffolding_notebook(gw->scaffold));
- nsgtk_toolbar_update(gw->toolbar);
+ nsgtk_toolbar_restyle(gw->toolbar);
/** \todo update search bar */
browser_window_schedule_reformat(gw->bw);
}
@@ -1525,3 +1525,14 @@ nserror nsgtk_window_toolbar_show(struct nsgtk_scaffolding *gs, bool show)
}
return NSERROR_OK;
}
+
+/* exported interface documented in window.h */
+nserror nsgtk_window_toolbar_update(void)
+{
+ struct gui_window *gw;
+ for (gw = window_list; gw != NULL; gw = gw->next) {
+ nsgtk_toolbar_update(gw->toolbar);
+
+ }
+ return NSERROR_OK;
+}
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index 1b3c8aa..9d8d16e 100644
--- a/frontends/gtk/window.h
+++ b/frontends/gtk/window.h
@@ -55,6 +55,11 @@ struct nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *gw);
nserror nsgtk_window_update_all(void);
/**
+ * every window will have its toolbar updated to reflect user settings
+ */
+nserror nsgtk_window_toolbar_update(void);
+
+/**
* Windows associated with a scaffold will have their toolbar show state set
*/
nserror nsgtk_window_toolbar_show(struct nsgtk_scaffolding *gs, bool show);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=db558f862bdf3c4a639...
commit db558f862bdf3c4a6392ab3b3b5bcacaf87b29bd
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
fix dragging into customisation toolbar
diff --git a/frontends/gtk/res/toolbar.gtk3.ui b/frontends/gtk/res/toolbar.gtk3.ui
index c8713ba..60452f4 100644
--- a/frontends/gtk/res/toolbar.gtk3.ui
+++ b/frontends/gtk/res/toolbar.gtk3.ui
@@ -24,6 +24,22 @@
</packing>
</child>
<child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xpad">6</property>
+ <property name="label" translatable="yes">gtkCustomizeToolbarInstructions</property>
+ <property name="wrap">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">6</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -48,7 +64,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child>
@@ -103,7 +119,7 @@
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">6</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
</object>
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index dca1524..c3a95b9 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -1422,6 +1422,31 @@ itemid_from_location(struct nsgtk_toolbar *tb, int location)
/**
+ * connect signals to a toolbar item in a customisation toolbar
+ *
+ * \param tb The toolbar
+ * \param itemid The item id within to toolbar to connect
+ * \param NSERROR_OK on success
+ */
+static nserror
+toolbar_item_connect_signals(struct nsgtk_toolbar *tb, int itemid)
+{
+ /* set toolbar items to be a drag source */
+ gtk_tool_item_set_use_drag_window(tb->buttons[itemid]->button, TRUE);
+ gtk_drag_source_set(GTK_WIDGET(tb->buttons[itemid]->button),
+ GDK_BUTTON1_MASK,
+ &target_entry,
+ 1,
+ GDK_ACTION_COPY);
+ g_signal_connect(tb->buttons[itemid]->button,
+ "drag-data-get",
+ G_CALLBACK(tb->buttons[itemid]->dataminus),
+ tb);
+ return NSERROR_OK;
+}
+
+
+/**
* customisation container handler for drag drop signal
*
* called when a widget is dropped onto the store window
@@ -1461,6 +1486,7 @@ customisation_container_drag_drop_cb(GtkWidget *widget,
tbc->toolbar.buttons[itemid]->location--;
}
+ /* remove existing item */
tbc->toolbar.buttons[tbc->dragitem]->location = -1;
gtk_container_remove(GTK_CONTAINER(tbc->toolbar.widget),
GTK_WIDGET(tbc->toolbar.buttons[tbc->dragitem]->button));
@@ -1499,78 +1525,76 @@ customisation_toolbar_drag_drop_cb(GtkWidget *widget,
guint time,
gpointer data)
{
-#if 0
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- int ind = gtk_toolbar_get_drop_index(nsgtk_scaffolding_toolbar(g),
- x, y);
- int q, i;
- if (window->currentbutton == -1)
+ struct nsgtk_toolbar_customisation *tbc;
+ tbc = (struct nsgtk_toolbar_customisation *)data;
+ gint position; /* drop position in toolbar */
+ struct nsgtk_theme *theme;
+ int location;
+ int itemid;
+ struct nsgtk_toolbar_item *dragitem; /* toolbar item being dragged */
+
+ position = gtk_toolbar_get_drop_index(tbc->toolbar.widget, x, y);
+ if (tbc->dragitem == -1) {
return TRUE;
- struct nsgtk_theme *theme =
- nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR, false);
+ }
+
+ /* pure conveiance variable */
+ dragitem = tbc->toolbar.buttons[tbc->dragitem];
+
+ /* deal with replacing existing item in toolbar */
+ if (dragitem->location != INACTIVE_LOCATION) {
+ if (dragitem->location < position) {
+ position--;
+ }
+
+ /* update the locations for all the subsequent toolbar items */
+ for (location = dragitem->location;
+ location < PLACEHOLDER_BUTTON;
+ location++) {
+ itemid = itemid_from_location(&tbc->toolbar, location);
+ if (itemid == PLACEHOLDER_BUTTON) {
+ break;
+ }
+ tbc->toolbar.buttons[itemid]->location--;
+ }
+
+ /* remove existing item */
+ dragitem->location = INACTIVE_LOCATION;
+ gtk_container_remove(GTK_CONTAINER(tbc->toolbar.widget),
+ GTK_WIDGET(dragitem->button));
+ }
+
+ /* add dropped item into toolbar */
+ theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR, false);
if (theme == NULL) {
nsgtk_warning(messages_get("NoMemory"), 0);
return TRUE;
}
- if (nsgtk_scaffolding_button(g, window->currentbutton)->location
- != -1) {
- /* widget was already in the toolbar; so replace */
- if (nsgtk_scaffolding_button(g, window->currentbutton)->
- location < ind)
- ind--;
- gtk_container_remove(GTK_CONTAINER(
- nsgtk_scaffolding_toolbar(g)), GTK_WIDGET(
- nsgtk_scaffolding_button(g,
- window->currentbutton)->button));
- /* 'move' all widgets further right than the original location,
- * one place to the left in logical schema */
- for (i = nsgtk_scaffolding_button(g, window->currentbutton)->
- location + 1; i < PLACEHOLDER_BUTTON; i++) {
- q = nsgtk_toolbar_get_id_at_location(g, i);
- if (q == -1)
- continue;
- nsgtk_scaffolding_button(g, q)->location--;
- }
- nsgtk_scaffolding_button(g, window->currentbutton)->
- location = -1;
- }
- nsgtk_scaffolding_button(g, window->currentbutton)->button =
- GTK_TOOL_ITEM(make_toolbar_item(window->currentbutton, theme));
+
+ dragitem->button = make_toolbar_item(tbc->dragitem, theme);
+
free(theme);
- if (nsgtk_scaffolding_button(g, window->currentbutton)->button
- == NULL) {
+ if (dragitem->button == NULL) {
nsgtk_warning("NoMemory", 0);
return TRUE;
}
- /* update logical schema */
- nsgtk_scaffolding_reset_offset(g);
- /* 'move' all widgets further right than the new location, one place to
- * the right in logical schema */
- for (i = PLACEHOLDER_BUTTON - 1; i >= ind; i--) {
- q = nsgtk_toolbar_get_id_at_location(g, i);
- if (q == -1)
- continue;
- nsgtk_scaffolding_button(g, q)->location++;
- }
- nsgtk_scaffolding_button(g, window->currentbutton)->location = ind;
-
- /* complete action */
- GtkToolItem *current_button;
- current_button = GTK_TOOL_ITEM(nsgtk_scaffolding_button(g, window->currentbutton)->button);
-
- gtk_toolbar_insert(nsgtk_scaffolding_toolbar(g), current_button, ind);
-
- gtk_tool_item_set_use_drag_window(current_button, TRUE);
- gtk_drag_source_set(GTK_WIDGET(current_button),
- GDK_BUTTON1_MASK, &entry, 1,
- GDK_ACTION_COPY);
- nsgtk_toolbar_temp_connect(g, window->currentbutton);
- gtk_widget_show_all(GTK_WIDGET(current_button));
+ /* update locations */
+ for (location = PLACEHOLDER_BUTTON; location >= position; location--) {
+ itemid = itemid_from_location(&tbc->toolbar, location);
+ if (itemid != PLACEHOLDER_BUTTON) {
+ tbc->toolbar.buttons[itemid]->location++;
+ }
+ }
+ dragitem->location = position;
+ gtk_toolbar_insert(tbc->toolbar.widget,
+ dragitem->button,
+ dragitem->location);
- window->currentbutton = -1;
-#endif
+ toolbar_item_connect_signals(&tbc->toolbar, tbc->dragitem);
+ gtk_widget_show_all(GTK_WIDGET(dragitem->button));
+ tbc->dragitem = -1;
return TRUE;
}
@@ -1610,7 +1634,7 @@ customisation_toolbar_drag_motion_cb(GtkWidget *widget,
{
struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
GtkToolItem *item;
- gint position;
+ gint position; /* position in toolbar */
item = gtk_tool_button_new(NULL, NULL);
position = gtk_toolbar_get_drop_index(tb->widget, x, y);
@@ -2010,21 +2034,9 @@ toolbar_customisation_connect_signals(struct nsgtk_toolbar *tb)
for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
/* skip inactive items in toolbar */
- if (tb->buttons[iidx]->location == INACTIVE_LOCATION) {
- continue;
+ if (tb->buttons[iidx]->location != INACTIVE_LOCATION) {
+ toolbar_item_connect_signals(tb, iidx);
}
-
- /* set toolbar items to be a drag source */
- gtk_tool_item_set_use_drag_window(tb->buttons[iidx]->button, TRUE);
- gtk_drag_source_set(GTK_WIDGET(tb->buttons[iidx]->button),
- GDK_BUTTON1_MASK,
- &target_entry,
- 1,
- GDK_ACTION_COPY);
- g_signal_connect(tb->buttons[iidx]->button,
- "drag-data-get",
- G_CALLBACK(tb->buttons[iidx]->dataminus),
- tb);
}
/* add move button listeners */
diff --git a/resources/FatMessages b/resources/FatMessages
index 008afef..d42a4de 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -3264,11 +3264,8 @@ fr.gtk.gtkCopylink:_Copier le lien
it.gtk.gtkCopylink:Copia in_dirizzo link
nl.gtk.gtkCopylink:Koppelingsloc_atie kopiëren
-en.gtk.gtkToolBarTitle:Toolbar custom button store
-de.gtk.gtkToolBarTitle:Benutzerdefinierter Ort für Toolbar-Icons
-fr.gtk.gtkToolBarTitle:Personaliser la barre d'outils
-it.gtk.gtkToolBarTitle:Pulsanti della barra strumenti
-nl.gtk.gtkToolBarTitle:Werkbalk aanpassen
+# GTK theme handling
+
en.gtk.gtkAddThemeTitle:Select folder containing theme images
de.gtk.gtkAddThemeTitle:Ordner mit Themenbildern auswählen
fr.gtk.gtkAddThemeTitle:Sélectionner le dossier contenant des images de thèmes
@@ -3296,6 +3293,11 @@ fr.gtk.gtkThemeAdd:Le thème a été ajouté avec succes
it.gtk.gtkThemeAdd:Il tema è stato aggiunto con successo
nl.gtk.gtkThemeAdd:Thema is succesvol toegevoegd
+# GTK toolbar customisation
+
+en.gtk.gtkCustomizeToolbarTitle:Customise Toolbar
+en.gtk.gtkCustomizeToolbarInstructions:Drag toolbar items into and out of the toolbar.
+
# GTK preferences dialog
en.gtk.preferencesTitle:Netsurf Preferences
@@ -6481,3 +6483,8 @@ nl.all.SetPassword:Stel wachtwoord in
#it.all.MNGTitle:%s (Immagine MNG %lux%lu pixel)
#nl.all.MNGTitle:%s (MNG-afbeelding %lux%lu punten)
#en.all.LoginLabel:A website is requesting credentials for access.
+#en.gtk.gtkToolBarTitle:Toolbar custom button store
+#de.gtk.gtkToolBarTitle:Benutzerdefinierter Ort für Toolbar-Icons
+#fr.gtk.gtkToolBarTitle:Personaliser la barre d'outils
+#it.gtk.gtkToolBarTitle:Pulsanti della barra strumenti
+#nl.gtk.gtkToolBarTitle:Werkbalk aanpassen
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c7ad2553d8a001d1dfc...
commit c7ad2553d8a001d1dfc492a816b7b507836e05e9
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
allow toolbar customisation to remove widgets from the toolbar
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 7184ead..dca1524 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -1205,52 +1205,7 @@ static gboolean nsgtk_toolbar_delete(GtkWidget *widget, GdkEvent *event,
return TRUE;
}
-/**
- * called when a widget is dropped onto the store window
- */
-static gboolean
-nsgtk_toolbar_store_return(GtkWidget *widget, GdkDragContext *gdc,
- gint x, gint y, guint time, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- int q, i;
- if ((window->fromstore) || (window->currentbutton == -1)) {
- window->currentbutton = -1;
- return FALSE;
- }
- if (nsgtk_scaffolding_button(g, window->currentbutton)->location
- != -1) {
- /* 'move' all widgets further right, one place to the left
- * in logical schema */
- for (i = nsgtk_scaffolding_button(g, window->currentbutton)->
- location + 1; i < PLACEHOLDER_BUTTON; i++) {
- q = nsgtk_toolbar_get_id_at_location(g, i);
- if (q == -1)
- continue;
- nsgtk_scaffolding_button(g, q)->location--;
- }
- gtk_container_remove(GTK_CONTAINER(
- nsgtk_scaffolding_toolbar(g)), GTK_WIDGET(
- nsgtk_scaffolding_button(g,
- window->currentbutton)->button));
- nsgtk_scaffolding_button(g, window->currentbutton)->location
- = -1;
- }
- window->currentbutton = -1;
- gtk_drag_finish(gdc, TRUE, TRUE, time);
- return FALSE;
-}
-
-/**
- * called when hovering above the store
- */
-static gboolean
-nsgtk_toolbar_store_action(GtkWidget *widget, GdkDragContext *gdc,
- gint x, gint y, guint time, gpointer data)
-{
- return FALSE;
-}
/**
* create store window
@@ -1446,8 +1401,94 @@ void nsgtk_toolbar_customisation_init(struct nsgtk_scaffolding *g)
}
#endif
+/**
+ * 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->buttons[iidx]->location == location) {
+ break;
+ }
+ }
+ return iidx;
+}
+
+
+/**
+ * customisation container handler for drag drop signal
+ *
+ * called when a widget is dropped onto the store window
+ */
+static gboolean
+customisation_container_drag_drop_cb(GtkWidget *widget,
+ GdkDragContext *gdc,
+ gint x, gint y,
+ guint time,
+ gpointer data)
+{
+ struct nsgtk_toolbar_customisation *tbc;
+ tbc = (struct nsgtk_toolbar_customisation *)data;
+ int location;
+ int itemid;
+
+ if ((tbc->dragfrom) || (tbc->dragitem == -1)) {
+ tbc->dragitem = -1;
+ return FALSE;
+ }
+
+ if (tbc->toolbar.buttons[tbc->dragitem]->location == INACTIVE_LOCATION) {
+ tbc->dragitem = -1;
+ gtk_drag_finish(gdc, TRUE, TRUE, time);
+ return FALSE;
+
+ }
+
+ /* update the locations for all the subsequent toolbar items */
+ for (location = tbc->toolbar.buttons[tbc->dragitem]->location;
+ location < PLACEHOLDER_BUTTON;
+ location++) {
+ itemid = itemid_from_location(&tbc->toolbar, location);
+ if (itemid == PLACEHOLDER_BUTTON) {
+ break;
+ }
+ tbc->toolbar.buttons[itemid]->location--;
+ }
+
+ tbc->toolbar.buttons[tbc->dragitem]->location = -1;
+ gtk_container_remove(GTK_CONTAINER(tbc->toolbar.widget),
+ GTK_WIDGET(tbc->toolbar.buttons[tbc->dragitem]->button));
+
+ tbc->dragitem = -1;
+ gtk_drag_finish(gdc, TRUE, TRUE, time);
+ return FALSE;
+}
+
+/**
+ * customisation container handler for drag motion signal
+ *
+ * called when hovering above the store
+ */
+static gboolean
+customisation_container_drag_motion_cb(GtkWidget *widget,
+ GdkDragContext *gdc,
+ gint x, gint y,
+ guint time,
+ gpointer data)
+{
+ return FALSE;
+}
+
/**
+ * customisation toolbar handler for drag drop signal
+ *
* called when a widget is dropped onto the toolbar
*/
static gboolean
@@ -1814,24 +1855,6 @@ static nserror populate_gtk_toolbar_widget(struct nsgtk_toolbar *tb)
}
-/**
- * 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->buttons[iidx]->location == location) {
- break;
- }
- }
- return iidx;
-}
/**
* find the toolbar item with a given gtk widget.
@@ -2275,7 +2298,7 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
tbc->container);
#if 0
- g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "close")),
+ g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "apply")),
"clicked",
G_CALLBACK(nsgtk_toolbar_persist),
g);
@@ -2290,16 +2313,17 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
G_CALLBACK(nsgtk_toolbar_delete),
g);
+
+#endif
g_signal_connect(tbc->container,
"drag-drop",
- G_CALLBACK(nsgtk_toolbar_store_return),
- g);
+ G_CALLBACK(customisation_container_drag_drop_cb),
+ tbc);
g_signal_connect(tbc->container,
"drag-motion",
- G_CALLBACK(nsgtk_toolbar_store_action),
- g);
-#endif
+ G_CALLBACK(customisation_container_drag_motion_cb),
+ tbc);
nsgtk_tab_add_page(notebook,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=dbc5b5df6af05e2218d...
commit dbc5b5df6af05e2218de3d07fcc602ae88520b57
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
fixup gtk2 ui builder for toolbar customisation
diff --git a/frontends/gtk/res/toolbar.gtk2.ui b/frontends/gtk/res/toolbar.gtk2.ui
index cb5e9eb..eb882f3 100644
--- a/frontends/gtk/res/toolbar.gtk2.ui
+++ b/frontends/gtk/res/toolbar.gtk2.ui
@@ -2,174 +2,7 @@
<interface>
<!-- interface-requires gtk+ 2.12 -->
<!-- interface-naming-policy toplevel-contextual -->
- <object class="GtkDialog" id="dialogToolbar">
- <property name="width_request">700</property>
- <property name="height_request">450</property>
- <property name="can_focus">False</property>
- <property name="border_width">5</property>
- <property name="title" translatable="yes">gtkToolBarTitle</property>
- <property name="window_position">center-on-parent</property>
- <property name="destroy_with_parent">True</property>
- <property name="type_hint">dialog</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkHBox" id="hbox1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="homogeneous">True</property>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Move items from store to toolbar</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Rearrange items in toolbar</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Move items from toolbar to store</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="padding">2</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="hscrollbar_policy">automatic</property>
- <property name="vscrollbar_policy">automatic</property>
- <child>
- <object class="GtkViewport" id="viewport1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkVBox" id="widgetvbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="reset">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">False</property>
- <child>
- <object class="GtkHBox" id="button1hbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkImage" id="image1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-refresh</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="refreshbuttonlabel">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Reset to defaults</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="padding">10</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="close">
- <property name="label">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="0">reset</action-widget>
- <action-widget response="0">close</action-widget>
- </action-widgets>
- </object>
- <object class="GtkVBox" id="tabBox">
+ <object class="GtkVBox" id="customisation">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
@@ -184,11 +17,28 @@
</packing>
</child>
<child>
- <object class="GtkViewport" id="viewport">
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
<child>
- <placeholder/>
+ <object class="GtkViewport" id="viewport1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkVBox" id="toolbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
</child>
</object>
<packing>
@@ -203,7 +53,7 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="resetdefault">
+ <object class="GtkButton" id="reset">
<property name="label" translatable="yes">Reset to defaults</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
diff --git a/frontends/gtk/res/toolbar.gtk3.ui b/frontends/gtk/res/toolbar.gtk3.ui
index e74ddb0..c8713ba 100644
--- a/frontends/gtk/res/toolbar.gtk3.ui
+++ b/frontends/gtk/res/toolbar.gtk3.ui
@@ -3,140 +3,12 @@
<!--*- mode: xml -*-->
<interface>
<requires lib="gtk+" version="3.0"/>
- <object class="GtkDialog" id="dialogToolbar">
- <property name="width_request">700</property>
- <property name="height_request">450</property>
- <property name="can_focus">False</property>
- <property name="title" translatable="yes">gtkToolBarTitle</property>
- <property name="type_hint">dialog</property>
- <child>
- <placeholder/>
- </child>
- <child internal-child="vbox">
- <object class="GtkBox" id="dialog-vbox1">
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child internal-child="action_area">
- <object class="GtkButtonBox" id="dialog-action_area1">
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="reset">
- <property name="label" translatable="yes">Reset To Defaults</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="yalign">0.52999997138977051</property>
- <property name="always_show_image">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="close">
- <property name="label">gtk-close</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkGrid" id="grid1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="column_homogeneous">True</property>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Move items from store to toolbar</property>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Rearrange items in toolbar</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="label" translatable="yes">Move items from toolbar to store</property>
- </object>
- <packing>
- <property name="left_attach">2</property>
- <property name="top_attach">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <child>
- <object class="GtkViewport" id="viewport1">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <object class="GtkVBox" id="widgetvbox">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">2</property>
- </packing>
- </child>
- </object>
- </child>
- </object>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="stock">gtk-refresh</property>
</object>
- <object class="GtkBox" id="tabBox">
+ <object class="GtkBox" id="customisation">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
@@ -185,7 +57,7 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="resetdefault">
+ <object class="GtkButton" id="reset">
<property name="label" translatable="yes">Reset</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 3cd936c..7184ead 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -2180,7 +2180,7 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
}
/* get container box widget which forms a page of the tabs */
- tbc->container = GTK_WIDGET(gtk_builder_get_object(builder, "tabBox"));
+ tbc->container = GTK_WIDGET(gtk_builder_get_object(builder, "customisation"));
if (tbc->container == NULL) {
goto cutomize_button_clicked_cb_error;
}
@@ -2262,13 +2262,18 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
/* close and cleanup on destroy signal */
/* configure the container */
- gtk_window_set_accept_focus(GTK_WINDOW(tbc->container), FALSE);
-
gtk_drag_dest_set(GTK_WIDGET(tbc->container),
GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
&target_entry,
1,
GDK_ACTION_COPY);
+
+ g_signal_connect_swapped(GTK_WIDGET(gtk_builder_get_object(builder,
+ "discard")),
+ "clicked",
+ G_CALLBACK(gtk_widget_destroy),
+ tbc->container);
+
#if 0
g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "close")),
"clicked",
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=df398ed886a020c5044...
commit df398ed886a020c5044239f43b0d73faa323545e
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
populate toolbar customisation with icons
diff --git a/frontends/gtk/res/toolbar.gtk3.ui b/frontends/gtk/res/toolbar.gtk3.ui
index 0b0f087..e74ddb0 100644
--- a/frontends/gtk/res/toolbar.gtk3.ui
+++ b/frontends/gtk/res/toolbar.gtk3.ui
@@ -3,11 +3,6 @@
<!--*- mode: xml -*-->
<interface>
<requires lib="gtk+" version="3.0"/>
- <object class="GtkImage" id="image2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="stock">gtk-refresh</property>
- </object>
<object class="GtkDialog" id="dialogToolbar">
<property name="width_request">700</property>
<property name="height_request">450</property>
@@ -32,7 +27,6 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
- <property name="image">image2</property>
<property name="yalign">0.52999997138977051</property>
<property name="always_show_image">True</property>
</object>
@@ -137,6 +131,11 @@
</object>
</child>
</object>
+ <object class="GtkImage" id="image2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-refresh</property>
+ </object>
<object class="GtkBox" id="tabBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -153,12 +152,29 @@
</packing>
</child>
<child>
- <object class="GtkLayout" id="viewport">
+ <object class="GtkScrolledWindow">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkViewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkBox" id="toolbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
@@ -174,6 +190,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
+ <property name="image">image2</property>
</object>
<packing>
<property name="expand">True</property>
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index f104606..3cd936c 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -94,8 +94,8 @@ struct nsgtk_toolbar_item {
*/
gboolean (*bhandler)(GtkWidget *widget, gpointer data);
- void *dataplus; /* customization -> toolbar */
- void *dataminus; /* customization -> store */
+ void *dataplus; /* customisation -> toolbar */
+ void *dataminus; /* customisation -> store */
};
@@ -140,7 +140,7 @@ struct nsgtk_toolbar {
/**
* toolbar cusomisation context
*/
-struct nsgtk_toolbar_customization {
+struct nsgtk_toolbar_customisation {
/**
* first entry is a toolbar widget so a customisation widget
* can be cast to toolbar and back.
@@ -152,23 +152,28 @@ struct nsgtk_toolbar_customization {
*/
GtkWidget *container;
-};
+ /**
+ * The vertical box into which the available tools are shown
+ */
+ GtkBox *toolbox;
+
+ /**
+ * widget handles for items in the customisation toolbox area
+ */
+ GtkToolItem *items[PLACEHOLDER_BUTTON];
+
+ /**
+ * which item is being dragged
+ */
+ int dragitem; /* currentbutton */
+ /**
+ * true if item being dragged onto toolbar, false if from toolbar
+ */
+ bool dragfrom; /*fromstore */
-/**
- * toolbar customization window context
- */
-struct nsgtk_toolbar_custom_store {
- GtkWidget *window;
- GtkWidget *store_buttons[PLACEHOLDER_BUTTON];
- GtkWidget *widgetvbox;
- GtkWidget *currentbar;
- char numberh; /* current horizontal location while adding */
- GtkBuilder *builder; /* button widgets to store */
- int buttonlocations[PLACEHOLDER_BUTTON];
- int currentbutton;
- bool fromstore;
};
+
static bool edit_mode = false;
/* the number of buttons that fit in the width of the store window */
@@ -176,7 +181,7 @@ static bool edit_mode = false;
/* the 'standard' width of a button that makes sufficient of its label
visible */
-#define NSGTK_BUTTON_WIDTH 111
+#define NSGTK_BUTTON_WIDTH 130
/* the 'standard' height of a button that fits as many toolbars as
possible into the store */
@@ -185,8 +190,6 @@ possible into the store */
/* the 'normal' width of the websearch bar */
#define NSGTK_WEBSEARCH_WIDTH 150
-static struct nsgtk_toolbar_custom_store store;
-static struct nsgtk_toolbar_custom_store *window = &store;
enum image_sets {
@@ -225,8 +228,10 @@ nsgtk_toolbar_##name##_data_plus(GtkWidget *widget, \
guint time, \
gpointer data) \
{ \
- window->currentbutton = identifier; \
- window->fromstore = true; \
+ struct nsgtk_toolbar_customisation *tbc; \
+ tbc = (struct nsgtk_toolbar_customisation *)data; \
+ tbc->dragitem = identifier; \
+ tbc->dragfrom = true; \
return TRUE; \
} \
static gboolean \
@@ -237,8 +242,10 @@ nsgtk_toolbar_##name##_data_minus(GtkWidget *widget, \
guint time, \
gpointer data) \
{ \
- window->currentbutton = identifier; \
- window->fromstore = false; \
+ struct nsgtk_toolbar_customisation *tbc; \
+ tbc = (struct nsgtk_toolbar_customisation *)data; \
+ tbc->dragitem = identifier; \
+ tbc->dragfrom = false; \
return TRUE; \
}
@@ -676,10 +683,10 @@ make_toolbar_item_websearch(void)
* \param theme the theme to make the widgets from
* \return gtk widget
*/
-static GtkWidget *
+static GtkToolItem *
make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
{
- GtkWidget *w = NULL;
+ GtkToolItem *w = NULL;
switch(i) {
@@ -691,12 +698,12 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
if (nsgtk_stock_lookup(q, &item) && \
(item.label != NULL) && \
((label = remove_underscores(item.label, false)) != NULL)) { \
- w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET( \
- theme->image[p##_BUTTON]), label)); \
+ w = gtk_tool_button_new(GTK_WIDGET( \
+ theme->image[p##_BUTTON]), label); \
free(label); \
} else { \
- w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET( \
- theme->image[p##_BUTTON]), q)); \
+ w = gtk_tool_button_new(GTK_WIDGET( \
+ theme->image[p##_BUTTON]), q); \
} \
break; \
}
@@ -709,20 +716,22 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
#undef MAKE_STOCKBUTTON
case HISTORY_BUTTON:
- w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(
- theme->image[HISTORY_BUTTON]), "H"));
+ w = gtk_tool_button_new(GTK_WIDGET(
+ theme->image[HISTORY_BUTTON]), "H");
+ /* set history widget minimum width */
+ gtk_widget_set_size_request(GTK_WIDGET(w), 20, -1);
break;
case URL_BAR_ITEM:
- w = GTK_WIDGET(make_toolbar_item_url_bar());
+ w = make_toolbar_item_url_bar();
break;
case THROBBER_ITEM:
- w = GTK_WIDGET(make_toolbar_item_throbber());
+ w = make_toolbar_item_throbber();
break;
case WEBSEARCH_ITEM:
- w = GTK_WIDGET(make_toolbar_item_websearch());
+ w = make_toolbar_item_websearch();
break;
/* gtk_tool_button_new accepts NULL args */
@@ -730,9 +739,9 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
case p##_BUTTON: { \
char *label = NULL; \
label = remove_underscores(messages_get(#q), false); \
- w = GTK_WIDGET(gtk_tool_button_new( \
+ w = gtk_tool_button_new( \
GTK_WIDGET(theme->image[p##_BUTTON]), \
- label)); \
+ label); \
if (label != NULL) { \
free(label); \
} \
@@ -789,16 +798,36 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
}
- if (w == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- }
-
return w;
}
+
+/**
+ * target entry for drag source
+ */
+static GtkTargetEntry target_entry = {
+ (char *)"nsgtk_button_data",
+ GTK_TARGET_SAME_APP,
+ 0
+};
+
#if 0
-static GtkTargetEntry entry = {(char *)"nsgtk_button_data",
- GTK_TARGET_SAME_APP, 0};
+/**
+ * toolbar customisation window context
+ */
+struct nsgtk_toolbar_custom_store {
+ GtkWidget *window;
+ GtkWidget *store_buttons[PLACEHOLDER_BUTTON];
+ GtkWidget *widgetvbox;
+ GtkWidget *currentbar;
+ char numberh; /* current horizontal location while adding */
+ GtkBuilder *builder; /* button widgets to store */
+ int buttonlocations[PLACEHOLDER_BUTTON];
+ int currentbutton;
+ bool fromstore;
+};
+static struct nsgtk_toolbar_custom_store store;
+static struct nsgtk_toolbar_custom_store *window = &store;
/* exported interface documented in gtk/scaffolding.h */
static GtkToolbar *nsgtk_scaffolding_toolbar(struct nsgtk_scaffolding *g)
@@ -844,108 +873,8 @@ static void nsgtk_scaffolding_reset_offset(struct nsgtk_scaffolding *g)
//g->offset = 0;
}
-/**
- * called when a widget is dropped onto the toolbar
- */
-static gboolean
-nsgtk_toolbar_data(GtkWidget *widget,
- GdkDragContext *gdc,
- gint x,
- gint y,
- guint time,
- gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- int ind = gtk_toolbar_get_drop_index(nsgtk_scaffolding_toolbar(g),
- x, y);
- int q, i;
- if (window->currentbutton == -1)
- return TRUE;
- struct nsgtk_theme *theme =
- nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR, false);
- if (theme == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- return TRUE;
- }
- if (nsgtk_scaffolding_button(g, window->currentbutton)->location
- != -1) {
- /* widget was already in the toolbar; so replace */
- if (nsgtk_scaffolding_button(g, window->currentbutton)->
- location < ind)
- ind--;
- gtk_container_remove(GTK_CONTAINER(
- nsgtk_scaffolding_toolbar(g)), GTK_WIDGET(
- nsgtk_scaffolding_button(g,
- window->currentbutton)->button));
- /* 'move' all widgets further right than the original location,
- * one place to the left in logical schema */
- for (i = nsgtk_scaffolding_button(g, window->currentbutton)->
- location + 1; i < PLACEHOLDER_BUTTON; i++) {
- q = nsgtk_toolbar_get_id_at_location(g, i);
- if (q == -1)
- continue;
- nsgtk_scaffolding_button(g, q)->location--;
- }
- nsgtk_scaffolding_button(g, window->currentbutton)->
- location = -1;
- }
- nsgtk_scaffolding_button(g, window->currentbutton)->button =
- GTK_TOOL_ITEM(make_toolbar_item(window->currentbutton, theme));
- free(theme);
- if (nsgtk_scaffolding_button(g, window->currentbutton)->button
- == NULL) {
- nsgtk_warning("NoMemory", 0);
- return TRUE;
- }
- /* update logical schema */
- nsgtk_scaffolding_reset_offset(g);
- /* 'move' all widgets further right than the new location, one place to
- * the right in logical schema */
- for (i = PLACEHOLDER_BUTTON - 1; i >= ind; i--) {
- q = nsgtk_toolbar_get_id_at_location(g, i);
- if (q == -1)
- continue;
- nsgtk_scaffolding_button(g, q)->location++;
- }
- nsgtk_scaffolding_button(g, window->currentbutton)->location = ind;
-
- /* complete action */
- GtkToolItem *current_button;
-
- current_button = GTK_TOOL_ITEM(nsgtk_scaffolding_button(g, window->currentbutton)->button);
-
- gtk_toolbar_insert(nsgtk_scaffolding_toolbar(g), current_button, ind);
-
- gtk_tool_item_set_use_drag_window(current_button, TRUE);
- gtk_drag_source_set(GTK_WIDGET(current_button),
- GDK_BUTTON1_MASK, &entry, 1,
- GDK_ACTION_COPY);
- nsgtk_toolbar_temp_connect(g, window->currentbutton);
- gtk_widget_show_all(GTK_WIDGET(current_button));
- window->currentbutton = -1;
-
- return TRUE;
-}
-
-/**
- * connected to toolbutton drop; perhaps one day it'll work properly so it may
- * replace the global current_button
- */
-static gboolean
-nsgtk_toolbar_move_complete(GtkWidget *widget,
- GdkDragContext *gdc,
- gint x,
- gint y,
- GtkSelectionData *selection,
- guint info,
- guint time,
- gpointer data)
-{
- return FALSE;
-}
-
/**
* called when hovering an item above the toolbar
*/
@@ -964,15 +893,6 @@ nsgtk_toolbar_action(GtkWidget *widget, GdkDragContext *gdc, gint x,
return FALSE;
}
-/**
- * called when hovering stops
- */
-static void
-nsgtk_toolbar_clear(GtkWidget *widget, GdkDragContext *gdc, guint time,
- gpointer data)
-{
- gtk_toolbar_set_drop_highlight_item(GTK_TOOLBAR(widget), NULL, 0);
-}
/**
* add item to toolbar.
@@ -1178,7 +1098,7 @@ static void nsgtk_toolbar_cast(struct nsgtk_scaffolding *g)
/**
* save toolbar settings to file
*/
-static nserror nsgtk_toolbar_customization_save(struct nsgtk_scaffolding *g)
+static nserror nsgtk_toolbar_customisation_save(struct nsgtk_scaffolding *g)
{
char *choices = NULL;
char *order;
@@ -1232,7 +1152,7 @@ static gboolean nsgtk_toolbar_persist(GtkWidget *widget, gpointer data)
edit_mode = false;
/* save state to file, update toolbars for all windows */
- nsgtk_toolbar_customization_save(g);
+ nsgtk_toolbar_customisation_save(g);
nsgtk_toolbar_cast(g);
nsgtk_toolbar_set_physical(g);
nsgtk_toolbar_close(g);
@@ -1440,7 +1360,7 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g)
* All buttons as well as window clicks are desensitized; then buttons
* in the front window are changed to movable buttons
*/
-void nsgtk_toolbar_customization_init(struct nsgtk_scaffolding *g)
+void nsgtk_toolbar_customisation_init(struct nsgtk_scaffolding *g)
{
int i;
struct nsgtk_scaffolding *list;
@@ -1500,15 +1420,21 @@ void nsgtk_toolbar_customization_init(struct nsgtk_scaffolding *g)
/* add move button listeners */
g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
- "drag-drop", G_CALLBACK(nsgtk_toolbar_data), g);
+ "drag-drop",
+ G_CALLBACK(nsgtk_toolbar_data),
+ g);
g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
- "drag-data-received", G_CALLBACK(
- nsgtk_toolbar_move_complete), g);
+ "drag-data-received",
+ G_CALLBACK(nsgtk_toolbar_move_complete),
+ g);
g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
- "drag-motion", G_CALLBACK(nsgtk_toolbar_action), g);
+ "drag-motion",
+ G_CALLBACK(nsgtk_toolbar_action),
+ g);
g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
- "drag-leave", G_CALLBACK(
- nsgtk_toolbar_clear), g);
+ "drag-leave",
+ G_CALLBACK(nsgtk_toolbar_clear),
+ g);
/* set data types */
gtk_drag_dest_set(GTK_WIDGET(nsgtk_scaffolding_toolbar(g)),
@@ -1521,6 +1447,152 @@ void nsgtk_toolbar_customization_init(struct nsgtk_scaffolding *g)
#endif
+/**
+ * called when a widget is dropped onto the toolbar
+ */
+static gboolean
+customisation_toolbar_drag_drop_cb(GtkWidget *widget,
+ GdkDragContext *gdc,
+ gint x,
+ gint y,
+ guint time,
+ gpointer data)
+{
+#if 0
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ int ind = gtk_toolbar_get_drop_index(nsgtk_scaffolding_toolbar(g),
+ x, y);
+ int q, i;
+ if (window->currentbutton == -1)
+ return TRUE;
+ struct nsgtk_theme *theme =
+ nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR, false);
+ if (theme == NULL) {
+ nsgtk_warning(messages_get("NoMemory"), 0);
+ return TRUE;
+ }
+ if (nsgtk_scaffolding_button(g, window->currentbutton)->location
+ != -1) {
+ /* widget was already in the toolbar; so replace */
+ if (nsgtk_scaffolding_button(g, window->currentbutton)->
+ location < ind)
+ ind--;
+ gtk_container_remove(GTK_CONTAINER(
+ nsgtk_scaffolding_toolbar(g)), GTK_WIDGET(
+ nsgtk_scaffolding_button(g,
+ window->currentbutton)->button));
+ /* 'move' all widgets further right than the original location,
+ * one place to the left in logical schema */
+ for (i = nsgtk_scaffolding_button(g, window->currentbutton)->
+ location + 1; i < PLACEHOLDER_BUTTON; i++) {
+ q = nsgtk_toolbar_get_id_at_location(g, i);
+ if (q == -1)
+ continue;
+ nsgtk_scaffolding_button(g, q)->location--;
+ }
+ nsgtk_scaffolding_button(g, window->currentbutton)->
+ location = -1;
+ }
+ nsgtk_scaffolding_button(g, window->currentbutton)->button =
+ GTK_TOOL_ITEM(make_toolbar_item(window->currentbutton, theme));
+ free(theme);
+ if (nsgtk_scaffolding_button(g, window->currentbutton)->button
+ == NULL) {
+ nsgtk_warning("NoMemory", 0);
+ return TRUE;
+ }
+ /* update logical schema */
+ nsgtk_scaffolding_reset_offset(g);
+ /* 'move' all widgets further right than the new location, one place to
+ * the right in logical schema */
+ for (i = PLACEHOLDER_BUTTON - 1; i >= ind; i--) {
+ q = nsgtk_toolbar_get_id_at_location(g, i);
+ if (q == -1)
+ continue;
+ nsgtk_scaffolding_button(g, q)->location++;
+ }
+ nsgtk_scaffolding_button(g, window->currentbutton)->location = ind;
+
+ /* complete action */
+ GtkToolItem *current_button;
+
+ current_button = GTK_TOOL_ITEM(nsgtk_scaffolding_button(g, window->currentbutton)->button);
+
+ gtk_toolbar_insert(nsgtk_scaffolding_toolbar(g), current_button, ind);
+
+ gtk_tool_item_set_use_drag_window(current_button, TRUE);
+ gtk_drag_source_set(GTK_WIDGET(current_button),
+ GDK_BUTTON1_MASK, &entry, 1,
+ GDK_ACTION_COPY);
+ nsgtk_toolbar_temp_connect(g, window->currentbutton);
+ gtk_widget_show_all(GTK_WIDGET(current_button));
+
+
+ window->currentbutton = -1;
+#endif
+ return TRUE;
+}
+
+
+/**
+ * customisation toolbar handler for drag data received signal
+ *
+ * connected to toolbutton drop; perhaps one day it'll work properly
+ * so it may replace the global current_button
+ */
+static gboolean
+customisation_toolbar_drag_data_received_cb(GtkWidget *widget,
+ GdkDragContext *gdc,
+ gint x,
+ gint y,
+ GtkSelectionData *selection,
+ guint info,
+ guint time,
+ gpointer data)
+{
+ return FALSE;
+}
+
+
+/**
+ * customisation toolbar handler for drag motion signal
+ *
+ * called when hovering an item above the toolbar
+ */
+static gboolean
+customisation_toolbar_drag_motion_cb(GtkWidget *widget,
+ GdkDragContext *gdc,
+ gint x,
+ gint y,
+ guint time,
+ gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ GtkToolItem *item;
+ gint position;
+
+ item = gtk_tool_button_new(NULL, NULL);
+ position = gtk_toolbar_get_drop_index(tb->widget, x, y);
+
+ gtk_toolbar_set_drop_highlight_item(tb->widget, item, position);
+
+ return FALSE; /* drag not in drop zone */
+}
+
+
+/**
+ * customisation toolbar handler for drag leave signal
+ *
+ * called when hovering stops
+ */
+static void
+customisation_toolbar_drag_leave_cb(GtkWidget *widget,
+ GdkDragContext *gdc,
+ guint time,
+ gpointer data)
+{
+ gtk_toolbar_set_drop_highlight_item(GTK_TOOLBAR(widget), NULL, 0);
+}
/**
* create a new browser window
@@ -1606,11 +1678,11 @@ void nsgtk_toolbar_connect_all(struct nsgtk_scaffolding *g)
* GTK specific user option string is a set of fields arranged as
* [itemreference];[itemlocation]|[itemreference];[itemlocation]| etc
*
- * \param tb The toolbar to apply customization to
+ * \param tb The toolbar to apply customisation to
* \param NSERROR_OK on success else error code.
*/
static nserror
-apply_user_button_customization(struct nsgtk_toolbar *tb)
+apply_user_button_customisation(struct nsgtk_toolbar *tb)
{
int i, ii;
char *buffer;
@@ -1685,8 +1757,8 @@ add_item_to_toolbar(struct nsgtk_toolbar *tb,
if (tb->buttons[bidx]->location == location) {
- tb->buttons[bidx]->button = GTK_TOOL_ITEM(
- make_toolbar_item(bidx, theme));
+ tb->buttons[bidx]->button = make_toolbar_item(bidx,
+ theme);
/* set widgets initial sensitivity */
gtk_widget_set_sensitive(GTK_WIDGET(tb->buttons[bidx]->button),
@@ -1905,12 +1977,168 @@ nsgtk_saveas_dialog(struct browser_window *bw,
}
+/**
+ * connect all signals to widgets in a customisation
+ */
+static nserror
+toolbar_customisation_connect_signals(struct nsgtk_toolbar *tb)
+{
+ int iidx;
+
+ for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
+ /* skip inactive items in toolbar */
+ if (tb->buttons[iidx]->location == INACTIVE_LOCATION) {
+ continue;
+ }
+
+ /* set toolbar items to be a drag source */
+ gtk_tool_item_set_use_drag_window(tb->buttons[iidx]->button, TRUE);
+ gtk_drag_source_set(GTK_WIDGET(tb->buttons[iidx]->button),
+ GDK_BUTTON1_MASK,
+ &target_entry,
+ 1,
+ GDK_ACTION_COPY);
+ g_signal_connect(tb->buttons[iidx]->button,
+ "drag-data-get",
+ G_CALLBACK(tb->buttons[iidx]->dataminus),
+ tb);
+ }
+
+ /* add move button listeners */
+ g_signal_connect(tb->widget,
+ "drag-drop",
+ G_CALLBACK(customisation_toolbar_drag_drop_cb),
+ tb);
+ g_signal_connect(tb->widget,
+ "drag-data-received",
+ G_CALLBACK(customisation_toolbar_drag_data_received_cb),
+ tb);
+ g_signal_connect(tb->widget,
+ "drag-motion",
+ G_CALLBACK(customisation_toolbar_drag_motion_cb),
+ tb);
+ g_signal_connect(tb->widget,
+ "drag-leave",
+ G_CALLBACK(customisation_toolbar_drag_leave_cb),
+ tb);
+
+ /* set data types */
+ gtk_drag_dest_set(GTK_WIDGET(tb->widget),
+ GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
+ &target_entry,
+ 1,
+ GDK_ACTION_COPY);
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * add a row to a toolbar customisation toolbox
+ *
+ * \param tbc The toolbar customisation context
+ * \param startitem The item index of the beginning of the row
+ * \param enditem The item index of teh beginning of teh next row
+ * \return NSERROR_OK on successs else error
+ */
+static nserror
+add_toolbox_row(struct nsgtk_toolbar_customisation *tbc,
+ int startitem,
+ int enditem)
+{
+ GtkToolbar *rowbar;
+ int iidx;
+
+ rowbar = GTK_TOOLBAR(gtk_toolbar_new());
+ if (rowbar == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ gtk_toolbar_set_style(rowbar, GTK_TOOLBAR_BOTH);
+ gtk_toolbar_set_icon_size(rowbar, GTK_ICON_SIZE_LARGE_TOOLBAR);
+ gtk_box_pack_start(tbc->toolbox, GTK_WIDGET(rowbar), FALSE, FALSE, 0);
+
+ for (iidx = startitem; iidx < enditem; iidx++) {
+ if (tbc->items[iidx] == NULL) {
+ /* skip any widgets that failed to initialise */
+ continue;
+ }
+ gtk_widget_set_size_request(GTK_WIDGET(tbc->items[iidx]),
+ NSGTK_BUTTON_WIDTH,
+ NSGTK_BUTTON_HEIGHT);
+ gtk_tool_item_set_use_drag_window(tbc->items[iidx], TRUE);
+ gtk_drag_source_set(GTK_WIDGET(tbc->items[iidx]),
+ GDK_BUTTON1_MASK,
+ &target_entry,
+ 1,
+ GDK_ACTION_COPY);
+ g_signal_connect(tbc->items[iidx],
+ "drag-data-get",
+ G_CALLBACK(tbc->toolbar.buttons[iidx]->dataplus),
+ &tbc->toolbar);
+ gtk_toolbar_insert(rowbar, tbc->items[iidx], iidx - startitem);
+ }
+ return NSERROR_OK;
+}
+
+
+/**
+ * creates widgets in customisation toolbox
+ *
+ * \param tbc The toolbar customisation context
+ * \param width The width to layout the toolbox to
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+toolbar_customisation_create_toolbox(struct nsgtk_toolbar_customisation *tbc,
+ int width)
+{
+ int columns; /* number of items in a single row */
+ int curcol; /* current column in creation */
+ int iidx; /* item index */
+ int startidx; /* index of item at start of row */
+ struct nsgtk_theme *theme;
+
+ theme = nsgtk_theme_load(GTK_ICON_SIZE_LARGE_TOOLBAR, true);
+ if (theme == NULL) {
+ return NSERROR_NOMEM;
+ }
+
+ /* ensure there are a minimum number of items per row */
+ columns = width / NSGTK_BUTTON_WIDTH;
+ if (columns < NSGTK_STORE_WIDTH) {
+ columns = NSGTK_STORE_WIDTH;
+ }
+
+ edit_mode = true;
+ curcol = 0;
+ for (iidx = startidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
+ if (curcol >= columns) {
+ add_toolbox_row(tbc, startidx, iidx);
+ curcol = 0;
+ startidx = iidx;
+ }
+ tbc->items[iidx] = make_toolbar_item(iidx, theme);
+ if (tbc->items[iidx] != NULL) {
+ curcol++;
+ }
+ }
+ if (curcol > 0) {
+ add_toolbox_row(tbc, startidx, iidx);
+ }
+ edit_mode = false;
+
+ free(theme);
+
+ return NSERROR_OK;
+}
+
/*
* Toolbar button clicked handlers
*/
/**
- * create a toolbar customization tab
+ * create a toolbar customisation tab
*
* this is completely different approach to previous implementation. it
* is not modal and the toolbar configuration is performed completely
@@ -1919,13 +2147,19 @@ nsgtk_saveas_dialog(struct browser_window *bw,
*/
static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
{
- struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
- struct nsgtk_toolbar_customization *tbc;
+ struct nsgtk_toolbar_customisation *tbc;
nserror res;
GtkBuilder *builder;
- GtkNotebook *notebook;
- struct gui_window *gw;
- int bidx;
+ GtkNotebook *notebook; /* notebook containing widget */
+ GtkAllocation notebook_alloc; /* notebook size allocation */
+ int iidx; /* item index */
+
+ /* obtain the notebook being added to */
+ notebook = GTK_NOTEBOOK(gtk_widget_get_ancestor(widget,
+ GTK_TYPE_NOTEBOOK));
+ if (notebook == NULL) {
+ return TRUE;
+ }
/* create builder */
res = nsgtk_builder_new_from_resname("toolbar", &builder);
@@ -1935,11 +2169,11 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
}
gtk_builder_connect_signals(builder, NULL);
- /* create nsgtk_toolbar_customization which has nsgtk_toolbar
+ /* create nsgtk_toolbar_customisation which has nsgtk_toolbar
* at the front so we can reuse functions that take
* nsgtk_toolbar
*/
- tbc = calloc(1, sizeof(struct nsgtk_toolbar_customization));
+ tbc = calloc(1, sizeof(struct nsgtk_toolbar_customisation));
if (tbc == NULL) {
g_object_unref(builder);
return TRUE;
@@ -1948,60 +2182,120 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
/* get container box widget which forms a page of the tabs */
tbc->container = GTK_WIDGET(gtk_builder_get_object(builder, "tabBox"));
if (tbc->container == NULL) {
- free(tbc);
- g_object_unref(builder);
- return TRUE;
+ goto cutomize_button_clicked_cb_error;
}
- /* get toolbar widget from builder */
+ /* vertical box for the toolbox to drag items into and out of */
+ tbc->toolbox = GTK_BOX(gtk_builder_get_object(builder, "toolbox"));
+ if (tbc->toolbox == NULL) {
+ goto cutomize_button_clicked_cb_error;
+ }
+ /* customisation toolbar container */
tbc->toolbar.widget = GTK_TOOLBAR(gtk_builder_get_object(builder, "toolbar"));
+ if (tbc->toolbar.widget == NULL) {
+ goto cutomize_button_clicked_cb_error;
+ }
+
+ /* build customisation toolbar */
gtk_toolbar_set_show_arrow(tbc->toolbar.widget, TRUE);
- /* populate toolbar widget in edit mode */
- for (bidx = BACK_BUTTON; bidx < PLACEHOLDER_BUTTON; bidx++) {
- res = toolbar_item_create(bidx, &tbc->toolbar.buttons[bidx]);
+ for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
+ res = toolbar_item_create(iidx, &tbc->toolbar.buttons[iidx]);
if (res != NSERROR_OK) {
- for (bidx-- ; bidx >= BACK_BUTTON; bidx--) {
- free(tbc->toolbar.buttons[bidx]);
+ for (iidx-- ; iidx >= BACK_BUTTON; iidx--) {
+ free(tbc->toolbar.buttons[iidx]);
}
- free(tbc);
- return res;
+ goto cutomize_button_clicked_cb_error;
}
}
- res = apply_user_button_customization(&tbc->toolbar);
+ res = apply_user_button_customisation(&tbc->toolbar);
if (res != NSERROR_OK) {
- free(tbc);
- return res;
+ goto cutomize_button_clicked_cb_error;
}
- edit_mode = true;
+ /* populate toolbar widget */
res = populate_gtk_toolbar_widget(&tbc->toolbar);
- edit_mode = false;
if (res != NSERROR_OK) {
- free(tbc);
- return res;
+ goto cutomize_button_clicked_cb_error;
}
+ /* ensure icon sizes and text labels on toolbar are set */
res = nsgtk_toolbar_update(&tbc->toolbar);
if (res != NSERROR_OK) {
- free(tbc);
- return res;
+ goto cutomize_button_clicked_cb_error;
}
- gtk_widget_show_all(GTK_WIDGET(tbc->toolbar.widget));
-
/* attach handlers to toolbar widgets */
+ res = toolbar_customisation_connect_signals(&tbc->toolbar);
+ if (res != NSERROR_OK) {
+ goto cutomize_button_clicked_cb_error;
+ }
+
+ if (tbc->toolbar.buttons[URL_BAR_ITEM]->location != INACTIVE_LOCATION) {
+ GtkEntry *entry;
+ entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tbc->toolbar.buttons[URL_BAR_ITEM]->button)));
+
+ gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
+ }
+
+ if (tbc->toolbar.buttons[WEBSEARCH_ITEM]->location != INACTIVE_LOCATION) {
+ GtkEntry *entry;
+ entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tbc->toolbar.buttons[WEBSEARCH_ITEM]->button)));
+
+ gtk_widget_set_sensitive(GTK_WIDGET(entry), FALSE);
+ }
+
+ /* use toolbox for widgets to drag to/from */
+
+ gtk_widget_get_allocation(GTK_WIDGET(notebook), ¬ebook_alloc);
+
+ res = toolbar_customisation_create_toolbox(tbc, notebook_alloc.width);
+ if (res != NSERROR_OK) {
+ goto cutomize_button_clicked_cb_error;
+ }
+
- /* use layout box for widgets to drag to/from */
/* save and update on apply button then discard */
/* discard button causes destruction */
/* close and cleanup on destroy signal */
+ /* configure the container */
+ gtk_window_set_accept_focus(GTK_WINDOW(tbc->container), FALSE);
+
+ gtk_drag_dest_set(GTK_WIDGET(tbc->container),
+ GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP,
+ &target_entry,
+ 1,
+ GDK_ACTION_COPY);
+#if 0
+ g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "close")),
+ "clicked",
+ G_CALLBACK(nsgtk_toolbar_persist),
+ g);
+
+ g_signal_connect(GTK_WIDGET(gtk_builder_get_object(builder, "reset")),
+ "clicked",
+ G_CALLBACK(nsgtk_toolbar_reset),
+ g);
+
+ g_signal_connect(tbc->container,
+ "delete-event",
+ G_CALLBACK(nsgtk_toolbar_delete),
+ g);
+
+ g_signal_connect(tbc->container,
+ "drag-drop",
+ G_CALLBACK(nsgtk_toolbar_store_return),
+ g);
+
+ g_signal_connect(tbc->container,
+ "drag-motion",
+ G_CALLBACK(nsgtk_toolbar_store_action),
+ g);
+#endif
- gw = tb->get_ctx; /** \todo stop assuming the context is a gui window */
- notebook = nsgtk_scaffolding_notebook(nsgtk_get_scaffold(gw));
nsgtk_tab_add_page(notebook,
tbc->container,
@@ -2009,12 +2303,19 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
messages_get("gtkCustomizeToolbarTitle"),
favicon_pixbuf);
+
/* safe to drop the reference to the builder as the container is
* referenced by the notebook now.
*/
g_object_unref(builder);
return TRUE;
+
+ cutomize_button_clicked_cb_error:
+ free(tbc);
+ g_object_unref(builder);
+ return TRUE;
+
}
@@ -3607,6 +3908,7 @@ static nserror toolbar_connect_signals(struct nsgtk_toolbar *tb)
return NSERROR_OK;
}
+
/**
* signal handler for toolbar context menu
*
@@ -3678,7 +3980,7 @@ nsgtk_toolbar_create(GtkBuilder *builder,
}
}
- res = apply_user_button_customization(tb);
+ res = apply_user_button_customisation(tb);
if (res != NSERROR_OK) {
free(tb);
return res;
@@ -3696,14 +3998,6 @@ nsgtk_toolbar_create(GtkBuilder *builder,
return res;
}
- gtk_widget_show_all(GTK_WIDGET(tb->widget));
-
- /* if there is a history widget set its size */
- if (tb->buttons[HISTORY_BUTTON]->button != NULL) {
- gtk_widget_set_size_request(GTK_WIDGET(
- tb->buttons[HISTORY_BUTTON]->button), 20, -1);
- }
-
res = toolbar_connect_signals(tb);
if (res != NSERROR_OK) {
free(tb);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=778c05a1949b61fbe37...
commit 778c05a1949b61fbe37b06313e5b1e3c0f05f7e4
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
populate customize window toolbar
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 04a0204..f104606 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -212,6 +212,7 @@ struct nsgtk_theme {
/* forward declaration */
void nsgtk_toolbar_connect_all(struct nsgtk_scaffolding *g);
int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, struct nsgtk_scaffolding *g);
+static nserror toolbar_item_create(nsgtk_toolbar_button id, struct nsgtk_toolbar_item **item_out);
/* define data plus and data minus handlers */
@@ -1520,75 +1521,6 @@ void nsgtk_toolbar_customization_init(struct nsgtk_scaffolding *g)
#endif
-/**
- * create a toolbar customization tab
- *
- * this is completely different approach to previous implementation. it
- * is not modal and the toolbar configuration is performed completely
- * within the tab. once the user is happy they can apply the change or
- * cancel as they see fit while continuing to use the browser as usual.
- */
-static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
-{
- struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
- struct nsgtk_toolbar_customization *tbc;
- nserror res;
- GtkBuilder *builder;
- GtkNotebook *notebook;
- struct gui_window *gw;
-
- /* create builder */
- res = nsgtk_builder_new_from_resname("toolbar", &builder);
- if (res != NSERROR_OK) {
- NSLOG(netsurf, INFO, "Toolbar UI builder init failed");
- return TRUE;
- }
- gtk_builder_connect_signals(builder, NULL);
-
- /* create nsgtk_toolbar_customization which has nsgtk_toolbar
- * at the front so we can reuse functions that take
- * nsgtk_toolbar
- */
- tbc = calloc(1, sizeof(struct nsgtk_toolbar_customization));
- if (tbc == NULL) {
- g_object_unref(builder);
- return TRUE;
- }
-
- /* get container box widget which forms a page of the tabs */
- tbc->container = GTK_WIDGET(gtk_builder_get_object(builder, "tabBox"));
- if (tbc->container == NULL) {
- free(tbc);
- g_object_unref(builder);
- NSLOG(netsurf, ERROR, "dammit");
- return TRUE;
- }
-
- /* get toolbar widget from builder */
- /* populate toolbar widget in edit mode */
- /* attach handlers to widgets */
- /* use layout box for widgets to drag to/from */
- /* save and update on apply button then discard */
- /* discard button causes destruction */
- /* close and cleanup on destroy signal */
-
-
- gw = tb->get_ctx; /** \todo stop assuming the context is a gui window */
- notebook = nsgtk_scaffolding_notebook(nsgtk_get_scaffold(gw));
-
- nsgtk_tab_add_page(notebook,
- tbc->container,
- false,
- messages_get("gtkCustomizeToolbarTitle"),
- favicon_pixbuf);
-
- /* safe to drop the reference to the builder as the container is
- * referenced by the notebook now.
- */
- g_object_unref(builder);
-
- return TRUE;
-}
/**
* create a new browser window
@@ -1978,6 +1910,115 @@ nsgtk_saveas_dialog(struct browser_window *bw,
*/
/**
+ * create a toolbar customization tab
+ *
+ * this is completely different approach to previous implementation. it
+ * is not modal and the toolbar configuration is performed completely
+ * within the tab. once the user is happy they can apply the change or
+ * cancel as they see fit while continuing to use the browser as usual.
+ */
+static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct nsgtk_toolbar_customization *tbc;
+ nserror res;
+ GtkBuilder *builder;
+ GtkNotebook *notebook;
+ struct gui_window *gw;
+ int bidx;
+
+ /* create builder */
+ res = nsgtk_builder_new_from_resname("toolbar", &builder);
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, INFO, "Toolbar UI builder init failed");
+ return TRUE;
+ }
+ gtk_builder_connect_signals(builder, NULL);
+
+ /* create nsgtk_toolbar_customization which has nsgtk_toolbar
+ * at the front so we can reuse functions that take
+ * nsgtk_toolbar
+ */
+ tbc = calloc(1, sizeof(struct nsgtk_toolbar_customization));
+ if (tbc == NULL) {
+ g_object_unref(builder);
+ return TRUE;
+ }
+
+ /* get container box widget which forms a page of the tabs */
+ tbc->container = GTK_WIDGET(gtk_builder_get_object(builder, "tabBox"));
+ if (tbc->container == NULL) {
+ free(tbc);
+ g_object_unref(builder);
+ return TRUE;
+ }
+
+ /* get toolbar widget from builder */
+
+ tbc->toolbar.widget = GTK_TOOLBAR(gtk_builder_get_object(builder, "toolbar"));
+ gtk_toolbar_set_show_arrow(tbc->toolbar.widget, TRUE);
+
+ /* populate toolbar widget in edit mode */
+ for (bidx = BACK_BUTTON; bidx < PLACEHOLDER_BUTTON; bidx++) {
+ res = toolbar_item_create(bidx, &tbc->toolbar.buttons[bidx]);
+ if (res != NSERROR_OK) {
+ for (bidx-- ; bidx >= BACK_BUTTON; bidx--) {
+ free(tbc->toolbar.buttons[bidx]);
+ }
+ free(tbc);
+ return res;
+ }
+ }
+
+ res = apply_user_button_customization(&tbc->toolbar);
+ if (res != NSERROR_OK) {
+ free(tbc);
+ return res;
+ }
+
+ edit_mode = true;
+ res = populate_gtk_toolbar_widget(&tbc->toolbar);
+ edit_mode = false;
+ if (res != NSERROR_OK) {
+ free(tbc);
+ return res;
+ }
+
+ res = nsgtk_toolbar_update(&tbc->toolbar);
+ if (res != NSERROR_OK) {
+ free(tbc);
+ return res;
+ }
+
+ gtk_widget_show_all(GTK_WIDGET(tbc->toolbar.widget));
+
+ /* attach handlers to toolbar widgets */
+
+ /* use layout box for widgets to drag to/from */
+ /* save and update on apply button then discard */
+ /* discard button causes destruction */
+ /* close and cleanup on destroy signal */
+
+
+ gw = tb->get_ctx; /** \todo stop assuming the context is a gui window */
+ notebook = nsgtk_scaffolding_notebook(nsgtk_get_scaffold(gw));
+
+ nsgtk_tab_add_page(notebook,
+ tbc->container,
+ false,
+ messages_get("gtkCustomizeToolbarTitle"),
+ favicon_pixbuf);
+
+ /* safe to drop the reference to the builder as the container is
+ * referenced by the notebook now.
+ */
+ g_object_unref(builder);
+
+ return TRUE;
+}
+
+
+/**
* callback for all toolbar items widget size allocation
*
* handler connected to all toolbar items for the size-allocate signal
@@ -3375,6 +3416,7 @@ static gboolean openmenu_button_clicked_cb(GtkWidget *widget, gpointer data)
return TRUE;
}
+
/**
* create a toolbar item
*
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=608cc3cbbfae2749826...
commit 608cc3cbbfae27498268442aa31ef791894e0789
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
make handling of non browser window containing tabs reasonable
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 8712dcd..6ace032 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -1191,16 +1191,6 @@ static nserror nsgtk_search_connect_signals(struct nsgtk_scaffolding *gs)
}
-/* exported interface documented in gtk/scaffolding.h */
-struct nsgtk_scaffolding *nsgtk_current_scaffolding(void)
-{
- if (scaf_current == NULL) {
- scaf_current = scaf_list;
- }
- return scaf_current;
-}
-
-
/* exported function documented in gtk/scaffolding.h */
void nsgtk_scaffolding_set_title(struct gui_window *gw, const char *title)
{
@@ -1297,9 +1287,12 @@ struct gtk_search *nsgtk_scaffolding_search(struct nsgtk_scaffolding *g)
}
/* exported interface documented in gtk/scaffolding.h */
-GtkMenuBar *nsgtk_scaffolding_menu_bar(struct nsgtk_scaffolding *g)
+GtkMenuBar *nsgtk_scaffolding_menu_bar(struct nsgtk_scaffolding *gs)
{
- return g->menu_bar->bar_menu;
+ if (gs == NULL) {
+ return NULL;
+ }
+ return gs->menu_bar->bar_menu;
}
/* exported interface documented in gtk/scaffolding.h */
@@ -1354,6 +1347,8 @@ void nsgtk_scaffolding_set_top_level(struct gui_window *gw)
sc = nsgtk_get_scaffold(gw);
assert(sc != NULL);
+ scaf_current = sc;
+
sc->top_level = gw;
/* Synchronise the history (will also update the URL bar) */
@@ -1463,6 +1458,28 @@ nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g,
nsgtk_menu_popup_at_pointer(gtkmenu, NULL);
}
+/* exported interface documented in gtk/scaffolding.h */
+struct nsgtk_scaffolding *nsgtk_current_scaffolding(void)
+{
+ if (scaf_current == NULL) {
+ scaf_current = scaf_list;
+ }
+ return scaf_current;
+}
+
+/* exported interface documented in gtk/scaffolding.h */
+struct nsgtk_scaffolding *nsgtk_scaffolding_from_notebook(GtkNotebook *notebook)
+{
+ struct nsgtk_scaffolding *gs;
+ gs = scaf_list;
+ while (gs != NULL) {
+ if (gs->notebook == notebook) {
+ break;
+ }
+ gs = gs->next;
+ }
+ return gs;
+}
/* exported interface documented in gtk/scaffolding.h */
struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index 42ae6b6..28fa6ec 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -153,5 +153,12 @@ void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g, gdouble x, gdou
*/
void nsgtk_scaffolding_set_title(struct gui_window *gw, const char *title);
+/**
+ * find which scaffolding contains a gtk notebook
+ *
+ * \param notebook The notebook to search for.
+ * \return The scaffolding containing the notebook or NULL if not found
+ */
+struct nsgtk_scaffolding *nsgtk_scaffolding_from_notebook(GtkNotebook *notebook);
#endif /* NETSURF_GTK_SCAFFOLDING_H */
diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c
index 18dec61..b9e6dad 100644
--- a/frontends/gtk/tabs.c
+++ b/frontends/gtk/tabs.c
@@ -173,37 +173,50 @@ nsgtk_tab_switch_page_after(GtkNotebook *notebook,
{
GtkWidget *srcpage;
GtkWidget *addpage;
- struct gui_window *gw;
- nserror error;
+ GtkMenuBar *menubar;
+ struct gui_window *gw = NULL;
+ nserror res = NSERROR_INVALID;
addpage = g_object_get_data(G_OBJECT(notebook), "addtab");
- if (selpage == addpage) {
- if ((srcpagenum != -1) &&
- (srcpagenum != (gint)selpagenum)) {
- /* ensure the add tab is not actually selected */
- NSLOG(netsurf, INFO, "src %d sel %d", srcpagenum,
- selpagenum);
- srcpage = gtk_notebook_get_nth_page(notebook, srcpagenum);
- gw = g_object_get_data(G_OBJECT(srcpage), "gui_window");
- if ((gw != NULL) && (nsgtk_get_scaffold(gw) != NULL)) {
- error = nsgtk_window_item_activate(gw, NEWTAB_BUTTON);
- if (error != NSERROR_OK) {
- NSLOG(netsurf, INFO,
- "Failed to open new tab.");
- }
- }
- }
- } else {
+ /* check if trying to select the "add page" tab */
+ if (selpage != addpage) {
NSLOG(netsurf, INFO, "sel %d", selpagenum);
- /* tab with page in it */
+ menubar = nsgtk_scaffolding_menu_bar(nsgtk_scaffolding_from_notebook(notebook));
gw = g_object_get_data(G_OBJECT(selpage), "gui_window");
if (gw != NULL) {
+ /* tab with web page in it */
nsgtk_scaffolding_set_top_level(gw);
+ gtk_widget_show(GTK_WIDGET(addpage));
+ gtk_widget_set_sensitive(GTK_WIDGET(menubar), true);
+ } else {
+ /* tab with non browser content (e.g. tb customize) */
+ gtk_widget_hide(GTK_WIDGET(addpage));
+ gtk_widget_set_sensitive(GTK_WIDGET(menubar), false);
}
+ return;
+ }
+
+ NSLOG(netsurf, INFO, "src %d sel %d", srcpagenum, selpagenum);
+
+ /* ensure the add tab is not already selected */
+ if ((srcpagenum == -1) || (srcpagenum == (gint)selpagenum)) {
+ return;
+ }
+
+ srcpage = gtk_notebook_get_nth_page(notebook, srcpagenum);
+
+ gw = g_object_get_data(G_OBJECT(srcpage), "gui_window");
+
+ if (gw != NULL) {
+ res = nsgtk_window_item_activate(gw, NEWTAB_BUTTON);
+ }
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, INFO, "Failed to open new tab.");
}
}
+
/**
* The tab reordered gtk signal handler
*
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=747f135de5785e2a43f...
commit 747f135de5785e2a43ff4b27e07559d3aacd3377
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
make new browser window creation logic common
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 339263b..04a0204 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -1518,6 +1518,8 @@ void nsgtk_toolbar_customization_init(struct nsgtk_scaffolding *g)
nsgtk_toolbar_window_open(g);
}
#endif
+
+
/**
* create a toolbar customization tab
*
@@ -1589,6 +1591,49 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
}
/**
+ * create a new browser window
+ *
+ * creates a browser window with default url depending on user choices.
+ *
+ * \param bw The browser window to pass for existing window/
+ * \param intab true if the new window should be in a tab else false
+ * for new window.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+nsgtk_browser_window_create(struct browser_window *bw, bool intab)
+{
+ nserror res = NSERROR_OK;
+ nsurl *url = NULL;
+ int flags = BW_CREATE_HISTORY;
+
+ if (intab) {
+ flags |= BW_CREATE_TAB;
+ }
+
+ if (!nsoption_bool(new_blank)) {
+ const char *addr;
+ if (nsoption_charp(homepage_url) != NULL) {
+ addr = nsoption_charp(homepage_url);
+ } else {
+ addr = NETSURF_HOMEPAGE;
+ }
+ res = nsurl_create(addr, &url);
+ }
+
+ if (res == NSERROR_OK) {
+ res = browser_window_create(flags, url, NULL, bw, NULL);
+ }
+
+ if (url != NULL) {
+ nsurl_unref(url);
+ }
+
+ return res;
+}
+
+
+/**
* \return toolbar item id when a widget is an element of the scaffolding
* else -1
*/
@@ -2245,26 +2290,8 @@ newwindow_button_clicked_cb(GtkWidget *widget, gpointer data)
{
nserror res;
struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
- struct browser_window *bw;
- const char *addr;
- nsurl *url;
-
- if (nsoption_charp(homepage_url) != NULL) {
- addr = nsoption_charp(homepage_url);
- } else {
- addr = NETSURF_HOMEPAGE;
- }
- res = nsurl_create(addr, &url);
- if (res == NSERROR_OK) {
- bw = tb->get_bw(tb->get_ctx);
- res = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- bw,
- NULL);
- nsurl_unref(url);
- }
+ res = nsgtk_browser_window_create(tb->get_bw(tb->get_ctx), false);
if (res != NSERROR_OK) {
nsgtk_warning(messages_get_errorcode(res), 0);
}
@@ -2283,34 +2310,10 @@ newwindow_button_clicked_cb(GtkWidget *widget, gpointer data)
static gboolean
newtab_button_clicked_cb(GtkWidget *widget, gpointer data)
{
- nserror res = NSERROR_OK;
- nsurl *url = NULL;
+ nserror res;
struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
- struct browser_window *bw;
- if (!nsoption_bool(new_blank)) {
- const char *addr;
- if (nsoption_charp(homepage_url) != NULL) {
- addr = nsoption_charp(homepage_url);
- } else {
- addr = NETSURF_HOMEPAGE;
- }
- res = nsurl_create(addr, &url);
- }
-
- if (res == NSERROR_OK) {
- bw = tb->get_bw(tb->get_ctx);
-
- res = browser_window_create(BW_CREATE_HISTORY |
- BW_CREATE_TAB,
- url,
- NULL,
- bw,
- NULL);
- }
- if (url != NULL) {
- nsurl_unref(url);
- }
+ res = nsgtk_browser_window_create(tb->get_bw(tb->get_ctx), true);
if (res != NSERROR_OK) {
nsgtk_warning(messages_get_errorcode(res), 0);
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=fc4ad51a66785979280...
commit fc4ad51a66785979280b0609a39a3051dbc7d4a0
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
fix both gtk2 and 3 toolbar ui builder files
diff --git a/frontends/gtk/res/toolbar.gtk2.ui b/frontends/gtk/res/toolbar.gtk2.ui
index 4e8805a..cb5e9eb 100644
--- a/frontends/gtk/res/toolbar.gtk2.ui
+++ b/frontends/gtk/res/toolbar.gtk2.ui
@@ -169,4 +169,87 @@
<action-widget response="0">close</action-widget>
</action-widgets>
</object>
+ <object class="GtkVBox" id="tabBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkToolbar" id="toolbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkViewport" id="viewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox" id="hbuttonbox1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="resetdefault">
+ <property name="label" translatable="yes">Reset to defaults</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="discard">
+ <property name="label">gtk-discard</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="apply">
+ <property name="label">gtk-apply</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">6</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
</interface>
diff --git a/frontends/gtk/res/toolbar.gtk3.ui b/frontends/gtk/res/toolbar.gtk3.ui
index b9eee2c..0b0f087 100644
--- a/frontends/gtk/res/toolbar.gtk3.ui
+++ b/frontends/gtk/res/toolbar.gtk3.ui
@@ -169,7 +169,7 @@
<property name="can_focus">False</property>
<property name="layout_style">end</property>
<child>
- <object class="GtkButton" id="rese">
+ <object class="GtkButton" id="resetdefault">
<property name="label" translatable="yes">Reset</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
@@ -212,7 +212,8 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
+ <property name="fill">False</property>
+ <property name="padding">6</property>
<property name="position">2</property>
</packing>
</child>
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c7c89daff3f04d2ccc7...
commit c7c89daff3f04d2ccc78905c128e7dfa938543d4
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
allow toolbar customisation to open a tab
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index a2c3a7d..8712dcd 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -1202,23 +1202,19 @@ struct nsgtk_scaffolding *nsgtk_current_scaffolding(void)
/* exported function documented in gtk/scaffolding.h */
-void nsgtk_window_set_title(struct gui_window *gw, const char *title)
+void nsgtk_scaffolding_set_title(struct gui_window *gw, const char *title)
{
struct nsgtk_scaffolding *gs = nsgtk_get_scaffold(gw);
int title_len;
char *newtitle;
- if ((title == NULL) || (title[0] == '\0')) {
- if (gs->top_level != gw) {
- gtk_window_set_title(gs->window, "NetSurf");
- }
+ /* only set window title if top level window */
+ if (gs->top_level != gw) {
return;
}
- nsgtk_tab_set_title(gw, title);
-
- if (gs->top_level != gw) {
- /* not top level window so do not set window title */
+ if (title == NULL || title[0] == '\0') {
+ gtk_window_set_title(gs->window, "NetSurf");
return;
}
@@ -1233,6 +1229,7 @@ void nsgtk_window_set_title(struct gui_window *gw, const char *title)
gtk_window_set_title(gs->window, newtitle);
free(newtitle);
+
}
@@ -1366,7 +1363,7 @@ void nsgtk_scaffolding_set_top_level(struct gui_window *gw)
browser_window_search_clear(bw);
/* Ensure the window's title bar is updated */
- nsgtk_window_set_title(gw, browser_window_get_title(bw));
+ nsgtk_scaffolding_set_title(gw, browser_window_get_title(bw));
}
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index 89212a3..42ae6b6 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -145,14 +145,13 @@ void nsgtk_scaffolding_set_sensitivity(struct nsgtk_scaffolding *g);
*/
void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g, gdouble x, gdouble y);
-/* core acessors */
/**
* set the title in the window
*
* \param gw The gui window to set title on
* \param title The title to set which may be NULL
*/
-void nsgtk_window_set_title(struct gui_window *gw, const char *title);
+void nsgtk_scaffolding_set_title(struct gui_window *gw, const char *title);
#endif /* NETSURF_GTK_SCAFFOLDING_H */
diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c
index bb4135f..18dec61 100644
--- a/frontends/gtk/tabs.c
+++ b/frontends/gtk/tabs.c
@@ -73,9 +73,13 @@ nsgtk_tab_update_size(GtkWidget *hbox,
/**
* Create a notebook tab label
+ *
+ * \param page The page content widget
+ * \param title The title of the page
+ * \param icon_pixbuf The icon of the page
*/
static GtkWidget *
-nsgtk_tab_label_setup(struct gui_window *window,
+nsgtk_tab_label_setup(GtkWidget *page,
const char *title,
GdkPixbuf *icon_pixbuf)
{
@@ -108,10 +112,13 @@ nsgtk_tab_label_setup(struct gui_window *window,
gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
gtk_widget_set_tooltip_text(button, "Close this tab.");
- g_signal_connect_swapped(button, "clicked",
- G_CALLBACK(nsgtk_window_destroy_browser), window);
- g_signal_connect(hbox, "style-set",
- G_CALLBACK(nsgtk_tab_update_size), button);
+ g_signal_connect_swapped(button,
+ "clicked",
+ G_CALLBACK(gtk_widget_destroy), page);
+ g_signal_connect(hbox,
+ "style-set",
+ G_CALLBACK(nsgtk_tab_update_size),
+ button);
/* pack the widgets into the label box */
gtk_box_pack_start(GTK_BOX(hbox), favicon, FALSE, FALSE, 0);
@@ -355,25 +362,19 @@ nserror nsgtk_notebook_create(GtkBuilder *builder, GtkNotebook **notebook_out)
}
/* exported interface documented in gtk/tabs.h */
-void nsgtk_tab_add(struct gui_window *gw,
+nserror
+nsgtk_tab_add_page(GtkNotebook *notebook,
GtkWidget *tab_contents,
bool background,
const char *title,
GdkPixbuf *icon_pixbuf)
{
- GtkNotebook *notebook;
GtkWidget *tabBox;
gint remember;
gint pages;
gint newpage;
- g_object_set_data(G_OBJECT(tab_contents), "gui_window", gw);
-
- notebook = nsgtk_scaffolding_notebook(nsgtk_get_scaffold(gw));
-
- tabBox = nsgtk_tab_label_setup(gw, title, icon_pixbuf);
-
- nsgtk_window_set_tab(gw, tabBox);
+ tabBox = nsgtk_tab_label_setup(tab_contents, title, icon_pixbuf);
remember = gtk_notebook_get_current_page(notebook);
@@ -391,48 +392,85 @@ void nsgtk_tab_add(struct gui_window *gw,
gtk_notebook_set_current_page(notebook, newpage);
}
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in gtk/tabs.h */
+void nsgtk_tab_add(struct gui_window *gw,
+ GtkWidget *tab_contents,
+ bool background,
+ const char *title,
+ GdkPixbuf *icon_pixbuf)
+{
+ GtkNotebook *notebook;
+
+ g_object_set_data(G_OBJECT(tab_contents), "gui_window", gw);
+
+ notebook = nsgtk_scaffolding_notebook(nsgtk_get_scaffold(gw));
+
+ nsgtk_tab_add_page(notebook, tab_contents, background, title, icon_pixbuf);
+
gtk_widget_grab_focus(GTK_WIDGET(nsgtk_scaffolding_urlbar(
nsgtk_get_scaffold(gw))));
}
/* exported interface documented in gtk/tabs.h */
-nserror nsgtk_tab_set_icon(struct gui_window *gw, GdkPixbuf *pixbuf)
+nserror nsgtk_tab_set_icon(GtkWidget *page, GdkPixbuf *pixbuf)
{
- GtkWidget *favicon;
- GtkWidget *tab;
+ GtkImage *favicon;
+ GtkWidget *tab_label;
+ GtkNotebook *notebook;
if (pixbuf == NULL) {
return NSERROR_INVALID;
}
+ notebook = GTK_NOTEBOOK(gtk_widget_get_ancestor(page, GTK_TYPE_NOTEBOOK));
+ if (notebook == NULL) {
+ return NSERROR_BAD_PARAMETER;
+ }
- tab = nsgtk_window_get_tab(gw);
- if (tab == NULL) {
+ tab_label = gtk_notebook_get_tab_label(notebook, page);
+ if (tab_label == NULL) {
return NSERROR_INVALID;
}
- favicon = g_object_get_data(G_OBJECT(tab), "favicon");
+ favicon = GTK_IMAGE(g_object_get_data(G_OBJECT(tab_label), "favicon"));
- gtk_image_set_from_pixbuf(GTK_IMAGE(favicon), pixbuf);
+ gtk_image_set_from_pixbuf(favicon, pixbuf);
return NSERROR_OK;
}
/* exported interface documented in gtk/tabs.h */
-void nsgtk_tab_set_title(struct gui_window *g, const char *title)
+nserror nsgtk_tab_set_title(GtkWidget *page, const char *title)
{
- GtkWidget *label;
- GtkWidget *tab;
+ GtkLabel *label;
+ GtkWidget *tab_label;
+ GtkNotebook *notebook;
- tab = nsgtk_window_get_tab(g);
- if (tab == NULL) {
- return;
+ if (title == NULL) {
+ return NSERROR_INVALID;
+ }
+
+ notebook = GTK_NOTEBOOK(gtk_widget_get_ancestor(page, GTK_TYPE_NOTEBOOK));
+ if (notebook == NULL) {
+ return NSERROR_BAD_PARAMETER;
}
- label = g_object_get_data(G_OBJECT(tab), "label");
- gtk_label_set_text(GTK_LABEL(label), title);
- gtk_widget_set_tooltip_text(tab, title);
+ tab_label = gtk_notebook_get_tab_label(notebook, page);
+ if (tab_label == NULL) {
+ return NSERROR_INVALID;
+ }
+
+ label = GTK_LABEL(g_object_get_data(G_OBJECT(tab_label), "label"));
+
+ gtk_label_set_text(label, title);
+ gtk_widget_set_tooltip_text(tab_label, title);
+
+ return NSERROR_OK;
}
/* exported interface documented in gtk/tabs.h */
diff --git a/frontends/gtk/tabs.h b/frontends/gtk/tabs.h
index acec396..63edae3 100644
--- a/frontends/gtk/tabs.h
+++ b/frontends/gtk/tabs.h
@@ -34,32 +34,39 @@ struct gui_window;
nserror nsgtk_notebook_create(GtkBuilder *builder, GtkNotebook **notebook_out);
/**
- * Add new tab to notebook.
+ * Add new gui window page to notebook.
*/
void nsgtk_tab_add(struct gui_window *window, GtkWidget *tab_contents, bool background, const char *title, GdkPixbuf *icon_pixbuf);
/**
+ * Add new page to a notebook
+ */
+nserror nsgtk_tab_add_page(GtkNotebook *notebook, GtkWidget *tab_contents, bool background, const char *title, GdkPixbuf *icon_pixbuf);
+
+
+/**
* set the tab title
*
* The tab title will be set to the parameter
*
* \note currently only called from nsgtk_window_set_title()
*
- * \param g the gui window to set tab title for.
+ * \param page The page widget that was added to the notebook
* \param title The title text which may not be NULL.
+ * \return NSERROR_OK on sucess else appropriate code.
*/
-void nsgtk_tab_set_title(struct gui_window *g, const char *title);
+nserror nsgtk_tab_set_title(GtkWidget *page, const char *title);
/**
* set the tab icon
*
* The tab icon will be set to the \a pixbuf parameter
*
- * \param gw The gui window to set teh tab icon for.
+ * \param page The page widget that was added to the notebook
* \param pixbuf The pixbuf to set the icon to.
* \return NSERROR_OK on sucess else appropriate code.
*/
-nserror nsgtk_tab_set_icon(struct gui_window *gw, GdkPixbuf *pixbuf);
+nserror nsgtk_tab_set_icon(GtkWidget *page, GdkPixbuf *pixbuf);
void nsgtk_tab_options_changed(GtkNotebook *notebook);
nserror nsgtk_tab_close_current(GtkNotebook *notebook);
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index dadddc2..339263b 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -148,9 +148,10 @@ struct nsgtk_toolbar_customization {
struct nsgtk_toolbar toolbar;
/**
- * toolbar gtk builder
+ * The top level container (tabBox)
*/
- GtkBuilder *builder;
+ GtkWidget *container;
+
};
/**
@@ -1530,16 +1531,34 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
struct nsgtk_toolbar_customization *tbc;
nserror res;
+ GtkBuilder *builder;
+ GtkNotebook *notebook;
+ struct gui_window *gw;
+
+ /* create builder */
+ res = nsgtk_builder_new_from_resname("toolbar", &builder);
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, INFO, "Toolbar UI builder init failed");
+ return TRUE;
+ }
+ gtk_builder_connect_signals(builder, NULL);
+
/* create nsgtk_toolbar_customization which has nsgtk_toolbar
* at the front so we can reuse functions that take
* nsgtk_toolbar
*/
tbc = calloc(1, sizeof(struct nsgtk_toolbar_customization));
+ if (tbc == NULL) {
+ g_object_unref(builder);
+ return TRUE;
+ }
- /* create builder*/
- res = nsgtk_builder_new_from_resname("toolbar", &tbc->builder);
- if (res != NSERROR_OK) {
- NSLOG(netsurf, INFO, "Toolbar UI builder init failed");
+ /* get container box widget which forms a page of the tabs */
+ tbc->container = GTK_WIDGET(gtk_builder_get_object(builder, "tabBox"));
+ if (tbc->container == NULL) {
+ free(tbc);
+ g_object_unref(builder);
+ NSLOG(netsurf, ERROR, "dammit");
return TRUE;
}
@@ -1550,6 +1569,22 @@ static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
/* save and update on apply button then discard */
/* discard button causes destruction */
/* close and cleanup on destroy signal */
+
+
+ gw = tb->get_ctx; /** \todo stop assuming the context is a gui window */
+ notebook = nsgtk_scaffolding_notebook(nsgtk_get_scaffold(gw));
+
+ nsgtk_tab_add_page(notebook,
+ tbc->container,
+ false,
+ messages_get("gtkCustomizeToolbarTitle"),
+ favicon_pixbuf);
+
+ /* safe to drop the reference to the builder as the container is
+ * referenced by the notebook now.
+ */
+ g_object_unref(builder);
+
return TRUE;
}
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index f0eb743..76e9863 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -31,11 +31,13 @@
#include <gdk/gdkkeysyms.h>
#include <gdk-pixbuf/gdk-pixdata.h>
-#include "netsurf/inttypes.h"
+#include "utils/utils.h"
#include "utils/log.h"
#include "utils/utf8.h"
#include "utils/nsoption.h"
#include "utils/messages.h"
+#include "utils/nsurl.h"
+#include "netsurf/inttypes.h"
#include "netsurf/content.h"
#include "netsurf/browser_window.h"
#include "netsurf/mouse.h"
@@ -45,7 +47,6 @@
#include "netsurf/keypress.h"
#include "desktop/searchweb.h"
#include "desktop/textinput.h"
-#include "utils/nsurl.h"
#include "gtk/selection.h"
#include "gtk/warn.h"
@@ -940,7 +941,7 @@ gui_window_set_icon(struct gui_window *gw, struct hlcache_handle *icon)
gw->icon = favicon_pixbuf;
}
- nsgtk_tab_set_icon(gw, gw->icon);
+ nsgtk_tab_set_icon(gw->container, gw->icon);
}
@@ -1378,6 +1379,22 @@ static nserror gui_window_set_url(struct gui_window *gw, nsurl *url)
/**
+ * GTK window UI callback when core changes the current title
+ *
+ * \param gw The gui window on which the url has been set.
+ * \param url The new url.
+ */
+static void gui_window_set_title(struct gui_window *gw, const char *title)
+{
+
+ if ((title != NULL) && (title[0] != '\0')) {
+ nsgtk_tab_set_title(gw->container, title);
+ }
+ nsgtk_scaffolding_set_title(gw, title);
+}
+
+
+/**
* GTK UI callback when search provider details are updated.
*
* \param name The providers name.
@@ -1425,6 +1442,7 @@ static struct gui_window_table window_table = {
.event = gui_window_event,
.set_icon = gui_window_set_icon,
+ .set_title = gui_window_set_title,
.set_status = gui_window_set_status,
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
@@ -1432,8 +1450,7 @@ static struct gui_window_table window_table = {
.file_gadget_open = gui_window_file_gadget_open,
.set_url = gui_window_set_url,
- /* from scaffold */
- .set_title = nsgtk_window_set_title,
+
};
struct gui_window_table *nsgtk_window_table = &window_table;
@@ -1468,20 +1485,6 @@ GtkLayout *nsgtk_window_get_layout(struct gui_window *g)
/* exported interface documented in window.h */
-GtkWidget *nsgtk_window_get_tab(struct gui_window *g)
-{
- return g->tab;
-}
-
-
-/* exported interface documented in window.h */
-void nsgtk_window_set_tab(struct gui_window *g, GtkWidget *w)
-{
- g->tab = w;
-}
-
-
-/* exported interface documented in window.h */
nserror
nsgtk_window_item_activate(struct gui_window *gw, nsgtk_toolbar_button itemid)
{
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index ae3dae1..1b3c8aa 100644
--- a/frontends/gtk/window.h
+++ b/frontends/gtk/window.h
@@ -87,20 +87,6 @@ unsigned long nsgtk_window_get_signalhandler(struct gui_window *gw, int i);
*/
GtkLayout *nsgtk_window_get_layout(struct gui_window *gw);
-/**
- * get tab widget from gui window handle
- *
- * \param gw gui window handle
- */
-GtkWidget *nsgtk_window_get_tab(struct gui_window *gw);
-
-/**
- * set tab widget associated with gui window handle
- *
- * \param gw gui window handle
- * \param w gtk widget to associate
- */
-void nsgtk_window_set_tab(struct gui_window *gw, GtkWidget *w);
/**
* activate the handler for a item in a toolbar of a gui window
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=46e1116aaa38793ff3a...
commit 46e1116aaa38793ff3a36fb5ff05e3be448df49f
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
change toolbar customization to tab approach
diff --git a/frontends/gtk/res/toolbar.gtk3.ui b/frontends/gtk/res/toolbar.gtk3.ui
index 1f11487..b9eee2c 100644
--- a/frontends/gtk/res/toolbar.gtk3.ui
+++ b/frontends/gtk/res/toolbar.gtk3.ui
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.18.3 -->
+<!-- Generated with glade 3.22.1 -->
<!--*- mode: xml -*-->
<interface>
<requires lib="gtk+" version="3.0"/>
@@ -14,6 +14,9 @@
<property name="can_focus">False</property>
<property name="title" translatable="yes">gtkToolBarTitle</property>
<property name="type_hint">dialog</property>
+ <child>
+ <placeholder/>
+ </child>
<child internal-child="vbox">
<object class="GtkBox" id="dialog-vbox1">
<property name="can_focus">False</property>
@@ -134,4 +137,84 @@
</object>
</child>
</object>
+ <object class="GtkBox" id="tabBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkToolbar" id="toolbar">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLayout" id="viewport">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButtonBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="rese">
+ <property name="label" translatable="yes">Reset</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="discard">
+ <property name="label">gtk-discard</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="apply">
+ <property name="label">gtk-apply</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
</interface>
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 1022e76..a2c3a7d 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -586,15 +586,6 @@ nsgtk_on_link_copy_activate_menu(GtkMenuItem *widget, gpointer data)
}
-static gboolean
-nsgtk_on_customize_activate_menu(GtkMenuItem *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_toolbar_customization_init(g);
- return TRUE;
-}
-
-
static gboolean nsgtk_on_find_activate_menu(GtkMenuItem *widget, gpointer data)
{
struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
@@ -773,10 +764,6 @@ static void nsgtk_menu_connect_signals(struct nsgtk_scaffolding *g)
"toggled",
G_CALLBACK(nsgtk_on_toolbar_activate_menu),
g);
- g_signal_connect(g->menu_bar->view_submenu->toolbars_submenu->customize_menuitem,
- "activate",
- G_CALLBACK(nsgtk_on_customize_activate_menu),
- g);
}
@@ -807,10 +794,6 @@ create_scaffolding_burger_menu(struct nsgtk_scaffolding *gs,
"toggled",
G_CALLBACK(nsgtk_on_toolbar_activate_menu),
gs);
- g_signal_connect(nmenu->view_submenu->toolbars_submenu->customize_menuitem,
- "activate",
- G_CALLBACK(nsgtk_on_customize_activate_menu),
- gs);
return nmenu;
}
@@ -845,10 +828,6 @@ create_scaffolding_popup_menu(struct nsgtk_scaffolding *gs, GtkAccelGroup *group
"toggled",
G_CALLBACK(nsgtk_on_toolbar_activate_menu),
gs);
- g_signal_connect(nmenu->toolbars_submenu->customize_menuitem,
- "activate",
- G_CALLBACK(nsgtk_on_customize_activate_menu),
- gs);
/* set initial popup menu visibility */
popup_menu_hide(nmenu, false, false);
@@ -974,6 +953,9 @@ static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
ITEM_MB(NEXTTAB, nexttab, view_submenu->tabs);
ITEM_MB(PREVTAB, prevtab, view_submenu->tabs);
ITEM_MB(CLOSETAB, closetab, view_submenu->tabs);
+ /* view - toolbars submenu */
+ ITEM_MB(CUSTOMIZE, customize, view_submenu->toolbars);
+ g->menus[CUSTOMIZE_BUTTON].popup = g->popup_menu->toolbars_submenu->customize_menuitem;
/* navigation menu */
ITEM_MBp(BACK, back, nav);
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 5a7d252..dadddc2 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -137,11 +137,21 @@ struct nsgtk_toolbar {
void *get_ctx;
};
+/**
+ * toolbar cusomisation context
+ */
+struct nsgtk_toolbar_customization {
+ /**
+ * first entry is a toolbar widget so a customisation widget
+ * can be cast to toolbar and back.
+ */
+ struct nsgtk_toolbar toolbar;
-static GtkTargetEntry entry = {(char *)"nsgtk_button_data",
- GTK_TARGET_SAME_APP, 0};
-
-static bool edit_mode = false;
+ /**
+ * toolbar gtk builder
+ */
+ GtkBuilder *builder;
+};
/**
* toolbar customization window context
@@ -158,6 +168,8 @@ struct nsgtk_toolbar_custom_store {
bool fromstore;
};
+static bool edit_mode = false;
+
/* the number of buttons that fit in the width of the store window */
#define NSGTK_STORE_WIDTH 6
@@ -233,11 +245,6 @@ nsgtk_toolbar_##name##_data_minus(GtkWidget *widget, \
#undef TOOLBAR_ITEM
-/* exported interface documented in gtk/scaffolding.h */
-static GtkToolbar *nsgtk_scaffolding_toolbar(struct nsgtk_scaffolding *g)
-{
- return NULL;//g->tool_bar;
-}
/**
* get default image for buttons / menu items from gtk stock items.
@@ -494,37 +501,6 @@ void nsgtk_theme_implement(struct nsgtk_scaffolding *g)
}
-/**
- * callback function to iterate toolbar's widgets
- */
-static void nsgtk_toolbar_clear_toolbar(GtkWidget *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- gtk_container_remove(GTK_CONTAINER(nsgtk_scaffolding_toolbar(g)),
- widget);
-}
-
-/**
- * connect temporary handler for toolbar edit events
- *
- * \param g The scaffolding
- * \param bi The button index
- */
-static void nsgtk_toolbar_temp_connect(struct nsgtk_scaffolding *g,
- nsgtk_toolbar_button bi)
-{
- struct nsgtk_toolbar_item *bc;
-
- if (bi != URL_BAR_ITEM) {
- bc = nsgtk_scaffolding_button(g, bi);
- if ((bc->button != NULL) && (bc->dataminus != NULL)) {
- g_signal_connect(bc->button,
- "drag-data-get",
- G_CALLBACK(bc->dataminus),
- g);
- }
- }
-}
/**
* get scaffolding button index of button at location
@@ -817,6 +793,48 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
return w;
}
+#if 0
+
+static GtkTargetEntry entry = {(char *)"nsgtk_button_data",
+ GTK_TARGET_SAME_APP, 0};
+
+/* exported interface documented in gtk/scaffolding.h */
+static GtkToolbar *nsgtk_scaffolding_toolbar(struct nsgtk_scaffolding *g)
+{
+ return NULL;//g->tool_bar;
+}
+
+/**
+ * callback function to iterate toolbar's widgets
+ */
+static void nsgtk_toolbar_clear_toolbar(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ gtk_container_remove(GTK_CONTAINER(nsgtk_scaffolding_toolbar(g)),
+ widget);
+}
+
+/**
+ * connect temporary handler for toolbar edit events
+ *
+ * \param g The scaffolding
+ * \param bi The button index
+ */
+static void nsgtk_toolbar_temp_connect(struct nsgtk_scaffolding *g,
+ nsgtk_toolbar_button bi)
+{
+ struct nsgtk_toolbar_item *bc;
+
+ if (bi != URL_BAR_ITEM) {
+ bc = nsgtk_scaffolding_button(g, bi);
+ if ((bc->button != NULL) && (bc->dataminus != NULL)) {
+ g_signal_connect(bc->button,
+ "drag-data-get",
+ G_CALLBACK(bc->dataminus),
+ g);
+ }
+ }
+}
/* exported interface documented in gtk/scaffolding.h */
static void nsgtk_scaffolding_reset_offset(struct nsgtk_scaffolding *g)
@@ -1498,7 +1516,42 @@ void nsgtk_toolbar_customization_init(struct nsgtk_scaffolding *g)
/* open toolbar window */
nsgtk_toolbar_window_open(g);
}
+#endif
+/**
+ * create a toolbar customization tab
+ *
+ * this is completely different approach to previous implementation. it
+ * is not modal and the toolbar configuration is performed completely
+ * within the tab. once the user is happy they can apply the change or
+ * cancel as they see fit while continuing to use the browser as usual.
+ */
+static gboolean cutomize_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct nsgtk_toolbar_customization *tbc;
+ nserror res;
+ /* create nsgtk_toolbar_customization which has nsgtk_toolbar
+ * at the front so we can reuse functions that take
+ * nsgtk_toolbar
+ */
+ tbc = calloc(1, sizeof(struct nsgtk_toolbar_customization));
+ /* create builder*/
+ res = nsgtk_builder_new_from_resname("toolbar", &tbc->builder);
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, INFO, "Toolbar UI builder init failed");
+ return TRUE;
+ }
+
+ /* get toolbar widget from builder */
+ /* populate toolbar widget in edit mode */
+ /* attach handlers to widgets */
+ /* use layout box for widgets to drag to/from */
+ /* save and update on apply button then discard */
+ /* discard button causes destruction */
+ /* close and cleanup on destroy signal */
+ return TRUE;
+}
/**
* \return toolbar item id when a widget is an element of the scaffolding
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 0ed2f2a..661cbef 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -72,6 +72,7 @@ typedef enum {
INFO_BUTTON,
ABOUT_BUTTON,
OPENMENU_BUTTON,
+ CUSTOMIZE_BUTTON,
PLACEHOLDER_BUTTON /* size indicator; array maximum indices */
} nsgtk_toolbar_button; /* PLACEHOLDER_BUTTON - 1 */
@@ -144,6 +145,7 @@ TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, y, p)
TOOLBAR_ITEM(INFO_BUTTON, info, true, y, p)
TOOLBAR_ITEM(ABOUT_BUTTON, about, true, y, p)
TOOLBAR_ITEM(OPENMENU_BUTTON, openmenu, true, y, n)
+TOOLBAR_ITEM(CUSTOMIZE_BUTTON, cutomize, true, y, p)
#ifdef TOOLBAR_ITEM_SET
#undef TOOLBAR_ITEM
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=65d5161558cfd749f58...
commit 65d5161558cfd749f58de89990b739865f2bccaa
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
remove unsused junk gtk_history_window structure and functions
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 14ed230..1022e76 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -1310,11 +1310,6 @@ GtkWidget *nsgtk_scaffolding_urlbar(struct nsgtk_scaffolding *g)
return NULL;//g->url_bar;
}
-/* exported interface documented in gtk/scaffolding.h */
-GtkToolbar *nsgtk_scaffolding_toolbar(struct nsgtk_scaffolding *g)
-{
- return NULL;//g->tool_bar;
-}
/* exported interface documented in gtk/scaffolding.h */
struct gtk_search *nsgtk_scaffolding_search(struct nsgtk_scaffolding *g)
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index 16aaf03..89212a3 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -29,20 +29,12 @@ struct gui_search_web_table;
struct nsurl;
-
-struct gtk_history_window {
- struct nsgtk_scaffolding *g;
- GtkWindow *window;
- GtkScrolledWindow *scrolled;
- GtkDrawingArea *drawing_area;
-};
-
struct gtk_search {
- GtkToolbar *bar;
- GtkEntry *entry;
- GtkToolButton *buttons[3]; /* back, forward, */
- GtkCheckButton *checkAll; /* close */
- GtkCheckButton *caseSens;
+ GtkToolbar *bar;
+ GtkEntry *entry;
+ GtkToolButton *buttons[3]; /* back, forward, */
+ GtkCheckButton *checkAll;
+ GtkCheckButton *caseSens;
};
@@ -101,18 +93,11 @@ GtkNotebook *nsgtk_scaffolding_notebook(struct nsgtk_scaffolding *g);
*/
GtkWidget *nsgtk_scaffolding_urlbar(struct nsgtk_scaffolding *g);
-/**
- * Get the gtk toolbar from a scaffold.
- */
-GtkToolbar *nsgtk_scaffolding_toolbar(struct nsgtk_scaffolding *g);
-
struct gtk_search *nsgtk_scaffolding_search(struct nsgtk_scaffolding *g);
GtkMenuBar *nsgtk_scaffolding_menu_bar(struct nsgtk_scaffolding *g);
-struct gtk_history_window *nsgtk_scaffolding_history_window(struct nsgtk_scaffolding *g);
-
struct gui_window *nsgtk_scaffolding_top_level(struct nsgtk_scaffolding *g);
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index f595c05..5a7d252 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -233,6 +233,12 @@ nsgtk_toolbar_##name##_data_minus(GtkWidget *widget, \
#undef TOOLBAR_ITEM
+/* exported interface documented in gtk/scaffolding.h */
+static GtkToolbar *nsgtk_scaffolding_toolbar(struct nsgtk_scaffolding *g)
+{
+ return NULL;//g->tool_bar;
+}
+
/**
* get default image for buttons / menu items from gtk stock items.
*
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=635be1dfb88c01ab6a9...
commit 635be1dfb88c01ab6a901f6e88eb3b7187d2c03b
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
make toolbar and menubar hiding work appropriately
diff --git a/frontends/gtk/menu.c b/frontends/gtk/menu.c
index 6589fca..08af970 100644
--- a/frontends/gtk/menu.c
+++ b/frontends/gtk/menu.c
@@ -85,15 +85,17 @@ nsgtk_menu_add_image_item(GtkMenu *menu,
#define IMAGE_ITEM(p, q, r, s, t)\
nsgtk_menu_add_image_item(s->p##_menu, &(s->q##_menuitem), #r, t)
-#define CHECK_ITEM(p, q, r, s)\
- s->q##_menuitem = GTK_CHECK_MENU_ITEM(\
+#define CHECK_ITEM(p, q, r, s) \
+ do { \
+ s->q##_menuitem = GTK_CHECK_MENU_ITEM( \
gtk_check_menu_item_new_with_mnemonic(\
messages_get(#r)));\
- if ((s->q##_menuitem != NULL) && (s->p##_menu != NULL)) {\
- gtk_menu_shell_append(GTK_MENU_SHELL(s->p##_menu),\
- GTK_WIDGET(s->q##_menuitem));\
- gtk_widget_show(GTK_WIDGET(s->q##_menuitem));\
- }
+ if ((s->q##_menuitem != NULL) && (s->p##_menu != NULL)) { \
+ gtk_menu_shell_append(GTK_MENU_SHELL(s->p##_menu), \
+ GTK_WIDGET(s->q##_menuitem)); \
+ gtk_widget_show(GTK_WIDGET(s->q##_menuitem)); \
+ } \
+ } while(0)
#define SET_SUBMENU(q, r) \
do { \
@@ -224,28 +226,36 @@ static struct nsgtk_tabs_submenu *nsgtk_menu_tabs_submenu(GtkAccelGroup *group)
static struct nsgtk_toolbars_submenu *
nsgtk_menu_toolbars_submenu(GtkAccelGroup *group)
{
- struct nsgtk_toolbars_submenu *ret =
- malloc(sizeof(struct nsgtk_toolbars_submenu));
- if (ret == NULL) {
+ struct nsgtk_toolbars_submenu *tmenu;
+
+ tmenu = malloc(sizeof(struct nsgtk_toolbars_submenu));
+ if (tmenu == NULL) {
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
- ret->toolbars_menu = GTK_MENU(gtk_menu_new());
- if (ret->toolbars_menu == NULL) {
+
+ tmenu->toolbars_menu = GTK_MENU(gtk_menu_new());
+ if (tmenu->toolbars_menu == NULL) {
nsgtk_warning(messages_get("NoMemory"), 0);
- free(ret);
+ free(tmenu);
return NULL;
}
- CHECK_ITEM(toolbars, menubar, gtkMenuBar, ret)
- if (ret->menubar_menuitem != NULL)
- gtk_check_menu_item_set_active(ret->menubar_menuitem, TRUE);
- CHECK_ITEM(toolbars, toolbar, gtkToolBar, ret)
- if (ret->toolbar_menuitem != NULL)
- gtk_check_menu_item_set_active(ret->toolbar_menuitem, TRUE);
- ADD_SEP(toolbars, ret);
- IMAGE_ITEM(toolbars, customize, gtkCustomize, ret, group);
- return ret;
+ CHECK_ITEM(toolbars, menubar, gtkMenuBar, tmenu);
+ if (tmenu->menubar_menuitem != NULL) {
+ gtk_check_menu_item_set_active(tmenu->menubar_menuitem, TRUE);
+ }
+
+ CHECK_ITEM(toolbars, toolbar, gtkToolBar, tmenu);
+ if (tmenu->toolbar_menuitem != NULL) {
+ gtk_check_menu_item_set_active(tmenu->toolbar_menuitem, TRUE);
+ }
+
+ ADD_SEP(toolbars, tmenu);
+
+ IMAGE_ITEM(toolbars, customize, gtkCustomize, tmenu, group);
+
+ return tmenu;
}
/**
@@ -558,9 +568,11 @@ struct nsgtk_popup_menu *nsgtk_popup_menu_create(GtkAccelGroup *group)
ADD_NAMED_SEP(popup, second, nmenu);
+ IMAGE_ITEM(popup, toolbars, gtkToolbars, nmenu, group);
+ SET_SUBMENU(toolbars, nmenu);
+
IMAGE_ITEM(popup, tools, gtkTools, nmenu, group);
SET_SUBMENU(tools, nmenu);
- IMAGE_ITEM(popup, customize, gtkCustomize, nmenu, group);
return nmenu;
}
diff --git a/frontends/gtk/menu.h b/frontends/gtk/menu.h
index 4656e22..822e463 100644
--- a/frontends/gtk/menu.h
+++ b/frontends/gtk/menu.h
@@ -193,11 +193,10 @@ struct nsgtk_popup_menu {
GtkWidget *second_separator;
+ GtkWidget *toolbars_menuitem;
+ struct nsgtk_toolbars_submenu *toolbars_submenu;
GtkWidget *tools_menuitem;
struct nsgtk_tools_menu *tools_submenu;
-
- GtkWidget *customize_menuitem;
-
};
struct nsgtk_link_menu {
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 7c68b94..14ed230 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -120,7 +120,7 @@ static struct browser_window_features current_menu_features;
* \param custom flag to indicate if menu customisation is hidden.
*/
static void
-popup_menu_hide(struct nsgtk_popup_menu *menu, bool nav, bool cnp, bool custom)
+popup_menu_hide(struct nsgtk_popup_menu *menu, bool nav, bool cnp)
{
if (nav) {
gtk_widget_hide(GTK_WIDGET(menu->back_menuitem));
@@ -139,9 +139,6 @@ popup_menu_hide(struct nsgtk_popup_menu *menu, bool nav, bool cnp, bool custom)
gtk_widget_hide(menu->second_separator);
}
- if (custom) {
- gtk_widget_hide(GTK_WIDGET(menu->customize_menuitem));
- }
}
@@ -155,7 +152,7 @@ popup_menu_hide(struct nsgtk_popup_menu *menu, bool nav, bool cnp, bool custom)
* \param custom flag to indicate if menu customisation is visible.
*/
static void
-popup_menu_show(struct nsgtk_popup_menu *menu, bool nav, bool cnp, bool custom)
+popup_menu_show(struct nsgtk_popup_menu *menu, bool nav, bool cnp)
{
if (nav) {
gtk_widget_show(GTK_WIDGET(menu->back_menuitem));
@@ -174,9 +171,6 @@ popup_menu_show(struct nsgtk_popup_menu *menu, bool nav, bool cnp, bool custom)
gtk_widget_show(menu->second_separator);
}
- if (custom) {
- gtk_widget_show(GTK_WIDGET(menu->customize_menuitem));
- }
}
@@ -322,7 +316,7 @@ nsgtk_scaffolding_enable_edit_actions_sensitivity(struct nsgtk_scaffolding *g)
g->menus[CUT_BUTTON].sensitivity = true;
nsgtk_scaffolding_set_sensitivity(g);
- popup_menu_show(g->popup_menu, false, true, false);
+ popup_menu_show(g->popup_menu, false, true);
}
/* signal handling functions for the toolbar, URL bar, and menu bar */
@@ -615,10 +609,12 @@ nsgtk_on_menubar_activate_menu(GtkMenuItem *widget, gpointer data)
{
struct nsgtk_scaffolding *gs = (struct nsgtk_scaffolding *)data;
GtkCheckMenuItem *bmcmi; /* burger menu check */
- GtkCheckMenuItem *mbcmi; /* menu bar check*/
+ GtkCheckMenuItem *mbcmi; /* menu bar check */
+ GtkCheckMenuItem *tbcmi; /* popup menu check */
bmcmi = GTK_CHECK_MENU_ITEM(gs->burger_menu->view_submenu->toolbars_submenu->menubar_menuitem);
mbcmi = GTK_CHECK_MENU_ITEM(gs->menu_bar->view_submenu->toolbars_submenu->menubar_menuitem);
+ tbcmi = GTK_CHECK_MENU_ITEM(gs->popup_menu->toolbars_submenu->menubar_menuitem);
/* ensure menubar and burger menu checkboxes are both updated */
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
@@ -630,10 +626,12 @@ nsgtk_on_menubar_activate_menu(GtkMenuItem *widget, gpointer data)
gtk_check_menu_item_set_active(mbcmi, TRUE);
}
+ if (gtk_check_menu_item_get_active(tbcmi) == FALSE) {
+ gtk_check_menu_item_set_active(tbcmi, TRUE);
+ }
+
gtk_widget_show(GTK_WIDGET(gs->menu_bar->bar_menu));
- popup_menu_show(gs->popup_menu, true, true, true);
- popup_menu_hide(gs->popup_menu, false, false, false);
} else {
if (gtk_check_menu_item_get_active(bmcmi) == TRUE) {
gtk_check_menu_item_set_active(bmcmi, FALSE);
@@ -643,10 +641,11 @@ nsgtk_on_menubar_activate_menu(GtkMenuItem *widget, gpointer data)
gtk_check_menu_item_set_active(mbcmi, FALSE);
}
- gtk_widget_hide(GTK_WIDGET(gs->menu_bar->bar_menu));
-
- popup_menu_show(gs->popup_menu, true, true, true);
+ if (gtk_check_menu_item_get_active(tbcmi) == TRUE) {
+ gtk_check_menu_item_set_active(tbcmi, FALSE);
+ }
+ gtk_widget_hide(GTK_WIDGET(gs->menu_bar->bar_menu));
}
return TRUE;
}
@@ -658,9 +657,11 @@ nsgtk_on_toolbar_activate_menu(GtkMenuItem *widget, gpointer data)
struct nsgtk_scaffolding *gs = (struct nsgtk_scaffolding *)data;
GtkCheckMenuItem *bmcmi; /* burger menu check */
GtkCheckMenuItem *mbcmi; /* menu bar check */
+ GtkCheckMenuItem *tbcmi; /* popup menu check */
bmcmi = GTK_CHECK_MENU_ITEM(gs->burger_menu->view_submenu->toolbars_submenu->toolbar_menuitem);
mbcmi = GTK_CHECK_MENU_ITEM(gs->menu_bar->view_submenu->toolbars_submenu->toolbar_menuitem);
+ tbcmi = GTK_CHECK_MENU_ITEM(gs->popup_menu->toolbars_submenu->toolbar_menuitem);
/* ensure menubar and burger menu checkboxes are both updated */
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
@@ -672,7 +673,11 @@ nsgtk_on_toolbar_activate_menu(GtkMenuItem *widget, gpointer data)
gtk_check_menu_item_set_active(mbcmi, TRUE);
}
- //gtk_widget_show(GTK_WIDGET(g->tool_bar));
+ if (gtk_check_menu_item_get_active(tbcmi) == FALSE) {
+ gtk_check_menu_item_set_active(tbcmi, TRUE);
+ }
+
+ nsgtk_window_toolbar_show(gs, true);
} else {
if (gtk_check_menu_item_get_active(bmcmi) == TRUE) {
gtk_check_menu_item_set_active(bmcmi, FALSE);
@@ -682,7 +687,11 @@ nsgtk_on_toolbar_activate_menu(GtkMenuItem *widget, gpointer data)
gtk_check_menu_item_set_active(mbcmi, FALSE);
}
- //gtk_widget_hide(GTK_WIDGET(g->tool_bar));
+ if (gtk_check_menu_item_get_active(tbcmi) == TRUE) {
+ gtk_check_menu_item_set_active(tbcmi, FALSE);
+ }
+
+ nsgtk_window_toolbar_show(gs, false);
}
return TRUE;
}
@@ -828,13 +837,21 @@ create_scaffolding_popup_menu(struct nsgtk_scaffolding *gs, GtkAccelGroup *group
G_CALLBACK(nsgtk_window_popup_menu_hidden),
gs);
- g_signal_connect(nmenu->customize_menuitem,
+ g_signal_connect(nmenu->toolbars_submenu->menubar_menuitem,
+ "toggled",
+ G_CALLBACK(nsgtk_on_menubar_activate_menu),
+ gs);
+ g_signal_connect(nmenu->toolbars_submenu->toolbar_menuitem,
+ "toggled",
+ G_CALLBACK(nsgtk_on_toolbar_activate_menu),
+ gs);
+ g_signal_connect(nmenu->toolbars_submenu->customize_menuitem,
"activate",
G_CALLBACK(nsgtk_on_customize_activate_menu),
gs);
/* set initial popup menu visibility */
- popup_menu_hide(nmenu, false, false, true);
+ popup_menu_hide(nmenu, false, false);
return nmenu;
}
@@ -1411,8 +1428,7 @@ void nsgtk_scaffolding_set_sensitivity(struct nsgtk_scaffolding *g)
nserror nsgtk_scaffolding_toolbar_context_menu(struct nsgtk_scaffolding *gs)
{
/* set visibility for right-click popup menu */
- popup_menu_hide(gs->popup_menu, false, true, false);
- popup_menu_show(gs->popup_menu, false, false, true);
+ popup_menu_hide(gs->popup_menu, false, true);
nsgtk_menu_popup_at_pointer(gs->popup_menu->popup_menu, NULL);
@@ -1445,11 +1461,6 @@ nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g,
if (current_menu_features.link != NULL) {
/* menu is opening over a link */
gtkmenu = g->link_menu->link_menu;
- } else if (gtk_widget_get_visible(GTK_WIDGET(g->menu_bar->bar_menu)) == FALSE) {
- gtkmenu = g->burger_menu->burger_menu;
-
- nsgtk_scaffolding_update_edit_actions_sensitivity(g);
-
} else {
gtkmenu = g->popup_menu->popup_menu;
@@ -1473,8 +1484,6 @@ nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g,
gtk_widget_show(GTK_WIDGET(g->popup_menu->paste_menuitem));
}
- /* hide customise */
- popup_menu_hide(g->popup_menu, false, false, true);
}
nsgtk_menu_popup_at_pointer(gtkmenu, NULL);
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 02097ea..f595c05 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -3758,3 +3758,16 @@ nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb,
return NSERROR_OK;
}
+
+
+/* exported interface documented in toolbar.h */
+nserror nsgtk_toolbar_show(struct nsgtk_toolbar *tb, bool show)
+{
+ if (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 dc229e7..75fb3ab 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -95,6 +95,14 @@ nserror nsgtk_toolbar_set_websearch_image(struct nsgtk_toolbar *tb, GdkPixbuf *p
*/
nserror nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid);
+/**
+ * set the toolbar to be shown or hidden
+ *
+ * \param toolbar A toolbar returned from a creation
+ * \param show true to show the toolbar and false to hide it.
+ * \return NSERROR_OK on success
+ */
+nserror nsgtk_toolbar_show(struct nsgtk_toolbar *tb, bool show);
/**
* sets up the images for scaffolding.
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 0daf0fe..f0eb743 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -66,9 +66,6 @@
static GtkWidget *select_menu;
static struct form_control *select_menu_control;
-static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
- gpointer user_data);
-
struct gui_window {
/**
* The gtk scaffold object containing menu, buttons, url bar, [tabs],
@@ -138,42 +135,12 @@ struct gui_window *window_list = NULL;
/** flag controlling opening of tabs in the background */
int temp_open_background = -1;
-struct nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g)
-{
- return g->scaffold;
-}
-
-struct browser_window *nsgtk_get_browser_window(struct gui_window *g)
-{
- return g->bw;
-}
-
-unsigned long nsgtk_window_get_signalhandler(struct gui_window *g, int i)
-{
- return g->signalhandler[i];
-}
-
-GtkLayout *nsgtk_window_get_layout(struct gui_window *g)
-{
- return g->layout;
-}
-
-GtkWidget *nsgtk_window_get_tab(struct gui_window *g)
-{
- return g->tab;
-}
-
-void nsgtk_window_set_tab(struct gui_window *g, GtkWidget *w)
-{
- g->tab = w;
-}
-
-
-static void nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
- gpointer user_data)
+static void
+nsgtk_select_menu_clicked(GtkCheckMenuItem *checkmenuitem,
+ gpointer user_data)
{
form_select_process_selection(select_menu_control,
- (intptr_t)user_data);
+ (intptr_t)user_data);
}
#if GTK_CHECK_VERSION(3,0,0)
@@ -270,8 +237,10 @@ nsgtk_window_draw_event(GtkWidget *widget, GdkEventExpose *event, gpointer data)
#endif
-static gboolean nsgtk_window_motion_notify_event(GtkWidget *widget,
- GdkEventMotion *event, gpointer data)
+static gboolean
+nsgtk_window_motion_notify_event(GtkWidget *widget,
+ GdkEventMotion *event,
+ gpointer data)
{
struct gui_window *g = data;
bool shift = event->state & GDK_SHIFT_MASK;
@@ -385,8 +354,11 @@ nsgtk_window_button_press_event(GtkWidget *widget,
return TRUE;
}
-static gboolean nsgtk_window_button_release_event(GtkWidget *widget,
- GdkEventButton *event, gpointer data)
+
+static gboolean
+nsgtk_window_button_release_event(GtkWidget *widget,
+ GdkEventButton *event,
+ gpointer data)
{
struct gui_window *g = data;
bool shift = event->state & GDK_SHIFT_MASK;
@@ -415,6 +387,7 @@ static gboolean nsgtk_window_button_release_event(GtkWidget *widget,
return TRUE;
}
+
static gboolean
nsgtk_window_scroll_event(GtkWidget *widget,
GdkEventScroll *event,
@@ -502,8 +475,11 @@ nsgtk_window_scroll_event(GtkWidget *widget,
return TRUE;
}
-static gboolean nsgtk_window_keypress_event(GtkWidget *widget,
- GdkEventKey *event, gpointer data)
+
+static gboolean
+nsgtk_window_keypress_event(GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer data)
{
struct gui_window *g = data;
uint32_t nskey;
@@ -619,8 +595,11 @@ static gboolean nsgtk_window_keypress_event(GtkWidget *widget,
return TRUE;
}
-static gboolean nsgtk_window_keyrelease_event(GtkWidget *widget,
- GdkEventKey *event, gpointer data)
+
+static gboolean
+nsgtk_window_keyrelease_event(GtkWidget *widget,
+ GdkEventKey *event,
+ gpointer data)
{
struct gui_window *g = data;
@@ -628,8 +607,10 @@ static gboolean nsgtk_window_keyrelease_event(GtkWidget *widget,
}
-static void nsgtk_window_input_method_commit(GtkIMContext *ctx,
- const gchar *str, gpointer data)
+static void
+nsgtk_window_input_method_commit(GtkIMContext *ctx,
+ const gchar *str,
+ gpointer data)
{
struct gui_window *g = data;
size_t len = strlen(str), offset = 0;
@@ -644,8 +625,10 @@ static void nsgtk_window_input_method_commit(GtkIMContext *ctx,
}
-static gboolean nsgtk_window_size_allocate_event(GtkWidget *widget,
- GtkAllocation *allocation, gpointer data)
+static gboolean
+nsgtk_window_size_allocate_event(GtkWidget *widget,
+ GtkAllocation *allocation,
+ gpointer data)
{
struct gui_window *g = data;
@@ -685,11 +668,15 @@ nsgtk_paned_notify__position(GObject *gobject, GParamSpec *pspec, gpointer data)
((gtk_paned_get_position(g->paned) * 10000) / (pane_alloc.width - 1)));
}
-/** Set status bar / scroll bar proportion according to user option
- * when pane is resized.
+
+/**
+ * Set status bar / scroll bar proportion according to user option
+ * when pane is resized.
*/
-static gboolean nsgtk_paned_size_allocate_event(GtkWidget *widget,
- GtkAllocation *allocation, gpointer data)
+static gboolean
+nsgtk_paned_size_allocate_event(GtkWidget *widget,
+ GtkAllocation *allocation,
+ gpointer data)
{
gtk_paned_set_position(GTK_PANED(widget),
(nsoption_int(toolbar_status_size) * allocation->width) / 10000);
@@ -697,7 +684,10 @@ static gboolean nsgtk_paned_size_allocate_event(GtkWidget *widget,
return TRUE;
}
-/* destroy the browsing context as there is nothing to display it now */
+
+/**
+ * destroy the browsing context as there is nothing to display it now
+ */
static void window_destroy(GtkWidget *widget, gpointer data)
{
struct gui_window *gw = data;
@@ -708,13 +698,13 @@ static void window_destroy(GtkWidget *widget, gpointer data)
}
-
static struct browser_window *bw_from_gw(void *data)
{
struct gui_window *gw = data;
return gw->bw;
}
+
/**
* Create and open a gtk container (window or tab) for a browsing context.
*
@@ -897,31 +887,6 @@ gui_window_create(struct browser_window *bw,
return g;
}
-/* exported interface documented in window.h */
-nserror
-nsgtk_window_item_activate(struct gui_window *gw, nsgtk_toolbar_button itemid)
-{
- return nsgtk_toolbar_item_activate(gw->toolbar, itemid);
-}
-
-/* exported interface documented in window.h */
-void nsgtk_window_update_all(void)
-{
- struct gui_window *gw;
- for (gw = window_list; gw != NULL; gw = gw->next) {
- nsgtk_tab_options_changed(nsgtk_scaffolding_notebook(gw->scaffold));
- nsgtk_toolbar_update(gw->toolbar);
- /** \todo update search bar */
- browser_window_schedule_reformat(gw->bw);
- }
-}
-
-
-void nsgtk_window_destroy_browser(struct gui_window *gw)
-{
- /* remove tab */
- gtk_widget_destroy(gw->container);
-}
static void gui_window_destroy(struct gui_window *g)
{
@@ -943,6 +908,7 @@ static void gui_window_destroy(struct gui_window *g)
NSLOG(netsurf, INFO, "window list head: %p", window_list);
}
+
/**
* favicon setting for gtk gui window.
*
@@ -977,6 +943,7 @@ gui_window_set_icon(struct gui_window *gw, struct hlcache_handle *icon)
nsgtk_tab_set_icon(gw, gw->icon);
}
+
static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
{
GtkAdjustment *vadj = nsgtk_layout_get_vadjustment(g->layout);
@@ -991,6 +958,7 @@ static bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy)
return true;
}
+
static void nsgtk_redraw_caret(struct gui_window *g)
{
int sx, sy;
@@ -1005,6 +973,7 @@ static void nsgtk_redraw_caret(struct gui_window *g)
}
+
static void gui_window_remove_caret(struct gui_window *g)
{
int sx, sy;
@@ -1022,6 +991,7 @@ static void gui_window_remove_caret(struct gui_window *g)
}
+
/**
* Invalidates an area of a GTK browser window
*
@@ -1054,6 +1024,7 @@ nsgtk_window_invalidate_area(struct gui_window *g, const struct rect *rect)
return NSERROR_OK;
}
+
static void gui_window_set_status(struct gui_window *g, const char *text)
{
assert(g);
@@ -1107,6 +1078,7 @@ gui_window_set_scroll(struct gui_window *g, const struct rect *rect)
return NSERROR_OK;
}
+
static void gui_window_update_extent(struct gui_window *g)
{
int w, h;
@@ -1116,8 +1088,9 @@ static void gui_window_update_extent(struct gui_window *g)
}
}
-static void gui_window_set_pointer(struct gui_window *g,
- gui_pointer_shape shape)
+
+static void
+gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
GdkCursor *cursor = NULL;
GdkCursorType cursortype;
@@ -1254,13 +1227,16 @@ gui_window_get_dimensions(struct gui_window *gw, int *width, int *height)
return NSERROR_OK;
}
+
static void gui_window_start_selection(struct gui_window *g)
{
gtk_widget_grab_focus(GTK_WIDGET(g->layout));
}
-static void gui_window_create_form_select_menu(struct gui_window *g,
- struct form_control *control)
+
+static void
+gui_window_create_form_select_menu(struct gui_window *g,
+ struct form_control *control)
{
intptr_t item;
struct form_option *option;
@@ -1425,6 +1401,7 @@ gui_search_web_provider_update(const char *name, struct bitmap *bitmap)
return NSERROR_OK;
}
+
/**
* GTK frontend web search operation table
*/
@@ -1460,3 +1437,88 @@ static struct gui_window_table window_table = {
};
struct gui_window_table *nsgtk_window_table = &window_table;
+
+
+/* exported interface documented in window.h */
+struct nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *g)
+{
+ return g->scaffold;
+}
+
+
+/* exported interface documented in window.h */
+struct browser_window *nsgtk_get_browser_window(struct gui_window *g)
+{
+ return g->bw;
+}
+
+
+/* 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;
+}
+
+
+/* exported interface documented in window.h */
+GtkWidget *nsgtk_window_get_tab(struct gui_window *g)
+{
+ return g->tab;
+}
+
+
+/* exported interface documented in window.h */
+void nsgtk_window_set_tab(struct gui_window *g, GtkWidget *w)
+{
+ g->tab = w;
+}
+
+
+/* exported interface documented in window.h */
+nserror
+nsgtk_window_item_activate(struct gui_window *gw, nsgtk_toolbar_button itemid)
+{
+ return nsgtk_toolbar_item_activate(gw->toolbar, itemid);
+}
+
+
+/* exported interface documented in window.h */
+void nsgtk_window_destroy_browser(struct gui_window *gw)
+{
+ /* remove tab */
+ gtk_widget_destroy(gw->container);
+}
+
+
+/* exported interface documented in window.h */
+nserror nsgtk_window_update_all(void)
+{
+ struct gui_window *gw;
+ for (gw = window_list; gw != NULL; gw = gw->next) {
+ nsgtk_tab_options_changed(nsgtk_scaffolding_notebook(gw->scaffold));
+ nsgtk_toolbar_update(gw->toolbar);
+ /** \todo update search bar */
+ browser_window_schedule_reformat(gw->bw);
+ }
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in window.h */
+nserror nsgtk_window_toolbar_show(struct nsgtk_scaffolding *gs, bool show)
+{
+ struct gui_window *gw;
+ for (gw = window_list; gw != NULL; gw = gw->next) {
+ if (gw->scaffold == gs) {
+ nsgtk_toolbar_show(gw->toolbar, show);
+ }
+ }
+ return NSERROR_OK;
+}
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index b6e00a6..ae3dae1 100644
--- a/frontends/gtk/window.h
+++ b/frontends/gtk/window.h
@@ -52,7 +52,12 @@ struct nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *gw);
* toolbar size and style is changed and the browser window contents
* redrawn.
*/
-void nsgtk_window_update_all(void);
+nserror nsgtk_window_update_all(void);
+
+/**
+ * Windows associated with a scaffold will have their toolbar show state set
+ */
+nserror nsgtk_window_toolbar_show(struct nsgtk_scaffolding *gs, bool show);
/**
* update targets
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=bcb2b7a2c4425ba888f...
commit bcb2b7a2c4425ba888f6236890d35a8f2d037360
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
simplify toolbar items macros
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 50e061e..7c68b94 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -459,7 +459,7 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook,
/**
* handle menu activate signals by calling toolbar item activation
*/
-#define TOOLBAR_ITEM_y(identifier, name) \
+#define TOOLBAR_ITEM_p(identifier, name) \
static gboolean \
nsgtk_on_##name##_activate_menu(GtkMenuItem *widget, gpointer data) \
{ \
@@ -467,12 +467,14 @@ nsgtk_on_##name##_activate_menu(GtkMenuItem *widget, gpointer data) \
nsgtk_window_item_activate(gs->top_level, identifier); \
return TRUE; \
}
+#define TOOLBAR_ITEM_y(identifier, name)
#define TOOLBAR_ITEM_n(identifier, name)
-#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, pass) \
- TOOLBAR_ITEM_ ## pass(identifier, name)
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate) \
+ TOOLBAR_ITEM_ ## activate(identifier, name)
#include "gtk/toolbar_items.h"
#undef TOOLBAR_ITEM_y
#undef TOOLBAR_ITEM_n
+#undef TOOLBAR_ITEM_p
#undef TOOLBAR_ITEM
@@ -890,11 +892,13 @@ create_scaffolding_link_menu(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
*/
static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
{
+#define TOOLBAR_ITEM_p(identifier, name) \
+ g->menus[identifier].mhandler = nsgtk_on_##name##_activate_menu;
#define TOOLBAR_ITEM_y(identifier, name) \
g->menus[identifier].mhandler = nsgtk_on_##name##_activate_menu;
-#define TOOLBAR_ITEM_n(identifier, name) \
+#define TOOLBAR_ITEM_n(identifier, name) \
g->menus[identifier].mhandler = NULL;
-#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, pass) \
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate) \
g->menus[identifier].sensitivity = snstvty; \
TOOLBAR_ITEM_ ## activate(identifier, name)
#include "gtk/toolbar_items.h"
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index aa5585b..02097ea 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -202,7 +202,7 @@ int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, struct nsgtk_scaffolding
/* define data plus and data minus handlers */
-#define TOOLBAR_ITEM(identifier, name, sensitivity, clicked, activate, pass)\
+#define TOOLBAR_ITEM(identifier, name, sensitivity, clicked, activate) \
static gboolean \
nsgtk_toolbar_##name##_data_plus(GtkWidget *widget, \
GdkDragContext *cont, \
@@ -3300,7 +3300,7 @@ toolbar_item_create(nsgtk_toolbar_button id,
item->bhandler = name##_button_clicked_cb;
#define TOOLBAR_ITEM_n(name) \
item->bhandler = NULL;
-#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, pass)\
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate) \
case identifier: \
item->sensitivity = snstvty; \
item->dataplus = nsgtk_toolbar_##name##_data_plus; \
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index ae5c6bb..0ed2f2a 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -82,68 +82,68 @@ typedef enum {
* identifier enum
* name
* initial sensitivity
- * if there is a toolbar click signal handler
- * if there is a menu activate signal handler
- * if the menu activate signal handler calls the toolbar click handler
+ * y/n - if there is a toolbar click signal handler
+ * y/n/p - if there is a menu activate signal handler and if it calls the
+ * toolbar click handler.
*/
#ifndef TOOLBAR_ITEM
-#define TOOLBAR_ITEM(a, b, c, d, e, f)
+#define TOOLBAR_ITEM(a, b, c, d, e)
#define TOOLBAR_ITEM_SET
#endif
-TOOLBAR_ITEM(BACK_BUTTON, back, false, y, y, y)
-TOOLBAR_ITEM(HISTORY_BUTTON, history, true, y, n, n)
-TOOLBAR_ITEM(FORWARD_BUTTON, forward, false, y, y, y)
-TOOLBAR_ITEM(STOP_BUTTON, stop, false, y, y, y)
-TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, y, y, y)
-TOOLBAR_ITEM(HOME_BUTTON, home, true, y, y, y)
-TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true, n, n, n)
-TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true, n, n, n)
-TOOLBAR_ITEM(THROBBER_ITEM, throbber, true, n, n, n)
-TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true, y, y, y)
-TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true, y, y, y)
-TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, y, y, y)
-TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, n, y, n)
-TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, y, y, y)
-TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, y, y, y)
-TOOLBAR_ITEM(PDF_BUTTON, pdf, false, y, y, y)
-TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true, y, y, y)
-TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false, n, n, n)
-TOOLBAR_ITEM(POSTSCRIPT_BUTTON, postscript, false, n, n, n)
-TOOLBAR_ITEM(PRINTPREVIEW_BUTTON, printpreview, false, n, y, y)
-TOOLBAR_ITEM(PRINT_BUTTON, print, true, y, y, y)
-TOOLBAR_ITEM(QUIT_BUTTON, quit, true, y, y, y)
-TOOLBAR_ITEM(CUT_BUTTON, cut, true, y, y, y)
-TOOLBAR_ITEM(COPY_BUTTON, copy, true, y, y, y)
-TOOLBAR_ITEM(PASTE_BUTTON, paste, true, y, y, y)
-TOOLBAR_ITEM(DELETE_BUTTON, delete, false, y, y, y)
-TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true, y, y, y)
-TOOLBAR_ITEM(FIND_BUTTON, find, true, n, y, n)
-TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true, y, y, y)
-TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true, y, y, y)
-TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, y, y, y)
-TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, y, y, y)
-TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true, y, y, y)
-TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true, y, y, y)
-TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true, y, y, y)
-TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true, y, y, y)
-TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, y, y, y)
-TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true, y, y, y)
-TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true, y, y, y)
-TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true, y, y, y)
-TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, y, y, y)
-TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, y, y, y)
-TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true, y, y, y)
-TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, y, y, y)
-TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true, y, y, y)
-TOOLBAR_ITEM(NEXTTAB_BUTTON, nexttab, false, n, y, n)
-TOOLBAR_ITEM(PREVTAB_BUTTON, prevtab, false, n, y, n)
-TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true, y, y, y)
-TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, y, y, y)
-TOOLBAR_ITEM(INFO_BUTTON, info, true, y, y, y)
-TOOLBAR_ITEM(ABOUT_BUTTON, about, true, y, y, y)
-TOOLBAR_ITEM(OPENMENU_BUTTON, openmenu, true, y, n, n)
+TOOLBAR_ITEM(BACK_BUTTON, back, false, y, p)
+TOOLBAR_ITEM(HISTORY_BUTTON, history, true, y, n)
+TOOLBAR_ITEM(FORWARD_BUTTON, forward, false, y, p)
+TOOLBAR_ITEM(STOP_BUTTON, stop, false, y, p)
+TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, y, p)
+TOOLBAR_ITEM(HOME_BUTTON, home, true, y, p)
+TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true, n, n)
+TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true, n, n)
+TOOLBAR_ITEM(THROBBER_ITEM, throbber, true, n, n)
+TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true, y, p)
+TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true, y, p)
+TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, y, p)
+TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, n, y)
+TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, y, p)
+TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, y, p)
+TOOLBAR_ITEM(PDF_BUTTON, pdf, false, y, p)
+TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true, y, p)
+TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false, n, n)
+TOOLBAR_ITEM(POSTSCRIPT_BUTTON, postscript, false, n, n)
+TOOLBAR_ITEM(PRINTPREVIEW_BUTTON, printpreview, false, n, p)
+TOOLBAR_ITEM(PRINT_BUTTON, print, true, y, p)
+TOOLBAR_ITEM(QUIT_BUTTON, quit, true, y, p)
+TOOLBAR_ITEM(CUT_BUTTON, cut, true, y, p)
+TOOLBAR_ITEM(COPY_BUTTON, copy, true, y, p)
+TOOLBAR_ITEM(PASTE_BUTTON, paste, true, y, p)
+TOOLBAR_ITEM(DELETE_BUTTON, delete, false, y, p)
+TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true, y, p)
+TOOLBAR_ITEM(FIND_BUTTON, find, true, n, y)
+TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true, y, p)
+TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true, y, p)
+TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, y, p)
+TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, y, p)
+TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true, y, p)
+TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true, y, p)
+TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true, y, p)
+TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true, y, p)
+TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, y, p)
+TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true, y, p)
+TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true, y, p)
+TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true, y, p)
+TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, y, p)
+TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, y, p)
+TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true, y, p)
+TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, y, p)
+TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true, y, p)
+TOOLBAR_ITEM(NEXTTAB_BUTTON, nexttab, false, n, y)
+TOOLBAR_ITEM(PREVTAB_BUTTON, prevtab, false, n, y)
+TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true, y, p)
+TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, y, p)
+TOOLBAR_ITEM(INFO_BUTTON, info, true, y, p)
+TOOLBAR_ITEM(ABOUT_BUTTON, about, true, y, p)
+TOOLBAR_ITEM(OPENMENU_BUTTON, openmenu, true, y, n)
#ifdef TOOLBAR_ITEM_SET
#undef TOOLBAR_ITEM
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=11197074102a46cb85d...
commit 11197074102a46cb85d108f0915fc2929e79b26a
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
add toolbar customize to main and burger menu
diff --git a/frontends/gtk/menu.c b/frontends/gtk/menu.c
index 3e144f0..6589fca 100644
--- a/frontends/gtk/menu.c
+++ b/frontends/gtk/menu.c
@@ -217,12 +217,12 @@ static struct nsgtk_tabs_submenu *nsgtk_menu_tabs_submenu(GtkAccelGroup *group)
/**
-* creates a toolbars submenu
-* \param group the 'global' in a gtk sense accelerator reference
-*/
-
-static struct nsgtk_toolbars_submenu *nsgtk_menu_toolbars_submenu(
- GtkAccelGroup *group)
+ * creates a toolbars submenu
+ *
+ * \param group the 'global' in a gtk sense accelerator reference
+ */
+static struct nsgtk_toolbars_submenu *
+nsgtk_menu_toolbars_submenu(GtkAccelGroup *group)
{
struct nsgtk_toolbars_submenu *ret =
malloc(sizeof(struct nsgtk_toolbars_submenu));
@@ -242,6 +242,9 @@ static struct nsgtk_toolbars_submenu *nsgtk_menu_toolbars_submenu(
CHECK_ITEM(toolbars, toolbar, gtkToolBar, ret)
if (ret->toolbar_menuitem != NULL)
gtk_check_menu_item_set_active(ret->toolbar_menuitem, TRUE);
+ ADD_SEP(toolbars, ret);
+ IMAGE_ITEM(toolbars, customize, gtkCustomize, ret, group);
+
return ret;
}
diff --git a/frontends/gtk/menu.h b/frontends/gtk/menu.h
index 1ef3187..4656e22 100644
--- a/frontends/gtk/menu.h
+++ b/frontends/gtk/menu.h
@@ -124,6 +124,7 @@ struct nsgtk_toolbars_submenu {
GtkMenu *toolbars_menu;
GtkCheckMenuItem *menubar_menuitem;
GtkCheckMenuItem *toolbar_menuitem;
+ GtkWidget *customize_menuitem;
};
struct nsgtk_developer_submenu {
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index e0ca65a..50e061e 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -757,19 +757,16 @@ static void nsgtk_menu_connect_signals(struct nsgtk_scaffolding *g)
"toggled",
G_CALLBACK(nsgtk_on_menubar_activate_menu),
g);
- g_signal_connect(g->burger_menu->view_submenu->toolbars_submenu->menubar_menuitem,
- "toggled",
- G_CALLBACK(nsgtk_on_menubar_activate_menu),
- g);
g_signal_connect(g->menu_bar->view_submenu->toolbars_submenu->toolbar_menuitem,
"toggled",
G_CALLBACK(nsgtk_on_toolbar_activate_menu),
g);
- g_signal_connect(g->burger_menu->view_submenu->toolbars_submenu->toolbar_menuitem,
- "toggled",
- G_CALLBACK(nsgtk_on_toolbar_activate_menu),
+ g_signal_connect(g->menu_bar->view_submenu->toolbars_submenu->customize_menuitem,
+ "activate",
+ G_CALLBACK(nsgtk_on_customize_activate_menu),
g);
+
}
@@ -791,6 +788,18 @@ create_scaffolding_burger_menu(struct nsgtk_scaffolding *gs,
if (nmenu == NULL) {
return NULL;
}
+ g_signal_connect(nmenu->view_submenu->toolbars_submenu->menubar_menuitem,
+ "toggled",
+ G_CALLBACK(nsgtk_on_menubar_activate_menu),
+ gs);
+ g_signal_connect(nmenu->view_submenu->toolbars_submenu->toolbar_menuitem,
+ "toggled",
+ G_CALLBACK(nsgtk_on_toolbar_activate_menu),
+ gs);
+ g_signal_connect(nmenu->view_submenu->toolbars_submenu->customize_menuitem,
+ "activate",
+ G_CALLBACK(nsgtk_on_customize_activate_menu),
+ gs);
return nmenu;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=5f5b94c2aee697e2da5...
commit 5f5b94c2aee697e2da5ab6819b19a00b83f50390
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
simplify menu initialisation macros
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 7432812..e0ca65a 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -894,101 +894,88 @@ static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
#undef TOOLBAR_ITEM
/* items on menubar, burger */
-#define ITEM_MAIN(p, q, r) \
- g->menus[p##_BUTTON].main = g->menu_bar->q->r##_menuitem; \
- g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_menuitem
+#define ITEM_MB(p, q, r) \
+ g->menus[p##_BUTTON].main = g->menu_bar->r##_submenu->q##_menuitem; \
+ g->menus[p##_BUTTON].burger = g->burger_menu->r##_submenu->q##_menuitem
- /* submenu items on menubar, burger */
-#define ITEM_SUB(p, q, r, s) \
- g->menus[p##_BUTTON].main = g->menu_bar->q->r##_submenu->s##_menuitem;\
- g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_submenu->s##_menuitem
+ /* items on menubar, burger and context popup submenu */
+#define ITEM_MBP(p, q, r) \
+ g->menus[p##_BUTTON].main = g->menu_bar->r##_submenu->q##_menuitem; \
+ g->menus[p##_BUTTON].burger = g->burger_menu->r##_submenu->q##_menuitem; \
+ g->menus[p##_BUTTON].popup = g->popup_menu->r##_submenu->q##_menuitem
/* items on menubar, burger and context popup */
-#define ITEM_POP(p, q, r) \
- g->menus[p##_BUTTON].main = g->menu_bar->q->r##_menuitem; \
- g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_menuitem; \
- g->menus[p##_BUTTON].popup = g->popup_menu->r##_menuitem
-
- /* items on menubar, burger and context popup */
-#define ITEM_MAINPOP(p, q, r) \
- g->menus[p##_BUTTON].main = g->menu_bar->q->r##_menuitem; \
- g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_menuitem; \
- g->menus[p##_BUTTON].popup = g->popup_menu->q->r##_menuitem
-
- /* sub submenu items on menubar, burger and context popup */
-#define ITEM_SUBPOP(p, q, r, s) \
- g->menus[p##_BUTTON].main = g->menu_bar->q->r##_submenu->s##_menuitem;\
- g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_submenu->s##_menuitem; \
- g->menus[p##_BUTTON].popup = g->popup_menu->q->r##_submenu->s##_menuitem
+#define ITEM_MBp(p, q, r) \
+ g->menus[p##_BUTTON].main = g->menu_bar->r##_submenu->q##_menuitem; \
+ g->menus[p##_BUTTON].burger = g->burger_menu->r##_submenu->q##_menuitem; \
+ g->menus[p##_BUTTON].popup = g->popup_menu->q##_menuitem
/* file menu */
- ITEM_MAIN(NEWWINDOW, file_submenu, newwindow);
- ITEM_MAIN(NEWTAB, file_submenu, newtab);
- ITEM_MAIN(OPENFILE, file_submenu, openfile);
- ITEM_MAIN(CLOSEWINDOW, file_submenu, closewindow);
- ITEM_MAIN(PRINTPREVIEW, file_submenu, printpreview);
- ITEM_MAIN(PRINT, file_submenu, print);
- ITEM_MAIN(QUIT, file_submenu, quit);
+ ITEM_MB(NEWWINDOW, newwindow, file);
+ ITEM_MB(NEWTAB, newtab, file);
+ ITEM_MB(OPENFILE, openfile, file);
+ ITEM_MB(CLOSEWINDOW, closewindow, file);
+ ITEM_MB(PRINTPREVIEW, printpreview, file);
+ ITEM_MB(PRINT, print, file);
+ ITEM_MB(QUIT, quit, file);
/* file - export submenu */
- ITEM_SUB(SAVEPAGE, file_submenu, export, savepage);
- ITEM_SUB(PLAINTEXT, file_submenu, export, plaintext);
- ITEM_SUB(PDF, file_submenu, export, pdf);
+ ITEM_MB(SAVEPAGE, savepage, file_submenu->export);
+ ITEM_MB(PLAINTEXT, plaintext, file_submenu->export);
+ ITEM_MB(PDF, pdf, file_submenu->export);
/* edit menu */
- ITEM_POP(CUT, edit_submenu, cut);
- ITEM_POP(COPY, edit_submenu, copy);
- ITEM_POP(PASTE, edit_submenu, paste);
- ITEM_MAIN(DELETE, edit_submenu, delete);
- ITEM_MAIN(SELECTALL, edit_submenu, selectall);
- ITEM_MAIN(FIND, edit_submenu, find);
- ITEM_MAIN(PREFERENCES, edit_submenu, preferences);
+ ITEM_MBp(CUT, cut, edit);
+ ITEM_MBp(COPY, copy, edit);
+ ITEM_MBp(PASTE, paste, edit);
+ ITEM_MB(DELETE, delete, edit);
+ ITEM_MB(SELECTALL, selectall, edit);
+ ITEM_MB(FIND, find, edit);
+ ITEM_MB(PREFERENCES, preferences, edit);
/* view menu */
- ITEM_MAIN(FULLSCREEN, view_submenu, fullscreen);
- ITEM_MAIN(SAVEWINDOWSIZE, view_submenu, savewindowsize);
+ ITEM_MB(FULLSCREEN, fullscreen, view);
+ ITEM_MB(SAVEWINDOWSIZE, savewindowsize, view);
/* view - scale submenu */
- ITEM_SUB(ZOOMPLUS, view_submenu, scaleview, zoomplus);
- ITEM_SUB(ZOOMMINUS, view_submenu, scaleview, zoomminus);
- ITEM_SUB(ZOOMNORMAL, view_submenu, scaleview, zoomnormal);
+ ITEM_MB(ZOOMPLUS, zoomplus, view_submenu->scaleview);
+ ITEM_MB(ZOOMMINUS, zoomminus, view_submenu->scaleview);
+ ITEM_MB(ZOOMNORMAL, zoomnormal, view_submenu->scaleview);
/* view - tabs submenu */
- ITEM_SUB(NEXTTAB, view_submenu, tabs, nexttab);
- ITEM_SUB(PREVTAB, view_submenu, tabs, prevtab);
- ITEM_SUB(CLOSETAB, view_submenu, tabs, closetab);
+ ITEM_MB(NEXTTAB, nexttab, view_submenu->tabs);
+ ITEM_MB(PREVTAB, prevtab, view_submenu->tabs);
+ ITEM_MB(CLOSETAB, closetab, view_submenu->tabs);
/* navigation menu */
- ITEM_POP(BACK, nav_submenu, back);
- ITEM_POP(FORWARD, nav_submenu, forward);
- ITEM_POP(STOP, nav_submenu, stop);
- ITEM_POP(RELOAD, nav_submenu, reload);
- ITEM_MAIN(HOME, nav_submenu, home);
- ITEM_MAIN(LOCALHISTORY, nav_submenu, localhistory);
- ITEM_MAIN(GLOBALHISTORY, nav_submenu, globalhistory);
- ITEM_MAIN(ADDBOOKMARKS, nav_submenu, addbookmarks);
- ITEM_MAIN(SHOWBOOKMARKS, nav_submenu, showbookmarks);
- ITEM_MAIN(OPENLOCATION, nav_submenu, openlocation);
+ ITEM_MBp(BACK, back, nav);
+ ITEM_MBp(FORWARD, forward, nav);
+ ITEM_MBp(STOP, stop, nav);
+ ITEM_MBp(RELOAD, reload, nav);
+ ITEM_MB(HOME, home, nav);
+ ITEM_MB(LOCALHISTORY, localhistory, nav);
+ ITEM_MB(GLOBALHISTORY, globalhistory, nav);
+ ITEM_MB(ADDBOOKMARKS, addbookmarks, nav);
+ ITEM_MB(SHOWBOOKMARKS, showbookmarks, nav);
+ ITEM_MB(OPENLOCATION, openlocation, nav);
/* tools menu */
- ITEM_MAINPOP(DOWNLOADS, tools_submenu, downloads);
- ITEM_MAINPOP(SHOWCOOKIES, tools_submenu, showcookies);
+ ITEM_MBP(DOWNLOADS, downloads, tools);
+ ITEM_MBP(SHOWCOOKIES, showcookies, tools);
/* tools > developer submenu */
- ITEM_SUBPOP(VIEWSOURCE, tools_submenu, developer, viewsource);
- ITEM_SUBPOP(TOGGLEDEBUGGING, tools_submenu, developer, toggledebugging);
- ITEM_SUBPOP(SAVEBOXTREE, tools_submenu, developer, debugboxtree);
- ITEM_SUBPOP(SAVEDOMTREE, tools_submenu, developer, debugdomtree);
+ ITEM_MBP(VIEWSOURCE, viewsource, tools_submenu->developer);
+ ITEM_MBP(TOGGLEDEBUGGING, toggledebugging, tools_submenu->developer);
+ ITEM_MBP(SAVEBOXTREE, debugboxtree, tools_submenu->developer);
+ ITEM_MBP(SAVEDOMTREE, debugdomtree, tools_submenu->developer);
/* help menu */
- ITEM_MAIN(CONTENTS, help_submenu, contents);
- ITEM_MAIN(GUIDE, help_submenu, guide);
- ITEM_MAIN(INFO, help_submenu, info);
- ITEM_MAIN(ABOUT, help_submenu, about);
+ ITEM_MB(CONTENTS, contents, help);
+ ITEM_MB(GUIDE, guide, help);
+ ITEM_MB(INFO, info, help);
+ ITEM_MB(ABOUT, about, help);
-#undef ITEM_MAIN
-#undef ITEM_SUB
-#undef ITEM_POP
-#undef ITEM_MAINPOP
-#undef ITEM_SUBPOP
+#undef ITEM_MB
+#undef ITEM_MBp
+#undef ITEM_MBP
return NSERROR_OK;
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=061499eef611ed39831...
commit 061499eef611ed39831a38384bba42d71d0e58c1
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
set menu activation handler using toolbar items
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 350d5a9..7432812 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -459,8 +459,8 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook,
/**
* handle menu activate signals by calling toolbar item activation
*/
-#define TOOLBAR_ITEM_y(identifier, name) \
-static gboolean \
+#define TOOLBAR_ITEM_y(identifier, name) \
+ static gboolean \
nsgtk_on_##name##_activate_menu(GtkMenuItem *widget, gpointer data) \
{ \
struct nsgtk_scaffolding *gs = (struct nsgtk_scaffolding *)data;\
@@ -468,8 +468,8 @@ nsgtk_on_##name##_activate_menu(GtkMenuItem *widget, gpointer data) \
return TRUE; \
}
#define TOOLBAR_ITEM_n(identifier, name)
-#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate) \
- TOOLBAR_ITEM_ ## activate(identifier, name)
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, pass) \
+ TOOLBAR_ITEM_ ## pass(identifier, name)
#include "gtk/toolbar_items.h"
#undef TOOLBAR_ITEM_y
#undef TOOLBAR_ITEM_n
@@ -881,40 +881,42 @@ create_scaffolding_link_menu(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
*/
static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
{
-#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate) \
- g->menus[identifier].sensitivity = snstvty;
+#define TOOLBAR_ITEM_y(identifier, name) \
+ g->menus[identifier].mhandler = nsgtk_on_##name##_activate_menu;
+#define TOOLBAR_ITEM_n(identifier, name) \
+ g->menus[identifier].mhandler = NULL;
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, pass) \
+ g->menus[identifier].sensitivity = snstvty; \
+ TOOLBAR_ITEM_ ## activate(identifier, name)
#include "gtk/toolbar_items.h"
+#undef TOOLBAR_ITEM_y
+#undef TOOLBAR_ITEM_n
#undef TOOLBAR_ITEM
/* items on menubar, burger */
#define ITEM_MAIN(p, q, r) \
- g->menus[p##_BUTTON].mhandler = nsgtk_on_##r##_activate_menu; \
g->menus[p##_BUTTON].main = g->menu_bar->q->r##_menuitem; \
g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_menuitem
/* submenu items on menubar, burger */
#define ITEM_SUB(p, q, r, s) \
- g->menus[p##_BUTTON].mhandler = nsgtk_on_##s##_activate_menu; \
g->menus[p##_BUTTON].main = g->menu_bar->q->r##_submenu->s##_menuitem;\
g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_submenu->s##_menuitem
/* items on menubar, burger and context popup */
#define ITEM_POP(p, q, r) \
- g->menus[p##_BUTTON].mhandler = nsgtk_on_##r##_activate_menu; \
g->menus[p##_BUTTON].main = g->menu_bar->q->r##_menuitem; \
g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_menuitem; \
g->menus[p##_BUTTON].popup = g->popup_menu->r##_menuitem
/* items on menubar, burger and context popup */
#define ITEM_MAINPOP(p, q, r) \
- g->menus[p##_BUTTON].mhandler = nsgtk_on_##r##_activate_menu; \
g->menus[p##_BUTTON].main = g->menu_bar->q->r##_menuitem; \
g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_menuitem; \
g->menus[p##_BUTTON].popup = g->popup_menu->q->r##_menuitem
/* sub submenu items on menubar, burger and context popup */
#define ITEM_SUBPOP(p, q, r, s) \
- g->menus[p##_BUTTON].mhandler = nsgtk_on_##s##_activate_menu; \
g->menus[p##_BUTTON].main = g->menu_bar->q->r##_submenu->s##_menuitem;\
g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_submenu->s##_menuitem; \
g->menus[p##_BUTTON].popup = g->popup_menu->q->r##_submenu->s##_menuitem
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 02097ea..aa5585b 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -202,7 +202,7 @@ int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, struct nsgtk_scaffolding
/* define data plus and data minus handlers */
-#define TOOLBAR_ITEM(identifier, name, sensitivity, clicked, activate) \
+#define TOOLBAR_ITEM(identifier, name, sensitivity, clicked, activate, pass)\
static gboolean \
nsgtk_toolbar_##name##_data_plus(GtkWidget *widget, \
GdkDragContext *cont, \
@@ -3300,7 +3300,7 @@ toolbar_item_create(nsgtk_toolbar_button id,
item->bhandler = name##_button_clicked_cb;
#define TOOLBAR_ITEM_n(name) \
item->bhandler = NULL;
-#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate) \
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, pass)\
case identifier: \
item->sensitivity = snstvty; \
item->dataplus = nsgtk_toolbar_##name##_data_plus; \
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 0de276f..ae5c6bb 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -83,66 +83,67 @@ typedef enum {
* name
* initial sensitivity
* if there is a toolbar click signal handler
+ * if there is a menu activate signal handler
* if the menu activate signal handler calls the toolbar click handler
*/
#ifndef TOOLBAR_ITEM
-#define TOOLBAR_ITEM(a, b, c, d, e)
+#define TOOLBAR_ITEM(a, b, c, d, e, f)
#define TOOLBAR_ITEM_SET
#endif
-TOOLBAR_ITEM(BACK_BUTTON, back, false, y, y)
-TOOLBAR_ITEM(HISTORY_BUTTON, history, true, y, n)
-TOOLBAR_ITEM(FORWARD_BUTTON, forward, false, y, y)
-TOOLBAR_ITEM(STOP_BUTTON, stop, false, y, y)
-TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, y, y)
-TOOLBAR_ITEM(HOME_BUTTON, home, true, y, y)
-TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true, n, n)
-TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true, n, n)
-TOOLBAR_ITEM(THROBBER_ITEM, throbber, true, n, n)
-TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true, y, y)
-TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true, y, y)
-TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, y, y)
-TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, n, n)
-TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, y, y)
-TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, y, y)
-TOOLBAR_ITEM(PDF_BUTTON, pdf, false, y, y)
-TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true, y, y)
-TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false, n, n)
-TOOLBAR_ITEM(POSTSCRIPT_BUTTON, postscript, false, n, n)
-TOOLBAR_ITEM(PRINTPREVIEW_BUTTON, printpreview, false, n, y)
-TOOLBAR_ITEM(PRINT_BUTTON, print, true, y, y)
-TOOLBAR_ITEM(QUIT_BUTTON, quit, true, y, y)
-TOOLBAR_ITEM(CUT_BUTTON, cut, true, y, y)
-TOOLBAR_ITEM(COPY_BUTTON, copy, true, y, y)
-TOOLBAR_ITEM(PASTE_BUTTON, paste, true, y, y)
-TOOLBAR_ITEM(DELETE_BUTTON, delete, false, y, y)
-TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true, y, y)
-TOOLBAR_ITEM(FIND_BUTTON, find, true, n, n)
-TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true, y, y)
-TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true, y, y)
-TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, y, y)
-TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, y, y)
-TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true, y, y)
-TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true, y, y)
-TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true, y, y)
-TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true, y, y)
-TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, y, y)
-TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true, y, y)
-TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true, y, y)
-TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true, y, y)
-TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, y, y)
-TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, y, y)
-TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true, y, y)
-TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, y, y)
-TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true, y, y)
-TOOLBAR_ITEM(NEXTTAB_BUTTON, nexttab, false, n, n)
-TOOLBAR_ITEM(PREVTAB_BUTTON, prevtab, false, n, n)
-TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true, y, y)
-TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, y, y)
-TOOLBAR_ITEM(INFO_BUTTON, info, true, y, y)
-TOOLBAR_ITEM(ABOUT_BUTTON, about, true, y, y)
-TOOLBAR_ITEM(OPENMENU_BUTTON, openmenu, true, y, n)
+TOOLBAR_ITEM(BACK_BUTTON, back, false, y, y, y)
+TOOLBAR_ITEM(HISTORY_BUTTON, history, true, y, n, n)
+TOOLBAR_ITEM(FORWARD_BUTTON, forward, false, y, y, y)
+TOOLBAR_ITEM(STOP_BUTTON, stop, false, y, y, y)
+TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, y, y, y)
+TOOLBAR_ITEM(HOME_BUTTON, home, true, y, y, y)
+TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true, n, n, n)
+TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true, n, n, n)
+TOOLBAR_ITEM(THROBBER_ITEM, throbber, true, n, n, n)
+TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true, y, y, y)
+TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true, y, y, y)
+TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, y, y, y)
+TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, n, y, n)
+TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, y, y, y)
+TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, y, y, y)
+TOOLBAR_ITEM(PDF_BUTTON, pdf, false, y, y, y)
+TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true, y, y, y)
+TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false, n, n, n)
+TOOLBAR_ITEM(POSTSCRIPT_BUTTON, postscript, false, n, n, n)
+TOOLBAR_ITEM(PRINTPREVIEW_BUTTON, printpreview, false, n, y, y)
+TOOLBAR_ITEM(PRINT_BUTTON, print, true, y, y, y)
+TOOLBAR_ITEM(QUIT_BUTTON, quit, true, y, y, y)
+TOOLBAR_ITEM(CUT_BUTTON, cut, true, y, y, y)
+TOOLBAR_ITEM(COPY_BUTTON, copy, true, y, y, y)
+TOOLBAR_ITEM(PASTE_BUTTON, paste, true, y, y, y)
+TOOLBAR_ITEM(DELETE_BUTTON, delete, false, y, y, y)
+TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true, y, y, y)
+TOOLBAR_ITEM(FIND_BUTTON, find, true, n, y, n)
+TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true, y, y, y)
+TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true, y, y, y)
+TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, y, y, y)
+TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, y, y, y)
+TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true, y, y, y)
+TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true, y, y, y)
+TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true, y, y, y)
+TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true, y, y, y)
+TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, y, y, y)
+TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true, y, y, y)
+TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true, y, y, y)
+TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true, y, y, y)
+TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, y, y, y)
+TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, y, y, y)
+TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true, y, y, y)
+TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, y, y, y)
+TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true, y, y, y)
+TOOLBAR_ITEM(NEXTTAB_BUTTON, nexttab, false, n, y, n)
+TOOLBAR_ITEM(PREVTAB_BUTTON, prevtab, false, n, y, n)
+TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true, y, y, y)
+TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, y, y, y)
+TOOLBAR_ITEM(INFO_BUTTON, info, true, y, y, y)
+TOOLBAR_ITEM(ABOUT_BUTTON, about, true, y, y, y)
+TOOLBAR_ITEM(OPENMENU_BUTTON, openmenu, true, y, n, n)
#ifdef TOOLBAR_ITEM_SET
#undef TOOLBAR_ITEM
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=64b2f355dc8b1779996...
commit 64b2f355dc8b1779996f9cb981b1e9ddebd7d7cd
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
use toolbar_items to generate more boilerplate code through macros
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 3a097cc..350d5a9 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -459,221 +459,21 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook,
/**
* handle menu activate signals by calling toolbar item activation
*/
-#define MENUHANDLER(name, itemid) \
+#define TOOLBAR_ITEM_y(identifier, name) \
static gboolean \
nsgtk_on_##name##_activate_menu(GtkMenuItem *widget, gpointer data) \
{ \
struct nsgtk_scaffolding *gs = (struct nsgtk_scaffolding *)data;\
- nsgtk_window_item_activate(gs->top_level, itemid); \
+ nsgtk_window_item_activate(gs->top_level, identifier); \
return TRUE; \
}
-
-/**
- * menu signal handler for activation on new window item
- */
-MENUHANDLER(newwindow, NEWWINDOW_BUTTON);
-
-/**
- * menu signal handler for activation on new tab item
- */
-MENUHANDLER(newtab, NEWTAB_BUTTON);
-
-/**
- * menu signal handler for activation on open file item
- */
-MENUHANDLER(openfile, OPENFILE_BUTTON);
-
-/**
- * menu signal handler for activation on export complete page item
- */
-MENUHANDLER(savepage, SAVEPAGE_BUTTON);
-
-/**
- * menu signal handler for activation on export pdf item
- */
-MENUHANDLER(pdf, PDF_BUTTON);
-
-/**
- * menu signal handler for activation on export plain text item
- */
-MENUHANDLER(plaintext, PLAINTEXT_BUTTON);
-
-/**
- * menu signal handler for activation on print preview item
- */
-MENUHANDLER(printpreview, PRINTPREVIEW_BUTTON);
-
-/**
- * menu signal handler for activation on print item
- */
-MENUHANDLER(print, PRINT_BUTTON);
-
-/**
- * menu signal handler for activation on close window item
- */
-MENUHANDLER(closewindow, CLOSEWINDOW_BUTTON);
-
-/**
- * menu signal handler for activation on close window item
- */
-MENUHANDLER(quit, QUIT_BUTTON);
-
-/**
- * menu signal handler for activation on cut item
- */
-MENUHANDLER(cut, CUT_BUTTON);
-
-/**
- * menu signal handler for activation on copy item
- */
-MENUHANDLER(copy, COPY_BUTTON);
-
-/**
- * menu signal handler for activation on paste item
- */
-MENUHANDLER(paste, PASTE_BUTTON);
-
-/**
- * menu signal handler for activation on delete item
- */
-MENUHANDLER(delete, DELETE_BUTTON);
-
-/**
- * menu signal handler for activation on selectall item
- */
-MENUHANDLER(selectall, SELECTALL_BUTTON);
-
-/**
- * menu signal handler for activation on preferences item
- */
-MENUHANDLER(preferences, PREFERENCES_BUTTON);
-
-/**
- * menu signal handler for activation on zoom plus item
- */
-MENUHANDLER(zoomplus, ZOOMPLUS_BUTTON);
-
-/**
- * menu signal handler for activation on zoom minus item
- */
-MENUHANDLER(zoomminus, ZOOMMINUS_BUTTON);
-
-/**
- * menu signal handler for activation on zoom normal item
- */
-MENUHANDLER(zoomnormal, ZOOMNORMAL_BUTTON);
-
-/**
- * menu signal handler for activation on full screen item
- */
-MENUHANDLER(fullscreen, FULLSCREEN_BUTTON);
-
-/**
- * menu signal handler for activation on view source item
- */
-MENUHANDLER(viewsource, VIEWSOURCE_BUTTON);
-
-/**
- * menu signal handler for activation on downloads item
- */
-MENUHANDLER(downloads, DOWNLOADS_BUTTON);
-
-/**
- * menu signal handler for activation on save window size item
- */
-MENUHANDLER(savewindowsize, SAVEWINDOWSIZE_BUTTON);
-
-/**
- * menu signal handler for activation on toggle debug render item
- */
-MENUHANDLER(toggledebugging, TOGGLEDEBUGGING_BUTTON);
-
-/**
- * menu signal handler for activation on debug box tree item
- */
-MENUHANDLER(debugboxtree, SAVEBOXTREE_BUTTON);
-
-/**
- * menu signal handler for activation on debug dom tree item
- */
-MENUHANDLER(debugdomtree, SAVEDOMTREE_BUTTON);
-
-/**
- * menu signal handler for activation on stop item
- */
-MENUHANDLER(stop, STOP_BUTTON);
-
-/**
- * menu signal handler for activation on reload item
- */
-MENUHANDLER(reload, RELOAD_BUTTON);
-
-/**
- * menu signal handler for activation on back item
- */
-MENUHANDLER(back, BACK_BUTTON);
-
-/**
- * menu signal handler for activation on forward item
- */
-MENUHANDLER(forward, FORWARD_BUTTON);
-
-/**
- * menu signal handler for activation on home item
- */
-MENUHANDLER(home, HOME_BUTTON);
-
-/**
- * menu signal handler for activation on localhistory item
- */
-MENUHANDLER(localhistory, LOCALHISTORY_BUTTON);
-
-/**
- * menu signal handler for activation on globalhistory item
- */
-MENUHANDLER(globalhistory, GLOBALHISTORY_BUTTON);
-
-/**
- * menu signal handler for activation on addbookmarks item
- */
-MENUHANDLER(addbookmarks, ADDBOOKMARKS_BUTTON);
-
-/**
- * menu signal handler for activation on showbookmarks item
- */
-MENUHANDLER(showbookmarks, SHOWBOOKMARKS_BUTTON);
-
-/**
- * menu signal handler for activation on showcookies item
- */
-MENUHANDLER(showcookies, SHOWCOOKIES_BUTTON);
-
-/**
- * menu signal handler for activation on showcookies item
- */
-MENUHANDLER(openlocation, OPENLOCATION_BUTTON);
-
-/**
- * menu signal handler for activation on showcookies item
- */
-MENUHANDLER(contents, CONTENTS_BUTTON);
-
-/**
- * menu signal handler for activation on showcookies item
- */
-MENUHANDLER(guide, GUIDE_BUTTON);
-
-/**
- * menu signal handler for activation on showcookies item
- */
-MENUHANDLER(info, INFO_BUTTON);
-
-/**
- * menu signal handler for activation on showcookies item
- */
-MENUHANDLER(about, ABOUT_BUTTON);
-
-#undef MENUHANDLER
+#define TOOLBAR_ITEM_n(identifier, name)
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate) \
+ TOOLBAR_ITEM_ ## activate(identifier, name)
+#include "gtk/toolbar_items.h"
+#undef TOOLBAR_ITEM_y
+#undef TOOLBAR_ITEM_n
+#undef TOOLBAR_ITEM
static gboolean
@@ -1081,7 +881,7 @@ create_scaffolding_link_menu(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
*/
static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
{
-#define TOOLBAR_ITEM(identifier, name, snstvty, clicked) \
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate) \
g->menus[identifier].sensitivity = snstvty;
#include "gtk/toolbar_items.h"
#undef TOOLBAR_ITEM
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index e27d6a8..02097ea 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -202,7 +202,7 @@ int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, struct nsgtk_scaffolding
/* define data plus and data minus handlers */
-#define TOOLBAR_ITEM(identifier, name, sensitivity, clicked) \
+#define TOOLBAR_ITEM(identifier, name, sensitivity, clicked, activate) \
static gboolean \
nsgtk_toolbar_##name##_data_plus(GtkWidget *widget, \
GdkDragContext *cont, \
@@ -3058,6 +3058,19 @@ localhistory_button_clicked_cb(GtkWidget *widget, gpointer data)
return TRUE;
}
+/**
+ * handler for history 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
+history_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ return localhistory_button_clicked_cb(widget, data);
+}
+
/**
* handler for global history tool bar item clicked signal
@@ -3283,14 +3296,20 @@ toolbar_item_create(nsgtk_toolbar_button id,
/* set item defaults from macro */
switch (id) {
-#define TOOLBAR_ITEM(identifier, name, snstvty, clicked) \
+#define TOOLBAR_ITEM_y(name) \
+ item->bhandler = name##_button_clicked_cb;
+#define TOOLBAR_ITEM_n(name) \
+ item->bhandler = NULL;
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate) \
case identifier: \
item->sensitivity = snstvty; \
item->dataplus = nsgtk_toolbar_##name##_data_plus; \
item->dataminus = nsgtk_toolbar_##name##_data_minus; \
- item->bhandler = clicked; \
+ TOOLBAR_ITEM_ ## clicked(name) \
break;
#include "gtk/toolbar_items.h"
+#undef TOOLBAR_ITEM_y
+#undef TOOLBAR_ITEM_n
#undef TOOLBAR_ITEM
case PLACEHOLDER_BUTTON:
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index cbb6a24..0de276f 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -79,68 +79,70 @@ typedef enum {
/*
* Item fields are:
- * item identifier enum
- * item name
- * item initial visibility
+ * identifier enum
+ * name
+ * initial sensitivity
+ * if there is a toolbar click signal handler
+ * if the menu activate signal handler calls the toolbar click handler
*/
#ifndef TOOLBAR_ITEM
-#define TOOLBAR_ITEM(a, b, c, d)
+#define TOOLBAR_ITEM(a, b, c, d, e)
#define TOOLBAR_ITEM_SET
#endif
-TOOLBAR_ITEM(BACK_BUTTON, back, false, back_button_clicked_cb)
-TOOLBAR_ITEM(HISTORY_BUTTON, history, true, localhistory_button_clicked_cb)
-TOOLBAR_ITEM(FORWARD_BUTTON, forward, false, forward_button_clicked_cb)
-TOOLBAR_ITEM(STOP_BUTTON, stop, false, stop_button_clicked_cb)
-TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, reload_button_clicked_cb)
-TOOLBAR_ITEM(HOME_BUTTON, home, true, home_button_clicked_cb)
-TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true, NULL)
-TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true, NULL)
-TOOLBAR_ITEM(THROBBER_ITEM, throbber, true, NULL)
-TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true, newwindow_button_clicked_cb)
-TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true, newtab_button_clicked_cb)
-TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, openfile_button_clicked_cb)
-TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, NULL)
-TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, closewindow_button_clicked_cb)
-TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, savepage_button_clicked_cb)
-TOOLBAR_ITEM(PDF_BUTTON, pdf, false, pdf_button_clicked_cb)
-TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true, plaintext_button_clicked_cb)
-TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false, NULL)
-TOOLBAR_ITEM(POSTSCRIPT_BUTTON, postscript, false, NULL)
-TOOLBAR_ITEM(PRINTPREVIEW_BUTTON, printpreview, false, NULL)
-TOOLBAR_ITEM(PRINT_BUTTON, print, true, print_button_clicked_cb)
-TOOLBAR_ITEM(QUIT_BUTTON, quit, true, quit_button_clicked_cb)
-TOOLBAR_ITEM(CUT_BUTTON, cut, true, cut_button_clicked_cb)
-TOOLBAR_ITEM(COPY_BUTTON, copy, true, copy_button_clicked_cb)
-TOOLBAR_ITEM(PASTE_BUTTON, paste, true, paste_button_clicked_cb)
-TOOLBAR_ITEM(DELETE_BUTTON, delete, false, delete_button_clicked_cb)
-TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true, selectall_button_clicked_cb)
-TOOLBAR_ITEM(FIND_BUTTON, find, true, NULL)
-TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true, preferences_button_clicked_cb)
-TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true, zoomplus_button_clicked_cb)
-TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, zoomminus_button_clicked_cb)
-TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, zoomnormal_button_clicked_cb)
-TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true, fullscreen_button_clicked_cb)
-TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true, viewsource_button_clicked_cb)
-TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true, downloads_button_clicked_cb)
-TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true, savewindowsize_button_clicked_cb)
-TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, toggledebugging_button_clicked_cb)
-TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true, debugboxtree_button_clicked_cb)
-TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true, debugdomtree_button_clicked_cb)
-TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true, localhistory_button_clicked_cb)
-TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, globalhistory_button_clicked_cb)
-TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, addbookmarks_button_clicked_cb)
-TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true, showbookmarks_button_clicked_cb)
-TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, showcookies_button_clicked_cb)
-TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true, openlocation_button_clicked_cb)
-TOOLBAR_ITEM(NEXTTAB_BUTTON, nexttab, false, NULL)
-TOOLBAR_ITEM(PREVTAB_BUTTON, prevtab, false, NULL)
-TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true, contents_button_clicked_cb)
-TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, guide_button_clicked_cb)
-TOOLBAR_ITEM(INFO_BUTTON, info, true, info_button_clicked_cb)
-TOOLBAR_ITEM(ABOUT_BUTTON, about, true, about_button_clicked_cb)
-TOOLBAR_ITEM(OPENMENU_BUTTON, openmenu, true, openmenu_button_clicked_cb)
+TOOLBAR_ITEM(BACK_BUTTON, back, false, y, y)
+TOOLBAR_ITEM(HISTORY_BUTTON, history, true, y, n)
+TOOLBAR_ITEM(FORWARD_BUTTON, forward, false, y, y)
+TOOLBAR_ITEM(STOP_BUTTON, stop, false, y, y)
+TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, y, y)
+TOOLBAR_ITEM(HOME_BUTTON, home, true, y, y)
+TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true, n, n)
+TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true, n, n)
+TOOLBAR_ITEM(THROBBER_ITEM, throbber, true, n, n)
+TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true, y, y)
+TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true, y, y)
+TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, y, y)
+TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, n, n)
+TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, y, y)
+TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, y, y)
+TOOLBAR_ITEM(PDF_BUTTON, pdf, false, y, y)
+TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true, y, y)
+TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false, n, n)
+TOOLBAR_ITEM(POSTSCRIPT_BUTTON, postscript, false, n, n)
+TOOLBAR_ITEM(PRINTPREVIEW_BUTTON, printpreview, false, n, y)
+TOOLBAR_ITEM(PRINT_BUTTON, print, true, y, y)
+TOOLBAR_ITEM(QUIT_BUTTON, quit, true, y, y)
+TOOLBAR_ITEM(CUT_BUTTON, cut, true, y, y)
+TOOLBAR_ITEM(COPY_BUTTON, copy, true, y, y)
+TOOLBAR_ITEM(PASTE_BUTTON, paste, true, y, y)
+TOOLBAR_ITEM(DELETE_BUTTON, delete, false, y, y)
+TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true, y, y)
+TOOLBAR_ITEM(FIND_BUTTON, find, true, n, n)
+TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true, y, y)
+TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true, y, y)
+TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, y, y)
+TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, y, y)
+TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true, y, y)
+TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true, y, y)
+TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true, y, y)
+TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true, y, y)
+TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, y, y)
+TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true, y, y)
+TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true, y, y)
+TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true, y, y)
+TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, y, y)
+TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, y, y)
+TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true, y, y)
+TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, y, y)
+TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true, y, y)
+TOOLBAR_ITEM(NEXTTAB_BUTTON, nexttab, false, n, n)
+TOOLBAR_ITEM(PREVTAB_BUTTON, prevtab, false, n, n)
+TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true, y, y)
+TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, y, y)
+TOOLBAR_ITEM(INFO_BUTTON, info, true, y, y)
+TOOLBAR_ITEM(ABOUT_BUTTON, about, true, y, y)
+TOOLBAR_ITEM(OPENMENU_BUTTON, openmenu, true, y, n)
#ifdef TOOLBAR_ITEM_SET
#undef TOOLBAR_ITEM
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ec62f346e11bc17c9d7...
commit ec62f346e11bc17c9d7c9955697503f309162fb3
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
fix toolbar property update
diff --git a/frontends/gtk/preferences.c b/frontends/gtk/preferences.c
index efef4a2..3aaaa90 100644
--- a/frontends/gtk/preferences.c
+++ b/frontends/gtk/preferences.c
@@ -512,7 +512,7 @@ SPINBUTTON_SIGNALS(spinDefaultSize, font_size, 10.0)
G_MODULE_EXPORT void
nsgtk_preferences_fontPreview_clicked(GtkButton *button, struct ppref *priv)
{
- nsgtk_reflow_all_windows();
+ nsgtk_window_update_all();
}
@@ -714,7 +714,7 @@ nsgtk_preferences_checkShowSingleTab_toggled(GtkToggleButton *togglebutton,
{
nsoption_set_bool(show_single_tab,
gtk_toggle_button_get_active(togglebutton));
- nsgtk_reflow_all_windows();
+ nsgtk_window_update_all();
}
G_MODULE_EXPORT void
@@ -736,20 +736,11 @@ G_MODULE_EXPORT void
nsgtk_preferences_comboTabPosition_changed(GtkComboBox *widget,
struct ppref *priv)
{
- struct nsgtk_scaffolding *current;
-
/* set the option */
nsoption_set_int(position_tab, gtk_combo_box_get_active(widget));
- /* update all notebooks in all scaffolds */
- current = nsgtk_scaffolding_iterate(NULL);
- while (current) {
- nsgtk_scaffolding_reset_offset(current);
-
- nsgtk_reflow_all_windows();
-
- current = nsgtk_scaffolding_iterate(current);
- }
+ /* update all windows */
+ nsgtk_window_update_all();
}
G_MODULE_EXPORT void
@@ -792,18 +783,10 @@ G_MODULE_EXPORT void
nsgtk_preferences_comboButtonType_changed(GtkComboBox *widget,
struct ppref *priv)
{
- struct nsgtk_scaffolding *current;
-
nsoption_set_int(button_type, gtk_combo_box_get_active(widget) + 1);
- current = nsgtk_scaffolding_iterate(NULL);
- while (current != NULL) {
- nsgtk_scaffolding_reset_offset(current);
-
- nsgtk_scaffolding_toolbars(current);
-
- current = nsgtk_scaffolding_iterate(current);
- }
+ /* update all windows to adopt change */
+ nsgtk_window_update_all();
}
G_MODULE_EXPORT void
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 17cbb5a..3a097cc 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -1400,14 +1400,6 @@ struct nsgtk_scaffolding *nsgtk_current_scaffolding(void)
}
-/* exported interface documented in gtk/scaffolding.h */
-void nsgtk_scaffolding_toolbars(struct nsgtk_scaffolding *g)
-{
- // nsgtk_toolbar_update(g->toolbar);
- nsgtk_search_update(g->search);
-}
-
-
/* exported function documented in gtk/scaffolding.h */
void nsgtk_window_set_title(struct gui_window *gw, const char *title)
{
@@ -1528,13 +1520,6 @@ struct nsgtk_scaffolding *nsgtk_scaffolding_iterate(struct nsgtk_scaffolding *g)
/* exported interface documented in gtk/scaffolding.h */
-void nsgtk_scaffolding_reset_offset(struct nsgtk_scaffolding *g)
-{
- //g->offset = 0;
-}
-
-
-/* exported interface documented in gtk/scaffolding.h */
struct gui_window *nsgtk_scaffolding_top_level(struct nsgtk_scaffolding *g)
{
return g->top_level;
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index 43ad1a9..16aaf03 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -115,14 +115,6 @@ struct gtk_history_window *nsgtk_scaffolding_history_window(struct nsgtk_scaffol
struct gui_window *nsgtk_scaffolding_top_level(struct nsgtk_scaffolding *g);
-/**
- * reset the scaffold offset value to 0.
- *
- * \todo The value is only ever altered in
- * nsgtk_scaffolding_toolbar_size_allocate and is something to do with
- * the history button either clarify or remove!
- */
-void nsgtk_scaffolding_reset_offset(struct nsgtk_scaffolding *g);
/**
* Iterate through available scaffolding.
@@ -177,9 +169,5 @@ void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g, gdouble x, gdou
*/
void nsgtk_window_set_title(struct gui_window *gw, const char *title);
-/**
- * toolbar style changed
- */
-void nsgtk_scaffolding_toolbars(struct nsgtk_scaffolding *g);
#endif /* NETSURF_GTK_SCAFFOLDING_H */
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index ad2990a..e27d6a8 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -812,6 +812,11 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
return w;
}
+/* exported interface documented in gtk/scaffolding.h */
+static void nsgtk_scaffolding_reset_offset(struct nsgtk_scaffolding *g)
+{
+ //g->offset = 0;
+}
/**
* called when a widget is dropped onto the toolbar
@@ -2928,10 +2933,9 @@ toggledebugging_button_clicked_cb(GtkWidget *widget, gpointer data)
browser_window_debug(bw, CONTENT_DEBUG_REDRAW);
- nsgtk_reflow_all_windows();
+ nsgtk_window_update_all();
return TRUE;
-
}
@@ -3564,6 +3568,12 @@ nserror nsgtk_toolbar_destroy(struct nsgtk_toolbar *tb)
/* exported interface documented in toolbar.h */
nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb)
{
+ /*
+ * reset toolbar size allocation so icon size change affects
+ * allocated widths.
+ */
+ tb->offset = 0;
+
switch (nsoption_int(button_type)) {
case 1: /* Small icons */
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index b43a0ec..0daf0fe 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -904,11 +904,15 @@ nsgtk_window_item_activate(struct gui_window *gw, nsgtk_toolbar_button itemid)
return nsgtk_toolbar_item_activate(gw->toolbar, itemid);
}
-void nsgtk_reflow_all_windows(void)
+/* exported interface documented in window.h */
+void nsgtk_window_update_all(void)
{
- for (struct gui_window *g = window_list; g; g = g->next) {
- nsgtk_tab_options_changed(nsgtk_scaffolding_notebook(g->scaffold));
- browser_window_schedule_reformat(g->bw);
+ struct gui_window *gw;
+ for (gw = window_list; gw != NULL; gw = gw->next) {
+ nsgtk_tab_options_changed(nsgtk_scaffolding_notebook(gw->scaffold));
+ nsgtk_toolbar_update(gw->toolbar);
+ /** \todo update search bar */
+ browser_window_schedule_reformat(gw->bw);
}
}
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index dd49c71..b6e00a6 100644
--- a/frontends/gtk/window.h
+++ b/frontends/gtk/window.h
@@ -46,9 +46,13 @@ struct browser_window *nsgtk_get_browser_window(struct gui_window *gw);
struct nsgtk_scaffolding *nsgtk_get_scaffold(struct gui_window *gw);
/**
- * cause all windows be be reflowed
+ * Every window will have its tab, toolbar and drawing area updated
+ *
+ * The update will ensure the correct tab options are used, the
+ * toolbar size and style is changed and the browser window contents
+ * redrawn.
*/
-void nsgtk_reflow_all_windows(void);
+void nsgtk_window_update_all(void);
/**
* update targets
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f6a669464f67bbed442...
commit f6a669464f67bbed442c80cb3b6d207eacf4fa9a
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
split burger menu from popup context menu
diff --git a/frontends/gtk/compat.h b/frontends/gtk/compat.h
index 20a75a3..feb0abe 100644
--- a/frontends/gtk/compat.h
+++ b/frontends/gtk/compat.h
@@ -51,6 +51,7 @@
#define NSGTK_STOCK_STOP "process-stop"
#define NSGTK_STOCK_OK "_OK"
#define NSGTK_STOCK_OPEN "_Open"
+#define NSGTK_STOCK_OPEN_MENU "open-menu"
#else
#define NSGTK_STOCK_ADD GTK_STOCK_ADD
#define NSGTK_STOCK_CANCEL GTK_STOCK_CANCEL
@@ -67,6 +68,7 @@
#define NSGTK_STOCK_STOP GTK_STOCK_STOP
#define NSGTK_STOCK_OK GTK_STOCK_OK
#define NSGTK_STOCK_OPEN GTK_STOCK_OPEN
+#define NSGTK_STOCK_OPEN_MENU GTK_STOCK_JUSTIFY_FILL
#endif
/* widget alignment only available since 3.0 */
diff --git a/frontends/gtk/menu.c b/frontends/gtk/menu.c
index 909016a..3e144f0 100644
--- a/frontends/gtk/menu.c
+++ b/frontends/gtk/menu.c
@@ -49,12 +49,12 @@ nsgtk_menu_add_image_item(GtkMenu *menu,
GdkModifierType mod;
GtkWidget *item;
const char *accelerator_desc; /* accelerator key description */
-
+
item = nsgtk_image_menu_item_new_with_mnemonic(messages_get(message));
if (item == NULL) {
return false;
}
-
+
accelerator_desc = nsgtk_accelerator_get_desc(message);
if (accelerator_desc != NULL) {
gtk_accelerator_parse(accelerator_desc, &key, &mod);
@@ -215,29 +215,6 @@ static struct nsgtk_tabs_submenu *nsgtk_menu_tabs_submenu(GtkAccelGroup *group)
return ret;
}
-/**
-* creates an images submenu
-* \param group the 'global' in a gtk sense accelerator reference
-*/
-
-static struct nsgtk_images_submenu *nsgtk_menu_images_submenu(GtkAccelGroup *group)
-{
- struct nsgtk_images_submenu *ret =
- malloc(sizeof(struct nsgtk_images_submenu));
- if (ret == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- return NULL;
- }
- ret->images_menu = GTK_MENU(gtk_menu_new());
- if (ret->images_menu == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- free(ret);
- return NULL;
- }
- CHECK_ITEM(images, foregroundimages, gtkForegroundImages, ret)
- CHECK_ITEM(images, backgroundimages, gtkBackgroundImages, ret)
- return ret;
-}
/**
* creates a toolbars submenu
@@ -386,22 +363,16 @@ static struct nsgtk_view_menu *nsgtk_menu_view_submenu(GtkAccelGroup *group)
free(ret);
return NULL;
}
- IMAGE_ITEM(view, stop, gtkStop, ret, group);
- IMAGE_ITEM(view, reload, gtkReload, ret, group);
- ADD_SEP(view, ret);
IMAGE_ITEM(view, scaleview, gtkScaleView, ret, group);
+ SET_SUBMENU(scaleview, ret);
IMAGE_ITEM(view, fullscreen, gtkFullScreen, ret, group);
ADD_SEP(view, ret);
- IMAGE_ITEM(view, images, gtkImages, ret, group);
IMAGE_ITEM(view, toolbars, gtkToolbars, ret, group);
+ SET_SUBMENU(toolbars, ret);
IMAGE_ITEM(view, tabs, gtkTabs, ret, group);
+ SET_SUBMENU(tabs, ret);
ADD_SEP(view, ret);
IMAGE_ITEM(view, savewindowsize, gtkSaveWindowSize, ret, group);
- SET_SUBMENU(scaleview, ret);
- SET_SUBMENU(images, ret);
- SET_SUBMENU(toolbars, ret);
- SET_SUBMENU(tabs, ret);
-
return ret;
}
@@ -427,6 +398,8 @@ static struct nsgtk_nav_menu *nsgtk_menu_nav_submenu(GtkAccelGroup *group)
IMAGE_ITEM(nav, back, gtkBack, ret, group);
IMAGE_ITEM(nav, forward, gtkForward, ret, group);
+ IMAGE_ITEM(nav, stop, gtkStop, ret, group);
+ IMAGE_ITEM(nav, reload, gtkReload, ret, group);
IMAGE_ITEM(nav, home, gtkHome, ret, group);
ADD_SEP(nav, ret);
IMAGE_ITEM(nav, localhistory, gtkLocalHistory, ret, group);
@@ -532,43 +505,58 @@ nsgtk_menu_bar_create(GtkMenuShell *menubar, GtkAccelGroup *group)
return nmenu;
}
+
/* exported function documented in gtk/menu.h */
-struct nsgtk_popup_menu *nsgtk_popup_menu_create(GtkAccelGroup *group)
+struct nsgtk_burger_menu *nsgtk_burger_menu_create(GtkAccelGroup *group)
{
- struct nsgtk_popup_menu *nmenu;
+ struct nsgtk_burger_menu *nmenu;
- NEW_MENU(nmenu, popup);
+ NEW_MENU(nmenu, burger);
- IMAGE_ITEM(popup, file, gtkFile, nmenu, group);
+ IMAGE_ITEM(burger, file, gtkFile, nmenu, group);
SET_SUBMENU(file, nmenu);
- IMAGE_ITEM(popup, edit, gtkEdit, nmenu, group);
+ IMAGE_ITEM(burger, edit, gtkEdit, nmenu, group);
SET_SUBMENU(edit, nmenu);
- IMAGE_ITEM(popup, view, gtkView, nmenu, group);
+ IMAGE_ITEM(burger, view, gtkView, nmenu, group);
SET_SUBMENU(view, nmenu);
- IMAGE_ITEM(popup, nav, gtkNavigate, nmenu, group);
+ IMAGE_ITEM(burger, nav, gtkNavigate, nmenu, group);
SET_SUBMENU(nav, nmenu);
- IMAGE_ITEM(popup, tools, gtkTools, nmenu, group);
+ IMAGE_ITEM(burger, tools, gtkTools, nmenu, group);
SET_SUBMENU(tools, nmenu);
- IMAGE_ITEM(popup, help, gtkHelp, nmenu, group);
+ IMAGE_ITEM(burger, help, gtkHelp, nmenu, group);
SET_SUBMENU(help, nmenu);
- ADD_NAMED_SEP(popup, first, nmenu);
+ return nmenu;
+}
- IMAGE_ITEM(popup, back, gtkBack, nmenu, group);
- IMAGE_ITEM(popup, forward, gtkForward, nmenu, group);
- ADD_NAMED_SEP(popup, third, nmenu);
+/* exported function documented in gtk/menu.h */
+struct nsgtk_popup_menu *nsgtk_popup_menu_create(GtkAccelGroup *group)
+{
+ struct nsgtk_popup_menu *nmenu;
+
+ NEW_MENU(nmenu, popup);
+ IMAGE_ITEM(popup, back, gtkBack, nmenu, group);
+ IMAGE_ITEM(popup, forward, gtkForward, nmenu, group);
IMAGE_ITEM(popup, stop, gtkStop, nmenu, group);
IMAGE_ITEM(popup, reload, gtkReload, nmenu, group);
+
+ ADD_NAMED_SEP(popup, first, nmenu);
+
IMAGE_ITEM(popup, cut, gtkCut, nmenu, group);
IMAGE_ITEM(popup, copy, gtkCopy, nmenu, group);
IMAGE_ITEM(popup, paste, gtkPaste, nmenu, group);
+
+ ADD_NAMED_SEP(popup, second, nmenu);
+
+ IMAGE_ITEM(popup, tools, gtkTools, nmenu, group);
+ SET_SUBMENU(tools, nmenu);
IMAGE_ITEM(popup, customize, gtkCustomize, nmenu, group);
return nmenu;
diff --git a/frontends/gtk/menu.h b/frontends/gtk/menu.h
index 6dbb433..1ef3187 100644
--- a/frontends/gtk/menu.h
+++ b/frontends/gtk/menu.h
@@ -38,45 +38,45 @@ struct nsgtk_file_menu {
};
struct nsgtk_edit_menu {
- GtkMenuItem *edit; /* Edit menu item on menubar */
- GtkMenu *edit_menu;
- GtkWidget *cut_menuitem;
- GtkWidget *copy_menuitem;
- GtkWidget *paste_menuitem;
- GtkWidget *delete_menuitem;
- GtkWidget *selectall_menuitem;
- GtkWidget *find_menuitem;
- GtkWidget *preferences_menuitem;
+ GtkMenuItem *edit; /* Edit menu item on menubar */
+ GtkMenu *edit_menu;
+ GtkWidget *cut_menuitem;
+ GtkWidget *copy_menuitem;
+ GtkWidget *paste_menuitem;
+ GtkWidget *delete_menuitem;
+ GtkWidget *selectall_menuitem;
+ GtkWidget *find_menuitem;
+ GtkWidget *preferences_menuitem;
};
struct nsgtk_view_menu {
- GtkMenuItem *view; /* View menu item on menubar */
- GtkMenu *view_menu; /* gtk menu attached to menu item */
- GtkWidget *stop_menuitem;
- GtkWidget *reload_menuitem;
- GtkWidget *scaleview_menuitem;
+ GtkMenuItem *view; /* View menu item on menubar */
+ GtkMenu *view_menu; /* gtk menu attached to menu item */
+
+ GtkWidget *scaleview_menuitem;
struct nsgtk_scaleview_submenu *scaleview_submenu;
- GtkWidget *fullscreen_menuitem;
- GtkWidget *images_menuitem;
- struct nsgtk_images_submenu *images_submenu;
- GtkWidget *toolbars_menuitem;
- struct nsgtk_toolbars_submenu *toolbars_submenu;
- GtkWidget *tabs_menuitem;
- struct nsgtk_tabs_submenu *tabs_submenu;
- GtkWidget *savewindowsize_menuitem;
+ GtkWidget *fullscreen_menuitem;
+ GtkWidget *toolbars_menuitem;
+ struct nsgtk_toolbars_submenu *toolbars_submenu;
+ GtkWidget *tabs_menuitem;
+ struct nsgtk_tabs_submenu *tabs_submenu;
+ GtkWidget *savewindowsize_menuitem;
};
struct nsgtk_nav_menu {
- GtkMenuItem *nav; /* Nav menu item on menubar */
- GtkMenu *nav_menu;
- GtkWidget *back_menuitem;
- GtkWidget *forward_menuitem;
- GtkWidget *home_menuitem;
- GtkWidget *localhistory_menuitem;
- GtkWidget *globalhistory_menuitem;
- GtkWidget *addbookmarks_menuitem;
- GtkWidget *showbookmarks_menuitem;
- GtkWidget *openlocation_menuitem;
+ GtkMenuItem *nav; /* Nav menu item on menubar */
+ GtkMenu *nav_menu;
+
+ GtkWidget *back_menuitem;
+ GtkWidget *forward_menuitem;
+ GtkWidget *stop_menuitem;
+ GtkWidget *reload_menuitem;
+ GtkWidget *home_menuitem;
+ GtkWidget *localhistory_menuitem;
+ GtkWidget *globalhistory_menuitem;
+ GtkWidget *addbookmarks_menuitem;
+ GtkWidget *showbookmarks_menuitem;
+ GtkWidget *openlocation_menuitem;
};
struct nsgtk_tools_menu {
@@ -120,16 +120,10 @@ struct nsgtk_tabs_submenu {
GtkWidget *closetab_menuitem;
};
-struct nsgtk_images_submenu {
- GtkMenu *images_menu;
- GtkCheckMenuItem *foregroundimages_menuitem;
- GtkCheckMenuItem *backgroundimages_menuitem;
-};
-
struct nsgtk_toolbars_submenu {
- GtkMenu *toolbars_menu;
- GtkCheckMenuItem *menubar_menuitem;
- GtkCheckMenuItem *toolbar_menuitem;
+ GtkMenu *toolbars_menu;
+ GtkCheckMenuItem *menubar_menuitem;
+ GtkCheckMenuItem *toolbar_menuitem;
};
struct nsgtk_developer_submenu {
@@ -141,7 +135,9 @@ struct nsgtk_developer_submenu {
GtkWidget *debugdomtree_menuitem;
};
-
+/**
+ * main menubar
+ */
struct nsgtk_bar_submenu {
GtkMenuBar *bar_menu;
struct nsgtk_file_menu *file_submenu;
@@ -153,8 +149,8 @@ struct nsgtk_bar_submenu {
struct nsgtk_help_menu *help_submenu;
};
-struct nsgtk_popup_menu {
- GtkMenu *popup_menu;
+struct nsgtk_burger_menu {
+ GtkMenu *burger_menu;
GtkWidget *file_menuitem;
struct nsgtk_file_menu *file_submenu;
@@ -176,22 +172,29 @@ struct nsgtk_popup_menu {
GtkWidget *help_menuitem;
struct nsgtk_help_menu *help_submenu;
+};
- GtkWidget *first_separator;
+struct nsgtk_popup_menu {
+ GtkMenu *popup_menu;
/* navigation entries */
GtkWidget *back_menuitem;
GtkWidget *forward_menuitem;
-
- GtkWidget *third_separator;
-
- /* view entries */
GtkWidget *stop_menuitem;
GtkWidget *reload_menuitem;
+ GtkWidget *first_separator;
+
+ /* edit entries */
GtkWidget *cut_menuitem;
GtkWidget *copy_menuitem;
GtkWidget *paste_menuitem;
+
+ GtkWidget *second_separator;
+
+ GtkWidget *tools_menuitem;
+ struct nsgtk_tools_menu *tools_submenu;
+
GtkWidget *customize_menuitem;
};
@@ -208,18 +211,23 @@ struct nsgtk_link_menu {
};
/**
- * Create main menu bar.
+ * Create main menubar menu.
*/
struct nsgtk_bar_submenu *nsgtk_menu_bar_create(GtkMenuShell *menubar, GtkAccelGroup *group);
/**
- * Generate right click menu menu.
+ * Generate burger menu.
+ */
+struct nsgtk_burger_menu *nsgtk_burger_menu_create(GtkAccelGroup *group);
+
+/**
+ * Generate right click popup menu.
*
*/
struct nsgtk_popup_menu *nsgtk_popup_menu_create(GtkAccelGroup *group);
/**
- * Generate context sensitive popup menu for link.
+ * Generate context sensitive link popup menu.
*
*/
struct nsgtk_link_menu *nsgtk_link_menu_create(GtkAccelGroup *group);
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 8c6a399..17cbb5a 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -50,7 +50,7 @@
*/
struct nsgtk_menu {
GtkWidget *main; /* main menu entry */
- GtkWidget *rclick; /* right click menu */
+ GtkWidget *burger; /* right click menu */
GtkWidget *popup; /* popup menu entry */
void *mhandler; /* menu item handler */
bool sensitivity; /* menu item is sensitive */
@@ -81,8 +81,11 @@ struct nsgtk_scaffolding {
/** menu bar hierarchy */
struct nsgtk_bar_submenu *menu_bar;
+ /** burger menu hierarchy */
+ struct nsgtk_burger_menu *burger_menu;
+
/** right click popup menu hierarchy */
- struct nsgtk_popup_menu *menu_popup;
+ struct nsgtk_popup_menu *popup_menu;
/** link popup menu */
struct nsgtk_link_menu *link_menu;
@@ -112,39 +115,28 @@ static struct browser_window_features current_menu_features;
* Helper to hide popup menu entries by grouping.
*
* \param menu The popup menu to modify.
- * \param submenu flag to indicate if submenus should be hidden.
* \param nav flag to indicate if navigation entries should be hidden.
* \param cnp flag to indicate if cut and paste entries should be hidden.
* \param custom flag to indicate if menu customisation is hidden.
*/
static void
-popup_menu_hide(struct nsgtk_popup_menu *menu,
- bool submenu,
- bool nav,
- bool cnp,
- bool custom)
+popup_menu_hide(struct nsgtk_popup_menu *menu, bool nav, bool cnp, bool custom)
{
- if (submenu) {
- gtk_widget_hide(GTK_WIDGET(menu->file_menuitem));
- gtk_widget_hide(GTK_WIDGET(menu->edit_menuitem));
- gtk_widget_hide(GTK_WIDGET(menu->view_menuitem));
- gtk_widget_hide(GTK_WIDGET(menu->nav_menuitem));
- gtk_widget_hide(GTK_WIDGET(menu->help_menuitem));
-
- gtk_widget_hide(menu->first_separator);
- }
-
if (nav) {
gtk_widget_hide(GTK_WIDGET(menu->back_menuitem));
gtk_widget_hide(GTK_WIDGET(menu->forward_menuitem));
gtk_widget_hide(GTK_WIDGET(menu->stop_menuitem));
gtk_widget_hide(GTK_WIDGET(menu->reload_menuitem));
+
+ gtk_widget_hide(menu->first_separator);
}
if (cnp) {
gtk_widget_hide(GTK_WIDGET(menu->cut_menuitem));
gtk_widget_hide(GTK_WIDGET(menu->copy_menuitem));
gtk_widget_hide(GTK_WIDGET(menu->paste_menuitem));
+
+ gtk_widget_hide(menu->second_separator);
}
if (custom) {
@@ -158,39 +150,28 @@ popup_menu_hide(struct nsgtk_popup_menu *menu,
* Helper to show popup menu entries by grouping.
*
* \param menu The popup menu to modify.
- * \param submenu flag to indicate if submenus should be visible.
* \param nav flag to indicate if navigation entries should be visible.
* \param cnp flag to indicate if cut and paste entries should be visible.
* \param custom flag to indicate if menu customisation is visible.
*/
static void
-popup_menu_show(struct nsgtk_popup_menu *menu,
- bool submenu,
- bool nav,
- bool cnp,
- bool custom)
+popup_menu_show(struct nsgtk_popup_menu *menu, bool nav, bool cnp, bool custom)
{
- if (submenu) {
- gtk_widget_show(GTK_WIDGET(menu->file_menuitem));
- gtk_widget_show(GTK_WIDGET(menu->edit_menuitem));
- gtk_widget_show(GTK_WIDGET(menu->view_menuitem));
- gtk_widget_show(GTK_WIDGET(menu->nav_menuitem));
- gtk_widget_show(GTK_WIDGET(menu->help_menuitem));
-
- gtk_widget_show(menu->first_separator);
- }
-
if (nav) {
gtk_widget_show(GTK_WIDGET(menu->back_menuitem));
gtk_widget_show(GTK_WIDGET(menu->forward_menuitem));
gtk_widget_show(GTK_WIDGET(menu->stop_menuitem));
gtk_widget_show(GTK_WIDGET(menu->reload_menuitem));
+
+ gtk_widget_show(menu->first_separator);
}
if (cnp) {
gtk_widget_show(GTK_WIDGET(menu->cut_menuitem));
gtk_widget_show(GTK_WIDGET(menu->copy_menuitem));
gtk_widget_show(GTK_WIDGET(menu->paste_menuitem));
+
+ gtk_widget_show(menu->second_separator);
}
if (custom) {
@@ -319,6 +300,7 @@ nsgtk_scaffolding_update_edit_actions_sensitivity(struct nsgtk_scaffolding *g)
}
nsgtk_scaffolding_set_sensitivity(g);
+
return ((g->menus[COPY_BUTTON].sensitivity) |
(g->menus[CUT_BUTTON].sensitivity) |
(g->menus[PASTE_BUTTON].sensitivity));
@@ -340,7 +322,7 @@ nsgtk_scaffolding_enable_edit_actions_sensitivity(struct nsgtk_scaffolding *g)
g->menus[CUT_BUTTON].sensitivity = true;
nsgtk_scaffolding_set_sensitivity(g);
- popup_menu_show(g->menu_popup, false, false, true, false);
+ popup_menu_show(g->popup_menu, false, true, false);
}
/* signal handling functions for the toolbar, URL bar, and menu bar */
@@ -415,7 +397,7 @@ nsgtk_window_tabs_add(GtkNotebook *notebook,
"visible",
visible,
NULL);
- g_object_set(g->menu_popup->view_submenu->tabs_menuitem,
+ g_object_set(g->burger_menu->view_submenu->tabs_menuitem,
"visible",
visible,
NULL);
@@ -459,8 +441,10 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook,
}
gboolean visible = gtk_notebook_get_show_tabs(gs->notebook);
- g_object_set(gs->menu_bar->view_submenu->tabs_menuitem, "visible", visible, NULL);
- g_object_set(gs->menu_popup->view_submenu->tabs_menuitem, "visible", visible, NULL);
+ g_object_set(gs->menu_bar->view_submenu->tabs_menuitem,
+ "visible", visible, NULL);
+ g_object_set(gs->burger_menu->view_submenu->tabs_menuitem,
+ "visible", visible, NULL);
gs->menus[NEXTTAB_BUTTON].sensitivity = visible;
gs->menus[PREVTAB_BUTTON].sensitivity = visible;
@@ -827,45 +811,39 @@ static gboolean nsgtk_on_find_activate_menu(GtkMenuItem *widget, gpointer data)
static gboolean
nsgtk_on_menubar_activate_menu(GtkMenuItem *widget, gpointer data)
{
- GtkWidget *w;
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ struct nsgtk_scaffolding *gs = (struct nsgtk_scaffolding *)data;
+ GtkCheckMenuItem *bmcmi; /* burger menu check */
+ GtkCheckMenuItem *mbcmi; /* menu bar check*/
- /* if the menubar is not being shown the popup menu shows the
- * menubar entries instead.
- */
+ bmcmi = GTK_CHECK_MENU_ITEM(gs->burger_menu->view_submenu->toolbars_submenu->menubar_menuitem);
+ mbcmi = GTK_CHECK_MENU_ITEM(gs->menu_bar->view_submenu->toolbars_submenu->menubar_menuitem);
+
+ /* ensure menubar and burger menu checkboxes are both updated */
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
- /* need to synchronise menus as gtk grumbles when one menu
- * is attached to both headers */
- w = GTK_WIDGET(g->menu_popup->view_submenu->toolbars_submenu->menubar_menuitem);
- if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
- == FALSE)
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
- TRUE);
-
- w = GTK_WIDGET(g->menu_bar->view_submenu->toolbars_submenu->menubar_menuitem);
- if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
- == FALSE)
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
- TRUE);
-
- gtk_widget_show(GTK_WIDGET(g->menu_bar->bar_menu));
-
- popup_menu_show(g->menu_popup, false, true, true, true);
- popup_menu_hide(g->menu_popup, true, false, false, false);
+ if (gtk_check_menu_item_get_active(bmcmi) == FALSE) {
+ gtk_check_menu_item_set_active(bmcmi, TRUE);
+ }
+
+ if (gtk_check_menu_item_get_active(mbcmi) == FALSE) {
+ gtk_check_menu_item_set_active(mbcmi, TRUE);
+ }
+
+ gtk_widget_show(GTK_WIDGET(gs->menu_bar->bar_menu));
+
+ popup_menu_show(gs->popup_menu, true, true, true);
+ popup_menu_hide(gs->popup_menu, false, false, false);
} else {
- w = GTK_WIDGET(g->menu_popup->view_submenu->toolbars_submenu->menubar_menuitem);
- if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
- FALSE);
+ if (gtk_check_menu_item_get_active(bmcmi) == TRUE) {
+ gtk_check_menu_item_set_active(bmcmi, FALSE);
+ }
- w = GTK_WIDGET(g->menu_bar->view_submenu->toolbars_submenu->menubar_menuitem);
- if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
- FALSE);
+ if (gtk_check_menu_item_get_active(mbcmi) == TRUE) {
+ gtk_check_menu_item_set_active(mbcmi, FALSE);
+ }
- gtk_widget_hide(GTK_WIDGET(g->menu_bar->bar_menu));
+ gtk_widget_hide(GTK_WIDGET(gs->menu_bar->bar_menu));
- popup_menu_show(g->menu_popup, true, true, true, true);
+ popup_menu_show(gs->popup_menu, true, true, true);
}
return TRUE;
@@ -875,34 +853,35 @@ nsgtk_on_menubar_activate_menu(GtkMenuItem *widget, gpointer data)
static gboolean
nsgtk_on_toolbar_activate_menu(GtkMenuItem *widget, gpointer data)
{
- GtkWidget *w;
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ struct nsgtk_scaffolding *gs = (struct nsgtk_scaffolding *)data;
+ GtkCheckMenuItem *bmcmi; /* burger menu check */
+ GtkCheckMenuItem *mbcmi; /* menu bar check */
+
+ bmcmi = GTK_CHECK_MENU_ITEM(gs->burger_menu->view_submenu->toolbars_submenu->toolbar_menuitem);
+ mbcmi = GTK_CHECK_MENU_ITEM(gs->menu_bar->view_submenu->toolbars_submenu->toolbar_menuitem);
+ /* ensure menubar and burger menu checkboxes are both updated */
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
- w = GTK_WIDGET(g->menu_popup->view_submenu->toolbars_submenu->toolbar_menuitem);
- if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
- == FALSE)
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
- TRUE);
-
- w = GTK_WIDGET(g->menu_bar->view_submenu->toolbars_submenu->toolbar_menuitem);
- if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
- == FALSE)
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
- TRUE);
+ if (gtk_check_menu_item_get_active(bmcmi) == FALSE) {
+ gtk_check_menu_item_set_active(bmcmi, TRUE);
+ }
+
+ if (gtk_check_menu_item_get_active(mbcmi) == FALSE) {
+ gtk_check_menu_item_set_active(mbcmi, TRUE);
+ }
+
//gtk_widget_show(GTK_WIDGET(g->tool_bar));
} else {
- w = GTK_WIDGET(g->menu_popup->view_submenu->toolbars_submenu->toolbar_menuitem);
- if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
- FALSE);
- w = GTK_WIDGET(g->menu_bar->view_submenu->toolbars_submenu->toolbar_menuitem);
- if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
- gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
- FALSE);
+ if (gtk_check_menu_item_get_active(bmcmi) == TRUE) {
+ gtk_check_menu_item_set_active(bmcmi, FALSE);
+ }
+
+ if (gtk_check_menu_item_get_active(mbcmi) == TRUE) {
+ gtk_check_menu_item_set_active(mbcmi, FALSE);
+ }
+
//gtk_widget_hide(GTK_WIDGET(g->tool_bar));
}
-
return TRUE;
}
@@ -957,8 +936,8 @@ static void nsgtk_menu_connect_signals(struct nsgtk_scaffolding *g)
G_CALLBACK(g->menus[idx].mhandler),
g);
}
- if (g->menus[idx].rclick != NULL) {
- g_signal_connect(g->menus[idx].rclick,
+ if (g->menus[idx].burger != NULL) {
+ g_signal_connect(g->menus[idx].burger,
"activate",
G_CALLBACK(g->menus[idx].mhandler),
g);
@@ -970,17 +949,52 @@ static void nsgtk_menu_connect_signals(struct nsgtk_scaffolding *g)
g);
}
}
-#define CONNECT_CHECK(q)\
- g_signal_connect(g->menu_bar->view_submenu->toolbars_submenu->q##_menuitem, "toggled", G_CALLBACK(nsgtk_on_##q##_activate_menu), g);\
- g_signal_connect(g->menu_popup->view_submenu->toolbars_submenu->q##_menuitem, "toggled", G_CALLBACK(nsgtk_on_##q##_activate_menu), g)
- CONNECT_CHECK(menubar);
- CONNECT_CHECK(toolbar);
-#undef CONNECT_CHECK
+ /*
+ * attach signal handlers for menubar and toolbar visibility toggling
+ */
+ g_signal_connect(g->menu_bar->view_submenu->toolbars_submenu->menubar_menuitem,
+ "toggled",
+ G_CALLBACK(nsgtk_on_menubar_activate_menu),
+ g);
+ g_signal_connect(g->burger_menu->view_submenu->toolbars_submenu->menubar_menuitem,
+ "toggled",
+ G_CALLBACK(nsgtk_on_menubar_activate_menu),
+ g);
+
+ g_signal_connect(g->menu_bar->view_submenu->toolbars_submenu->toolbar_menuitem,
+ "toggled",
+ G_CALLBACK(nsgtk_on_toolbar_activate_menu),
+ g);
+ g_signal_connect(g->burger_menu->view_submenu->toolbars_submenu->toolbar_menuitem,
+ "toggled",
+ G_CALLBACK(nsgtk_on_toolbar_activate_menu),
+ g);
}
/**
+ * Create and connect handlers to burger menu.
+ *
+ * \param g scaffolding to attach popup menu to.
+ * \param group The accelerator group to use for the popup.
+ * \return menu structure on success or NULL on error.
+ */
+static struct nsgtk_burger_menu *
+create_scaffolding_burger_menu(struct nsgtk_scaffolding *gs,
+ GtkAccelGroup *group)
+{
+ struct nsgtk_burger_menu *nmenu;
+
+ nmenu = nsgtk_burger_menu_create(group);
+
+ if (nmenu == NULL) {
+ return NULL;
+ }
+ return nmenu;
+}
+
+/**
* Create and connect handlers to popup menu.
*
* \param g scaffolding to attach popup menu to.
@@ -988,7 +1002,7 @@ static void nsgtk_menu_connect_signals(struct nsgtk_scaffolding *g)
* \return menu structure on success or NULL on error.
*/
static struct nsgtk_popup_menu *
-nsgtk_new_scaffolding_popup(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
+create_scaffolding_popup_menu(struct nsgtk_scaffolding *gs, GtkAccelGroup *group)
{
struct nsgtk_popup_menu *nmenu;
@@ -1001,30 +1015,15 @@ nsgtk_new_scaffolding_popup(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
g_signal_connect(nmenu->popup_menu,
"hide",
G_CALLBACK(nsgtk_window_popup_menu_hidden),
- g);
-
- g_signal_connect(nmenu->cut_menuitem,
- "activate",
- G_CALLBACK(nsgtk_on_cut_activate_menu),
- g);
-
- g_signal_connect(nmenu->copy_menuitem,
- "activate",
- G_CALLBACK(nsgtk_on_copy_activate_menu),
- g);
-
- g_signal_connect(nmenu->paste_menuitem,
- "activate",
- G_CALLBACK(nsgtk_on_paste_activate_menu),
- g);
+ gs);
g_signal_connect(nmenu->customize_menuitem,
"activate",
G_CALLBACK(nsgtk_on_customize_activate_menu),
- g);
+ gs);
/* set initial popup menu visibility */
- popup_menu_hide(nmenu, true, false, false, true);
+ popup_menu_hide(nmenu, false, false, true);
return nmenu;
}
@@ -1038,8 +1037,7 @@ nsgtk_new_scaffolding_popup(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
* \return true on success or false on error.
*/
static struct nsgtk_link_menu *
-nsgtk_new_scaffolding_link_popup(struct nsgtk_scaffolding *g,
- GtkAccelGroup *group)
+create_scaffolding_link_menu(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
{
struct nsgtk_link_menu *nmenu;
@@ -1088,20 +1086,39 @@ static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
#include "gtk/toolbar_items.h"
#undef TOOLBAR_ITEM
+ /* items on menubar, burger */
#define ITEM_MAIN(p, q, r) \
- g->menus[p##_BUTTON].main = g->menu_bar->q->r##_menuitem;\
- g->menus[p##_BUTTON].rclick = g->menu_popup->q->r##_menuitem;\
- g->menus[p##_BUTTON].mhandler = nsgtk_on_##r##_activate_menu;
-
-#define ITEM_SUB(p, q, r, s)\
- g->menus[p##_BUTTON].main =\
- g->menu_bar->q->r##_submenu->s##_menuitem;\
- g->menus[p##_BUTTON].rclick =\
- g->menu_popup->q->r##_submenu->s##_menuitem;\
- g->menus[p##_BUTTON].mhandler = nsgtk_on_##s##_activate_menu;
+ g->menus[p##_BUTTON].mhandler = nsgtk_on_##r##_activate_menu; \
+ g->menus[p##_BUTTON].main = g->menu_bar->q->r##_menuitem; \
+ g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_menuitem
+
+ /* submenu items on menubar, burger */
+#define ITEM_SUB(p, q, r, s) \
+ g->menus[p##_BUTTON].mhandler = nsgtk_on_##s##_activate_menu; \
+ g->menus[p##_BUTTON].main = g->menu_bar->q->r##_submenu->s##_menuitem;\
+ g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_submenu->s##_menuitem
+
+ /* items on menubar, burger and context popup */
+#define ITEM_POP(p, q, r) \
+ g->menus[p##_BUTTON].mhandler = nsgtk_on_##r##_activate_menu; \
+ g->menus[p##_BUTTON].main = g->menu_bar->q->r##_menuitem; \
+ g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_menuitem; \
+ g->menus[p##_BUTTON].popup = g->popup_menu->r##_menuitem
+
+ /* items on menubar, burger and context popup */
+#define ITEM_MAINPOP(p, q, r) \
+ g->menus[p##_BUTTON].mhandler = nsgtk_on_##r##_activate_menu; \
+ g->menus[p##_BUTTON].main = g->menu_bar->q->r##_menuitem; \
+ g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_menuitem; \
+ g->menus[p##_BUTTON].popup = g->popup_menu->q->r##_menuitem
+
+ /* sub submenu items on menubar, burger and context popup */
+#define ITEM_SUBPOP(p, q, r, s) \
+ g->menus[p##_BUTTON].mhandler = nsgtk_on_##s##_activate_menu; \
+ g->menus[p##_BUTTON].main = g->menu_bar->q->r##_submenu->s##_menuitem;\
+ g->menus[p##_BUTTON].burger = g->burger_menu->q->r##_submenu->s##_menuitem; \
+ g->menus[p##_BUTTON].popup = g->popup_menu->q->r##_submenu->s##_menuitem
-#define ITEM_POP(p, q) \
- g->menus[p##_BUTTON].popup = g->menu_popup->q##_menuitem
/* file menu */
ITEM_MAIN(NEWWINDOW, file_submenu, newwindow);
@@ -1117,17 +1134,15 @@ static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
ITEM_SUB(PDF, file_submenu, export, pdf);
/* edit menu */
- ITEM_MAIN(CUT, edit_submenu, cut);
- ITEM_MAIN(COPY, edit_submenu, copy);
- ITEM_MAIN(PASTE, edit_submenu, paste);
+ ITEM_POP(CUT, edit_submenu, cut);
+ ITEM_POP(COPY, edit_submenu, copy);
+ ITEM_POP(PASTE, edit_submenu, paste);
ITEM_MAIN(DELETE, edit_submenu, delete);
ITEM_MAIN(SELECTALL, edit_submenu, selectall);
ITEM_MAIN(FIND, edit_submenu, find);
ITEM_MAIN(PREFERENCES, edit_submenu, preferences);
/* view menu */
- ITEM_MAIN(STOP, view_submenu, stop);
- ITEM_MAIN(RELOAD, view_submenu, reload);
ITEM_MAIN(FULLSCREEN, view_submenu, fullscreen);
ITEM_MAIN(SAVEWINDOWSIZE, view_submenu, savewindowsize);
/* view - scale submenu */
@@ -1140,8 +1155,10 @@ static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
ITEM_SUB(CLOSETAB, view_submenu, tabs, closetab);
/* navigation menu */
- ITEM_MAIN(BACK, nav_submenu, back);
- ITEM_MAIN(FORWARD, nav_submenu, forward);
+ ITEM_POP(BACK, nav_submenu, back);
+ ITEM_POP(FORWARD, nav_submenu, forward);
+ ITEM_POP(STOP, nav_submenu, stop);
+ ITEM_POP(RELOAD, nav_submenu, reload);
ITEM_MAIN(HOME, nav_submenu, home);
ITEM_MAIN(LOCALHISTORY, nav_submenu, localhistory);
ITEM_MAIN(GLOBALHISTORY, nav_submenu, globalhistory);
@@ -1150,13 +1167,13 @@ static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
ITEM_MAIN(OPENLOCATION, nav_submenu, openlocation);
/* tools menu */
- ITEM_MAIN(DOWNLOADS, tools_submenu, downloads);
- ITEM_MAIN(SHOWCOOKIES, tools_submenu, showcookies);
+ ITEM_MAINPOP(DOWNLOADS, tools_submenu, downloads);
+ ITEM_MAINPOP(SHOWCOOKIES, tools_submenu, showcookies);
/* tools > developer submenu */
- ITEM_SUB(VIEWSOURCE, tools_submenu, developer, viewsource);
- ITEM_SUB(TOGGLEDEBUGGING, tools_submenu, developer, toggledebugging);
- ITEM_SUB(SAVEBOXTREE, tools_submenu, developer, debugboxtree);
- ITEM_SUB(SAVEDOMTREE, tools_submenu, developer, debugdomtree);
+ ITEM_SUBPOP(VIEWSOURCE, tools_submenu, developer, viewsource);
+ ITEM_SUBPOP(TOGGLEDEBUGGING, tools_submenu, developer, toggledebugging);
+ ITEM_SUBPOP(SAVEBOXTREE, tools_submenu, developer, debugboxtree);
+ ITEM_SUBPOP(SAVEDOMTREE, tools_submenu, developer, debugdomtree);
/* help menu */
ITEM_MAIN(CONTENTS, help_submenu, contents);
@@ -1164,17 +1181,12 @@ static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
ITEM_MAIN(INFO, help_submenu, info);
ITEM_MAIN(ABOUT, help_submenu, about);
- /* popup menu */
- ITEM_POP(STOP, stop);
- ITEM_POP(RELOAD, reload);
- ITEM_POP(BACK, back);
- ITEM_POP(FORWARD, forward);
-
#undef ITEM_MAIN
#undef ITEM_SUB
-#undef ITEM_BUTTON
#undef ITEM_POP
+#undef ITEM_MAINPOP
+#undef ITEM_SUBPOP
return NSERROR_OK;
}
@@ -1189,9 +1201,9 @@ static void nsgtk_menu_set_sensitivity(struct nsgtk_scaffolding *g)
g->menus[i].main),
g->menus[i].sensitivity);
}
- if (g->menus[i].rclick != NULL) {
+ if (g->menus[i].burger != NULL) {
gtk_widget_set_sensitive(GTK_WIDGET(
- g->menus[i].rclick),
+ g->menus[i].burger),
g->menus[i].sensitivity);
}
if (g->menus[i].popup != NULL) {
@@ -1200,13 +1212,29 @@ static void nsgtk_menu_set_sensitivity(struct nsgtk_scaffolding *g)
g->menus[i].sensitivity);
}
}
- gtk_widget_set_sensitive(GTK_WIDGET(g->menu_bar->view_submenu->images_menuitem), FALSE);
}
/**
* create and initialise menus
+ *
+ * There are four menus held by the scaffolding:
+ *
+ * 1. Main menubar menu.
+ * This can be hidden which causes the right click popup context menu
+ * to use the burger menu.
+ * 2. Burger menu.
+ * This can be opened from a burger icon on the toolbar.
+ * 3. popup context menu.
+ * This is opened by right mouse clicking on the toolbar or browser area
+ * 4. link context menu
+ * Opened like the other popup menu when the mouse is over a link in the
+ * browser area
+ *
+ * The cut, copy, paste, delete and back, forwards, stop, reload groups of
+ * menu entries are context sensitive and must be updated as appropriate
+ * when a menu is opened which contains those groups.
*/
-nserror nsgtk_menus_create(struct nsgtk_scaffolding *gs)
+static nserror nsgtk_menus_create(struct nsgtk_scaffolding *gs)
{
GtkMenuShell *menushell;
GtkAccelGroup *group;
@@ -1232,10 +1260,11 @@ nserror nsgtk_menus_create(struct nsgtk_scaffolding *gs)
gs);
- /* create popup menu */
- gs->menu_popup = nsgtk_new_scaffolding_popup(gs, group);
+ gs->burger_menu = create_scaffolding_burger_menu(gs, group);
+
+ gs->popup_menu = create_scaffolding_popup_menu(gs, group);
- gs->link_menu = nsgtk_new_scaffolding_link_popup(gs, group);
+ gs->link_menu = create_scaffolding_link_menu(gs, group);
/* set up the menu signal handlers */
nsgtk_menu_initialise(gs);
@@ -1569,8 +1598,8 @@ void nsgtk_scaffolding_set_sensitivity(struct nsgtk_scaffolding *g)
if (g->menus[i].main != NULL) \
gtk_widget_set_sensitive(GTK_WIDGET(g->menus[i].main), \
g->menus[i].sensitivity); \
- if (g->menus[i].rclick != NULL) \
- gtk_widget_set_sensitive(GTK_WIDGET(g->menus[i].rclick), \
+ if (g->menus[i].burger != NULL) \
+ gtk_widget_set_sensitive(GTK_WIDGET(g->menus[i].burger), \
g->menus[i].sensitivity); \
if (g->menus[i].popup != NULL) \
gtk_widget_set_sensitive(GTK_WIDGET(g->menus[i].popup), \
@@ -1595,10 +1624,18 @@ void nsgtk_scaffolding_set_sensitivity(struct nsgtk_scaffolding *g)
nserror nsgtk_scaffolding_toolbar_context_menu(struct nsgtk_scaffolding *gs)
{
/* set visibility for right-click popup menu */
- popup_menu_hide(gs->menu_popup, true, false, true, false);
- popup_menu_show(gs->menu_popup, false, false, false, true);
+ popup_menu_hide(gs->popup_menu, false, true, false);
+ popup_menu_show(gs->popup_menu, false, false, true);
- nsgtk_menu_popup_at_pointer(gs->menu_popup->popup_menu, NULL);
+ nsgtk_menu_popup_at_pointer(gs->popup_menu->popup_menu, NULL);
+
+ return NSERROR_OK;
+}
+
+/* exported interface documented in gtk/scaffolding.h */
+nserror nsgtk_scaffolding_burger_menu(struct nsgtk_scaffolding *gs)
+{
+ nsgtk_menu_popup_at_pointer(gs->burger_menu->burger_menu, NULL);
return NSERROR_OK;
}
@@ -1621,31 +1658,36 @@ nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g,
if (current_menu_features.link != NULL) {
/* menu is opening over a link */
gtkmenu = g->link_menu->link_menu;
+ } else if (gtk_widget_get_visible(GTK_WIDGET(g->menu_bar->bar_menu)) == FALSE) {
+ gtkmenu = g->burger_menu->burger_menu;
+
+ nsgtk_scaffolding_update_edit_actions_sensitivity(g);
+
} else {
- gtkmenu = g->menu_popup->popup_menu;
+ gtkmenu = g->popup_menu->popup_menu;
nsgtk_scaffolding_update_edit_actions_sensitivity(g);
if (!(g->menus[COPY_BUTTON].sensitivity)) {
- gtk_widget_hide(GTK_WIDGET(g->menu_popup->copy_menuitem));
+ gtk_widget_hide(GTK_WIDGET(g->popup_menu->copy_menuitem));
} else {
- gtk_widget_show(GTK_WIDGET(g->menu_popup->copy_menuitem));
+ gtk_widget_show(GTK_WIDGET(g->popup_menu->copy_menuitem));
}
if (!(g->menus[CUT_BUTTON].sensitivity)) {
- gtk_widget_hide(GTK_WIDGET(g->menu_popup->cut_menuitem));
+ gtk_widget_hide(GTK_WIDGET(g->popup_menu->cut_menuitem));
} else {
- gtk_widget_show(GTK_WIDGET(g->menu_popup->cut_menuitem));
+ gtk_widget_show(GTK_WIDGET(g->popup_menu->cut_menuitem));
}
if (!(g->menus[PASTE_BUTTON].sensitivity)) {
- gtk_widget_hide(GTK_WIDGET(g->menu_popup->paste_menuitem));
+ gtk_widget_hide(GTK_WIDGET(g->popup_menu->paste_menuitem));
} else {
- gtk_widget_show(GTK_WIDGET(g->menu_popup->paste_menuitem));
+ gtk_widget_show(GTK_WIDGET(g->popup_menu->paste_menuitem));
}
/* hide customise */
- popup_menu_hide(g->menu_popup, false, false, false, true);
+ popup_menu_hide(g->popup_menu, false, false, true);
}
nsgtk_menu_popup_at_pointer(gtkmenu, NULL);
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index f1aa7e8..43ad1a9 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -68,11 +68,16 @@ nserror nsgtk_scaffolding_destroy_all(void);
nserror nsgtk_scaffolding_throbber(struct gui_window* gw, bool active);
/**
- * open a toolbar context menu
+ * open the toolbar context menu
*/
nserror nsgtk_scaffolding_toolbar_context_menu(struct nsgtk_scaffolding *gs);
/**
+ * open the burger menu
+ */
+nserror nsgtk_scaffolding_burger_menu(struct nsgtk_scaffolding *gs);
+
+/**
* Obtain the most recently used scaffolding element.
*
* This allows tabs to be opened in the most recently used window
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 544b25a..ad2990a 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -283,6 +283,7 @@ nsgtk_theme_image_default(nsgtk_toolbar_button tbbutton,
BUTTON_IMAGE(VIEWSOURCE, "gtk-index");
BUTTON_IMAGE(CONTENTS, "gtk-help");
BUTTON_IMAGE(ABOUT, "gtk-about");
+ BUTTON_IMAGE(OPENMENU, NSGTK_STOCK_OPEN_MENU);
#undef BUTTON_IMAGE
case HISTORY_BUTTON:
@@ -796,6 +797,7 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
MAKE_MENUBUTTON(PREVTAB, gtkPrevTab)
MAKE_MENUBUTTON(GUIDE, gtkGuide)
MAKE_MENUBUTTON(INFO, gtkUserInformation)
+ MAKE_MENUBUTTON(OPENMENU, gtkOpenMenu)
#undef MAKE_MENUBUTTON
default:
@@ -3227,8 +3229,7 @@ info_button_clicked_cb(GtkWidget *widget, gpointer data)
* \param data The toolbar context passed when the signal was connected
* \return TRUE
*/
-static gboolean
-about_button_clicked_cb(GtkWidget *widget, gpointer data)
+static gboolean about_button_clicked_cb(GtkWidget *widget, gpointer data)
{
GtkWindow *parent; /* gtk window widget is in */
@@ -3239,6 +3240,28 @@ about_button_clicked_cb(GtkWidget *widget, gpointer data)
}
/**
+ * handler for openmenu 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 to indicate signal handled.
+ */
+static gboolean openmenu_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct gui_window *gw;
+ struct nsgtk_scaffolding *gs;
+
+ gw = tb->get_ctx; /** \todo stop assuming the context is a gui window */
+
+ gs = nsgtk_get_scaffold(gw);
+
+ nsgtk_scaffolding_burger_menu(gs);
+
+ return TRUE;
+}
+
+/**
* create a toolbar item
*
* create a toolbar item and set up its default handlers
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index fbfa5e5..cbb6a24 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -71,6 +71,7 @@ typedef enum {
GUIDE_BUTTON,
INFO_BUTTON,
ABOUT_BUTTON,
+ OPENMENU_BUTTON,
PLACEHOLDER_BUTTON /* size indicator; array maximum indices */
} nsgtk_toolbar_button; /* PLACEHOLDER_BUTTON - 1 */
@@ -139,6 +140,7 @@ TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true, contents_button_clicked_cb)
TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, guide_button_clicked_cb)
TOOLBAR_ITEM(INFO_BUTTON, info, true, info_button_clicked_cb)
TOOLBAR_ITEM(ABOUT_BUTTON, about, true, about_button_clicked_cb)
+TOOLBAR_ITEM(OPENMENU_BUTTON, openmenu, true, openmenu_button_clicked_cb)
#ifdef TOOLBAR_ITEM_SET
#undef TOOLBAR_ITEM
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=85b65921ed38b3ce0bd...
commit 85b65921ed38b3ce0bd795e9455afbd53610b309
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
cleanup scaffolding a bit
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index ccfe1a1..8c6a399 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -17,67 +17,32 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <assert.h>
-#include <stdbool.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
#include <gtk/gtk.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
#include "utils/utils.h"
-#include "utils/dirent.h"
-#include "utils/messages.h"
-#include "utils/corestrings.h"
#include "utils/log.h"
-#include "utils/nsoption.h"
-#include "utils/file.h"
#include "utils/nsurl.h"
-#include "netsurf/content.h"
-#include "netsurf/keypress.h"
+#include "utils/messages.h"
+#include "utils/nsoption.h"
#include "netsurf/browser_window.h"
-#include "netsurf/plotters.h"
#include "desktop/browser_history.h"
#include "desktop/hotlist.h"
-#include "desktop/print.h"
-#include "desktop/save_complete.h"
-#ifdef WITH_PDF_EXPORT
-#include "desktop/font_haru.h"
-#include "desktop/save_pdf.h"
-#endif
-#include "desktop/save_text.h"
-#include "desktop/searchweb.h"
#include "desktop/search.h"
#include "gtk/compat.h"
#include "gtk/warn.h"
-#include "gtk/cookies.h"
-#include "gtk/completion.h"
-#include "gtk/preferences.h"
-#include "gtk/about.h"
-#include "gtk/viewsource.h"
-#include "gtk/bitmap.h"
-#include "gtk/gui.h"
-#include "gtk/global_history.h"
-#include "gtk/local_history.h"
-#include "gtk/hotlist.h"
-#include "gtk/download.h"
-#include "gtk/menu.h"
-#include "gtk/plotters.h"
-#include "gtk/print.h"
-#include "gtk/search.h"
-#include "gtk/throbber.h"
#include "gtk/toolbar_items.h"
#include "gtk/toolbar.h"
+#include "gtk/menu.h"
+#include "gtk/local_history.h"
+#include "gtk/download.h"
+#include "gtk/gui.h"
#include "gtk/window.h"
-#include "gtk/gdk.h"
-#include "gtk/scaffolding.h"
+#include "gtk/completion.h"
#include "gtk/tabs.h"
-#include "gtk/viewdata.h"
+#include "gtk/search.h"
#include "gtk/resources.h"
-#include "gtk/layout_pango.h"
+#include "gtk/scaffolding.h"
/**
@@ -131,7 +96,9 @@ struct nsgtk_scaffolding {
*/
static struct nsgtk_scaffolding *scaf_current;
-/** global list for interface changes */
+/**
+ * global list for interface changes
+ */
static struct nsgtk_scaffolding *scaf_list = NULL;
/**
@@ -410,6 +377,7 @@ nsgtk_window_edit_menu_hidden(GtkWidget *widget,
return TRUE;
}
+
/**
* gtk event handler for popup menu being hidden.
*
@@ -417,8 +385,8 @@ nsgtk_window_edit_menu_hidden(GtkWidget *widget,
* \param g scaffolding handle
* \return TRUE to indicate event handled
*/
-static gboolean nsgtk_window_popup_menu_hidden(GtkWidget *widget,
- struct nsgtk_scaffolding *g)
+static gboolean
+nsgtk_window_popup_menu_hidden(GtkWidget *widget, struct nsgtk_scaffolding *g)
{
nsgtk_scaffolding_enable_edit_actions_sensitivity(g);
return TRUE;
@@ -426,35 +394,6 @@ static gboolean nsgtk_window_popup_menu_hidden(GtkWidget *widget,
/**
- * update handler for URL entry widget
- *
- * \param widget The widget receiving the delete event
- * \param event The event
- * \param data The context pointer passed when the connection was made.
- * \return TRUE to indicate signal handled.
- */
-gboolean
-nsgtk_window_url_changed(GtkWidget *widget,
- GdkEventKey *event,
- gpointer data)
-{
- return nsgtk_completion_update(GTK_ENTRY(widget));
-}
-
-/* exported interface documented in gtk/scaffolding.h */
-nserror nsgtk_scaffolding_toolbar_context_menu(struct nsgtk_scaffolding *gs)
-{
- /* set visibility for right-click popup menu */
- popup_menu_hide(gs->menu_popup, true, false, true, false);
- popup_menu_show(gs->menu_popup, false, false, false, true);
-
- nsgtk_menu_popup_at_pointer(gs->menu_popup->popup_menu, NULL);
-
- return NSERROR_OK;
-}
-
-
-/**
* Update the menus when the number of tabs changes.
*
* \todo toolbar sensitivity
@@ -615,8 +554,6 @@ MENUHANDLER(paste, PASTE_BUTTON);
*/
MENUHANDLER(delete, DELETE_BUTTON);
-
-
/**
* menu signal handler for activation on selectall item
*/
@@ -1092,6 +1029,7 @@ nsgtk_new_scaffolding_popup(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
return nmenu;
}
+
/**
* Create and connect handlers to link popup menu.
*
@@ -1139,14 +1077,6 @@ nsgtk_new_scaffolding_link_popup(struct nsgtk_scaffolding *g,
return nmenu;
}
-/* exported interface documented in gtk/scaffolding.h */
-struct nsgtk_scaffolding *nsgtk_current_scaffolding(void)
-{
- if (scaf_current == NULL) {
- scaf_current = scaf_list;
- }
- return scaf_current;
-}
/**
* initialiase the menu signal handlers ready for connection
@@ -1274,6 +1204,49 @@ static void nsgtk_menu_set_sensitivity(struct nsgtk_scaffolding *g)
}
/**
+ * create and initialise menus
+ */
+nserror nsgtk_menus_create(struct nsgtk_scaffolding *gs)
+{
+ GtkMenuShell *menushell;
+ GtkAccelGroup *group;
+
+ menushell = GTK_MENU_SHELL(gtk_builder_get_object(gs->builder,
+ "menubar"));
+
+ group = gtk_accel_group_new();
+
+ gtk_window_add_accel_group(gs->window, group);
+
+ gs->menu_bar = nsgtk_menu_bar_create(menushell, group);
+
+ /* toolbar URL bar menu bar search bar signal handlers */
+ g_signal_connect(gs->menu_bar->edit_submenu->edit,
+ "show",
+ G_CALLBACK(nsgtk_window_edit_menu_shown),
+ gs);
+
+ g_signal_connect(gs->menu_bar->edit_submenu->edit,
+ "hide",
+ G_CALLBACK(nsgtk_window_edit_menu_hidden),
+ gs);
+
+
+ /* create popup menu */
+ gs->menu_popup = nsgtk_new_scaffolding_popup(gs, group);
+
+ gs->link_menu = nsgtk_new_scaffolding_link_popup(gs, group);
+
+ /* set up the menu signal handlers */
+ nsgtk_menu_initialise(gs);
+ nsgtk_menu_connect_signals(gs);
+ nsgtk_menu_set_sensitivity(gs);
+
+ return NSERROR_OK;
+}
+
+
+/**
* update search toolbar size and style
*/
static nserror nsgtk_search_update(struct gtk_search *search)
@@ -1389,6 +1362,16 @@ static nserror nsgtk_search_connect_signals(struct nsgtk_scaffolding *gs)
/* exported interface documented in gtk/scaffolding.h */
+struct nsgtk_scaffolding *nsgtk_current_scaffolding(void)
+{
+ if (scaf_current == NULL) {
+ scaf_current = scaf_list;
+ }
+ return scaf_current;
+}
+
+
+/* exported interface documented in gtk/scaffolding.h */
void nsgtk_scaffolding_toolbars(struct nsgtk_scaffolding *g)
{
// nsgtk_toolbar_update(g->toolbar);
@@ -1396,7 +1379,6 @@ void nsgtk_scaffolding_toolbars(struct nsgtk_scaffolding *g)
}
-
/* exported function documented in gtk/scaffolding.h */
void nsgtk_window_set_title(struct gui_window *gw, const char *title)
{
@@ -1515,6 +1497,7 @@ struct nsgtk_scaffolding *nsgtk_scaffolding_iterate(struct nsgtk_scaffolding *g)
return g->next;
}
+
/* exported interface documented in gtk/scaffolding.h */
void nsgtk_scaffolding_reset_offset(struct nsgtk_scaffolding *g)
{
@@ -1523,6 +1506,13 @@ void nsgtk_scaffolding_reset_offset(struct nsgtk_scaffolding *g)
/* exported interface documented in gtk/scaffolding.h */
+struct gui_window *nsgtk_scaffolding_top_level(struct nsgtk_scaffolding *g)
+{
+ return g->top_level;
+}
+
+
+/* exported interface documented in gtk/scaffolding.h */
void nsgtk_scaffolding_toggle_search_bar_visibility(struct nsgtk_scaffolding *g)
{
gboolean vis;
@@ -1541,11 +1531,6 @@ void nsgtk_scaffolding_toggle_search_bar_visibility(struct nsgtk_scaffolding *g)
}
}
-/* exported interface documented in gtk/scaffolding.h */
-struct gui_window *nsgtk_scaffolding_top_level(struct nsgtk_scaffolding *g)
-{
- return g->top_level;
-}
/* exported interface documented in gtk/scaffolding.h */
void nsgtk_scaffolding_set_top_level(struct gui_window *gw)
@@ -1572,9 +1557,9 @@ void nsgtk_scaffolding_set_top_level(struct gui_window *gw)
/* Ensure the window's title bar is updated */
nsgtk_window_set_title(gw, browser_window_get_title(bw));
-
}
+
/* exported interface documented in scaffolding.h */
void nsgtk_scaffolding_set_sensitivity(struct nsgtk_scaffolding *g)
{
@@ -1607,9 +1592,23 @@ void nsgtk_scaffolding_set_sensitivity(struct nsgtk_scaffolding *g)
/* exported interface documented in gtk/scaffolding.h */
-void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g,
- gdouble x,
- gdouble y)
+nserror nsgtk_scaffolding_toolbar_context_menu(struct nsgtk_scaffolding *gs)
+{
+ /* set visibility for right-click popup menu */
+ popup_menu_hide(gs->menu_popup, true, false, true, false);
+ popup_menu_show(gs->menu_popup, false, false, false, true);
+
+ nsgtk_menu_popup_at_pointer(gs->menu_popup->popup_menu, NULL);
+
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in gtk/scaffolding.h */
+void
+nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g,
+ gdouble x,
+ gdouble y)
{
GtkMenu *gtkmenu;
struct browser_window *bw;
@@ -1653,13 +1652,11 @@ void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g,
}
-
/* exported interface documented in gtk/scaffolding.h */
struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
{
nserror res;
struct nsgtk_scaffolding *gs;
- GtkAccelGroup *group;
gs = calloc(1, sizeof(*gs));
if (gs == NULL) {
@@ -1679,25 +1676,13 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
gtk_builder_connect_signals(gs->builder, NULL);
+ /* containing window setup */
gs->window = GTK_WINDOW(gtk_builder_get_object(gs->builder,
"wndBrowser"));
- gs->notebook = GTK_NOTEBOOK(gtk_builder_get_object(gs->builder,
- "notebook"));
-
-
- res = nsgtk_search_create(gs->builder, &gs->search);
- if (res != NSERROR_OK) {
- free(gs);
- return NULL;
- }
-
- group = gtk_accel_group_new();
- gtk_window_add_accel_group(gs->window, group);
-
- gs->menu_bar = nsgtk_menu_bar_create(GTK_MENU_SHELL(gtk_builder_get_object(gs->builder, "menubar")), group);
- /* set this window's size and position to what's in the options, or
- * or some sensible default if they're not set yet.
+ /**
+ * set this window's size and position to what's in the options, or
+ * some sensible default if they are not set yet.
*/
if (nsoption_int(window_width) > 0) {
gtk_window_move(gs->window,
@@ -1714,19 +1699,6 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
gtk_window_set_default_size(gs->window, 1000, 700);
}
-
- nsgtk_tab_init(gs);
-
- g_signal_connect_after(gs->notebook,
- "page-added",
- G_CALLBACK(nsgtk_window_tabs_add),
- gs);
- g_signal_connect_after(gs->notebook,
- "page-removed",
- G_CALLBACK(nsgtk_window_tabs_remove),
- gs);
-
- /* connect main window signals to their handlers. */
g_signal_connect(gs->window,
"delete-event",
G_CALLBACK(scaffolding_window_delete_event),
@@ -1737,28 +1709,38 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
G_CALLBACK(scaffolding_window_destroy),
gs);
- /* toolbar URL bar menu bar search bar signal handlers */
- g_signal_connect(gs->menu_bar->edit_submenu->edit,
- "show",
- G_CALLBACK(nsgtk_window_edit_menu_shown),
- gs);
- g_signal_connect(gs->menu_bar->edit_submenu->edit,
- "hide",
- G_CALLBACK(nsgtk_window_edit_menu_hidden),
- gs);
+ /* notebook */
+ res = nsgtk_notebook_create(gs->builder, &gs->notebook);
+ if (res != NSERROR_OK) {
+ free(gs);
+ return NULL;
+ }
- nsgtk_search_connect_signals(gs);
+ g_signal_connect_after(gs->notebook,
+ "page-added",
+ G_CALLBACK(nsgtk_window_tabs_add),
+ gs);
+ g_signal_connect_after(gs->notebook,
+ "page-removed",
+ G_CALLBACK(nsgtk_window_tabs_remove),
+ gs);
- /* create popup menu */
- gs->menu_popup = nsgtk_new_scaffolding_popup(gs, group);
- gs->link_menu = nsgtk_new_scaffolding_link_popup(gs, group);
+ /* local page text search */
+ res = nsgtk_search_create(gs->builder, &gs->search);
+ if (res != NSERROR_OK) {
+ free(gs);
+ return NULL;
+ }
- /* set up the menu signal handlers */
- nsgtk_menu_initialise(gs);
- nsgtk_menu_connect_signals(gs);
- nsgtk_menu_set_sensitivity(gs);
+ nsgtk_search_connect_signals(gs);
+
+ res = nsgtk_menus_create(gs);
+ if (res != NSERROR_OK) {
+ free(gs);
+ return NULL;
+ }
/* attach to the list */
if (scaf_list) {
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index 825310f..f1aa7e8 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -163,8 +163,6 @@ void nsgtk_scaffolding_set_sensitivity(struct nsgtk_scaffolding *g);
*/
void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g, gdouble x, gdouble y);
-gboolean nsgtk_window_url_changed(GtkWidget *, GdkEventKey *, gpointer);
-
/* core acessors */
/**
* set the title in the window
diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c
index 3d21c65..bb4135f 100644
--- a/frontends/gtk/tabs.c
+++ b/frontends/gtk/tabs.c
@@ -318,28 +318,40 @@ void nsgtk_tab_options_changed(GtkNotebook *notebook)
/* exported interface documented in gtk/tabs.h */
-void nsgtk_tab_init(struct nsgtk_scaffolding *gs)
+nserror nsgtk_notebook_create(GtkBuilder *builder, GtkNotebook **notebook_out)
{
GtkNotebook *notebook;
- notebook = nsgtk_scaffolding_notebook(gs);
+ notebook = GTK_NOTEBOOK(gtk_builder_get_object(builder, "notebook"));
nsgtk_tab_add_newtab(notebook);
- g_signal_connect(notebook, "switch-page",
- G_CALLBACK(nsgtk_tab_switch_page), NULL);
- g_signal_connect_after(notebook, "switch-page",
- G_CALLBACK(nsgtk_tab_switch_page_after), NULL);
+ g_signal_connect(notebook,
+ "switch-page",
+ G_CALLBACK(nsgtk_tab_switch_page),
+ NULL);
+ g_signal_connect_after(notebook,
+ "switch-page",
+ G_CALLBACK(nsgtk_tab_switch_page_after),
+ NULL);
+ g_signal_connect(notebook,
+ "page-removed",
+ G_CALLBACK(nsgtk_tab_visibility_update),
+ NULL);
+ g_signal_connect(notebook,
+ "page-added",
+ G_CALLBACK(nsgtk_tab_visibility_update),
+ NULL);
+ g_signal_connect(notebook,
+ "page-reordered",
+ G_CALLBACK(nsgtk_tab_page_reordered),
+ NULL);
- g_signal_connect(notebook, "page-removed",
- G_CALLBACK(nsgtk_tab_visibility_update), NULL);
- g_signal_connect(notebook, "page-added",
- G_CALLBACK(nsgtk_tab_visibility_update), NULL);
- g_signal_connect(notebook, "page-reordered",
- G_CALLBACK(nsgtk_tab_page_reordered), NULL);
+ nsgtk_tab_options_changed(notebook);
+ *notebook_out = notebook;
- nsgtk_tab_options_changed(notebook);
+ return NSERROR_OK;
}
/* exported interface documented in gtk/tabs.h */
diff --git a/frontends/gtk/tabs.h b/frontends/gtk/tabs.h
index 4e9e2c8..acec396 100644
--- a/frontends/gtk/tabs.h
+++ b/frontends/gtk/tabs.h
@@ -21,7 +21,17 @@
struct gui_window;
-void nsgtk_tab_init(struct nsgtk_scaffolding *gs);
+/**
+ * create notebook
+ *
+ * creates a notebook for use inside a window, creates the special add
+ * page(tab) and attaches all signals.
+ *
+ * \param builder the gtk builder object to create notbook from
+ * \param notebook_out reciveds the created notebook
+ * \return NSERROR_OK and notebook_out updated else error code
+ */
+nserror nsgtk_notebook_create(GtkBuilder *builder, GtkNotebook **notebook_out);
/**
* Add new tab to notebook.
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index ae87010..544b25a 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -196,6 +196,10 @@ struct nsgtk_theme {
GtkImage *searchimage[SEARCH_BUTTONS_COUNT];
};
+/* forward declaration */
+void nsgtk_toolbar_connect_all(struct nsgtk_scaffolding *g);
+int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, struct nsgtk_scaffolding *g);
+
/* define data plus and data minus handlers */
#define TOOLBAR_ITEM(identifier, name, sensitivity, clicked) \
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index c302194..dc229e7 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -23,7 +23,7 @@
* control toolbar context
*/
struct nsgtk_toolbar;
-
+struct nsgtk_scaffolding;
/**
* create a control toolbar
@@ -52,6 +52,7 @@ nserror nsgtk_toolbar_destroy(struct nsgtk_toolbar *toolbar);
*/
nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb);
+
/**
* Start or stop a throbber in a toolbar
*
@@ -61,6 +62,7 @@ nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb);
*/
nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active);
+
/**
* Update the toolbar url entry
*
@@ -70,16 +72,22 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active);
*/
nserror nsgtk_toolbar_set_url(struct nsgtk_toolbar *tb, nsurl *url);
+
/**
* set the websearch image
+ *
+ * \param toolbar A toolbar returned from a creation
+ * \param pixbuf The pixel buffer data to use to set the web search icon
+ * \return NSERROR_OK on success
*/
nserror nsgtk_toolbar_set_websearch_image(struct nsgtk_toolbar *tb, GdkPixbuf *pixbuf);
+
/**
* activate the handler for a toolbar item
*
* This allows the same action to be performed for menu enties as if
- * the user had clicked the toolbar widget.
+ * the user had clicked the toolbar widget.
*
* \param toolbar A toolbar returned from a creation
* \param itemid the id of the item to activate
@@ -87,14 +95,16 @@ nserror nsgtk_toolbar_set_websearch_image(struct nsgtk_toolbar *tb, GdkPixbuf *p
*/
nserror nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid);
+
/**
* sets up the images for scaffolding.
*/
void nsgtk_theme_implement(struct nsgtk_scaffolding *g);
+/**
+ * Initialise customization of toolbar entries
+ */
void nsgtk_toolbar_customization_init(struct nsgtk_scaffolding *g);
-void nsgtk_toolbar_connect_all(struct nsgtk_scaffolding *g);
-int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, struct nsgtk_scaffolding *g);
#endif
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=2e8861dc05325c88cfb...
commit 2e8861dc05325c88cfb8130e7eddd0967e4d4b09
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
make web search icon setting work properly
diff --git a/desktop/searchweb.c b/desktop/searchweb.c
index 91a8118..2c0873d 100644
--- a/desktop/searchweb.c
+++ b/desktop/searchweb.c
@@ -366,6 +366,33 @@ search_web_omni(const char *term,
}
/* exported interface documented in desktop/searchweb.h */
+nserror search_web_get_provider_bitmap(struct bitmap **bitmap_out)
+{
+ struct search_provider *provider;
+ struct bitmap *ico_bitmap = NULL;
+
+ /* must be initialised */
+ if (search_web_ctx.providers == NULL) {
+ return NSERROR_INIT_FAILED;
+ }
+
+ provider = &search_web_ctx.providers[search_web_ctx.current];
+
+ /* set the icon now (if we can) at least to the default */
+ if (provider->ico_handle != NULL) {
+ ico_bitmap = content_get_bitmap(provider->ico_handle);
+ }
+ if ((ico_bitmap == NULL) &&
+ (search_web_ctx.default_ico_handle != NULL)) {
+ ico_bitmap = content_get_bitmap(search_web_ctx.default_ico_handle);
+ }
+
+ *bitmap_out = ico_bitmap;
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in desktop/searchweb.h */
nserror search_web_select_provider(int selection)
{
struct search_provider *provider;
@@ -520,10 +547,14 @@ nserror search_web_init(const char *provider_fname)
}
/* get default search icon */
- ret = hlcache_handle_retrieve(icon_nsurl, 0, NULL, NULL,
+ ret = hlcache_handle_retrieve(icon_nsurl,
+ 0,
+ NULL,
+ NULL,
default_ico_callback,
&search_web_ctx,
- NULL, CONTENT_IMAGE,
+ NULL,
+ CONTENT_IMAGE,
&search_web_ctx.default_ico_handle);
nsurl_unref(icon_nsurl);
if (ret != NSERROR_OK) {
diff --git a/desktop/searchweb.h b/desktop/searchweb.h
index a96e778..69748b6 100644
--- a/desktop/searchweb.h
+++ b/desktop/searchweb.h
@@ -72,6 +72,17 @@ enum search_web_omni_flags {
*/
nserror search_web_omni(const char *term, enum search_web_omni_flags flags, struct nsurl **url_out);
+
+/**
+ * obtain the current providers bitmap
+ *
+ * obtain the icon representing the current web search provider
+ *
+ * \param bitmap_out recives the resulting bitmap which may be NULL
+ * \return NSERROR_OK on success or NSERROR_INIT_FAILED if not initialised
+ */
+nserror search_web_get_provider_bitmap(struct bitmap **bitmap_out);
+
/**
* Change the currently selected web search provider.
*
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index ba37413..d033a57 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -304,6 +304,7 @@ static nserror nsgtk_init(int argc, char** argv, char **respath)
resource_filename);
free(resource_filename);
}
+ search_web_select_provider(nsoption_int(search_provider));
/* Default favicon */
res = nsgdk_pixbuf_new_from_resname("favicon.png", &favicon_pixbuf);
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index a7414eb..ccfe1a1 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -1449,135 +1449,6 @@ nserror nsgtk_scaffolding_throbber(struct gui_window* gw, bool active)
}
-static void
-nsgtk_scaffolding_set_websearch(struct nsgtk_scaffolding *g, const char *content)
-{
-#if 0
- /** \todo this code appears technically correct, though
- * currently has no effect at all.
- */
- PangoLayout *lo = gtk_entry_get_layout(GTK_ENTRY(g->webSearchEntry));
- if (lo != NULL) {
- pango_layout_set_font_description(lo, NULL);
- PangoFontDescription *desc = pango_font_description_new();
- if (desc != NULL) {
- pango_font_description_set_style(desc,
- PANGO_STYLE_ITALIC);
- pango_font_description_set_family(desc, "Arial");
- pango_font_description_set_weight(desc,
- PANGO_WEIGHT_ULTRALIGHT);
- pango_font_description_set_size(desc,
- 10 * PANGO_SCALE);
- pango_layout_set_font_description(lo, desc);
- }
-
- PangoAttrList *list = pango_attr_list_new();
- if (list != NULL) {
- PangoAttribute *italic = pango_attr_style_new(
- PANGO_STYLE_ITALIC);
- if (italic != NULL) {
- italic->start_index = 0;
- italic->end_index = strlen(content);
- }
- PangoAttribute *grey = pango_attr_foreground_new(
- 0x7777, 0x7777, 0x7777);
- if (grey != NULL) {
- grey->start_index = 0;
- grey->end_index = strlen(content);
- }
- pango_attr_list_insert(list, italic);
- pango_attr_list_insert(list, grey);
- pango_layout_set_attributes(lo, list);
- pango_attr_list_unref(list);
- }
- pango_layout_set_text(lo, content, -1);
- }
-/* an alternative method */
-/* char *parse = malloc(strlen(content) + 1);
- PangoAttrList *list = pango_layout_get_attributes(lo);
- char *markup = g_strconcat("<span foreground='#777777'><i>", content,
- "</i></span>", NULL);
- pango_parse_markup(markup, -1, 0, &list, &parse, NULL, NULL);
- gtk_widget_show_all(g->webSearchEntry);
-*/
- gtk_entry_set_visibility(GTK_ENTRY(g->webSearchEntry), TRUE);
- gtk_entry_set_text(GTK_ENTRY(g->webSearchEntry), content);
-#endif
-}
-
-
-/**
- * GTK UI callback when search provider details are updated.
- *
- * \param provider_name The providers name.
- * \param provider_bitmap The bitmap representing the provider.
- * \return NSERROR_OK on success else error code.
- */
-static nserror
-gui_search_web_provider_update(const char *provider_name,
- struct bitmap *provider_bitmap)
-{
- struct nsgtk_scaffolding *current;
- GdkPixbuf *srch_pixbuf = NULL;
- char *searchcontent;
-
- NSLOG(netsurf, INFO, "name:%s bitmap %p", provider_name,
- provider_bitmap);
-
- if (provider_bitmap != NULL) {
- srch_pixbuf = nsgdk_pixbuf_get_from_surface(provider_bitmap->surface, 16, 16);
-
- if (srch_pixbuf == NULL) {
- return NSERROR_NOMEM;
- }
- }
-
- /* setup the search content name */
- searchcontent = malloc(strlen(provider_name) + SLEN("Search ") + 1);
- if (searchcontent != NULL) {
- sprintf(searchcontent, "Search %s", provider_name);
- }
-#if 0
- /* set the search provider parameters up in each scaffold */
- for (current = scaf_list; current != NULL; current = current->next) {
- if (current->webSearchEntry == NULL) {
- continue;
- }
-
- /* add ico to each window's toolbar */
- if (srch_pixbuf != NULL) {
- nsgtk_entry_set_icon_from_pixbuf(current->webSearchEntry,
- GTK_ENTRY_ICON_PRIMARY,
- srch_pixbuf);
- } else {
- nsgtk_entry_set_icon_from_stock(current->webSearchEntry,
- GTK_ENTRY_ICON_PRIMARY,
- NSGTK_STOCK_FIND);
- }
-
- /* set search entry text */
- if (searchcontent != NULL) {
- nsgtk_scaffolding_set_websearch(current, searchcontent);
- } else {
- nsgtk_scaffolding_set_websearch(current, provider_name);
- }
- }
-#endif
- free(searchcontent);
-
- if (srch_pixbuf != NULL) {
- g_object_unref(srch_pixbuf);
- }
-
- return NSERROR_OK;
-}
-
-static struct gui_search_web_table search_web_table = {
- .provider_update = gui_search_web_provider_update,
-};
-
-struct gui_search_web_table *nsgtk_search_web_table = &search_web_table;
-
/* exported interface documented in gtk/scaffolding.h */
nserror nsgtk_scaffolding_destroy_all(void)
{
@@ -1618,12 +1489,6 @@ GtkWidget *nsgtk_scaffolding_urlbar(struct nsgtk_scaffolding *g)
}
/* exported interface documented in gtk/scaffolding.h */
-GtkWidget *nsgtk_scaffolding_websearch(struct nsgtk_scaffolding *g)
-{
- return NULL;//g->webSearchEntry;
-}
-
-/* exported interface documented in gtk/scaffolding.h */
GtkToolbar *nsgtk_scaffolding_toolbar(struct nsgtk_scaffolding *g)
{
return NULL;//g->tool_bar;
@@ -1658,15 +1523,6 @@ void nsgtk_scaffolding_reset_offset(struct nsgtk_scaffolding *g)
/* exported interface documented in gtk/scaffolding.h */
-void nsgtk_scaffolding_update_websearch_ref(struct nsgtk_scaffolding *g)
-{
-#if 0
- g->webSearchEntry = gtk_bin_get_child(GTK_BIN(
- g->buttons[WEBSEARCH_ITEM]->button));
-#endif
-}
-
-/* exported interface documented in gtk/scaffolding.h */
void nsgtk_scaffolding_toggle_search_bar_visibility(struct nsgtk_scaffolding *g)
{
gboolean vis;
@@ -1803,7 +1659,6 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
{
nserror res;
struct nsgtk_scaffolding *gs;
- int i;
GtkAccelGroup *group;
gs = calloc(1, sizeof(*gs));
@@ -1916,9 +1771,6 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
/* set icon images */
nsgtk_theme_implement(gs);
- /* set web search provider */
- search_web_select_provider(nsoption_int(search_provider));
-
/* finally, show the window. */
gtk_widget_show(GTK_WIDGET(gs->window));
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index a8cea20..825310f 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -28,7 +28,6 @@ struct gui_window;
struct gui_search_web_table;
struct nsurl;
-extern struct gui_search_web_table *nsgtk_search_web_table;
struct gtk_history_window {
@@ -98,11 +97,6 @@ GtkNotebook *nsgtk_scaffolding_notebook(struct nsgtk_scaffolding *g);
GtkWidget *nsgtk_scaffolding_urlbar(struct nsgtk_scaffolding *g);
/**
- * Get the gtk web search entry from a scaffold.
- */
-GtkWidget *nsgtk_scaffolding_websearch(struct nsgtk_scaffolding *g);
-
-/**
* Get the gtk toolbar from a scaffold.
*/
GtkToolbar *nsgtk_scaffolding_toolbar(struct nsgtk_scaffolding *g);
@@ -131,8 +125,6 @@ void nsgtk_scaffolding_reset_offset(struct nsgtk_scaffolding *g);
struct nsgtk_scaffolding *nsgtk_scaffolding_iterate(struct nsgtk_scaffolding *g);
-void nsgtk_scaffolding_update_websearch_ref(struct nsgtk_scaffolding *g);
-
void nsgtk_scaffolding_toggle_search_bar_visibility(struct nsgtk_scaffolding *g);
/**
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 694c271..ae87010 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -67,6 +67,8 @@
#include "gtk/hotlist.h"
#include "gtk/cookies.h"
#include "gtk/about.h"
+#include "gtk/gdk.h"
+#include "gtk/bitmap.h"
#include "gtk/toolbar.h"
/**
@@ -641,8 +643,12 @@ make_toolbar_item_websearch(void)
GTK_ICON_SIZE_LARGE_TOOLBAR)),
"[websearch]");
} else {
- GtkWidget *entry = nsgtk_entry_new();
+ nserror res;
+ GtkWidget *entry;
+ struct bitmap *bitmap;
+ GdkPixbuf *pixbuf = NULL;
+ entry = nsgtk_entry_new();
item = gtk_tool_item_new();
if ((entry == NULL) || (item == NULL)) {
@@ -651,9 +657,21 @@ make_toolbar_item_websearch(void)
gtk_widget_set_size_request(entry, NSGTK_WEBSEARCH_WIDTH, -1);
- nsgtk_entry_set_icon_from_stock(entry,
- GTK_ENTRY_ICON_PRIMARY,
- NSGTK_STOCK_INFO);
+ res = search_web_get_provider_bitmap(&bitmap);
+ if ((res == NSERROR_OK) && (bitmap != NULL)) {
+ pixbuf = nsgdk_pixbuf_get_from_surface(bitmap->surface,
+ 16, 16);
+ }
+
+ if (pixbuf != NULL) {
+ nsgtk_entry_set_icon_from_pixbuf(entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ pixbuf);
+ } else {
+ nsgtk_entry_set_icon_from_stock(entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ NSGTK_STOCK_INFO);
+ }
gtk_container_add(GTK_CONTAINER(item), entry);
}
@@ -3629,6 +3647,33 @@ nserror nsgtk_toolbar_set_url(struct nsgtk_toolbar *tb, nsurl *url)
/* exported interface documented in toolbar.h */
nserror
+nsgtk_toolbar_set_websearch_image(struct nsgtk_toolbar *tb, GdkPixbuf *pixbuf)
+{
+ GtkWidget *entry;
+
+ if (tb->buttons[WEBSEARCH_ITEM]->button == NULL) {
+ /* no toolbar item */
+ return NSERROR_INVALID;
+ }
+
+ entry = gtk_bin_get_child(GTK_BIN(tb->buttons[WEBSEARCH_ITEM]->button));
+
+ if (pixbuf != NULL) {
+ nsgtk_entry_set_icon_from_pixbuf(entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ pixbuf);
+ } else {
+ nsgtk_entry_set_icon_from_stock(entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ NSGTK_STOCK_INFO);
+ }
+
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in toolbar.h */
+nserror
nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb,
nsgtk_toolbar_button itemid)
{
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index b89774b..c302194 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -70,6 +70,10 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active);
*/
nserror nsgtk_toolbar_set_url(struct nsgtk_toolbar *tb, nsurl *url);
+/**
+ * set the websearch image
+ */
+nserror nsgtk_toolbar_set_websearch_image(struct nsgtk_toolbar *tb, GdkPixbuf *pixbuf);
/**
* activate the handler for a toolbar item
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 666e6ea..b43a0ec 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -655,7 +655,8 @@ static gboolean nsgtk_window_size_allocate_event(GtkWidget *widget,
}
-/** when the pane position is changed update the user option
+/**
+ * when the pane position is changed update the user option
*
* The slightly awkward implementation with the first allocation flag
* is necessary because the initial window creation does not cause an
@@ -794,6 +795,7 @@ gui_window_create(struct browser_window *bw,
return NULL;
}
+
/* set a default favicon */
g_object_ref(favicon_pixbuf);
g->icon = favicon_pixbuf;
@@ -1196,8 +1198,10 @@ static void gui_window_set_pointer(struct gui_window *g,
}
-static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
- const struct rect *clip)
+static void
+gui_window_place_caret(struct gui_window *g,
+ int x, int y, int height,
+ const struct rect *clip)
{
nsgtk_redraw_caret(g);
@@ -1302,6 +1306,12 @@ static void gui_window_create_form_select_menu(struct gui_window *g,
nsgtk_menu_popup_at_pointer(GTK_MENU(select_menu), NULL);
}
+
+/**
+ * GTK window UI callback when core needs a file selection gadget
+ *
+ * \param g The gui window on which the gadget has been requested
+ */
static void
gui_window_file_gadget_open(struct gui_window *g,
struct hlcache_handle *hl,
@@ -1336,7 +1346,7 @@ gui_window_file_gadget_open(struct gui_window *g,
/**
- * process miscellaneous window events
+ * GTK window UI callback to process miscellaneous events
*
* \param gw The window receiving the event.
* \param event The event code.
@@ -1374,11 +1384,56 @@ gui_window_event(struct gui_window *gw, enum gui_window_event event)
return NSERROR_OK;
}
+
+/**
+ * GTK window UI callback when core changes the current url
+ *
+ * \param gw The gui window on which the url has been set.
+ * \param url The new url.
+ */
static nserror gui_window_set_url(struct gui_window *gw, nsurl *url)
{
return nsgtk_toolbar_set_url(gw->toolbar, url);
}
+
+/**
+ * GTK UI callback when search provider details are updated.
+ *
+ * \param name The providers name.
+ * \param bitmap The bitmap representing the provider.
+ * \return NSERROR_OK on success else error code.
+ */
+static nserror
+gui_search_web_provider_update(const char *name, struct bitmap *bitmap)
+{
+ struct gui_window *gw;
+ GdkPixbuf *pixbuf = NULL;
+
+ if (bitmap != NULL) {
+ pixbuf = nsgdk_pixbuf_get_from_surface(bitmap->surface, 16, 16);
+ }
+
+ for (gw = window_list; gw != NULL; gw = gw->next) {
+ nsgtk_toolbar_set_websearch_image(gw->toolbar, pixbuf);
+ }
+
+ return NSERROR_OK;
+}
+
+/**
+ * GTK frontend web search operation table
+ */
+static struct gui_search_web_table search_web_table = {
+ .provider_update = gui_search_web_provider_update,
+};
+
+struct gui_search_web_table *nsgtk_search_web_table = &search_web_table;
+
+
+/**
+ * GTK frontend browser window operation table
+ */
static struct gui_window_table window_table = {
.create = gui_window_create,
.destroy = gui_window_destroy,
@@ -1394,10 +1449,10 @@ static struct gui_window_table window_table = {
.place_caret = gui_window_place_caret,
.create_form_select_menu = gui_window_create_form_select_menu,
.file_gadget_open = gui_window_file_gadget_open,
+ .set_url = gui_window_set_url,
/* from scaffold */
.set_title = nsgtk_window_set_title,
- .set_url = gui_window_set_url,
};
struct gui_window_table *nsgtk_window_table = &window_table;
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index a991f03..dd49c71 100644
--- a/frontends/gtk/window.h
+++ b/frontends/gtk/window.h
@@ -20,6 +20,7 @@
#define NETSURF_GTK_WINDOW_H 1
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,
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e84990bc891c7a75930...
commit e84990bc891c7a75930fddd614516d3eb170cd75
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
make popup context menu work on toolbar
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index d7e7d59..a7414eb 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -79,29 +79,6 @@
#include "gtk/resources.h"
#include "gtk/layout_pango.h"
-/** Macro to define a handler for menu, button and activate events. */
-#define MULTIHANDLER(q)\
-static gboolean nsgtk_on_##q##_activate(struct nsgtk_scaffolding *g);\
-static gboolean nsgtk_on_##q##_activate_menu(GtkMenuItem *widget, gpointer data)\
-{\
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;\
- return nsgtk_on_##q##_activate(g);\
-}\
-static gboolean nsgtk_on_##q##_activate(struct nsgtk_scaffolding *g)
-
-
-/**
- * handle menu activate signals by calling toolbar item activation
- */
-#define MENUHANDLER(name, itemid) \
-static gboolean \
-nsgtk_on_##name##_activate_menu(GtkMenuItem *widget, gpointer data) \
-{ \
- struct nsgtk_scaffolding *gs = (struct nsgtk_scaffolding *)data;\
- nsgtk_window_item_activate(gs->top_level, itemid); \
- return TRUE; \
-}
-
/**
* menu entry context
@@ -464,33 +441,16 @@ nsgtk_window_url_changed(GtkWidget *widget,
return nsgtk_completion_update(GTK_ENTRY(widget));
}
-
-/**
- * Event handler for popup menu on toolbar.
- *
- * \param toolbar The toolbar being clicked
- * \param x The x coordinate where the click happened
- * \param y The x coordinate where the click happened
- * \param button the buttons being pressed
- * \param data The context pointer passed when the connection was made.
- * \return TRUE to indicate event handled.
- */
-static gboolean
-nsgtk_window_tool_bar_clicked(GtkToolbar *toolbar,
- gint x,
- gint y,
- gint button,
- gpointer data)
+/* exported interface documented in gtk/scaffolding.h */
+nserror nsgtk_scaffolding_toolbar_context_menu(struct nsgtk_scaffolding *gs)
{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
-
/* set visibility for right-click popup menu */
- popup_menu_hide(g->menu_popup, true, false, true, false);
- popup_menu_show(g->menu_popup, false, false, false, true);
+ popup_menu_hide(gs->menu_popup, true, false, true, false);
+ popup_menu_show(gs->menu_popup, false, false, false, true);
- nsgtk_menu_popup_at_pointer(g->menu_popup->popup_menu, NULL);
+ nsgtk_menu_popup_at_pointer(gs->menu_popup->popup_menu, NULL);
- return TRUE;
+ return NSERROR_OK;
}
@@ -574,6 +534,18 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook,
/* signal handlers for menu entries */
/**
+ * handle menu activate signals by calling toolbar item activation
+ */
+#define MENUHANDLER(name, itemid) \
+static gboolean \
+nsgtk_on_##name##_activate_menu(GtkMenuItem *widget, gpointer data) \
+{ \
+ struct nsgtk_scaffolding *gs = (struct nsgtk_scaffolding *)data;\
+ nsgtk_window_item_activate(gs->top_level, itemid); \
+ return TRUE; \
+}
+
+/**
* menu signal handler for activation on new window item
*/
MENUHANDLER(newwindow, NEWWINDOW_BUTTON);
@@ -623,6 +595,165 @@ MENUHANDLER(closewindow, CLOSEWINDOW_BUTTON);
*/
MENUHANDLER(quit, QUIT_BUTTON);
+/**
+ * menu signal handler for activation on cut item
+ */
+MENUHANDLER(cut, CUT_BUTTON);
+
+/**
+ * menu signal handler for activation on copy item
+ */
+MENUHANDLER(copy, COPY_BUTTON);
+
+/**
+ * menu signal handler for activation on paste item
+ */
+MENUHANDLER(paste, PASTE_BUTTON);
+
+/**
+ * menu signal handler for activation on delete item
+ */
+MENUHANDLER(delete, DELETE_BUTTON);
+
+
+
+/**
+ * menu signal handler for activation on selectall item
+ */
+MENUHANDLER(selectall, SELECTALL_BUTTON);
+
+/**
+ * menu signal handler for activation on preferences item
+ */
+MENUHANDLER(preferences, PREFERENCES_BUTTON);
+
+/**
+ * menu signal handler for activation on zoom plus item
+ */
+MENUHANDLER(zoomplus, ZOOMPLUS_BUTTON);
+
+/**
+ * menu signal handler for activation on zoom minus item
+ */
+MENUHANDLER(zoomminus, ZOOMMINUS_BUTTON);
+
+/**
+ * menu signal handler for activation on zoom normal item
+ */
+MENUHANDLER(zoomnormal, ZOOMNORMAL_BUTTON);
+
+/**
+ * menu signal handler for activation on full screen item
+ */
+MENUHANDLER(fullscreen, FULLSCREEN_BUTTON);
+
+/**
+ * menu signal handler for activation on view source item
+ */
+MENUHANDLER(viewsource, VIEWSOURCE_BUTTON);
+
+/**
+ * menu signal handler for activation on downloads item
+ */
+MENUHANDLER(downloads, DOWNLOADS_BUTTON);
+
+/**
+ * menu signal handler for activation on save window size item
+ */
+MENUHANDLER(savewindowsize, SAVEWINDOWSIZE_BUTTON);
+
+/**
+ * menu signal handler for activation on toggle debug render item
+ */
+MENUHANDLER(toggledebugging, TOGGLEDEBUGGING_BUTTON);
+
+/**
+ * menu signal handler for activation on debug box tree item
+ */
+MENUHANDLER(debugboxtree, SAVEBOXTREE_BUTTON);
+
+/**
+ * menu signal handler for activation on debug dom tree item
+ */
+MENUHANDLER(debugdomtree, SAVEDOMTREE_BUTTON);
+
+/**
+ * menu signal handler for activation on stop item
+ */
+MENUHANDLER(stop, STOP_BUTTON);
+
+/**
+ * menu signal handler for activation on reload item
+ */
+MENUHANDLER(reload, RELOAD_BUTTON);
+
+/**
+ * menu signal handler for activation on back item
+ */
+MENUHANDLER(back, BACK_BUTTON);
+
+/**
+ * menu signal handler for activation on forward item
+ */
+MENUHANDLER(forward, FORWARD_BUTTON);
+
+/**
+ * menu signal handler for activation on home item
+ */
+MENUHANDLER(home, HOME_BUTTON);
+
+/**
+ * menu signal handler for activation on localhistory item
+ */
+MENUHANDLER(localhistory, LOCALHISTORY_BUTTON);
+
+/**
+ * menu signal handler for activation on globalhistory item
+ */
+MENUHANDLER(globalhistory, GLOBALHISTORY_BUTTON);
+
+/**
+ * menu signal handler for activation on addbookmarks item
+ */
+MENUHANDLER(addbookmarks, ADDBOOKMARKS_BUTTON);
+
+/**
+ * menu signal handler for activation on showbookmarks item
+ */
+MENUHANDLER(showbookmarks, SHOWBOOKMARKS_BUTTON);
+
+/**
+ * menu signal handler for activation on showcookies item
+ */
+MENUHANDLER(showcookies, SHOWCOOKIES_BUTTON);
+
+/**
+ * menu signal handler for activation on showcookies item
+ */
+MENUHANDLER(openlocation, OPENLOCATION_BUTTON);
+
+/**
+ * menu signal handler for activation on showcookies item
+ */
+MENUHANDLER(contents, CONTENTS_BUTTON);
+
+/**
+ * menu signal handler for activation on showcookies item
+ */
+MENUHANDLER(guide, GUIDE_BUTTON);
+
+/**
+ * menu signal handler for activation on showcookies item
+ */
+MENUHANDLER(info, INFO_BUTTON);
+
+/**
+ * menu signal handler for activation on showcookies item
+ */
+MENUHANDLER(about, ABOUT_BUTTON);
+
+#undef MENUHANDLER
+
static gboolean
nsgtk_on_savelink_activate_menu(GtkMenuItem *widget, gpointer data)
@@ -649,6 +780,7 @@ nsgtk_on_savelink_activate_menu(GtkMenuItem *widget, gpointer data)
return TRUE;
}
+
/**
* Handler for opening new window from a link. attached to the popup menu.
*/
@@ -672,6 +804,7 @@ nsgtk_on_link_openwin_activate_menu(GtkMenuItem *widget, gpointer data)
return TRUE;
}
+
/**
* Handler for opening new tab from a link. attached to the popup menu.
*/
@@ -701,6 +834,7 @@ nsgtk_on_link_opentab_activate_menu(GtkMenuItem *widget, gpointer data)
return TRUE;
}
+
/**
* Handler for bookmarking a link. attached to the popup menu.
*/
@@ -715,6 +849,7 @@ nsgtk_on_link_bookmark_activate_menu(GtkMenuItem *widget, gpointer data)
return TRUE;
}
+
/**
* Handler for copying a link. attached to the popup menu.
*/
@@ -734,27 +869,6 @@ nsgtk_on_link_copy_activate_menu(GtkMenuItem *widget, gpointer data)
}
-/**
- * menu signal handler for activation on cut item
- */
-MENUHANDLER(cut, CUT_BUTTON);
-
-/**
- * menu signal handler for activation on copy item
- */
-MENUHANDLER(copy, COPY_BUTTON);
-
-/**
- * menu signal handler for activation on paste item
- */
-MENUHANDLER(paste, PASTE_BUTTON);
-
-/**
- * menu signal handler for activation on delete item
- */
-MENUHANDLER(delete, DELETE_BUTTON);
-
-
static gboolean
nsgtk_on_customize_activate_menu(GtkMenuItem *widget, gpointer data)
{
@@ -763,48 +877,15 @@ nsgtk_on_customize_activate_menu(GtkMenuItem *widget, gpointer data)
return TRUE;
}
-/**
- * menu signal handler for activation on selectall item
- */
-MENUHANDLER(selectall, SELECTALL_BUTTON);
-
-MULTIHANDLER(find)
+static gboolean nsgtk_on_find_activate_menu(GtkMenuItem *widget, gpointer data)
{
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+
nsgtk_scaffolding_toggle_search_bar_visibility(g);
return TRUE;
}
-/**
- * menu signal handler for activation on preferences item
- */
-MENUHANDLER(preferences, PREFERENCES_BUTTON);
-
-/**
- * menu signal handler for activation on zoom plus item
- */
-MENUHANDLER(zoomplus, ZOOMPLUS_BUTTON);
-
-/**
- * menu signal handler for activation on zoom minus item
- */
-MENUHANDLER(zoomminus, ZOOMMINUS_BUTTON);
-
-/**
- * menu signal handler for activation on zoom normal item
- */
-MENUHANDLER(zoomnormal, ZOOMNORMAL_BUTTON);
-
-/**
- * menu signal handler for activation on full screen item
- */
-MENUHANDLER(fullscreen, FULLSCREEN_BUTTON);
-
-/**
- * menu signal handler for activation on view source item
- */
-MENUHANDLER(viewsource, VIEWSOURCE_BUTTON);
-
static gboolean
nsgtk_on_menubar_activate_menu(GtkMenuItem *widget, gpointer data)
@@ -888,102 +969,29 @@ nsgtk_on_toolbar_activate_menu(GtkMenuItem *widget, gpointer data)
return TRUE;
}
-/**
- * menu signal handler for activation on downloads item
- */
-MENUHANDLER(downloads, DOWNLOADS_BUTTON);
-
-/**
- * menu signal handler for activation on save window size item
- */
-MENUHANDLER(savewindowsize, SAVEWINDOWSIZE_BUTTON);
-
-/**
- * menu signal handler for activation on toggle debug render item
- */
-MENUHANDLER(toggledebugging, TOGGLEDEBUGGING_BUTTON);
-
-/**
- * menu signal handler for activation on debug box tree item
- */
-MENUHANDLER(debugboxtree, SAVEBOXTREE_BUTTON);
-
-/**
- * menu signal handler for activation on debug dom tree item
- */
-MENUHANDLER(debugdomtree, SAVEDOMTREE_BUTTON);
-
-/**
- * menu signal handler for activation on stop item
- */
-MENUHANDLER(stop, STOP_BUTTON);
-
-/**
- * menu signal handler for activation on reload item
- */
-MENUHANDLER(reload, RELOAD_BUTTON);
-
-/**
- * menu signal handler for activation on back item
- */
-MENUHANDLER(back, BACK_BUTTON);
-
-/**
- * menu signal handler for activation on forward item
- */
-MENUHANDLER(forward, FORWARD_BUTTON);
-/**
- * menu signal handler for activation on home item
- */
-MENUHANDLER(home, HOME_BUTTON);
-
-/**
- * menu signal handler for activation on localhistory item
- */
-MENUHANDLER(localhistory, LOCALHISTORY_BUTTON);
-
-/**
- * menu signal handler for activation on globalhistory item
- */
-MENUHANDLER(globalhistory, GLOBALHISTORY_BUTTON);
-
-/**
- * menu signal handler for activation on addbookmarks item
- */
-MENUHANDLER(addbookmarks, ADDBOOKMARKS_BUTTON);
-
-/**
- * menu signal handler for activation on showbookmarks item
- */
-MENUHANDLER(showbookmarks, SHOWBOOKMARKS_BUTTON);
-
-/**
- * menu signal handler for activation on showcookies item
- */
-MENUHANDLER(showcookies, SHOWCOOKIES_BUTTON);
-
-/**
- * menu signal handler for activation on showcookies item
- */
-MENUHANDLER(openlocation, OPENLOCATION_BUTTON);
-
-
-MULTIHANDLER(nexttab)
+static gboolean
+nsgtk_on_nexttab_activate_menu(GtkMenuItem *widget, gpointer data)
{
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+
nsgtk_tab_next(g->notebook);
return TRUE;
}
-MULTIHANDLER(prevtab)
+
+static gboolean
+nsgtk_on_prevtab_activate_menu(GtkMenuItem *widget, gpointer data)
{
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
nsgtk_tab_prev(g->notebook);
return TRUE;
}
+
/**
* menu signal handler for activation on close tab item
*/
@@ -991,33 +999,13 @@ static gboolean
nsgtk_on_closetab_activate_menu(GtkMenuItem *widget, gpointer data)
{
struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_window_item_activate(g->top_level, CLOSETAB_BUTTON);
- return TRUE;
-}
-/**
- * menu signal handler for activation on showcookies item
- */
-MENUHANDLER(contents, CONTENTS_BUTTON);
-
-/**
- * menu signal handler for activation on showcookies item
- */
-MENUHANDLER(guide, GUIDE_BUTTON);
-
-/**
- * menu signal handler for activation on showcookies item
- */
-MENUHANDLER(info, INFO_BUTTON);
-
-/**
- * menu signal handler for activation on showcookies item
- */
-MENUHANDLER(about, ABOUT_BUTTON);
+ nsgtk_tab_close_current(g->notebook);
+ return TRUE;
+}
-#undef MULTIHANDLER
-#undef MENUHANDLER
+/* end of menu callback handlers */
/**
* attach gtk signal handlers for menus
@@ -1322,7 +1310,9 @@ static nserror nsgtk_search_update(struct gtk_search *search)
return NSERROR_OK;
}
-
+/**
+ * create text search context
+ */
static nserror
nsgtk_search_create(GtkBuilder *builder, struct gtk_search **search_out)
{
@@ -1350,6 +1340,50 @@ nsgtk_search_create(GtkBuilder *builder, struct gtk_search **search_out)
nsgtk_search_update(search);
*search_out = search;
+
+ return NSERROR_OK;
+}
+
+/**
+ * connect signals to search bar
+ */
+static nserror nsgtk_search_connect_signals(struct nsgtk_scaffolding *gs)
+{
+ g_signal_connect(gs->search->buttons[1],
+ "clicked",
+ G_CALLBACK(nsgtk_search_forward_button_clicked),
+ gs);
+
+ g_signal_connect(gs->search->buttons[0],
+ "clicked",
+ G_CALLBACK(nsgtk_search_back_button_clicked),
+ gs);
+
+ g_signal_connect(gs->search->entry,
+ "changed",
+ G_CALLBACK(nsgtk_search_entry_changed),
+ gs);
+
+ g_signal_connect(gs->search->entry,
+ "activate",
+ G_CALLBACK(nsgtk_search_entry_activate),
+ gs);
+
+ g_signal_connect(gs->search->entry,
+ "key-press-event",
+ G_CALLBACK(nsgtk_search_entry_key),
+ gs);
+
+ g_signal_connect(gs->search->buttons[2],
+ "clicked",
+ G_CALLBACK(nsgtk_search_close_button_clicked),
+ gs);
+
+ g_signal_connect(gs->search->caseSens,
+ "toggled",
+ G_CALLBACK(nsgtk_search_entry_changed),
+ gs);
+
return NSERROR_OK;
}
@@ -1471,6 +1505,7 @@ nsgtk_scaffolding_set_websearch(struct nsgtk_scaffolding *g, const char *content
#endif
}
+
/**
* GTK UI callback when search provider details are updated.
*
@@ -1789,8 +1824,10 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
gtk_builder_connect_signals(gs->builder, NULL);
- gs->window = GTK_WINDOW(gtk_builder_get_object(gs->builder, "wndBrowser"));
- gs->notebook = GTK_NOTEBOOK(gtk_builder_get_object(gs->builder, "notebook"));
+ gs->window = GTK_WINDOW(gtk_builder_get_object(gs->builder,
+ "wndBrowser"));
+ gs->notebook = GTK_NOTEBOOK(gtk_builder_get_object(gs->builder,
+ "notebook"));
res = nsgtk_search_create(gs->builder, &gs->search);
@@ -1825,50 +1862,38 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
nsgtk_tab_init(gs);
- g_signal_connect_after(gs->notebook, "page-added",
- G_CALLBACK(nsgtk_window_tabs_add), gs);
- g_signal_connect_after(gs->notebook, "page-removed",
- G_CALLBACK(nsgtk_window_tabs_remove), gs);
-
-#define CONNECT(obj, sig, callback, ptr) \
- g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr))
+ g_signal_connect_after(gs->notebook,
+ "page-added",
+ G_CALLBACK(nsgtk_window_tabs_add),
+ gs);
+ g_signal_connect_after(gs->notebook,
+ "page-removed",
+ G_CALLBACK(nsgtk_window_tabs_remove),
+ gs);
/* connect main window signals to their handlers. */
- CONNECT(gs->window,
- "delete-event",
- scaffolding_window_delete_event,
- gs);
+ g_signal_connect(gs->window,
+ "delete-event",
+ G_CALLBACK(scaffolding_window_delete_event),
+ gs);
- CONNECT(gs->window, "destroy", scaffolding_window_destroy, gs);
+ g_signal_connect(gs->window,
+ "destroy",
+ G_CALLBACK(scaffolding_window_destroy),
+ gs);
/* toolbar URL bar menu bar search bar signal handlers */
- CONNECT(gs->menu_bar->edit_submenu->edit, "show",
- nsgtk_window_edit_menu_shown, gs);
- CONNECT(gs->menu_bar->edit_submenu->edit, "hide",
- nsgtk_window_edit_menu_hidden, gs);
-
- CONNECT(gs->search->buttons[1], "clicked",
- nsgtk_search_forward_button_clicked, gs);
+ g_signal_connect(gs->menu_bar->edit_submenu->edit,
+ "show",
+ G_CALLBACK(nsgtk_window_edit_menu_shown),
+ gs);
- CONNECT(gs->search->buttons[0], "clicked",
- nsgtk_search_back_button_clicked, gs);
-
- CONNECT(gs->search->entry, "changed", nsgtk_search_entry_changed, gs);
-
- CONNECT(gs->search->entry, "activate", nsgtk_search_entry_activate, gs);
-
- CONNECT(gs->search->entry, "key-press-event",
- nsgtk_search_entry_key, gs);
-
- CONNECT(gs->search->buttons[2], "clicked",
- nsgtk_search_close_button_clicked, gs);
-
- CONNECT(gs->search->caseSens, "toggled",
- nsgtk_search_entry_changed, gs);
+ g_signal_connect(gs->menu_bar->edit_submenu->edit,
+ "hide",
+ G_CALLBACK(nsgtk_window_edit_menu_hidden),
+ gs);
- /** \todo fix popup menu */
- //CONNECT(gs->tool_bar, "popup-context-menu",
- // nsgtk_window_tool_bar_clicked, gs);
+ nsgtk_search_connect_signals(gs);
/* create popup menu */
gs->menu_popup = nsgtk_new_scaffolding_popup(gs, group);
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index 666bc50..a8cea20 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -69,6 +69,11 @@ nserror nsgtk_scaffolding_destroy_all(void);
nserror nsgtk_scaffolding_throbber(struct gui_window* gw, bool active);
/**
+ * open a toolbar context menu
+ */
+nserror nsgtk_scaffolding_toolbar_context_menu(struct nsgtk_scaffolding *gs);
+
+/**
* Obtain the most recently used scaffolding element.
*
* This allows tabs to be opened in the most recently used window
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index fafa194..694c271 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -66,6 +66,7 @@
#include "gtk/preferences.h"
#include "gtk/hotlist.h"
#include "gtk/cookies.h"
+#include "gtk/about.h"
#include "gtk/toolbar.h"
/**
@@ -131,7 +132,7 @@ struct nsgtk_toolbar {
/**
* context passed to get_bw function
*/
- void *get_bw_ctx;
+ void *get_ctx;
};
@@ -1722,7 +1723,7 @@ toolbar_navigate_to_url(struct nsgtk_toolbar *tb, const char *urltxt)
return res;
}
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
res = browser_window_navigate(bw,
url,
@@ -1872,7 +1873,7 @@ back_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_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
if ((bw != NULL) && browser_window_history_back_available(bw)) {
/* clear potential search effects */
@@ -1904,7 +1905,7 @@ forward_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_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
if ((bw != NULL) && browser_window_history_forward_available(bw)) {
/* clear potential search effects */
@@ -1934,7 +1935,7 @@ stop_button_clicked_cb(GtkWidget *widget, gpointer data)
{
struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
- browser_window_stop(tb->get_bw(tb->get_bw_ctx));
+ browser_window_stop(tb->get_bw(tb->get_ctx));
return TRUE;
}
@@ -1953,7 +1954,7 @@ reload_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_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
/* clear potential search effects */
browser_window_search_clear(bw);
@@ -2013,7 +2014,7 @@ static gboolean url_entry_activate_cb(GtkWidget *widget, gpointer data)
SEARCH_WEB_OMNI_NONE,
&url);
if (res == NSERROR_OK) {
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
res = browser_window_navigate(
bw, url, NULL, BW_NAVIGATE_HISTORY, NULL, NULL, NULL);
nsurl_unref(url);
@@ -2067,7 +2068,7 @@ static gboolean websearch_entry_activate_cb(GtkWidget *widget, gpointer data)
&url);
if (res == NSERROR_OK) {
temp_open_background = 0;
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
res = browser_window_create(
BW_CREATE_HISTORY | BW_CREATE_TAB,
@@ -2133,7 +2134,7 @@ newwindow_button_clicked_cb(GtkWidget *widget, gpointer data)
res = nsurl_create(addr, &url);
if (res == NSERROR_OK) {
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
res = browser_window_create(BW_CREATE_HISTORY,
url,
NULL,
@@ -2175,7 +2176,7 @@ newtab_button_clicked_cb(GtkWidget *widget, gpointer data)
}
if (res == NSERROR_OK) {
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
res = browser_window_create(BW_CREATE_HISTORY |
BW_CREATE_TAB,
@@ -2234,7 +2235,7 @@ openfile_button_clicked_cb(GtkWidget *widget, gpointer data)
res = nsurl_create(urltxt, &url);
if (res == NSERROR_OK) {
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
res = browser_window_navigate(bw,
url,
NULL,
@@ -2261,24 +2262,6 @@ openfile_button_clicked_cb(GtkWidget *widget, gpointer data)
/**
- * handler for close tab 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
-closetab_button_clicked_cb(GtkWidget *widget, gpointer data)
-{
- struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
-
- nsgtk_tab_close_current(GTK_NOTEBOOK(tb->widget));
-
- return TRUE;
-}
-
-
-/**
* handler for close window tool bar item clicked signal
*
* \param widget The widget the signal is being delivered to.
@@ -2312,7 +2295,7 @@ savepage_button_clicked_cb(GtkWidget *widget, gpointer data)
nserror res;
GtkWidget *toplevel;
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
res = nsgtk_saveas_dialog(bw,
@@ -2363,7 +2346,7 @@ pdf_button_clicked_cb(GtkWidget *widget, gpointer data)
gchar *filename;
nserror res;
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
@@ -2415,7 +2398,7 @@ plaintext_button_clicked_cb(GtkWidget *widget, gpointer data)
gchar *filename;
nserror res;
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
@@ -2456,7 +2439,7 @@ print_button_clicked_cb(GtkWidget *widget, gpointer data)
char *settings_fname = NULL;
GtkWidget *toplevel;
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
@@ -2574,7 +2557,7 @@ cut_button_clicked_cb(GtkWidget *widget, gpointer data)
if (GTK_IS_EDITABLE(focused)) {
gtk_editable_cut_clipboard(GTK_EDITABLE(focused));
} else {
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
browser_window_key_press(bw, NS_KEY_CUT_SELECTION);
}
@@ -2605,7 +2588,7 @@ copy_button_clicked_cb(GtkWidget *widget, gpointer data)
if (GTK_IS_EDITABLE(focused)) {
gtk_editable_copy_clipboard(GTK_EDITABLE(focused));
} else {
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
browser_window_key_press(bw, NS_KEY_COPY_SELECTION);
}
@@ -2636,7 +2619,7 @@ paste_button_clicked_cb(GtkWidget *widget, gpointer data)
if (GTK_IS_EDITABLE(focused)) {
gtk_editable_paste_clipboard(GTK_EDITABLE(focused));
} else {
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
browser_window_key_press(bw, NS_KEY_PASTE);
}
@@ -2667,7 +2650,7 @@ delete_button_clicked_cb(GtkWidget *widget, gpointer data)
if (GTK_IS_EDITABLE(focused)) {
gtk_editable_delete_selection(GTK_EDITABLE(focused));
} else {
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
browser_window_key_press(bw, NS_KEY_CLEAR_SELECTION);
}
@@ -2698,7 +2681,7 @@ selectall_button_clicked_cb(GtkWidget *widget, gpointer data)
if (GTK_IS_EDITABLE(focused)) {
gtk_editable_select_region(GTK_EDITABLE(focused), 0, -1);
} else {
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
browser_window_key_press(bw, NS_KEY_SELECT_ALL);
}
@@ -2721,7 +2704,7 @@ preferences_button_clicked_cb(GtkWidget *widget, gpointer data)
GtkWidget *toplevel;
GtkWidget *wndpreferences;
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
@@ -2747,7 +2730,7 @@ zoomplus_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_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
browser_window_set_scale(bw, 0.05, false);
@@ -2768,7 +2751,7 @@ zoomminus_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_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
browser_window_set_scale(bw, -0.05, false);
@@ -2790,7 +2773,7 @@ zoomnormal_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_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
browser_window_set_scale(bw, 1.0, true);
@@ -2840,7 +2823,7 @@ viewsource_button_clicked_cb(GtkWidget *widget, gpointer data)
struct browser_window *bw;
GtkWindow *gtkwindow; /* gtk window widget is in */
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
gtkwindow = GTK_WINDOW(gtk_widget_get_ancestor(widget,GTK_TYPE_WINDOW));
@@ -2917,7 +2900,7 @@ toggledebugging_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_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
browser_window_debug(bw, CONTENT_DEBUG_REDRAW);
@@ -2959,7 +2942,7 @@ debugboxtree_button_clicked_cb(GtkWidget *widget, gpointer data)
return TRUE;
}
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
browser_window_debug_dump(bw, f, CONTENT_DEBUG_RENDER);
@@ -3004,7 +2987,7 @@ debugdomtree_button_clicked_cb(GtkWidget *widget, gpointer data)
return TRUE;
}
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
browser_window_debug_dump(bw, f, CONTENT_DEBUG_DOM);
@@ -3036,7 +3019,7 @@ localhistory_button_clicked_cb(GtkWidget *widget, gpointer data)
toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
if (toplevel != NULL) {
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
res = nsgtk_local_history_present(GTK_WINDOW(toplevel), bw);
if (res != NSERROR_OK) {
@@ -3081,7 +3064,7 @@ addbookmarks_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_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
if (browser_window_has_content(bw)) {
hotlist_add_url(browser_window_access_url(bw));
}
@@ -3366,7 +3349,7 @@ toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
nsgtk_completion_connect_signals(entry,
tb->get_bw,
- tb->get_bw_ctx);
+ tb->get_ctx);
break;
@@ -3417,11 +3400,41 @@ static nserror toolbar_connect_signals(struct nsgtk_toolbar *tb)
return NSERROR_OK;
}
+/**
+ * signal handler for toolbar context menu
+ *
+ * \param toolbar The toolbar event is being delivered to
+ * \param x The x coordinate where the click happened
+ * \param y The x coordinate where the click happened
+ * \param button the buttons being pressed
+ * \param data The context pointer passed when the connection was made.
+ * \return TRUE to indicate signal handled.
+ */
+static gboolean
+toolbar_popup_context_menu_cb(GtkToolbar *toolbar,
+ gint x,
+ gint y,
+ gint button,
+ gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct gui_window *gw;
+ struct nsgtk_scaffolding *gs;
+
+ gw = tb->get_ctx; /** \todo stop assuming the context is a gui window */
+
+ gs = nsgtk_get_scaffold(gw);
+
+ nsgtk_scaffolding_toolbar_context_menu(gs);
+
+ return TRUE;
+}
+
/* exported interface documented in toolbar.h */
nserror
nsgtk_toolbar_create(GtkBuilder *builder,
struct browser_window *(*get_bw)(void *ctx),
- void *get_bw_ctx,
+ void *get_ctx,
struct nsgtk_toolbar **tb_out)
{
nserror res;
@@ -3434,13 +3447,18 @@ nsgtk_toolbar_create(GtkBuilder *builder,
}
tb->get_bw = get_bw;
- tb->get_bw_ctx = get_bw_ctx;
+ tb->get_ctx = get_ctx;
/* set the throbber start frame. */
tb->throb_frame = 0;
tb->widget = GTK_TOOLBAR(gtk_builder_get_object(builder, "toolbar"));
gtk_toolbar_set_show_arrow(tb->widget, TRUE);
+ g_signal_connect(tb->widget,
+ "popup-context-menu",
+ G_CALLBACK(toolbar_popup_context_menu_cb),
+ tb);
+
/* allocate button contexts */
for (bidx = BACK_BUTTON; bidx < PLACEHOLDER_BUTTON; bidx++) {
res = toolbar_item_create(bidx, &tb->buttons[bidx]);
@@ -3543,7 +3561,7 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active)
nserror res;
struct browser_window *bw;
- bw = tb->get_bw(tb->get_bw_ctx);
+ bw = tb->get_bw(tb->get_ctx);
/* when activating the throbber simply schedule the next frame update */
if (active) {
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 9bbb300..fbfa5e5 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -100,7 +100,7 @@ TOOLBAR_ITEM(THROBBER_ITEM, throbber, true, NULL)
TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true, newwindow_button_clicked_cb)
TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true, newtab_button_clicked_cb)
TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, openfile_button_clicked_cb)
-TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, closetab_button_clicked_cb)
+TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, NULL)
TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, closewindow_button_clicked_cb)
TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, savepage_button_clicked_cb)
TOOLBAR_ITEM(PDF_BUTTON, pdf, false, pdf_button_clicked_cb)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=e36338b6177df9617c8...
commit e36338b6177df9617c89e2eae4f3fcb0a77d7b5b
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
complete toolbar button click handler implementation
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 62b9c4f..d7e7d59 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -90,10 +90,6 @@ static gboolean nsgtk_on_##q##_activate_menu(GtkMenuItem *widget, gpointer data)
static gboolean nsgtk_on_##q##_activate(struct nsgtk_scaffolding *g)
-/** Macro to define a handler for button events. */
-#define BUTTONHANDLER(q)\
-static gboolean nsgtk_on_##q##_activate(GtkButton *widget, gpointer data)
-
/**
* handle menu activate signals by calling toolbar item activation
*/
@@ -574,41 +570,6 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook,
nsgtk_scaffolding_set_sensitivity(gs);
}
-/**
- * Handle opening a file path.
- *
- * \param filename The filename to open.
- */
-static void nsgtk_openfile_open(const char *filename)
-{
- struct browser_window *bw;
- char *urltxt;
- nsurl *url;
- nserror error;
-
- bw = nsgtk_get_browser_window(scaf_current->top_level);
-
- urltxt = malloc(strlen(filename) + FILE_SCHEME_PREFIX_LEN + 1);
-
- if (urltxt != NULL) {
- sprintf(urltxt, FILE_SCHEME_PREFIX"%s", filename);
-
- error = nsurl_create(urltxt, &url);
- if (error != NSERROR_OK) {
- nsgtk_warning(messages_get_errorcode(error), 0);
- } else {
- browser_window_navigate(bw,
- url,
- NULL,
- BW_NAVIGATE_HISTORY,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
- free(urltxt);
- }
-}
/* signal handlers for menu entries */
@@ -967,113 +928,46 @@ MENUHANDLER(reload, RELOAD_BUTTON);
*/
MENUHANDLER(back, BACK_BUTTON);
+/**
+ * menu signal handler for activation on forward item
+ */
+MENUHANDLER(forward, FORWARD_BUTTON);
-MULTIHANDLER(forward)
-{
- struct browser_window *bw =
- nsgtk_get_browser_window(g->top_level);
-
- if ((bw == NULL) || (!browser_window_history_forward_available(bw)))
- return TRUE;
-
- /* clear potential search effects */
- browser_window_search_clear(bw);
-
- browser_window_history_forward(bw, false);
- scaffolding_update_context(g);
-
- return TRUE;
-}
-
-MULTIHANDLER(home)
-{
- static const char *addr = NETSURF_HOMEPAGE;
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- nsurl *url;
- nserror error;
-
- if (nsoption_charp(homepage_url) != NULL) {
- addr = nsoption_charp(homepage_url);
- }
-
- error = nsurl_create(addr, &url);
- if (error != NSERROR_OK) {
- nsgtk_warning(messages_get_errorcode(error), 0);
- } else {
- browser_window_navigate(bw,
- url,
- NULL,
- BW_NAVIGATE_HISTORY,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
-
- return TRUE;
-}
-
-MULTIHANDLER(localhistory)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- nserror res;
+/**
+ * menu signal handler for activation on home item
+ */
+MENUHANDLER(home, HOME_BUTTON);
- res = nsgtk_local_history_present(g->window, bw);
- if (res != NSERROR_OK) {
- NSLOG(netsurf, INFO,
- "Unable to initialise local history window.");
- }
- return TRUE;
-}
+/**
+ * menu signal handler for activation on localhistory item
+ */
+MENUHANDLER(localhistory, LOCALHISTORY_BUTTON);
-MULTIHANDLER(globalhistory)
-{
- nserror res;
- res = nsgtk_global_history_present();
- if (res != NSERROR_OK) {
- NSLOG(netsurf, INFO,
- "Unable to initialise global history window.");
- }
- return TRUE;
-}
+/**
+ * menu signal handler for activation on globalhistory item
+ */
+MENUHANDLER(globalhistory, GLOBALHISTORY_BUTTON);
-MULTIHANDLER(addbookmarks)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
+/**
+ * menu signal handler for activation on addbookmarks item
+ */
+MENUHANDLER(addbookmarks, ADDBOOKMARKS_BUTTON);
- if (bw == NULL || !browser_window_has_content(bw))
- return TRUE;
- hotlist_add_url(browser_window_access_url(bw));
- return TRUE;
-}
+/**
+ * menu signal handler for activation on showbookmarks item
+ */
+MENUHANDLER(showbookmarks, SHOWBOOKMARKS_BUTTON);
-MULTIHANDLER(showbookmarks)
-{
- nserror res;
- res = nsgtk_hotlist_present();
- if (res != NSERROR_OK) {
- NSLOG(netsurf, INFO, "Unable to initialise bookmark window.");
- }
- return TRUE;
-}
+/**
+ * menu signal handler for activation on showcookies item
+ */
+MENUHANDLER(showcookies, SHOWCOOKIES_BUTTON);
-MULTIHANDLER(showcookies)
-{
- nserror res;
- res = nsgtk_cookies_present();
- if (res != NSERROR_OK) {
- NSLOG(netsurf, INFO, "Unable to initialise cookies window.");
- }
- return TRUE;
-}
+/**
+ * menu signal handler for activation on showcookies item
+ */
+MENUHANDLER(openlocation, OPENLOCATION_BUTTON);
-MULTIHANDLER(openlocation)
-{
- #if 0
- gtk_widget_grab_focus(GTK_WIDGET(g->url_bar));
- #endif
- return TRUE;
-}
MULTIHANDLER(nexttab)
{
@@ -1101,86 +995,29 @@ nsgtk_on_closetab_activate_menu(GtkMenuItem *widget, gpointer data)
return TRUE;
}
-MULTIHANDLER(contents)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- nsurl *url;
- nserror error;
-
- error = nsurl_create("http://www.netsurf-browser.org/documentation/", &url);
- if (error != NSERROR_OK) {
- nsgtk_warning(messages_get_errorcode(error), 0);
- } else {
- browser_window_navigate(bw,
- url,
- NULL,
- BW_NAVIGATE_HISTORY,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
-
- return TRUE;
-}
-
-MULTIHANDLER(guide)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- nsurl *url;
-
- if (nsurl_create("http://www.netsurf-browser.org/documentation/guide", &url) != NSERROR_OK) {
- nsgtk_warning("NoMemory", 0);
- } else {
- browser_window_navigate(bw,
- url,
- NULL,
- BW_NAVIGATE_HISTORY,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
-
- return TRUE;
-}
-
-MULTIHANDLER(info)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- nsurl *url;
+/**
+ * menu signal handler for activation on showcookies item
+ */
+MENUHANDLER(contents, CONTENTS_BUTTON);
- if (nsurl_create("http://www.netsurf-browser.org/documentation/info", &url) != NSERROR_OK) {
- nsgtk_warning("NoMemory", 0);
- } else {
- browser_window_navigate(bw,
- url,
- NULL,
- BW_NAVIGATE_HISTORY,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
+/**
+ * menu signal handler for activation on showcookies item
+ */
+MENUHANDLER(guide, GUIDE_BUTTON);
- return TRUE;
-}
+/**
+ * menu signal handler for activation on showcookies item
+ */
+MENUHANDLER(info, INFO_BUTTON);
-MULTIHANDLER(about)
-{
- nsgtk_about_dialog_init(g->window);
- return TRUE;
-}
+/**
+ * menu signal handler for activation on showcookies item
+ */
+MENUHANDLER(about, ABOUT_BUTTON);
-BUTTONHANDLER(history)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- return nsgtk_on_localhistory_activate(g);
-}
#undef MULTIHANDLER
-#undef CHECKHANDLER
-#undef BUTTONHANDLER
+#undef MENUHANDLER
/**
* attach gtk signal handlers for menus
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 03e07b9..fafa194 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -39,6 +39,7 @@
#include "desktop/save_complete.h"
#include "desktop/save_text.h"
#include "desktop/print.h"
+#include "desktop/hotlist.h"
#include "netsurf/content.h"
#include "netsurf/browser_window.h"
#include "netsurf/keypress.h"
@@ -55,10 +56,16 @@
#include "gtk/resources.h"
#include "gtk/schedule.h"
#include "gtk/local_history.h"
+#include "gtk/global_history.h"
+#include "gtk/viewsource.h"
+#include "gtk/download.h"
+#include "gtk/viewdata.h"
#include "gtk/tabs.h"
#include "gtk/print.h"
#include "gtk/layout_pango.h"
#include "gtk/preferences.h"
+#include "gtk/hotlist.h"
+#include "gtk/cookies.h"
#include "gtk/toolbar.h"
/**
@@ -1697,6 +1704,111 @@ set_item_sensitivity(struct nsgtk_toolbar_item *item, bool sensitivity)
/**
+ * cause the toolbar browsing context to navigate to a new url.
+ *
+ * \param tb the toolbar context.
+ * \param urltxt The url string.
+ * \return NSERROR_OK on success else appropriate error code.
+ */
+static nserror
+toolbar_navigate_to_url(struct nsgtk_toolbar *tb, const char *urltxt)
+{
+ struct browser_window *bw;
+ nsurl *url;
+ nserror res;
+
+ res = nsurl_create(urltxt, &url);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ res = browser_window_navigate(bw,
+ url,
+ NULL,
+ BW_NAVIGATE_HISTORY,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+
+ return res;
+}
+
+
+/**
+ * run a gtk file chooser as a save dialog to obtain a path
+ */
+static nserror
+nsgtk_saveas_dialog(struct browser_window *bw,
+ const char *title,
+ GtkWindow *parent,
+ bool folder,
+ gchar **path_out)
+{
+ nserror res;
+ GtkWidget *fc; /* file chooser widget */
+ GtkFileChooserAction action;
+ char *path; /* proposed path */
+
+ if (!browser_window_has_content(bw)) {
+ /* cannot save a page with no content */
+ return NSERROR_INVALID;
+ }
+
+ if (folder) {
+ action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
+ } else {
+ action = GTK_FILE_CHOOSER_ACTION_SAVE;
+ }
+
+ fc = gtk_file_chooser_dialog_new(title,
+ parent,
+ action,
+ NSGTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ NSGTK_STOCK_SAVE,
+ GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ /* set a default file name */
+ res = nsurl_nice(browser_window_access_url(bw), &path, false);
+ if (res != NSERROR_OK) {
+ path = strdup(messages_get("SaveText"));
+ if (path == NULL) {
+ gtk_widget_destroy(fc);
+ return NSERROR_NOMEM;
+ }
+ }
+
+ if ((!folder) || (access(path, F_OK) != 0)) {
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), path);
+ }
+ free(path);
+
+ /* confirm overwriting */
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(fc), TRUE);
+
+ /* run the dialog to let user select path */
+ if (gtk_dialog_run(GTK_DIALOG(fc)) != GTK_RESPONSE_ACCEPT) {
+ gtk_widget_destroy(fc);
+ return NSERROR_NOT_FOUND;
+ }
+
+ *path_out = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
+
+ gtk_widget_destroy(fc);
+
+ return NSERROR_OK;
+}
+
+
+/*
+ * Toolbar button clicked handlers
+ */
+
+/**
* callback for all toolbar items widget size allocation
*
* handler connected to all toolbar items for the size-allocate signal
@@ -1780,35 +1892,6 @@ back_button_clicked_cb(GtkWidget *widget, gpointer data)
/**
- * handler for local history 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
-localhistory_button_clicked_cb(GtkWidget *widget, gpointer data)
-{
- nserror res;
- struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
- struct browser_window *bw;
- GtkWidget *toplevel;
-
- toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
- if (toplevel != NULL) {
- bw = tb->get_bw(tb->get_bw_ctx);
-
- res = nsgtk_local_history_present(GTK_WINDOW(toplevel), bw);
- if (res != NSERROR_OK) {
- NSLOG(netsurf, INFO,
- "Unable to present local history window.");
- }
- }
- return TRUE;
-}
-
-
-/**
* handler for forward tool bar item clicked signal
*
* \param widget The widget the signal is being delivered to.
@@ -1891,11 +1974,9 @@ reload_button_clicked_cb(GtkWidget *widget, gpointer data)
static gboolean
home_button_clicked_cb(GtkWidget *widget, gpointer data)
{
- nserror res;
struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ nserror res;
const char *addr;
- struct browser_window *bw;
- nsurl *url;
if (nsoption_charp(homepage_url) != NULL) {
addr = nsoption_charp(homepage_url);
@@ -1903,19 +1984,7 @@ home_button_clicked_cb(GtkWidget *widget, gpointer data)
addr = NETSURF_HOMEPAGE;
}
- res = nsurl_create(addr, &url);
- if (res == NSERROR_OK) {
- bw = tb->get_bw(tb->get_bw_ctx);
-
- res = browser_window_navigate(bw,
- url,
- NULL,
- BW_NAVIGATE_HISTORY,
- NULL,
- NULL,
- NULL);
- nsurl_unref(url);
- }
+ res = toolbar_navigate_to_url(tb, addr);
if (res != NSERROR_OK) {
nsgtk_warning(messages_get_errorcode(res), 0);
}
@@ -2226,69 +2295,6 @@ closewindow_button_clicked_cb(GtkWidget *widget, gpointer data)
}
-static nserror
-nsgtk_saveas_dialog(struct browser_window *bw,
- const char *title,
- GtkWindow *parent,
- bool folder,
- gchar **path_out)
-{
- nserror res;
- GtkWidget *fc; /* file chooser widget */
- GtkFileChooserAction action;
- char *path; /* proposed path */
-
- if (!browser_window_has_content(bw)) {
- /* cannot save a page with no content */
- return NSERROR_INVALID;
- }
-
- if (folder) {
- action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
- } else {
- action = GTK_FILE_CHOOSER_ACTION_SAVE;
- }
-
- fc = gtk_file_chooser_dialog_new(title,
- parent,
- action,
- NSGTK_STOCK_CANCEL,
- GTK_RESPONSE_CANCEL,
- NSGTK_STOCK_SAVE,
- GTK_RESPONSE_ACCEPT,
- NULL);
-
- /* set a default file name */
- res = nsurl_nice(browser_window_access_url(bw), &path, false);
- if (res != NSERROR_OK) {
- path = strdup(messages_get("SaveText"));
- if (path == NULL) {
- gtk_widget_destroy(fc);
- return NSERROR_NOMEM;
- }
- }
-
- if ((!folder) || (access(path, F_OK) != 0)) {
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), path);
- }
- free(path);
-
- /* confirm overwriting */
- gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(fc), TRUE);
-
- /* run the dialog to let user select path */
- if (gtk_dialog_run(GTK_DIALOG(fc)) != GTK_RESPONSE_ACCEPT) {
- gtk_widget_destroy(fc);
- return NSERROR_NOT_FOUND;
- }
-
- *path_out = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
-
- gtk_widget_destroy(fc);
-
- return NSERROR_OK;
-}
-
/**
* handler for full save export tool bar item clicked signal
*
@@ -3014,6 +3020,220 @@ debugdomtree_button_clicked_cb(GtkWidget *widget, gpointer data)
/**
+ * handler for local history 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
+localhistory_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ nserror res;
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+ if (toplevel != NULL) {
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ res = nsgtk_local_history_present(GTK_WINDOW(toplevel), bw);
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, INFO,
+ "Unable to present local history window.");
+ }
+ }
+ return TRUE;
+}
+
+
+/**
+ * handler for global history 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
+globalhistory_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ nserror res;
+ res = nsgtk_global_history_present();
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, INFO,
+ "Unable to initialise global history window.");
+ }
+ return TRUE;
+}
+
+
+/**
+ * handler for add bookmark 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
+addbookmarks_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_bw_ctx);
+ if (browser_window_has_content(bw)) {
+ hotlist_add_url(browser_window_access_url(bw));
+ }
+ return TRUE;
+}
+
+
+/**
+ * handler for show bookmark 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
+showbookmarks_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ nserror res;
+ res = nsgtk_hotlist_present();
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, INFO, "Unable to initialise bookmark window.");
+ }
+ return TRUE;
+}
+
+
+/**
+ * handler for show cookies 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
+showcookies_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ nserror res;
+ res = nsgtk_cookies_present();
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, INFO, "Unable to initialise cookies window.");
+ }
+ return TRUE;
+}
+
+
+/**
+ * handler for open location 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
+openlocation_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ GtkToolItem *urltitem;
+
+ urltitem = tb->buttons[URL_BAR_ITEM]->button;
+ if (urltitem != NULL) {
+ GtkEntry *entry;
+ entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(urltitem)));
+ gtk_widget_grab_focus(GTK_WIDGET(entry));
+ }
+ return TRUE;
+}
+
+
+/**
+ * handler for contents 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
+contents_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ nserror res;
+
+ res = toolbar_navigate_to_url(tb, "http://www.netsurf-browser.org/documentation/");
+ if (res != NSERROR_OK) {
+ nsgtk_warning(messages_get_errorcode(res), 0);
+ }
+
+ return TRUE;
+}
+
+/**
+ * handler for contents 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
+guide_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ nserror res;
+
+ res = toolbar_navigate_to_url(tb, "http://www.netsurf-browser.org/documentation/guide");
+ if (res != NSERROR_OK) {
+ nsgtk_warning(messages_get_errorcode(res), 0);
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * handler for contents 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
+info_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ nserror res;
+
+ res = toolbar_navigate_to_url(tb, "http://www.netsurf-browser.org/documentation/info");
+ if (res != NSERROR_OK) {
+ nsgtk_warning(messages_get_errorcode(res), 0);
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * handler for contents 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
+about_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ GtkWindow *parent; /* gtk window widget is in */
+
+ parent = GTK_WINDOW(gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW));
+
+ nsgtk_about_dialog_init(parent);
+ return TRUE;
+}
+
+/**
* create a toolbar item
*
* create a toolbar item and set up its default handlers
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 909b00d..9bbb300 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -128,17 +128,17 @@ TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, toggledebugging_butt
TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true, debugboxtree_button_clicked_cb)
TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true, debugdomtree_button_clicked_cb)
TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true, localhistory_button_clicked_cb)
-TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, NULL)
-TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, NULL)
-TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true, NULL)
-TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, NULL)
-TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true, NULL)
+TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, globalhistory_button_clicked_cb)
+TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, addbookmarks_button_clicked_cb)
+TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true, showbookmarks_button_clicked_cb)
+TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, showcookies_button_clicked_cb)
+TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true, openlocation_button_clicked_cb)
TOOLBAR_ITEM(NEXTTAB_BUTTON, nexttab, false, NULL)
TOOLBAR_ITEM(PREVTAB_BUTTON, prevtab, false, NULL)
-TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true, NULL)
-TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, NULL)
-TOOLBAR_ITEM(INFO_BUTTON, info, true, NULL)
-TOOLBAR_ITEM(ABOUT_BUTTON, about, true, NULL)
+TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true, contents_button_clicked_cb)
+TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, guide_button_clicked_cb)
+TOOLBAR_ITEM(INFO_BUTTON, info, true, info_button_clicked_cb)
+TOOLBAR_ITEM(ABOUT_BUTTON, about, true, about_button_clicked_cb)
#ifdef TOOLBAR_ITEM_SET
#undef TOOLBAR_ITEM
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=08d7c55cc536211784a...
commit 08d7c55cc536211784a24df179719a802435ff0b
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
another five handlers and fix menu sensitivity on throbber state change
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index 2c23364..ba37413 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -249,7 +249,7 @@ static nserror set_defaults(struct nsoption_s *defaults)
nsoption_set_int(button_type, 2);
break;
}
-
+
return NSERROR_OK;
}
@@ -261,7 +261,7 @@ static nserror set_defaults(struct nsoption_s *defaults)
*
* \param argc The number of arguments on the command line
* \param argv A string vector of command line arguments.
- * \respath A string vector of the path elements of resources
+ * \respath A string vector of the path elements of resources
*/
static nserror nsgtk_init(int argc, char** argv, char **respath)
{
@@ -1204,7 +1204,7 @@ int main(int argc, char** argv)
NSLOG(netsurf, INFO, "Unable to load translated messages");
/** \todo decide if message load faliure should be fatal */
}
-
+
/* Locate the correct user cache directory path */
ret = get_cache_home(&cache_home);
if (ret == NSERROR_NOT_FOUND) {
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 685b5d4..62b9c4f 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -927,160 +927,46 @@ nsgtk_on_toolbar_activate_menu(GtkMenuItem *widget, gpointer data)
return TRUE;
}
-MULTIHANDLER(downloads)
-{
- nsgtk_download_show(g->window);
-
- return TRUE;
-}
-
-MULTIHANDLER(savewindowsize)
-{
- int x,y,w,h;
- char *choices = NULL;
-
- gtk_window_get_position(g->window, &x, &y);
- gtk_window_get_size(g->window, &w, &h);
-
- nsoption_set_int(window_width, w);
- nsoption_set_int(window_height, h);
- nsoption_set_int(window_x, x);
- nsoption_set_int(window_y, y);
-
- netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
- if (choices != NULL) {
- nsoption_write(choices, NULL, NULL);
- free(choices);
- }
-
- return TRUE;
-}
-
-MULTIHANDLER(toggledebugging)
-{
- struct browser_window *bw;
-
- bw = nsgtk_get_browser_window(g->top_level);
-
- browser_window_debug(bw, CONTENT_DEBUG_REDRAW);
-
- nsgtk_reflow_all_windows();
-
- return TRUE;
-}
-
-MULTIHANDLER(debugboxtree)
-{
- gchar *fname;
- gint handle;
- FILE *f;
- struct browser_window *bw;
-
- handle = g_file_open_tmp("nsgtkboxtreeXXXXXX", &fname, NULL);
- if ((handle == -1) || (fname == NULL)) {
- return TRUE;
- }
- close(handle); /* in case it was binary mode */
-
- /* save data to temporary file */
- f = fopen(fname, "w");
- if (f == NULL) {
- nsgtk_warning("Error saving box tree dump.",
- "Unable to open file for writing.");
- unlink(fname);
- return TRUE;
- }
-
- bw = nsgtk_get_browser_window(g->top_level);
-
- browser_window_debug_dump(bw, f, CONTENT_DEBUG_RENDER);
-
- fclose(f);
-
- nsgtk_viewfile("Box Tree Debug", "boxtree", fname);
-
- g_free(fname);
-
- return TRUE;
-}
-
-MULTIHANDLER(debugdomtree)
-{
- gchar *fname;
- gint handle;
- FILE *f;
- struct browser_window *bw;
-
- handle = g_file_open_tmp("nsgtkdomtreeXXXXXX", &fname, NULL);
- if ((handle == -1) || (fname == NULL)) {
- return TRUE;
- }
- close(handle); /* in case it was binary mode */
-
- /* save data to temporary file */
- f = fopen(fname, "w");
- if (f == NULL) {
- nsgtk_warning("Error saving box tree dump.",
- "Unable to open file for writing.");
- unlink(fname);
- return TRUE;
- }
-
- bw = nsgtk_get_browser_window(g->top_level);
-
- browser_window_debug_dump(bw, f, CONTENT_DEBUG_DOM);
-
- fclose(f);
-
- nsgtk_viewfile("DOM Tree Debug", "domtree", fname);
-
- g_free(fname);
-
- return TRUE;
-}
-
-
-MULTIHANDLER(stop)
-{
- struct browser_window *bw =
- nsgtk_get_browser_window(g->top_level);
-
- browser_window_stop(bw);
-
- return TRUE;
-}
-
-MULTIHANDLER(reload)
-{
- struct browser_window *bw =
- nsgtk_get_browser_window(g->top_level);
- if (bw == NULL)
- return TRUE;
+/**
+ * menu signal handler for activation on downloads item
+ */
+MENUHANDLER(downloads, DOWNLOADS_BUTTON);
- /* clear potential search effects */
- browser_window_search_clear(bw);
+/**
+ * menu signal handler for activation on save window size item
+ */
+MENUHANDLER(savewindowsize, SAVEWINDOWSIZE_BUTTON);
- browser_window_reload(bw, true);
+/**
+ * menu signal handler for activation on toggle debug render item
+ */
+MENUHANDLER(toggledebugging, TOGGLEDEBUGGING_BUTTON);
- return TRUE;
-}
+/**
+ * menu signal handler for activation on debug box tree item
+ */
+MENUHANDLER(debugboxtree, SAVEBOXTREE_BUTTON);
-MULTIHANDLER(back)
-{
- struct browser_window *bw =
- nsgtk_get_browser_window(g->top_level);
+/**
+ * menu signal handler for activation on debug dom tree item
+ */
+MENUHANDLER(debugdomtree, SAVEDOMTREE_BUTTON);
- if ((bw == NULL) || (!browser_window_history_back_available(bw)))
- return TRUE;
+/**
+ * menu signal handler for activation on stop item
+ */
+MENUHANDLER(stop, STOP_BUTTON);
- /* clear potential search effects */
- browser_window_search_clear(bw);
+/**
+ * menu signal handler for activation on reload item
+ */
+MENUHANDLER(reload, RELOAD_BUTTON);
- browser_window_history_back(bw, false);
- scaffolding_update_context(g);
+/**
+ * menu signal handler for activation on back item
+ */
+MENUHANDLER(back, BACK_BUTTON);
- return TRUE;
-}
MULTIHANDLER(forward)
{
@@ -1675,39 +1561,21 @@ void nsgtk_window_set_title(struct gui_window *gw, const char *title)
}
-
-
-#if 0
-static nserror gui_window_start_throbber(struct gui_window* gw)
-{
- struct nsgtk_scaffolding *g = nsgtk_get_scaffold(_g);
- g->buttons[STOP_BUTTON]->sensitivity = true;
- g->buttons[RELOAD_BUTTON]->sensitivity = false;
- nsgtk_scaffolding_set_sensitivity(g);
-
- scaffolding_update_context(g);
-}
-
-static nserror gui_window_stop_throbber(struct gui_window* gw)
+/* exported interface documented in scaffolding.h */
+nserror nsgtk_scaffolding_throbber(struct gui_window* gw, bool active)
{
- nserror res;
- GdkPixbuf *pixbuf;
- struct nsgtk_scaffolding *g = nsgtk_get_scaffold(_g);
-
- if (g == NULL) {
- return;
+ struct nsgtk_scaffolding *gs = nsgtk_get_scaffold(gw);
+ if (active) {
+ gs->menus[STOP_BUTTON].sensitivity = true;
+ gs->menus[RELOAD_BUTTON].sensitivity = false;
+ } else {
+ gs->menus[STOP_BUTTON].sensitivity = false;
+ gs->menus[RELOAD_BUTTON].sensitivity = true;
}
+ scaffolding_update_context(gs);
-
- if (g->buttons[STOP_BUTTON] != NULL)
- g->buttons[STOP_BUTTON]->sensitivity = false;
- if (g->buttons[RELOAD_BUTTON] != NULL)
- g->buttons[RELOAD_BUTTON]->sensitivity = true;
-
- nsgtk_scaffolding_set_sensitivity(g);
-
+ return NSERROR_OK;
}
-#endif
static void
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index 0f19a24..666bc50 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -64,6 +64,11 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *gw);
nserror nsgtk_scaffolding_destroy_all(void);
/**
+ * Update scaffolding window when throbber state changes
+ */
+nserror nsgtk_scaffolding_throbber(struct gui_window* gw, bool active);
+
+/**
* Obtain the most recently used scaffolding element.
*
* This allows tabs to be opened in the most recently used window
diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c
index 04bd69f..3d21c65 100644
--- a/frontends/gtk/tabs.c
+++ b/frontends/gtk/tabs.c
@@ -180,7 +180,7 @@ nsgtk_tab_switch_page_after(GtkNotebook *notebook,
srcpage = gtk_notebook_get_nth_page(notebook, srcpagenum);
gw = g_object_get_data(G_OBJECT(srcpage), "gui_window");
if ((gw != NULL) && (nsgtk_get_scaffold(gw) != NULL)) {
- error = nsgtk_window_item_activate(gw, NEWTAB_BUTTON);
+ error = nsgtk_window_item_activate(gw, NEWTAB_BUTTON);
if (error != NSERROR_OK) {
NSLOG(netsurf, INFO,
"Failed to open new tab.");
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 8fbdfa1..03e07b9 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -2820,7 +2820,7 @@ fullscreen_button_clicked_cb(GtkWidget *widget, gpointer data)
/**
- * handler for full screen tool bar item clicked signal
+ * handler for view source 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
@@ -2848,6 +2848,172 @@ viewsource_button_clicked_cb(GtkWidget *widget, gpointer data)
/**
+ * handler for show downloads 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
+downloads_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ GtkWindow *gtkwindow; /* gtk window widget is in */
+ gtkwindow = GTK_WINDOW(gtk_widget_get_ancestor(widget,GTK_TYPE_WINDOW));
+ nsgtk_download_show(gtkwindow);
+ return TRUE;
+}
+
+
+/**
+ * handler for show downloads 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
+savewindowsize_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ GtkWindow *gtkwindow; /* gtk window widget is in */
+ int x,y,w,h;
+ char *choices = NULL;
+
+ gtkwindow = GTK_WINDOW(gtk_widget_get_ancestor(widget,GTK_TYPE_WINDOW));
+
+ gtk_window_get_position(gtkwindow, &x, &y);
+ gtk_window_get_size(gtkwindow, &w, &h);
+
+ nsoption_set_int(window_width, w);
+ nsoption_set_int(window_height, h);
+ nsoption_set_int(window_x, x);
+ nsoption_set_int(window_y, y);
+
+ netsurf_mkpath(&choices, NULL, 2, nsgtk_config_home, "Choices");
+ if (choices != NULL) {
+ nsoption_write(choices, NULL, NULL);
+ free(choices);
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * handler for show downloads 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
+toggledebugging_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_bw_ctx);
+
+ browser_window_debug(bw, CONTENT_DEBUG_REDRAW);
+
+ nsgtk_reflow_all_windows();
+
+ return TRUE;
+
+}
+
+
+/**
+ * handler for debug box tree 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
+debugboxtree_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ gchar *fname;
+ gint handle;
+ FILE *f;
+
+ handle = g_file_open_tmp("nsgtkboxtreeXXXXXX", &fname, NULL);
+ if ((handle == -1) || (fname == NULL)) {
+ return TRUE;
+ }
+ close(handle); /* in case it was binary mode */
+
+ /* save data to temporary file */
+ f = fopen(fname, "w");
+ if (f == NULL) {
+ nsgtk_warning("Error saving box tree dump.",
+ "Unable to open file for writing.");
+ unlink(fname);
+ return TRUE;
+ }
+
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ browser_window_debug_dump(bw, f, CONTENT_DEBUG_RENDER);
+
+ fclose(f);
+
+ nsgtk_viewfile("Box Tree Debug", "boxtree", fname);
+
+ g_free(fname);
+
+ return TRUE;
+}
+
+
+/**
+ * handler for debug dom tree 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
+debugdomtree_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ gchar *fname;
+ gint handle;
+ FILE *f;
+
+ handle = g_file_open_tmp("nsgtkdomtreeXXXXXX", &fname, NULL);
+ if ((handle == -1) || (fname == NULL)) {
+ return TRUE;
+ }
+ close(handle); /* in case it was binary mode */
+
+ /* save data to temporary file */
+ f = fopen(fname, "w");
+ if (f == NULL) {
+ nsgtk_warning("Error saving box tree dump.",
+ "Unable to open file for writing.");
+ unlink(fname);
+ return TRUE;
+ }
+
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ browser_window_debug_dump(bw, f, CONTENT_DEBUG_DOM);
+
+ fclose(f);
+
+ nsgtk_viewfile("DOM Tree Debug", "domtree", fname);
+
+ g_free(fname);
+
+ return TRUE;
+
+}
+
+
+/**
* create a toolbar item
*
* create a toolbar item and set up its default handlers
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index ecdd978..909b00d 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -63,7 +63,7 @@ typedef enum {
GLOBALHISTORY_BUTTON,
ADDBOOKMARKS_BUTTON,
SHOWBOOKMARKS_BUTTON,
- SHOWCOOKIES_BUTTON,
+ SHOWCOOKIES_BUTTON,
OPENLOCATION_BUTTON,
NEXTTAB_BUTTON,
PREVTAB_BUTTON,
@@ -122,11 +122,11 @@ TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, zoomminus_button_clicked_cb)
TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, zoomnormal_button_clicked_cb)
TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true, fullscreen_button_clicked_cb)
TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true, viewsource_button_clicked_cb)
-TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true, NULL)
-TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true, NULL)
-TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, NULL)
-TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true, NULL)
-TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true, NULL)
+TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true, downloads_button_clicked_cb)
+TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true, savewindowsize_button_clicked_cb)
+TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, toggledebugging_button_clicked_cb)
+TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true, debugboxtree_button_clicked_cb)
+TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true, debugdomtree_button_clicked_cb)
TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true, localhistory_button_clicked_cb)
TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, NULL)
TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, NULL)
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 015b5fa..666e6ea 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -1360,12 +1360,12 @@ gui_window_event(struct gui_window *gw, enum gui_window_event event)
case GW_EVENT_START_THROBBER:
nsgtk_toolbar_throbber(gw->toolbar, true);
- /** \todo menu sensitivity for back/reload */
+ nsgtk_scaffolding_throbber(gw, true);
break;
case GW_EVENT_STOP_THROBBER:
nsgtk_toolbar_throbber(gw->toolbar, false);
- /** \todo menu sensitivity for back/reload */
+ nsgtk_scaffolding_throbber(gw, false);
break;
default:
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=45bd456cd86bd300ea5...
commit 45bd456cd86bd300ea51285c969b88e6ae68bbb9
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
add five more handlers
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 309ee04..685b5d4 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -133,8 +133,6 @@ struct nsgtk_scaffolding {
/** scaffold container window */
GtkWindow *window;
- /** flag for the scaffold window fullscreen status */
- bool fullscreen;
/** tab widget holding displayed pages */
GtkNotebook *notebook;
@@ -819,60 +817,32 @@ MULTIHANDLER(find)
/**
* menu signal handler for activation on preferences item
*/
-MENUHANDLER(preferences,PREFERENCES_BUTTON);
+MENUHANDLER(preferences, PREFERENCES_BUTTON);
+/**
+ * menu signal handler for activation on zoom plus item
+ */
+MENUHANDLER(zoomplus, ZOOMPLUS_BUTTON);
-MULTIHANDLER(zoomplus)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
-
- browser_window_set_scale(bw, 0.05, false);
-
- return TRUE;
-}
-
-MULTIHANDLER(zoomnormal)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
-
- browser_window_set_scale(bw, 1.0, true);
-
- return TRUE;
-}
-
-MULTIHANDLER(zoomminus)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
-
- browser_window_set_scale(bw, -0.05, false);
-
- return TRUE;
-}
-
-MULTIHANDLER(fullscreen)
-{
- if (g->fullscreen) {
- gtk_window_unfullscreen(g->window);
- } else {
- gtk_window_fullscreen(g->window);
- }
-
- g->fullscreen = !g->fullscreen;
-
- return TRUE;
-}
+/**
+ * menu signal handler for activation on zoom minus item
+ */
+MENUHANDLER(zoomminus, ZOOMMINUS_BUTTON);
-MULTIHANDLER(viewsource)
-{
- nserror ret;
+/**
+ * menu signal handler for activation on zoom normal item
+ */
+MENUHANDLER(zoomnormal, ZOOMNORMAL_BUTTON);
- ret = nsgtk_viewsource(g->window, nsgtk_get_browser_window(g->top_level));
- if (ret != NSERROR_OK) {
- nsgtk_warning(messages_get_errorcode(ret), 0);
- }
+/**
+ * menu signal handler for activation on full screen item
+ */
+MENUHANDLER(fullscreen, FULLSCREEN_BUTTON);
- return TRUE;
-}
+/**
+ * menu signal handler for activation on view source item
+ */
+MENUHANDLER(viewsource, VIEWSOURCE_BUTTON);
static gboolean
@@ -2205,8 +2175,6 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
nsgtk_menu_connect_signals(gs);
nsgtk_menu_set_sensitivity(gs);
- gs->fullscreen = false;
-
/* attach to the list */
if (scaf_list) {
scaf_list->prev = gs;
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 1560a6e..8fbdfa1 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -2725,7 +2725,125 @@ preferences_button_clicked_cb(GtkWidget *widget, gpointer data)
}
return TRUE;
+}
+
+
+/**
+ * handler for zoom plus 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
+zoomplus_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_bw_ctx);
+
+ browser_window_set_scale(bw, 0.05, false);
+
+ return TRUE;
+}
+
+/**
+ * handler for zoom minus 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
+zoomminus_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_bw_ctx);
+
+ browser_window_set_scale(bw, -0.05, false);
+
+ return TRUE;
+
+}
+
+
+/**
+ * handler for zoom normal 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
+zoomnormal_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_bw_ctx);
+
+ browser_window_set_scale(bw, 1.0, true);
+
+ return TRUE;
+}
+
+
+/**
+ * handler for full screen 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
+fullscreen_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ GtkWindow *gtkwindow; /* gtk window widget is in */
+ GdkWindow *gdkwindow;
+ GdkWindowState state;
+
+ gtkwindow = GTK_WINDOW(gtk_widget_get_ancestor(widget,GTK_TYPE_WINDOW));
+ gdkwindow = gtk_widget_get_window(GTK_WIDGET(gtkwindow));
+ state = gdk_window_get_state(gdkwindow);
+
+ if (state & GDK_WINDOW_STATE_FULLSCREEN) {
+ gtk_window_unfullscreen(gtkwindow);
+ } else {
+ gtk_window_fullscreen(gtkwindow);
+ }
+ return TRUE;
+}
+
+
+/**
+ * handler for full screen 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
+viewsource_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ nserror res;
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ GtkWindow *gtkwindow; /* gtk window widget is in */
+
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ gtkwindow = GTK_WINDOW(gtk_widget_get_ancestor(widget,GTK_TYPE_WINDOW));
+
+ res = nsgtk_viewsource(gtkwindow, bw);
+ if (res != NSERROR_OK) {
+ nsgtk_warning(messages_get_errorcode(res), 0);
+ }
+
+ return TRUE;
}
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index b4bc91f..ecdd978 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -117,11 +117,11 @@ TOOLBAR_ITEM(DELETE_BUTTON, delete, false, delete_button_clicked_cb)
TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true, selectall_button_clicked_cb)
TOOLBAR_ITEM(FIND_BUTTON, find, true, NULL)
TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true, preferences_button_clicked_cb)
-TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true, NULL)
-TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, NULL)
-TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, NULL)
-TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true, NULL)
-TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true, NULL)
+TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true, zoomplus_button_clicked_cb)
+TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, zoomminus_button_clicked_cb)
+TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, zoomnormal_button_clicked_cb)
+TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true, fullscreen_button_clicked_cb)
+TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true, viewsource_button_clicked_cb)
TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true, NULL)
TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true, NULL)
TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, NULL)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=7f115dc9268776a6308...
commit 7f115dc9268776a63084fe5e1cefa5852d6b2ff0
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
implemented another seven signal handlers
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index ceccda9..309ee04 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -95,6 +95,19 @@ static gboolean nsgtk_on_##q##_activate(struct nsgtk_scaffolding *g)
static gboolean nsgtk_on_##q##_activate(GtkButton *widget, gpointer data)
/**
+ * handle menu activate signals by calling toolbar item activation
+ */
+#define MENUHANDLER(name, itemid) \
+static gboolean \
+nsgtk_on_##name##_activate_menu(GtkMenuItem *widget, gpointer data) \
+{ \
+ struct nsgtk_scaffolding *gs = (struct nsgtk_scaffolding *)data;\
+ nsgtk_window_item_activate(gs->top_level, itemid); \
+ return TRUE; \
+}
+
+
+/**
* menu entry context
*/
struct nsgtk_menu {
@@ -604,122 +617,52 @@ static void nsgtk_openfile_open(const char *filename)
/**
* menu signal handler for activation on new window item
*/
-static gboolean
-nsgtk_on_newwindow_activate_menu(GtkMenuItem *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_window_item_activate(g->top_level, NEWWINDOW_BUTTON);
- return TRUE;
-}
+MENUHANDLER(newwindow, NEWWINDOW_BUTTON);
/**
* menu signal handler for activation on new tab item
*/
-static gboolean
-nsgtk_on_newtab_activate_menu(GtkMenuItem *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_window_item_activate(g->top_level, NEWTAB_BUTTON);
- return TRUE;
-}
+MENUHANDLER(newtab, NEWTAB_BUTTON);
/**
* menu signal handler for activation on open file item
*/
-static gboolean
-nsgtk_on_openfile_activate_menu(GtkMenuItem *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_window_item_activate(g->top_level, OPENFILE_BUTTON);
- return TRUE;
-}
-
+MENUHANDLER(openfile, OPENFILE_BUTTON);
/**
* menu signal handler for activation on export complete page item
*/
-static gboolean
-nsgtk_on_savepage_activate_menu(GtkMenuItem *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_window_item_activate(g->top_level, SAVEPAGE_BUTTON);
- return TRUE;
-}
-
+MENUHANDLER(savepage, SAVEPAGE_BUTTON);
/**
* menu signal handler for activation on export pdf item
*/
-static gboolean
-nsgtk_on_pdf_activate_menu(GtkMenuItem *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_window_item_activate(g->top_level, PDF_BUTTON);
- return TRUE;
-}
+MENUHANDLER(pdf, PDF_BUTTON);
/**
* menu signal handler for activation on export plain text item
*/
-static gboolean
-nsgtk_on_plaintext_activate_menu(GtkMenuItem *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_window_item_activate(g->top_level, PLAINTEXT_BUTTON);
- return TRUE;
-}
-
+MENUHANDLER(plaintext, PLAINTEXT_BUTTON);
/**
* menu signal handler for activation on print preview item
*/
-static gboolean
-nsgtk_on_printpreview_activate_menu(GtkMenuItem *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_window_item_activate(g->top_level, PRINTPREVIEW_BUTTON);
- return TRUE;
-}
-
+MENUHANDLER(printpreview, PRINTPREVIEW_BUTTON);
/**
* menu signal handler for activation on print item
*/
-static gboolean
-nsgtk_on_print_activate_menu(GtkMenuItem *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_window_item_activate(g->top_level, PRINT_BUTTON);
- return TRUE;
-}
-
+MENUHANDLER(print, PRINT_BUTTON);
/**
* menu signal handler for activation on close window item
*/
-static gboolean
-nsgtk_on_closewindow_activate_menu(GtkMenuItem *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- nsgtk_window_item_activate(g->top_level, CLOSEWINDOW_BUTTON);
- return TRUE;
-}
-
-
-MULTIHANDLER(quit)
-{
- struct nsgtk_scaffolding *gs;
-
- if (nsgtk_check_for_downloads(g->window) == false) {
- gs = scaf_list;
- while (gs != NULL) {
- gtk_widget_destroy(GTK_WIDGET(gs->window));
- gs = gs->next;
- }
- }
+MENUHANDLER(closewindow, CLOSEWINDOW_BUTTON);
- return TRUE;
-}
+/**
+ * menu signal handler for activation on close window item
+ */
+MENUHANDLER(quit, QUIT_BUTTON);
static gboolean
@@ -832,54 +775,25 @@ nsgtk_on_link_copy_activate_menu(GtkMenuItem *widget, gpointer data)
}
-MULTIHANDLER(cut)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- GtkWidget *focused = gtk_window_get_focus(g->window);
-
- /* If the url bar has focus, let gtk handle it */
- if (GTK_IS_EDITABLE (focused))
- //gtk_editable_cut_clipboard (GTK_EDITABLE(g->url_bar));
- ;
- else
- browser_window_key_press(bw, NS_KEY_CUT_SELECTION);
-
- return TRUE;
-}
-
-MULTIHANDLER(copy)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- GtkWidget *focused = gtk_window_get_focus(g->window);
-
- /* If the url bar has focus, let gtk handle it */
- if (GTK_IS_EDITABLE (focused))
- //gtk_editable_copy_clipboard(GTK_EDITABLE(g->url_bar));
- ;
- else
- browser_window_key_press(bw, NS_KEY_COPY_SELECTION);
-
- return TRUE;
-}
-
-MULTIHANDLER(paste)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- GtkWidget *focused = gtk_window_get_focus(g->window);
+/**
+ * menu signal handler for activation on cut item
+ */
+MENUHANDLER(cut, CUT_BUTTON);
- /* If the url bar has focus, let gtk handle it */
- if (GTK_IS_EDITABLE (focused))
- gtk_editable_paste_clipboard (GTK_EDITABLE (focused));
- else
- browser_window_key_press(bw, NS_KEY_PASTE);
+/**
+ * menu signal handler for activation on copy item
+ */
+MENUHANDLER(copy, COPY_BUTTON);
- return TRUE;
-}
+/**
+ * menu signal handler for activation on paste item
+ */
+MENUHANDLER(paste, PASTE_BUTTON);
-MULTIHANDLER(delete)
-{
- return TRUE;
-}
+/**
+ * menu signal handler for activation on delete item
+ */
+MENUHANDLER(delete, DELETE_BUTTON);
static gboolean
@@ -890,22 +804,11 @@ nsgtk_on_customize_activate_menu(GtkMenuItem *widget, gpointer data)
return TRUE;
}
-MULTIHANDLER(selectall)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
-#if 0
- if (nsgtk_widget_has_focus(GTK_WIDGET(g->url_bar))) {
- NSLOG(netsurf, INFO, "Selecting all URL bar text");
- gtk_editable_select_region(GTK_EDITABLE(g->url_bar), 0, -1);
- } else {
-#endif
- NSLOG(netsurf, INFO, "Selecting all document text");
- browser_window_key_press(bw, NS_KEY_SELECT_ALL);
-#if 0
- }
-#endif
- return TRUE;
-}
+/**
+ * menu signal handler for activation on selectall item
+ */
+MENUHANDLER(selectall, SELECTALL_BUTTON);
+
MULTIHANDLER(find)
{
@@ -913,18 +816,11 @@ MULTIHANDLER(find)
return TRUE;
}
-MULTIHANDLER(preferences)
-{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- GtkWidget* wndpreferences;
-
- wndpreferences = nsgtk_preferences(bw, g->window);
- if (wndpreferences != NULL) {
- gtk_widget_show(GTK_WIDGET(wndpreferences));
- }
+/**
+ * menu signal handler for activation on preferences item
+ */
+MENUHANDLER(preferences,PREFERENCES_BUTTON);
- return TRUE;
-}
MULTIHANDLER(zoomplus)
{
@@ -1973,6 +1869,27 @@ static struct gui_search_web_table search_web_table = {
struct gui_search_web_table *nsgtk_search_web_table = &search_web_table;
/* exported interface documented in gtk/scaffolding.h */
+nserror nsgtk_scaffolding_destroy_all(void)
+{
+ struct nsgtk_scaffolding *gs;
+
+ gs = scaf_list;
+ assert(gs != NULL);
+
+ if (nsgtk_check_for_downloads(gs->window) == true) {
+ return NSERROR_INVALID;
+ }
+
+ /* iterate all scaffolding windows and destroy them */
+ while (gs != NULL) {
+ gtk_widget_destroy(GTK_WIDGET(gs->window));
+ gs = gs->next;
+ }
+ return NSERROR_OK;
+}
+
+
+/* exported interface documented in gtk/scaffolding.h */
GtkWindow* nsgtk_scaffolding_window(struct nsgtk_scaffolding *g)
{
return g->window;
@@ -2242,8 +2159,10 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
g_signal_connect(G_OBJECT(obj), (sig), G_CALLBACK(callback), (ptr))
/* connect main window signals to their handlers. */
- CONNECT(gs->window, "delete-event",
- scaffolding_window_delete_event, gs);
+ CONNECT(gs->window,
+ "delete-event",
+ scaffolding_window_delete_event,
+ gs);
CONNECT(gs->window, "destroy", scaffolding_window_destroy, gs);
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index d5a916f..0f19a24 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -56,6 +56,14 @@ struct gtk_search {
struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *gw);
/**
+ * causes all scaffolding windows to be destroyed.
+ *
+ * \return NSERROR_OK and all scaffolding windows destroyed else
+ * NSERROR_INVALID if download in progress and user continued.
+ */
+nserror nsgtk_scaffolding_destroy_all(void);
+
+/**
* Obtain the most recently used scaffolding element.
*
* This allows tabs to be opened in the most recently used window
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 57cda1e..1560a6e 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -41,6 +41,7 @@
#include "desktop/print.h"
#include "netsurf/content.h"
#include "netsurf/browser_window.h"
+#include "netsurf/keypress.h"
#include "gtk/toolbar_items.h"
#include "gtk/completion.h"
@@ -57,6 +58,7 @@
#include "gtk/tabs.h"
#include "gtk/print.h"
#include "gtk/layout_pango.h"
+#include "gtk/preferences.h"
#include "gtk/toolbar.h"
/**
@@ -2528,6 +2530,204 @@ print_button_clicked_cb(GtkWidget *widget, gpointer data)
return TRUE;
}
+/**
+ * handler for quit 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
+quit_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ nsgtk_scaffolding_destroy_all();
+ return TRUE;
+}
+
+
+/**
+ * handler for cut 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
+cut_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ GtkWidget *focused;
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+
+ focused = gtk_window_get_focus(GTK_WINDOW(toplevel));
+
+ /* let gtk handle it if focused widget is an editable */
+ if (GTK_IS_EDITABLE(focused)) {
+ gtk_editable_cut_clipboard(GTK_EDITABLE(focused));
+ } else {
+ bw = tb->get_bw(tb->get_bw_ctx);
+ browser_window_key_press(bw, NS_KEY_CUT_SELECTION);
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * handler for copy 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
+copy_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ GtkWidget *focused;
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+
+ focused = gtk_window_get_focus(GTK_WINDOW(toplevel));
+
+ /* let gtk handle it if focused widget is an editable */
+ if (GTK_IS_EDITABLE(focused)) {
+ gtk_editable_copy_clipboard(GTK_EDITABLE(focused));
+ } else {
+ bw = tb->get_bw(tb->get_bw_ctx);
+ browser_window_key_press(bw, NS_KEY_COPY_SELECTION);
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * handler for paste 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
+paste_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ GtkWidget *focused;
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+
+ focused = gtk_window_get_focus(GTK_WINDOW(toplevel));
+
+ /* let gtk handle it if focused widget is an editable */
+ if (GTK_IS_EDITABLE(focused)) {
+ gtk_editable_paste_clipboard(GTK_EDITABLE(focused));
+ } else {
+ bw = tb->get_bw(tb->get_bw_ctx);
+ browser_window_key_press(bw, NS_KEY_PASTE);
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * handler for delete 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
+delete_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ GtkWidget *focused;
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+
+ focused = gtk_window_get_focus(GTK_WINDOW(toplevel));
+
+ /* let gtk handle it if focused widget is an editable */
+ if (GTK_IS_EDITABLE(focused)) {
+ gtk_editable_delete_selection(GTK_EDITABLE(focused));
+ } else {
+ bw = tb->get_bw(tb->get_bw_ctx);
+ browser_window_key_press(bw, NS_KEY_CLEAR_SELECTION);
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * handler for select all 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
+selectall_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ GtkWidget *focused;
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+
+ focused = gtk_window_get_focus(GTK_WINDOW(toplevel));
+
+ /* let gtk handle it if focused widget is an editable */
+ if (GTK_IS_EDITABLE(focused)) {
+ gtk_editable_select_region(GTK_EDITABLE(focused), 0, -1);
+ } else {
+ bw = tb->get_bw(tb->get_bw_ctx);
+ browser_window_key_press(bw, NS_KEY_SELECT_ALL);
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * handler for preferences 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
+preferences_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ GtkWidget *toplevel;
+ GtkWidget *wndpreferences;
+
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+
+ wndpreferences = nsgtk_preferences(bw, GTK_WINDOW(toplevel));
+ if (wndpreferences != NULL) {
+ gtk_widget_show(wndpreferences);
+ }
+
+ return TRUE;
+
+}
+
/**
* create a toolbar item
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 24afef9..b4bc91f 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -109,14 +109,14 @@ TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false, NULL)
TOOLBAR_ITEM(POSTSCRIPT_BUTTON, postscript, false, NULL)
TOOLBAR_ITEM(PRINTPREVIEW_BUTTON, printpreview, false, NULL)
TOOLBAR_ITEM(PRINT_BUTTON, print, true, print_button_clicked_cb)
-TOOLBAR_ITEM(QUIT_BUTTON, quit, true, NULL)
-TOOLBAR_ITEM(CUT_BUTTON, cut, true, NULL)
-TOOLBAR_ITEM(COPY_BUTTON, copy, true, NULL)
-TOOLBAR_ITEM(PASTE_BUTTON, paste, true, NULL)
-TOOLBAR_ITEM(DELETE_BUTTON, delete, false, NULL)
-TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true, NULL)
+TOOLBAR_ITEM(QUIT_BUTTON, quit, true, quit_button_clicked_cb)
+TOOLBAR_ITEM(CUT_BUTTON, cut, true, cut_button_clicked_cb)
+TOOLBAR_ITEM(COPY_BUTTON, copy, true, copy_button_clicked_cb)
+TOOLBAR_ITEM(PASTE_BUTTON, paste, true, paste_button_clicked_cb)
+TOOLBAR_ITEM(DELETE_BUTTON, delete, false, delete_button_clicked_cb)
+TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true, selectall_button_clicked_cb)
TOOLBAR_ITEM(FIND_BUTTON, find, true, NULL)
-TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true, NULL)
+TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true, preferences_button_clicked_cb)
TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true, NULL)
TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, NULL)
TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, NULL)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8f0c0734eaf27429b4c...
commit 8f0c0734eaf27429b4ca6c2c89517a3b5d476d87
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
implement more toolbar item handlers and make menus call them
diff --git a/frontends/gtk/menu.c b/frontends/gtk/menu.c
index 6a60332..909016a 100644
--- a/frontends/gtk/menu.c
+++ b/frontends/gtk/menu.c
@@ -142,21 +142,23 @@ nsgtk_menu_add_image_item(GtkMenu *menu,
static struct nsgtk_export_submenu *
nsgtk_menu_export_submenu(GtkAccelGroup *group)
{
- struct nsgtk_export_submenu *ret = malloc(sizeof(struct
- nsgtk_export_submenu));
+ struct nsgtk_export_submenu *ret;
+ ret = malloc(sizeof(struct nsgtk_export_submenu));
+
if (ret == NULL) {
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
+
ret->export_menu = GTK_MENU(gtk_menu_new());
if (ret->export_menu == NULL) {
nsgtk_warning(messages_get("NoMemory"), 0);
free(ret);
return NULL;
}
+
+ IMAGE_ITEM(export, savepage, gtkSavePage, ret, group);
IMAGE_ITEM(export, plaintext, gtkPlainText, ret, group);
- IMAGE_ITEM(export, drawfile, gtkDrawFile, ret, group);
- IMAGE_ITEM(export, postscript, gtkPostScript, ret, group);
IMAGE_ITEM(export, pdf, gtkPDF, ret, group);
return ret;
}
@@ -323,7 +325,6 @@ static struct nsgtk_file_menu *nsgtk_menu_file_submenu(GtkAccelGroup *group)
IMAGE_ITEM(file, openfile, gtkOpenFile, fmenu, group);
IMAGE_ITEM(file, closewindow, gtkCloseWindow, fmenu, group);
ADD_SEP(file, fmenu);
- IMAGE_ITEM(file, savepage, gtkSavePage, fmenu, group);
IMAGE_ITEM(file, export, gtkExport, fmenu, group);
ADD_SEP(file, fmenu);
IMAGE_ITEM(file, printpreview, gtkPrintPreview, fmenu, group);
diff --git a/frontends/gtk/menu.h b/frontends/gtk/menu.h
index 5da5cb1..6dbb433 100644
--- a/frontends/gtk/menu.h
+++ b/frontends/gtk/menu.h
@@ -15,24 +15,26 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef _NETSURF_GTK_MENU_H_
-#define _NETSURF_GTK_MENU_H_
+#ifndef NETSURF_GTK_MENU_H_
+#define NETSURF_GTK_MENU_H_
#include <gtk/gtk.h>
+/**
+ * File menu item on menubar
+ */
struct nsgtk_file_menu {
- GtkMenuItem *file; /* File menu item on menubar */
- GtkMenu *file_menu;
- GtkWidget *newwindow_menuitem;
- GtkWidget *newtab_menuitem;
- GtkWidget *openfile_menuitem;
- GtkWidget *closewindow_menuitem;
- GtkWidget *savepage_menuitem;
- GtkWidget *export_menuitem;
- struct nsgtk_export_submenu *export_submenu;
- GtkWidget *printpreview_menuitem;
- GtkWidget *print_menuitem;
- GtkWidget *quit_menuitem;
+ GtkMenuItem *file;
+ GtkMenu *file_menu;
+ GtkWidget *newwindow_menuitem;
+ GtkWidget *newtab_menuitem;
+ GtkWidget *openfile_menuitem;
+ GtkWidget *closewindow_menuitem;
+ GtkWidget *export_menuitem;
+ struct nsgtk_export_submenu *export_submenu;
+ GtkWidget *printpreview_menuitem;
+ GtkWidget *print_menuitem;
+ GtkWidget *quit_menuitem;
};
struct nsgtk_edit_menu {
@@ -88,35 +90,34 @@ struct nsgtk_tools_menu {
};
struct nsgtk_help_menu {
- GtkMenuItem *help; /* Help menu item on menubar */
- GtkMenu *help_menu;
- GtkWidget *contents_menuitem;
- GtkWidget *guide_menuitem;
- GtkWidget *info_menuitem;
- GtkWidget *about_menuitem;
+ GtkMenuItem *help; /* Help menu item on menubar */
+ GtkMenu *help_menu;
+ GtkWidget *contents_menuitem;
+ GtkWidget *guide_menuitem;
+ GtkWidget *info_menuitem;
+ GtkWidget *about_menuitem;
};
struct nsgtk_export_submenu {
- GtkMenu *export_menu;
- GtkWidget *plaintext_menuitem;
- GtkWidget *drawfile_menuitem;
- GtkWidget *postscript_menuitem;
- GtkWidget *pdf_menuitem;
+ GtkMenu *export_menu;
+ GtkWidget *savepage_menuitem;
+ GtkWidget *plaintext_menuitem;
+ GtkWidget *pdf_menuitem;
};
struct nsgtk_scaleview_submenu {
- GtkMenu *scaleview_menu;
- GtkWidget *zoomplus_menuitem;
- GtkWidget *zoomminus_menuitem;
- GtkWidget *zoomnormal_menuitem;
+ GtkMenu *scaleview_menu;
+ GtkWidget *zoomplus_menuitem;
+ GtkWidget *zoomminus_menuitem;
+ GtkWidget *zoomnormal_menuitem;
};
struct nsgtk_tabs_submenu {
- GtkMenu *tabs_menu;
- GtkWidget *nexttab_menuitem;
- GtkWidget *prevtab_menuitem;
- GtkWidget *closetab_menuitem;
+ GtkMenu *tabs_menu;
+ GtkWidget *nexttab_menuitem;
+ GtkWidget *prevtab_menuitem;
+ GtkWidget *closetab_menuitem;
};
struct nsgtk_images_submenu {
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 10d9681..ceccda9 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -624,7 +624,7 @@ nsgtk_on_newtab_activate_menu(GtkMenuItem *widget, gpointer data)
}
/**
- * menu signal handler for activation on openfile item
+ * menu signal handler for activation on open file item
*/
static gboolean
nsgtk_on_openfile_activate_menu(GtkMenuItem *widget, gpointer data)
@@ -636,303 +636,60 @@ nsgtk_on_openfile_activate_menu(GtkMenuItem *widget, gpointer data)
/**
- * callback to determine if a path is a directory.
- *
- * \param info The path information
- * \param data context pointer set to NULL
- * \return TRUE if path is a directory else false
+ * menu signal handler for activation on export complete page item
*/
static gboolean
-nsgtk_filter_directory(const GtkFileFilterInfo *info,
- gpointer data)
-{
- DIR *d = opendir(info->filename);
- if (d == NULL)
- return FALSE;
- closedir(d);
- return TRUE;
-}
-
-MULTIHANDLER(savepage)
+nsgtk_on_savepage_activate_menu(GtkMenuItem *widget, gpointer data)
{
- if (!browser_window_has_content(nsgtk_get_browser_window(g->top_level)))
- return FALSE;
-
- GtkWidget *fc;
- DIR *d;
- char *path;
- nserror res;
- GtkFileFilter *filter;
-
- fc = gtk_file_chooser_dialog_new(
- messages_get("gtkcompleteSave"), g->window,
- GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
- NSGTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- NSGTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
- NULL);
- filter = gtk_file_filter_new();
- gtk_file_filter_set_name(filter, "Directories");
- gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME,
- nsgtk_filter_directory, NULL, NULL);
- gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(fc), filter);
- gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(fc), filter);
-
- res = nsurl_nice(browser_window_access_url(
- nsgtk_get_browser_window(g->top_level)), &path, false);
- if (res != NSERROR_OK) {
- path = strdup(messages_get("SaveText"));
- if (path == NULL) {
- nsgtk_warning("NoMemory", 0);
- return FALSE;
- }
- }
-
- if (access(path, F_OK) != 0)
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), path);
- free(path);
-
- gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(fc),
- TRUE);
-
- if (gtk_dialog_run(GTK_DIALOG(fc)) != GTK_RESPONSE_ACCEPT) {
- gtk_widget_destroy(fc);
- return TRUE;
- }
-
- path = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
- d = opendir(path);
- if (d == NULL) {
- NSLOG(netsurf, INFO,
- "Unable to open directory %s for complete save: %s",
- path,
- strerror(errno));
- if (errno == ENOTDIR)
- nsgtk_warning("NoDirError", path);
- else
- nsgtk_warning("gtkFileError", path);
- gtk_widget_destroy(fc);
- g_free(path);
- return TRUE;
- }
- closedir(d);
- save_complete(browser_window_get_content(nsgtk_get_browser_window(
- g->top_level)), path, NULL);
- g_free(path);
-
- gtk_widget_destroy(fc);
-
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ nsgtk_window_item_activate(g->top_level, SAVEPAGE_BUTTON);
return TRUE;
}
-MULTIHANDLER(pdf)
-{
-#ifdef WITH_PDF_EXPORT
-
- GtkWidget *save_dialog;
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- struct print_settings *settings;
- char filename[PATH_MAX];
- char dirname[PATH_MAX];
- char *url_name;
- nserror res;
-
- NSLOG(netsurf, INFO, "Print preview (generating PDF) started.");
-
- res = nsurl_nice(browser_window_access_url(bw), &url_name, true);
- if (res != NSERROR_OK) {
- nsgtk_warning(messages_get_errorcode(res), 0);
- return TRUE;
- }
-
- strncpy(filename, url_name, PATH_MAX);
- strncat(filename, ".pdf", PATH_MAX - strlen(filename));
- filename[PATH_MAX - 1] = '\0';
-
- free(url_name);
-
- strncpy(dirname, option_downloads_directory, PATH_MAX);
- strncat(dirname, "/", PATH_MAX - strlen(dirname));
- dirname[PATH_MAX - 1] = '\0';
-
- /* this way the scale used by PDF functions is synchronised with that
- * used by the all-purpose print interface
- */
- haru_nsfont_set_scale((float)option_export_scale / 100);
-
- save_dialog = gtk_file_chooser_dialog_new("Export to PDF", g->window,
- GTK_FILE_CHOOSER_ACTION_SAVE,
- NSGTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- NSGTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
- NULL);
-
- gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(save_dialog),
- dirname);
-
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(save_dialog),
- filename);
-
- if (gtk_dialog_run(GTK_DIALOG(save_dialog)) == GTK_RESPONSE_ACCEPT) {
- gchar *filename = gtk_file_chooser_get_filename(
- GTK_FILE_CHOOSER(save_dialog));
-
- settings = print_make_settings(PRINT_OPTIONS,
- (const char *) filename, &haru_nsfont);
- g_free(filename);
-
- if (settings == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- gtk_widget_destroy(save_dialog);
- return TRUE;
- }
-
- /* This will clean up the print_settings object for us */
- print_basic_run(browser_window_get_content(bw),
- &pdf_printer, settings);
- }
-
- gtk_widget_destroy(save_dialog);
-
-#endif /* WITH_PDF_EXPORT */
-
- return TRUE;
-}
-
-MULTIHANDLER(plaintext)
+/**
+ * menu signal handler for activation on export pdf item
+ */
+static gboolean
+nsgtk_on_pdf_activate_menu(GtkMenuItem *widget, gpointer data)
{
- if (!browser_window_has_content(nsgtk_get_browser_window(g->top_level)))
- return FALSE;
-
- GtkWidget *fc = gtk_file_chooser_dialog_new(
- messages_get("gtkplainSave"), g->window,
- GTK_FILE_CHOOSER_ACTION_SAVE,
- NSGTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- NSGTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
- NULL);
- char *filename;
- nserror res;
-
- res = nsurl_nice(browser_window_access_url(
- nsgtk_get_browser_window(g->top_level)),
- &filename, false);
- if (res != NSERROR_OK) {
- filename = strdup(messages_get("SaveText"));
- if (filename == NULL) {
- nsgtk_warning("NoMemory", 0);
- return FALSE;
- }
- }
-
- gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), filename);
- gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(fc),
- TRUE);
-
- free(filename);
-
- if (gtk_dialog_run(GTK_DIALOG(fc)) == GTK_RESPONSE_ACCEPT) {
- filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
- save_as_text(browser_window_get_content(
- nsgtk_get_browser_window(
- g->top_level)), filename);
- g_free(filename);
- }
-
- gtk_widget_destroy(fc);
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ nsgtk_window_item_activate(g->top_level, PDF_BUTTON);
return TRUE;
}
-MULTIHANDLER(drawfile)
+/**
+ * menu signal handler for activation on export plain text item
+ */
+static gboolean
+nsgtk_on_plaintext_activate_menu(GtkMenuItem *widget, gpointer data)
{
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ nsgtk_window_item_activate(g->top_level, PLAINTEXT_BUTTON);
return TRUE;
}
-MULTIHANDLER(postscript)
-{
- return TRUE;
-}
-MULTIHANDLER(printpreview)
+/**
+ * menu signal handler for activation on print preview item
+ */
+static gboolean
+nsgtk_on_printpreview_activate_menu(GtkMenuItem *widget, gpointer data)
{
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ nsgtk_window_item_activate(g->top_level, PRINTPREVIEW_BUTTON);
return TRUE;
}
-MULTIHANDLER(print)
+/**
+ * menu signal handler for activation on print item
+ */
+static gboolean
+nsgtk_on_print_activate_menu(GtkMenuItem *widget, gpointer data)
{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
-
- GtkPrintOperation *print_op;
- GtkPageSetup *page_setup;
- GtkPrintSettings *print_settings;
- GtkPrintOperationResult res = GTK_PRINT_OPERATION_RESULT_ERROR;
- struct print_settings *nssettings;
- char *settings_fname = NULL;
-
- print_op = gtk_print_operation_new();
- if (print_op == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- return TRUE;
- }
-
- /* use previously saved settings if any */
- netsurf_mkpath(&settings_fname, NULL, 2, nsgtk_config_home, "Print");
- if (settings_fname != NULL) {
- print_settings = gtk_print_settings_new_from_file(settings_fname, NULL);
- if (print_settings != NULL) {
- gtk_print_operation_set_print_settings(print_op,
- print_settings);
-
- /* We're not interested in the settings any more */
- g_object_unref(print_settings);
- }
- }
-
- content_to_print = browser_window_get_content(bw);
-
- page_setup = gtk_print_run_page_setup_dialog(g->window, NULL, NULL);
- if (page_setup == NULL) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- free(settings_fname);
- g_object_unref(print_op);
- return TRUE;
- }
- gtk_print_operation_set_default_page_setup(print_op, page_setup);
-
- nssettings = print_make_settings(PRINT_DEFAULT, NULL, nsgtk_layout_table);
-
- g_signal_connect(print_op, "begin_print",
- G_CALLBACK(gtk_print_signal_begin_print), nssettings);
- g_signal_connect(print_op, "draw_page",
- G_CALLBACK(gtk_print_signal_draw_page), NULL);
- g_signal_connect(print_op, "end_print",
- G_CALLBACK(gtk_print_signal_end_print), nssettings);
-
- if (content_get_type(browser_window_get_content(bw)) !=
- CONTENT_TEXTPLAIN) {
- res = gtk_print_operation_run(print_op,
- GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
- g->window,
- NULL);
- }
-
- /* if the settings were used save them for future use */
- if (settings_fname != NULL) {
- if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
- /* Do not increment the settings reference */
- print_settings =
- gtk_print_operation_get_print_settings(print_op);
-
- gtk_print_settings_to_file(print_settings,
- settings_fname,
- NULL);
- }
- free(settings_fname);
- }
-
- /* Our print_settings object is destroyed by the end print handler */
- g_object_unref(page_setup);
- g_object_unref(print_op);
-
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ nsgtk_window_item_activate(g->top_level, PRINT_BUTTON);
return TRUE;
}
@@ -1839,16 +1596,20 @@ static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
#define ITEM_POP(p, q) \
g->menus[p##_BUTTON].popup = g->menu_popup->q##_menuitem
-
+ /* file menu */
ITEM_MAIN(NEWWINDOW, file_submenu, newwindow);
ITEM_MAIN(NEWTAB, file_submenu, newtab);
ITEM_MAIN(OPENFILE, file_submenu, openfile);
- ITEM_MAIN(PRINT, file_submenu, print);
ITEM_MAIN(CLOSEWINDOW, file_submenu, closewindow);
- ITEM_MAIN(SAVEPAGE, file_submenu, savepage);
ITEM_MAIN(PRINTPREVIEW, file_submenu, printpreview);
ITEM_MAIN(PRINT, file_submenu, print);
ITEM_MAIN(QUIT, file_submenu, quit);
+ /* file - export submenu */
+ ITEM_SUB(SAVEPAGE, file_submenu, export, savepage);
+ ITEM_SUB(PLAINTEXT, file_submenu, export, plaintext);
+ ITEM_SUB(PDF, file_submenu, export, pdf);
+
+ /* edit menu */
ITEM_MAIN(CUT, edit_submenu, cut);
ITEM_MAIN(COPY, edit_submenu, copy);
ITEM_MAIN(PASTE, edit_submenu, paste);
@@ -1856,45 +1617,52 @@ static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
ITEM_MAIN(SELECTALL, edit_submenu, selectall);
ITEM_MAIN(FIND, edit_submenu, find);
ITEM_MAIN(PREFERENCES, edit_submenu, preferences);
+
+ /* view menu */
ITEM_MAIN(STOP, view_submenu, stop);
- ITEM_POP(STOP, stop);
ITEM_MAIN(RELOAD, view_submenu, reload);
- ITEM_POP(RELOAD, reload);
ITEM_MAIN(FULLSCREEN, view_submenu, fullscreen);
- ITEM_MAIN(DOWNLOADS, tools_submenu, downloads);
ITEM_MAIN(SAVEWINDOWSIZE, view_submenu, savewindowsize);
+ /* view - scale submenu */
+ ITEM_SUB(ZOOMPLUS, view_submenu, scaleview, zoomplus);
+ ITEM_SUB(ZOOMMINUS, view_submenu, scaleview, zoomminus);
+ ITEM_SUB(ZOOMNORMAL, view_submenu, scaleview, zoomnormal);
+ /* view - tabs submenu */
+ ITEM_SUB(NEXTTAB, view_submenu, tabs, nexttab);
+ ITEM_SUB(PREVTAB, view_submenu, tabs, prevtab);
+ ITEM_SUB(CLOSETAB, view_submenu, tabs, closetab);
+
+ /* navigation menu */
ITEM_MAIN(BACK, nav_submenu, back);
- ITEM_POP(BACK, back);
ITEM_MAIN(FORWARD, nav_submenu, forward);
- ITEM_POP(FORWARD, forward);
ITEM_MAIN(HOME, nav_submenu, home);
ITEM_MAIN(LOCALHISTORY, nav_submenu, localhistory);
ITEM_MAIN(GLOBALHISTORY, nav_submenu, globalhistory);
ITEM_MAIN(ADDBOOKMARKS, nav_submenu, addbookmarks);
ITEM_MAIN(SHOWBOOKMARKS, nav_submenu, showbookmarks);
- ITEM_MAIN(SHOWCOOKIES, tools_submenu, showcookies);
ITEM_MAIN(OPENLOCATION, nav_submenu, openlocation);
- ITEM_MAIN(CONTENTS, help_submenu, contents);
- ITEM_MAIN(INFO, help_submenu, info);
- ITEM_MAIN(GUIDE, help_submenu, guide);
- ITEM_MAIN(ABOUT, help_submenu, about);
- ITEM_SUB(PLAINTEXT, file_submenu, export, plaintext);
- ITEM_SUB(PDF, file_submenu, export, pdf);
- ITEM_SUB(DRAWFILE, file_submenu, export, drawfile);
- ITEM_SUB(POSTSCRIPT, file_submenu, export, postscript);
- ITEM_SUB(ZOOMPLUS, view_submenu, scaleview, zoomplus);
- ITEM_SUB(ZOOMMINUS, view_submenu, scaleview, zoomminus);
- ITEM_SUB(ZOOMNORMAL, view_submenu, scaleview, zoomnormal);
- ITEM_SUB(NEXTTAB, view_submenu, tabs, nexttab);
- ITEM_SUB(PREVTAB, view_submenu, tabs, prevtab);
- ITEM_SUB(CLOSETAB, view_submenu, tabs, closetab);
- /* development submenu */
+ /* tools menu */
+ ITEM_MAIN(DOWNLOADS, tools_submenu, downloads);
+ ITEM_MAIN(SHOWCOOKIES, tools_submenu, showcookies);
+ /* tools > developer submenu */
ITEM_SUB(VIEWSOURCE, tools_submenu, developer, viewsource);
ITEM_SUB(TOGGLEDEBUGGING, tools_submenu, developer, toggledebugging);
ITEM_SUB(SAVEBOXTREE, tools_submenu, developer, debugboxtree);
ITEM_SUB(SAVEDOMTREE, tools_submenu, developer, debugdomtree);
+ /* help menu */
+ ITEM_MAIN(CONTENTS, help_submenu, contents);
+ ITEM_MAIN(GUIDE, help_submenu, guide);
+ ITEM_MAIN(INFO, help_submenu, info);
+ ITEM_MAIN(ABOUT, help_submenu, about);
+
+ /* popup menu */
+ ITEM_POP(STOP, stop);
+ ITEM_POP(RELOAD, reload);
+ ITEM_POP(BACK, back);
+ ITEM_POP(FORWARD, forward);
+
#undef ITEM_MAIN
#undef ITEM_SUB
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 4b3f23b..57cda1e 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -24,18 +24,23 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include <gtk/gtk.h>
-#include "netsurf/browser_window.h"
-#include "desktop/browser_history.h"
-#include "desktop/searchweb.h"
-#include "desktop/search.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsoption.h"
#include "utils/file.h"
#include "utils/nsurl.h"
#include "utils/corestrings.h"
+#include "desktop/browser_history.h"
+#include "desktop/searchweb.h"
+#include "desktop/search.h"
+#include "desktop/save_complete.h"
+#include "desktop/save_text.h"
+#include "desktop/print.h"
+#include "netsurf/content.h"
+#include "netsurf/browser_window.h"
#include "gtk/toolbar_items.h"
#include "gtk/completion.h"
@@ -49,6 +54,9 @@
#include "gtk/resources.h"
#include "gtk/schedule.h"
#include "gtk/local_history.h"
+#include "gtk/tabs.h"
+#include "gtk/print.h"
+#include "gtk/layout_pango.h"
#include "gtk/toolbar.h"
/**
@@ -2193,7 +2201,7 @@ closetab_button_clicked_cb(GtkWidget *widget, gpointer data)
{
struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
- nsgtk_tab_close_current(tb->widget);
+ nsgtk_tab_close_current(GTK_NOTEBOOK(tb->widget));
return TRUE;
}
@@ -2216,8 +2224,71 @@ closewindow_button_clicked_cb(GtkWidget *widget, gpointer data)
}
+static nserror
+nsgtk_saveas_dialog(struct browser_window *bw,
+ const char *title,
+ GtkWindow *parent,
+ bool folder,
+ gchar **path_out)
+{
+ nserror res;
+ GtkWidget *fc; /* file chooser widget */
+ GtkFileChooserAction action;
+ char *path; /* proposed path */
+
+ if (!browser_window_has_content(bw)) {
+ /* cannot save a page with no content */
+ return NSERROR_INVALID;
+ }
+
+ if (folder) {
+ action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
+ } else {
+ action = GTK_FILE_CHOOSER_ACTION_SAVE;
+ }
+
+ fc = gtk_file_chooser_dialog_new(title,
+ parent,
+ action,
+ NSGTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL,
+ NSGTK_STOCK_SAVE,
+ GTK_RESPONSE_ACCEPT,
+ NULL);
+
+ /* set a default file name */
+ res = nsurl_nice(browser_window_access_url(bw), &path, false);
+ if (res != NSERROR_OK) {
+ path = strdup(messages_get("SaveText"));
+ if (path == NULL) {
+ gtk_widget_destroy(fc);
+ return NSERROR_NOMEM;
+ }
+ }
+
+ if ((!folder) || (access(path, F_OK) != 0)) {
+ gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(fc), path);
+ }
+ free(path);
+
+ /* confirm overwriting */
+ gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(fc), TRUE);
+
+ /* run the dialog to let user select path */
+ if (gtk_dialog_run(GTK_DIALOG(fc)) != GTK_RESPONSE_ACCEPT) {
+ gtk_widget_destroy(fc);
+ return NSERROR_NOT_FOUND;
+ }
+
+ *path_out = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fc));
+
+ gtk_widget_destroy(fc);
+
+ return NSERROR_OK;
+}
+
/**
- * handler for new window tool bar item clicked signal
+ * handler for full save export 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
@@ -2226,6 +2297,235 @@ closewindow_button_clicked_cb(GtkWidget *widget, gpointer data)
static gboolean
savepage_button_clicked_cb(GtkWidget *widget, gpointer data)
{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ DIR *d;
+ gchar *path;
+ nserror res;
+ GtkWidget *toplevel;
+
+ bw = tb->get_bw(tb->get_bw_ctx);
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+
+ res = nsgtk_saveas_dialog(bw,
+ messages_get("gtkcompleteSave"),
+ GTK_WINDOW(toplevel),
+ true,
+ &path);
+ if (res != NSERROR_OK) {
+ return FALSE;
+ }
+
+ d = opendir(path);
+ if (d == NULL) {
+ NSLOG(netsurf, INFO,
+ "Unable to open directory %s for complete save: %s",
+ path,
+ strerror(errno));
+ if (errno == ENOTDIR) {
+ nsgtk_warning("NoDirError", path);
+ } else {
+ nsgtk_warning("gtkFileError", path);
+ }
+ g_free(path);
+ return TRUE;
+ }
+ closedir(d);
+
+ save_complete(browser_window_get_content(bw), path, NULL);
+ g_free(path);
+
+ return TRUE;
+}
+
+
+/**
+ * handler for pdf export 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
+pdf_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ GtkWidget *toplevel;
+ gchar *filename;
+ nserror res;
+
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+
+ res = nsgtk_saveas_dialog(bw,
+ "Export to PDF",
+ GTK_WINDOW(toplevel),
+ false,
+ &filename);
+ if (res != NSERROR_OK) {
+ return FALSE;
+ }
+
+#ifdef WITH_PDF_EXPORT
+ struct print_settings *settings;
+
+ /* this way the scale used by PDF functions is synchronised with that
+ * used by the all-purpose print interface
+ */
+ haru_nsfont_set_scale((float)option_export_scale / 100);
+
+ settings = print_make_settings(PRINT_OPTIONS,
+ (const char *) filename,
+ &haru_nsfont);
+ g_free(filename);
+ if (settings == NULL) {
+ return TRUE;
+ }
+ /* This will clean up the print_settings object for us */
+ print_basic_run(browser_window_get_content(bw), &pdf_printer, settings);
+#endif
+ return TRUE;
+
+}
+
+
+/**
+ * handler for plain text export 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
+plaintext_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ GtkWidget *toplevel;
+ gchar *filename;
+ nserror res;
+
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+
+ res = nsgtk_saveas_dialog(bw,
+ messages_get("gtkplainSave"),
+ GTK_WINDOW(toplevel),
+ false,
+ &filename);
+ if (res != NSERROR_OK) {
+ return FALSE;
+ }
+
+
+ save_as_text(browser_window_get_content(bw), filename);
+ g_free(filename);
+
+ return TRUE;
+}
+
+
+/**
+ * handler for print 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
+print_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ GtkPrintOperation *print_op;
+ GtkPageSetup *page_setup;
+ GtkPrintSettings *print_settings;
+ GtkPrintOperationResult res = GTK_PRINT_OPERATION_RESULT_ERROR;
+ struct print_settings *nssettings;
+ char *settings_fname = NULL;
+ GtkWidget *toplevel;
+
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+
+ print_op = gtk_print_operation_new();
+ if (print_op == NULL) {
+ nsgtk_warning(messages_get("NoMemory"), 0);
+ return TRUE;
+ }
+
+ /* use previously saved settings if any */
+ netsurf_mkpath(&settings_fname, NULL, 2, nsgtk_config_home, "Print");
+ if (settings_fname != NULL) {
+ print_settings = gtk_print_settings_new_from_file(settings_fname, NULL);
+ if (print_settings != NULL) {
+ gtk_print_operation_set_print_settings(print_op,
+ print_settings);
+
+ /* We're not interested in the settings any more */
+ g_object_unref(print_settings);
+ }
+ }
+
+ content_to_print = browser_window_get_content(bw);
+
+ page_setup = gtk_print_run_page_setup_dialog(GTK_WINDOW(toplevel),
+ NULL,
+ NULL);
+ if (page_setup == NULL) {
+ nsgtk_warning(messages_get("NoMemory"), 0);
+ free(settings_fname);
+ g_object_unref(print_op);
+ return TRUE;
+ }
+ gtk_print_operation_set_default_page_setup(print_op, page_setup);
+
+ nssettings = print_make_settings(PRINT_DEFAULT,
+ NULL,
+ nsgtk_layout_table);
+
+ g_signal_connect(print_op,
+ "begin_print",
+ G_CALLBACK(gtk_print_signal_begin_print),
+ nssettings);
+ g_signal_connect(print_op,
+ "draw_page",
+ G_CALLBACK(gtk_print_signal_draw_page),
+ NULL);
+ g_signal_connect(print_op,
+ "end_print",
+ G_CALLBACK(gtk_print_signal_end_print),
+ nssettings);
+
+ if (content_get_type(browser_window_get_content(bw)) != CONTENT_TEXTPLAIN) {
+ res = gtk_print_operation_run(print_op,
+ GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
+ GTK_WINDOW(toplevel),
+ NULL);
+ }
+
+ /* if the settings were used save them for future use */
+ if (settings_fname != NULL) {
+ if (res == GTK_PRINT_OPERATION_RESULT_APPLY) {
+ /* Do not increment the settings reference */
+ print_settings = gtk_print_operation_get_print_settings(print_op);
+
+ gtk_print_settings_to_file(print_settings,
+ settings_fname,
+ NULL);
+ }
+ free(settings_fname);
+ }
+
+ /* Our print_settings object is destroyed by the end print handler */
+ g_object_unref(page_setup);
+ g_object_unref(print_op);
+
+ return TRUE;
}
@@ -2628,7 +2928,7 @@ nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb,
if (tb->buttons[itemid]->button != NULL) {
widget = GTK_WIDGET(tb->buttons[itemid]->button);
} else {
- widget = tb->widget;
+ widget = GTK_WIDGET(tb->widget);
}
tb->buttons[itemid]->bhandler(widget, tb);
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 03188c2..24afef9 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -103,12 +103,12 @@ TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, openfile_button_clicked_cb)
TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, closetab_button_clicked_cb)
TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, closewindow_button_clicked_cb)
TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, savepage_button_clicked_cb)
-TOOLBAR_ITEM(PDF_BUTTON, pdf, false, NULL)
-TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true, NULL)
+TOOLBAR_ITEM(PDF_BUTTON, pdf, false, pdf_button_clicked_cb)
+TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true, plaintext_button_clicked_cb)
TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false, NULL)
TOOLBAR_ITEM(POSTSCRIPT_BUTTON, postscript, false, NULL)
TOOLBAR_ITEM(PRINTPREVIEW_BUTTON, printpreview, false, NULL)
-TOOLBAR_ITEM(PRINT_BUTTON, print, true, NULL)
+TOOLBAR_ITEM(PRINT_BUTTON, print, true, print_button_clicked_cb)
TOOLBAR_ITEM(QUIT_BUTTON, quit, true, NULL)
TOOLBAR_ITEM(CUT_BUTTON, cut, true, NULL)
TOOLBAR_ITEM(COPY_BUTTON, copy, true, NULL)
diff --git a/resources/FatMessages b/resources/FatMessages
index 54c69b8..008afef 100644
--- a/resources/FatMessages
+++ b/resources/FatMessages
@@ -2872,11 +2872,11 @@ de.gtk.gtkplainSave:Als Text speichern
fr.gtk.gtkplainSave:Enregistrer sans mise en forme
it.gtk.gtkplainSave:Salva come testo
nl.gtk.gtkplainSave:Als tekst bewaren
-en.gtk.gtkcompleteSave:Save webpage complete - select an empty directory
-de.gtk.gtkcompleteSave:Seite komplett speichern - ein leeres Verzeichnis wählen
-fr.gtk.gtkcompleteSave:Enregistrer page web complète - sélectioner un dossier vide
-it.gtk.gtkcompleteSave:Salva l'intera pagina web - seleziona una directory vuota
-nl.gtk.gtkcompleteSave:Complete webpagina bewaren - selecteer een lege map
+en.gtk.gtkcompleteSave:Export complete page as a folder
+de.gtk.gtkcompleteSave:Seite komplett speichern
+fr.gtk.gtkcompleteSave:Enregistrer page web complète
+it.gtk.gtkcompleteSave:Salva l'intera pagina web
+nl.gtk.gtkcompleteSave:Complete webpagina bewaren
en.gtk.gtkSaveConfirm:File saved
de.gtk.gtkSaveConfirm:Datei gespeichert
fr.gtk.gtkSaveConfirm:Fichier enregistré
@@ -2957,16 +2957,16 @@ de.gtk.gtkCloseWindow:Fenster schließen
fr.gtk.gtkCloseWindow:_Fermer la fenêtre
it.gtk.gtkCloseWindow:_Chiudi finestra
nl.gtk.gtkCloseWindow:_Venster sluiten
-en.gtk.gtkSavePage:Save Page…
-de.gtk.gtkSavePage:Seite speichern..
-fr.gtk.gtkSavePage:Enregistrer la Page...
-it.gtk.gtkSavePage:Salva pagina...
-nl.gtk.gtkSavePage:Pagina bewaren...
en.gtk.gtkExport:Export
de.gtk.gtkExport:Exportieren
fr.gtk.gtkExport:Exporter
it.gtk.gtkExport:Esporta
nl.gtk.gtkExport:Exporteren
+en.gtk.gtkSavePage:Complete Page…
+de.gtk.gtkSavePage:Seite speichern..
+fr.gtk.gtkSavePage:Enregistrer la Page...
+it.gtk.gtkSavePage:Salva pagina...
+nl.gtk.gtkSavePage:Pagina bewaren...
en.gtk.gtkPlainText:Plain Text…
de.gtk.gtkPlainText:Reiner Text..
fr.gtk.gtkPlainText:Texte...
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8eebe695f053abb390d...
commit 8eebe695f053abb390ddc9894415f595ad7f4177
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
allow menu activation to use the toolbar button implementations
diff --git a/frontends/gtk/completion.c b/frontends/gtk/completion.c
index 983ecab..1a76541 100644
--- a/frontends/gtk/completion.c
+++ b/frontends/gtk/completion.c
@@ -32,6 +32,7 @@
#include "gtk/compat.h"
#include "gtk/warn.h"
#include "gtk/scaffolding.h"
+#include "gtk/toolbar_items.h"
#include "gtk/window.h"
#include "gtk/completion.h"
diff --git a/frontends/gtk/download.c b/frontends/gtk/download.c
index 3eab532..0bb5bb3 100644
--- a/frontends/gtk/download.c
+++ b/frontends/gtk/download.c
@@ -34,6 +34,7 @@
#include "gtk/warn.h"
#include "gtk/scaffolding.h"
+#include "gtk/toolbar_items.h"
#include "gtk/window.h"
#include "gtk/compat.h"
#include "gtk/resources.h"
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c
index 7f33315..2c23364 100644
--- a/frontends/gtk/gui.c
+++ b/frontends/gtk/gui.c
@@ -63,6 +63,7 @@
#include "gtk/global_history.h"
#include "gtk/hotlist.h"
#include "gtk/throbber.h"
+#include "gtk/toolbar_items.h"
#include "gtk/scaffolding.h"
#include "gtk/window.h"
#include "gtk/schedule.h"
diff --git a/frontends/gtk/preferences.c b/frontends/gtk/preferences.c
index 652075c..efef4a2 100644
--- a/frontends/gtk/preferences.c
+++ b/frontends/gtk/preferences.c
@@ -30,6 +30,7 @@
#include "desktop/searchweb.h"
#include "gtk/compat.h"
+#include "gtk/toolbar_items.h"
#include "gtk/window.h"
#include "gtk/gui.h"
#include "gtk/scaffolding.h"
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 13a2ed5..10d9681 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -69,8 +69,8 @@
#include "gtk/print.h"
#include "gtk/search.h"
#include "gtk/throbber.h"
-#include "gtk/toolbar.h"
#include "gtk/toolbar_items.h"
+#include "gtk/toolbar.h"
#include "gtk/window.h"
#include "gtk/gdk.h"
#include "gtk/scaffolding.h"
@@ -601,105 +601,40 @@ static void nsgtk_openfile_open(const char *filename)
/* signal handlers for menu entries */
-MULTIHANDLER(newwindow)
+/**
+ * menu signal handler for activation on new window item
+ */
+static gboolean
+nsgtk_on_newwindow_activate_menu(GtkMenuItem *widget, gpointer data)
{
- struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
- const char *addr;
- nsurl *url;
- nserror error;
-
- if (nsoption_charp(homepage_url) != NULL) {
- addr = nsoption_charp(homepage_url);
- } else {
- addr = NETSURF_HOMEPAGE;
- }
-
- error = nsurl_create(addr, &url);
- if (error == NSERROR_OK) {
- error = browser_window_create(BW_CREATE_HISTORY,
- url,
- NULL,
- bw,
- NULL);
- nsurl_unref(url);
- }
- if (error != NSERROR_OK) {
- nsgtk_warning(messages_get_errorcode(error), 0);
- }
-
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ nsgtk_window_item_activate(g->top_level, NEWWINDOW_BUTTON);
return TRUE;
}
-/* exported interface documented in gtk/scaffolding.h */
-nserror nsgtk_scaffolding_new_tab(struct gui_window *gw)
-{
- struct browser_window *bw = nsgtk_get_browser_window(gw);
- nsurl *url = NULL;
- nserror error;
-
- if (!nsoption_bool(new_blank)) {
- const char *addr;
- if (nsoption_charp(homepage_url) != NULL) {
- addr = nsoption_charp(homepage_url);
- } else {
- addr = NETSURF_HOMEPAGE;
- }
- error = nsurl_create(addr, &url);
- if (error != NSERROR_OK) {
- nsgtk_warning(messages_get_errorcode(error), 0);
- }
- }
-
- error = browser_window_create(BW_CREATE_HISTORY |
- BW_CREATE_TAB,
- url,
- NULL,
- bw,
- NULL);
- if (url != NULL) {
- nsurl_unref(url);
- }
- return error;
-}
-
-MULTIHANDLER(newtab)
+/**
+ * menu signal handler for activation on new tab item
+ */
+static gboolean
+nsgtk_on_newtab_activate_menu(GtkMenuItem *widget, gpointer data)
{
- nserror error;
-
- error = nsgtk_scaffolding_new_tab(g->top_level);
- if (error != NSERROR_OK) {
- nsgtk_warning(messages_get_errorcode(error), 0);
- }
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ nsgtk_window_item_activate(g->top_level, NEWTAB_BUTTON);
return TRUE;
}
-MULTIHANDLER(openfile)
+/**
+ * menu signal handler for activation on openfile item
+ */
+static gboolean
+nsgtk_on_openfile_activate_menu(GtkMenuItem *widget, gpointer data)
{
- GtkWidget *dlgOpen;
- gint response;
-
- scaf_current = g;
- dlgOpen = gtk_file_chooser_dialog_new("Open File",
- scaf_current->window,
- GTK_FILE_CHOOSER_ACTION_OPEN,
- NSGTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- NSGTK_STOCK_OPEN, GTK_RESPONSE_OK,
- NULL, NULL);
-
- response = gtk_dialog_run(GTK_DIALOG(dlgOpen));
- if (response == GTK_RESPONSE_OK) {
- gchar *filename;
- filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dlgOpen));
-
- nsgtk_openfile_open((const char *)filename);
-
- g_free(filename);
- }
-
- gtk_widget_destroy(dlgOpen);
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ nsgtk_window_item_activate(g->top_level, OPENFILE_BUTTON);
return TRUE;
}
+
/**
* callback to determine if a path is a directory.
*
@@ -1001,12 +936,19 @@ MULTIHANDLER(print)
return TRUE;
}
-MULTIHANDLER(closewindow)
+
+/**
+ * menu signal handler for activation on close window item
+ */
+static gboolean
+nsgtk_on_closewindow_activate_menu(GtkMenuItem *widget, gpointer data)
{
- gtk_widget_destroy(GTK_WIDGET(g->window));
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ nsgtk_window_item_activate(g->top_level, CLOSEWINDOW_BUTTON);
return TRUE;
}
+
MULTIHANDLER(quit)
{
struct nsgtk_scaffolding *gs;
@@ -1639,10 +1581,14 @@ MULTIHANDLER(prevtab)
return TRUE;
}
-MULTIHANDLER(closetab)
+/**
+ * menu signal handler for activation on close tab item
+ */
+static gboolean
+nsgtk_on_closetab_activate_menu(GtkMenuItem *widget, gpointer data)
{
- nsgtk_tab_close_current(g->notebook);
-
+ struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
+ nsgtk_window_item_activate(g->top_level, CLOSETAB_BUTTON);
return TRUE;
}
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index 261d2f0..d5a916f 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -155,8 +155,6 @@ void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g, gdouble x, gdou
gboolean nsgtk_window_url_changed(GtkWidget *, GdkEventKey *, gpointer);
-nserror nsgtk_scaffolding_new_tab(struct gui_window *gw);
-
/* core acessors */
/**
* set the title in the window
diff --git a/frontends/gtk/search.c b/frontends/gtk/search.c
index 40c0253..6baf7f6 100644
--- a/frontends/gtk/search.c
+++ b/frontends/gtk/search.c
@@ -38,6 +38,7 @@
#include "gtk/warn.h"
#include "gtk/compat.h"
#include "gtk/search.h"
+#include "gtk/toolbar_items.h"
#include "gtk/scaffolding.h"
#include "gtk/window.h"
diff --git a/frontends/gtk/selection.c b/frontends/gtk/selection.c
index 228d65d..8715260 100644
--- a/frontends/gtk/selection.c
+++ b/frontends/gtk/selection.c
@@ -24,6 +24,7 @@
#include "netsurf/browser_window.h"
#include "netsurf/clipboard.h"
+#include "gtk/toolbar_items.h"
#include "gtk/window.h"
static GString *current_selection = NULL;
diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c
index 9e5c1b3..04bd69f 100644
--- a/frontends/gtk/tabs.c
+++ b/frontends/gtk/tabs.c
@@ -25,6 +25,7 @@
#include "desktop/search.h"
#include "gtk/compat.h"
+#include "gtk/toolbar_items.h"
#include "gtk/scaffolding.h"
#include "gtk/window.h"
#include "gtk/search.h"
@@ -179,7 +180,7 @@ nsgtk_tab_switch_page_after(GtkNotebook *notebook,
srcpage = gtk_notebook_get_nth_page(notebook, srcpagenum);
gw = g_object_get_data(G_OBJECT(srcpage), "gui_window");
if ((gw != NULL) && (nsgtk_get_scaffold(gw) != NULL)) {
- error = nsgtk_scaffolding_new_tab(gw);
+ error = nsgtk_window_item_activate(gw, NEWTAB_BUTTON);
if (error != NSERROR_OK) {
NSLOG(netsurf, INFO,
"Failed to open new tab.");
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index b1cd51c..4b3f23b 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -35,7 +35,9 @@
#include "utils/nsoption.h"
#include "utils/file.h"
#include "utils/nsurl.h"
+#include "utils/corestrings.h"
+#include "gtk/toolbar_items.h"
#include "gtk/completion.h"
#include "gtk/gui.h"
#include "gtk/warn.h"
@@ -45,10 +47,9 @@
#include "gtk/window.h"
#include "gtk/compat.h"
#include "gtk/resources.h"
-#include "gtk/toolbar_items.h"
-#include "gtk/toolbar.h"
#include "gtk/schedule.h"
#include "gtk/local_history.h"
+#include "gtk/toolbar.h"
/**
* button location indicating button is not to be shown
@@ -2030,6 +2031,205 @@ websearch_entry_button_press_cb(GtkWidget *widget,
/**
+ * handler for new window 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
+newwindow_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ nserror res;
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ const char *addr;
+ nsurl *url;
+
+ if (nsoption_charp(homepage_url) != NULL) {
+ addr = nsoption_charp(homepage_url);
+ } else {
+ addr = NETSURF_HOMEPAGE;
+ }
+
+ res = nsurl_create(addr, &url);
+ if (res == NSERROR_OK) {
+ bw = tb->get_bw(tb->get_bw_ctx);
+ res = browser_window_create(BW_CREATE_HISTORY,
+ url,
+ NULL,
+ bw,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (res != NSERROR_OK) {
+ nsgtk_warning(messages_get_errorcode(res), 0);
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * handler for new tab 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
+newtab_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ nserror res = NSERROR_OK;
+ nsurl *url = NULL;
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+
+ if (!nsoption_bool(new_blank)) {
+ const char *addr;
+ if (nsoption_charp(homepage_url) != NULL) {
+ addr = nsoption_charp(homepage_url);
+ } else {
+ addr = NETSURF_HOMEPAGE;
+ }
+ res = nsurl_create(addr, &url);
+ }
+
+ if (res == NSERROR_OK) {
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ res = browser_window_create(BW_CREATE_HISTORY |
+ BW_CREATE_TAB,
+ url,
+ NULL,
+ bw,
+ NULL);
+ }
+ if (url != NULL) {
+ nsurl_unref(url);
+ }
+ if (res != NSERROR_OK) {
+ nsgtk_warning(messages_get_errorcode(res), 0);
+ }
+ return TRUE;
+}
+
+
+/**
+ * handler for open file 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
+openfile_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ GtkWidget *dlgOpen;
+ gint response;
+ GtkWidget *toplevel;
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+
+ dlgOpen = gtk_file_chooser_dialog_new("Open File",
+ GTK_WINDOW(toplevel),
+ GTK_FILE_CHOOSER_ACTION_OPEN,
+ NSGTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ NSGTK_STOCK_OPEN, GTK_RESPONSE_OK,
+ NULL, NULL);
+
+ response = gtk_dialog_run(GTK_DIALOG(dlgOpen));
+ if (response == GTK_RESPONSE_OK) {
+ char *urltxt;
+ gchar *filename;
+ nserror res;
+ nsurl *url;
+
+ filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dlgOpen));
+
+ urltxt = malloc(strlen(filename) + FILE_SCHEME_PREFIX_LEN + 1);
+ if (urltxt != NULL) {
+ sprintf(urltxt, FILE_SCHEME_PREFIX"%s", filename);
+
+ res = nsurl_create(urltxt, &url);
+ if (res == NSERROR_OK) {
+ bw = tb->get_bw(tb->get_bw_ctx);
+ res = browser_window_navigate(bw,
+ url,
+ NULL,
+ BW_NAVIGATE_HISTORY,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (res != NSERROR_OK) {
+ nsgtk_warning(messages_get_errorcode(res), 0);
+ }
+ free(urltxt);
+ }
+
+
+ g_free(filename);
+ }
+
+ gtk_widget_destroy(dlgOpen);
+
+ return TRUE;
+}
+
+
+/**
+ * handler for close tab 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
+closetab_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+
+ nsgtk_tab_close_current(tb->widget);
+
+ return TRUE;
+}
+
+
+/**
+ * handler for close window 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
+closewindow_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ GtkWidget *toplevel;
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+ gtk_widget_destroy(toplevel);
+ return TRUE;
+}
+
+
+/**
+ * handler for new window 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
+savepage_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+}
+
+
+/**
* create a toolbar item
*
* create a toolbar item and set up its default handlers
@@ -2403,3 +2603,35 @@ nserror nsgtk_toolbar_set_url(struct nsgtk_toolbar *tb, nsurl *url)
return NSERROR_OK;
}
+
+
+/* exported interface documented in toolbar.h */
+nserror
+nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb,
+ nsgtk_toolbar_button itemid)
+{
+ GtkWidget *widget;
+
+ /* ensure item id in range */
+ if ((itemid < BACK_BUTTON) || (itemid >= PLACEHOLDER_BUTTON)) {
+ return NSERROR_BAD_PARAMETER;
+ }
+
+ if (tb->buttons[itemid]->bhandler == NULL) {
+ return NSERROR_INVALID;
+ }
+
+ /*
+ * if item has a widget in the current toolbar use that as the
+ * signal source otherwise use the toolbar widget itself.
+ */
+ if (tb->buttons[itemid]->button != NULL) {
+ widget = GTK_WIDGET(tb->buttons[itemid]->button);
+ } else {
+ widget = tb->widget;
+ }
+
+ tb->buttons[itemid]->bhandler(widget, tb);
+
+ return NSERROR_OK;
+}
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index f04d807..b89774b 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -70,6 +70,19 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active);
*/
nserror nsgtk_toolbar_set_url(struct nsgtk_toolbar *tb, nsurl *url);
+
+/**
+ * activate the handler for a toolbar item
+ *
+ * This allows the same action to be performed for menu enties as if
+ * the user had clicked the toolbar widget.
+ *
+ * \param toolbar A toolbar returned from a creation
+ * \param itemid the id of the item to activate
+ * \return NSERROR_OK on success
+ */
+nserror nsgtk_toolbar_item_activate(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid);
+
/**
* sets up the images for scaffolding.
*/
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 5281ab6..03188c2 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -97,12 +97,12 @@ TOOLBAR_ITEM(HOME_BUTTON, home, true, home_button_clicked_cb)
TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true, NULL)
TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true, NULL)
TOOLBAR_ITEM(THROBBER_ITEM, throbber, true, NULL)
-TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true, NULL)
-TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true, NULL)
-TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, NULL)
-TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, NULL)
-TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, NULL)
-TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, NULL)
+TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true, newwindow_button_clicked_cb)
+TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true, newtab_button_clicked_cb)
+TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, openfile_button_clicked_cb)
+TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, closetab_button_clicked_cb)
+TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, closewindow_button_clicked_cb)
+TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, savepage_button_clicked_cb)
TOOLBAR_ITEM(PDF_BUTTON, pdf, false, NULL)
TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true, NULL)
TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false, NULL)
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index ce67004..015b5fa 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -47,12 +47,12 @@
#include "desktop/textinput.h"
#include "utils/nsurl.h"
-#include "gtk/window.h"
#include "gtk/selection.h"
#include "gtk/warn.h"
#include "gtk/compat.h"
#include "gtk/gui.h"
#include "gtk/scaffolding.h"
+#include "gtk/toolbar_items.h"
#include "gtk/toolbar.h"
#include "gtk/local_history.h"
#include "gtk/plotters.h"
@@ -61,6 +61,7 @@
#include "gtk/bitmap.h"
#include "gtk/gdk.h"
#include "gtk/resources.h"
+#include "gtk/window.h"
static GtkWidget *select_menu;
static struct form_control *select_menu_control;
@@ -894,7 +895,12 @@ gui_window_create(struct browser_window *bw,
return g;
}
-
+/* exported interface documented in window.h */
+nserror
+nsgtk_window_item_activate(struct gui_window *gw, nsgtk_toolbar_button itemid)
+{
+ return nsgtk_toolbar_item_activate(gw->toolbar, itemid);
+}
void nsgtk_reflow_all_windows(void)
{
diff --git a/frontends/gtk/window.h b/frontends/gtk/window.h
index 462ed17..a991f03 100644
--- a/frontends/gtk/window.h
+++ b/frontends/gtk/window.h
@@ -92,4 +92,13 @@ GtkWidget *nsgtk_window_get_tab(struct gui_window *gw);
*/
void nsgtk_window_set_tab(struct gui_window *gw, GtkWidget *w);
+/**
+ * activate the handler for a item in a toolbar of a gui window
+ *
+ * \param gw The gui window handle
+ * \param itemid The id of the item to activate
+ */
+nserror nsgtk_window_item_activate(struct gui_window *gw, nsgtk_toolbar_button itemid);
+
+
#endif /* NETSURF_GTK_WINDOW_H */
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b24b28e40eb84e1ed36...
commit b24b28e40eb84e1ed361224b172928582b471e10
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
clean up some more handler code and remove button push
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 74a8043..13a2ed5 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -87,22 +87,16 @@ static gboolean nsgtk_on_##q##_activate_menu(GtkMenuItem *widget, gpointer data)
struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;\
return nsgtk_on_##q##_activate(g);\
}\
-static gboolean nsgtk_on_##q##_activate_button(GtkButton *widget, gpointer data)\
-{\
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;\
- return nsgtk_on_##q##_activate(g);\
-}\
static gboolean nsgtk_on_##q##_activate(struct nsgtk_scaffolding *g)
-/** Macro to define a handler for menu events. */
-#define MENUHANDLER(q)\
-static gboolean nsgtk_on_##q##_activate_menu(GtkMenuItem *widget, gpointer data)
/** Macro to define a handler for button events. */
#define BUTTONHANDLER(q)\
static gboolean nsgtk_on_##q##_activate(GtkButton *widget, gpointer data)
-
+/**
+ * menu entry context
+ */
struct nsgtk_menu {
GtkWidget *main; /* main menu entry */
GtkWidget *rclick; /* right click menu */
@@ -111,7 +105,9 @@ struct nsgtk_menu {
bool sensitivity; /* menu item is sensitive */
};
-/** Core scaffolding structure. */
+/**
+ * Core scaffolding structure.
+ */
struct nsgtk_scaffolding {
/** global linked list of scaffolding for gui interface adjustments */
struct nsgtk_scaffolding *next, *prev;
@@ -146,7 +142,9 @@ struct nsgtk_scaffolding {
struct nsgtk_menu menus[PLACEHOLDER_BUTTON];
};
-/** current scaffold for model dialogue use */
+/**
+ * current scaffold for model dialogue use
+ */
static struct nsgtk_scaffolding *scaf_current;
/** global list for interface changes */
@@ -336,8 +334,6 @@ static void scaffolding_update_context(struct nsgtk_scaffolding *g)
}
-
-
/**
* edit the sensitivity of focused widget
*
@@ -727,16 +723,19 @@ MULTIHANDLER(savepage)
if (!browser_window_has_content(nsgtk_get_browser_window(g->top_level)))
return FALSE;
- GtkWidget *fc = gtk_file_chooser_dialog_new(
+ GtkWidget *fc;
+ DIR *d;
+ char *path;
+ nserror res;
+ GtkFileFilter *filter;
+
+ fc = gtk_file_chooser_dialog_new(
messages_get("gtkcompleteSave"), g->window,
GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER,
NSGTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NSGTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
- DIR *d;
- char *path;
- nserror res;
- GtkFileFilter *filter = gtk_file_filter_new();
+ filter = gtk_file_filter_new();
gtk_file_filter_set_name(filter, "Directories");
gtk_file_filter_add_custom(filter, GTK_FILE_FILTER_FILENAME,
nsgtk_filter_directory, NULL, NULL);
@@ -1023,7 +1022,9 @@ MULTIHANDLER(quit)
return TRUE;
}
-MENUHANDLER(savelink)
+
+static gboolean
+nsgtk_on_savelink_activate_menu(GtkMenuItem *widget, gpointer data)
{
struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *) data;
struct gui_window *gui = g->top_level;
@@ -1050,7 +1051,8 @@ MENUHANDLER(savelink)
/**
* Handler for opening new window from a link. attached to the popup menu.
*/
-MENUHANDLER(link_openwin)
+static gboolean
+nsgtk_on_link_openwin_activate_menu(GtkMenuItem *widget, gpointer data)
{
struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *) data;
struct gui_window *gui = g->top_level;
@@ -1072,7 +1074,8 @@ MENUHANDLER(link_openwin)
/**
* Handler for opening new tab from a link. attached to the popup menu.
*/
-MENUHANDLER(link_opentab)
+static gboolean
+nsgtk_on_link_opentab_activate_menu(GtkMenuItem *widget, gpointer data)
{
struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *) data;
struct gui_window *gui = g->top_level;
@@ -1100,7 +1103,8 @@ MENUHANDLER(link_opentab)
/**
* Handler for bookmarking a link. attached to the popup menu.
*/
-MENUHANDLER(link_bookmark)
+static gboolean
+nsgtk_on_link_bookmark_activate_menu(GtkMenuItem *widget, gpointer data)
{
if (current_menu_features.link == NULL)
return FALSE;
@@ -1113,7 +1117,8 @@ MENUHANDLER(link_bookmark)
/**
* Handler for copying a link. attached to the popup menu.
*/
-MENUHANDLER(link_copy)
+static gboolean
+nsgtk_on_link_copy_activate_menu(GtkMenuItem *widget, gpointer data)
{
GtkClipboard *clipboard;
@@ -1177,7 +1182,9 @@ MULTIHANDLER(delete)
return TRUE;
}
-MENUHANDLER(customize)
+
+static gboolean
+nsgtk_on_customize_activate_menu(GtkMenuItem *widget, gpointer data)
{
struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
nsgtk_toolbar_customization_init(g);
@@ -1272,7 +1279,9 @@ MULTIHANDLER(viewsource)
return TRUE;
}
-MENUHANDLER(menubar)
+
+static gboolean
+nsgtk_on_menubar_activate_menu(GtkMenuItem *widget, gpointer data)
{
GtkWidget *w;
struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
@@ -1318,7 +1327,9 @@ MENUHANDLER(menubar)
return TRUE;
}
-MENUHANDLER(toolbar)
+
+static gboolean
+nsgtk_on_toolbar_activate_menu(GtkMenuItem *widget, gpointer data)
{
GtkWidget *w;
struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
@@ -1751,6 +1762,7 @@ static void nsgtk_menu_connect_signals(struct nsgtk_scaffolding *g)
}
+
/**
* Create and connect handlers to popup menu.
*
@@ -1769,20 +1781,30 @@ nsgtk_new_scaffolding_popup(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
return NULL;
}
- g_signal_connect(nmenu->popup_menu, "hide",
- G_CALLBACK(nsgtk_window_popup_menu_hidden), g);
+ g_signal_connect(nmenu->popup_menu,
+ "hide",
+ G_CALLBACK(nsgtk_window_popup_menu_hidden),
+ g);
- g_signal_connect(nmenu->cut_menuitem, "activate",
- G_CALLBACK(nsgtk_on_cut_activate_menu), g);
+ g_signal_connect(nmenu->cut_menuitem,
+ "activate",
+ G_CALLBACK(nsgtk_on_cut_activate_menu),
+ g);
- g_signal_connect(nmenu->copy_menuitem, "activate",
- G_CALLBACK(nsgtk_on_copy_activate_menu), g);
+ g_signal_connect(nmenu->copy_menuitem,
+ "activate",
+ G_CALLBACK(nsgtk_on_copy_activate_menu),
+ g);
- g_signal_connect(nmenu->paste_menuitem, "activate",
- G_CALLBACK(nsgtk_on_paste_activate_menu), g);
+ g_signal_connect(nmenu->paste_menuitem,
+ "activate",
+ G_CALLBACK(nsgtk_on_paste_activate_menu),
+ g);
- g_signal_connect(nmenu->customize_menuitem, "activate",
- G_CALLBACK(nsgtk_on_customize_activate_menu), g);
+ g_signal_connect(nmenu->customize_menuitem,
+ "activate",
+ G_CALLBACK(nsgtk_on_customize_activate_menu),
+ g);
/* set initial popup menu visibility */
popup_menu_hide(nmenu, true, false, false, true);
@@ -1798,7 +1820,8 @@ nsgtk_new_scaffolding_popup(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
* \return true on success or false on error.
*/
static struct nsgtk_link_menu *
-nsgtk_new_scaffolding_link_popup(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
+nsgtk_new_scaffolding_link_popup(struct nsgtk_scaffolding *g,
+ GtkAccelGroup *group)
{
struct nsgtk_link_menu *nmenu;
@@ -1808,20 +1831,30 @@ nsgtk_new_scaffolding_link_popup(struct nsgtk_scaffolding *g, GtkAccelGroup *gro
return NULL;
}
- g_signal_connect(nmenu->save_menuitem, "activate",
- G_CALLBACK(nsgtk_on_savelink_activate_menu), g);
+ g_signal_connect(nmenu->save_menuitem,
+ "activate",
+ G_CALLBACK(nsgtk_on_savelink_activate_menu),
+ g);
- g_signal_connect(nmenu->opentab_menuitem, "activate",
- G_CALLBACK(nsgtk_on_link_opentab_activate_menu), g);
+ g_signal_connect(nmenu->opentab_menuitem,
+ "activate",
+ G_CALLBACK(nsgtk_on_link_opentab_activate_menu),
+ g);
- g_signal_connect(nmenu->openwin_menuitem, "activate",
- G_CALLBACK(nsgtk_on_link_openwin_activate_menu), g);
+ g_signal_connect(nmenu->openwin_menuitem,
+ "activate",
+ G_CALLBACK(nsgtk_on_link_openwin_activate_menu),
+ g);
- g_signal_connect(nmenu->bookmark_menuitem, "activate",
- G_CALLBACK(nsgtk_on_link_bookmark_activate_menu), g);
+ g_signal_connect(nmenu->bookmark_menuitem,
+ "activate",
+ G_CALLBACK(nsgtk_on_link_bookmark_activate_menu),
+ g);
- g_signal_connect(nmenu->copy_menuitem, "activate",
- G_CALLBACK(nsgtk_on_link_copy_activate_menu), g);
+ g_signal_connect(nmenu->copy_menuitem,
+ "activate",
+ G_CALLBACK(nsgtk_on_link_copy_activate_menu),
+ g);
return nmenu;
}
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index bf7f1ef..b1cd51c 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -65,16 +65,16 @@
*/
struct nsgtk_toolbar_item {
GtkToolItem *button;
- int location; /* in toolbar */
- bool sensitivity;
+ int location; /* in toolbar */
+ bool sensitivity;
/**
* button clicked handler
*/
gboolean (*bhandler)(GtkWidget *widget, gpointer data);
- void *dataplus; /* customization -> toolbar */
- void *dataminus; /* customization -> store */
+ void *dataplus; /* customization -> toolbar */
+ void *dataminus; /* customization -> store */
};
@@ -225,39 +225,39 @@ nsgtk_theme_image_default(nsgtk_toolbar_button tbbutton,
switch(tbbutton) {
-#define BUTTON_IMAGE(p, q) \
+#define BUTTON_IMAGE(p, q) \
case p##_BUTTON: \
image = GTK_IMAGE(nsgtk_image_new_from_stock(q, iconsize)); \
break
- BUTTON_IMAGE(BACK, NSGTK_STOCK_GO_BACK);
- BUTTON_IMAGE(FORWARD, NSGTK_STOCK_GO_FORWARD);
- BUTTON_IMAGE(STOP, NSGTK_STOCK_STOP);
- BUTTON_IMAGE(RELOAD, NSGTK_STOCK_REFRESH);
- BUTTON_IMAGE(HOME, NSGTK_STOCK_HOME);
- BUTTON_IMAGE(NEWWINDOW, "gtk-new");
- BUTTON_IMAGE(NEWTAB, "gtk-new");
- BUTTON_IMAGE(OPENFILE, NSGTK_STOCK_OPEN);
- BUTTON_IMAGE(CLOSETAB, NSGTK_STOCK_CLOSE);
- BUTTON_IMAGE(CLOSEWINDOW, NSGTK_STOCK_CLOSE);
- BUTTON_IMAGE(SAVEPAGE, NSGTK_STOCK_SAVE_AS);
- BUTTON_IMAGE(PRINTPREVIEW, "gtk-print-preview");
- BUTTON_IMAGE(PRINT, "gtk-print");
- BUTTON_IMAGE(QUIT, "gtk-quit");
- BUTTON_IMAGE(CUT, "gtk-cut");
- BUTTON_IMAGE(COPY, "gtk-copy");
- BUTTON_IMAGE(PASTE, "gtk-paste");
- BUTTON_IMAGE(DELETE, "gtk-delete");
- BUTTON_IMAGE(SELECTALL, "gtk-select-all");
- BUTTON_IMAGE(FIND, NSGTK_STOCK_FIND);
- BUTTON_IMAGE(PREFERENCES, "gtk-preferences");
- BUTTON_IMAGE(ZOOMPLUS, "gtk-zoom-in");
- BUTTON_IMAGE(ZOOMMINUS, "gtk-zoom-out");
- BUTTON_IMAGE(ZOOMNORMAL, "gtk-zoom-100");
- BUTTON_IMAGE(FULLSCREEN, "gtk-fullscreen");
- BUTTON_IMAGE(VIEWSOURCE, "gtk-index");
- BUTTON_IMAGE(CONTENTS, "gtk-help");
- BUTTON_IMAGE(ABOUT, "gtk-about");
+ BUTTON_IMAGE(BACK, NSGTK_STOCK_GO_BACK);
+ BUTTON_IMAGE(FORWARD, NSGTK_STOCK_GO_FORWARD);
+ BUTTON_IMAGE(STOP, NSGTK_STOCK_STOP);
+ BUTTON_IMAGE(RELOAD, NSGTK_STOCK_REFRESH);
+ BUTTON_IMAGE(HOME, NSGTK_STOCK_HOME);
+ BUTTON_IMAGE(NEWWINDOW, "gtk-new");
+ BUTTON_IMAGE(NEWTAB, "gtk-new");
+ BUTTON_IMAGE(OPENFILE, NSGTK_STOCK_OPEN);
+ BUTTON_IMAGE(CLOSETAB, NSGTK_STOCK_CLOSE);
+ BUTTON_IMAGE(CLOSEWINDOW, NSGTK_STOCK_CLOSE);
+ BUTTON_IMAGE(SAVEPAGE, NSGTK_STOCK_SAVE_AS);
+ BUTTON_IMAGE(PRINTPREVIEW, "gtk-print-preview");
+ BUTTON_IMAGE(PRINT, "gtk-print");
+ BUTTON_IMAGE(QUIT, "gtk-quit");
+ BUTTON_IMAGE(CUT, "gtk-cut");
+ BUTTON_IMAGE(COPY, "gtk-copy");
+ BUTTON_IMAGE(PASTE, "gtk-paste");
+ BUTTON_IMAGE(DELETE, "gtk-delete");
+ BUTTON_IMAGE(SELECTALL, "gtk-select-all");
+ BUTTON_IMAGE(FIND, NSGTK_STOCK_FIND);
+ BUTTON_IMAGE(PREFERENCES, "gtk-preferences");
+ BUTTON_IMAGE(ZOOMPLUS, "gtk-zoom-in");
+ BUTTON_IMAGE(ZOOMMINUS, "gtk-zoom-out");
+ BUTTON_IMAGE(ZOOMNORMAL, "gtk-zoom-100");
+ BUTTON_IMAGE(FULLSCREEN, "gtk-fullscreen");
+ BUTTON_IMAGE(VIEWSOURCE, "gtk-index");
+ BUTTON_IMAGE(CONTENTS, "gtk-help");
+ BUTTON_IMAGE(ABOUT, "gtk-about");
#undef BUTTON_IMAGE
case HISTORY_BUTTON:
@@ -411,7 +411,8 @@ void nsgtk_theme_implement(struct nsgtk_scaffolding *g)
gtk_widget_show_all(GTK_WIDGET(button->popup));
}
#endif
- if ((button->location != -1) && (button->button != NULL) &&
+ if ((button->location != -1) &&
+ (button->button != NULL) &&
(theme[IMAGE_SET_BUTTONS] != NULL)) {
gtk_tool_button_set_icon_widget(
GTK_TOOL_BUTTON(button->button),
@@ -2017,7 +2018,7 @@ static gboolean websearch_entry_activate_cb(GtkWidget *widget, gpointer data)
* \return TRUE
*/
static gboolean
-websearch_entry_button_press(GtkWidget *widget,
+websearch_entry_button_press_cb(GtkWidget *widget,
GdkEventFocus *f,
gpointer data)
{
@@ -2174,7 +2175,7 @@ toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
tb);
g_signal_connect(GTK_WIDGET(entry),
"button-press-event",
- G_CALLBACK(websearch_entry_button_press),
+ G_CALLBACK(websearch_entry_button_press_cb),
tb);
break;
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=ff64341ed33d8abf722...
commit ff64341ed33d8abf722795ca4d51d81ce02d7694
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
make menu sensitivity work
what remains is interfaces to make the toolbar appropriately sensative
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 08dabc3..74a8043 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -104,10 +104,11 @@ static gboolean nsgtk_on_##q##_activate(GtkButton *widget, gpointer data)
struct nsgtk_menu {
- GtkWidget *main; /* main menu entry */
- GtkWidget *rclick; /* right click menu */
- GtkWidget *popup; /* popup menu entry */
- void *mhandler; /* menu item handler */
+ GtkWidget *main; /* main menu entry */
+ GtkWidget *rclick; /* right click menu */
+ GtkWidget *popup; /* popup menu entry */
+ void *mhandler; /* menu item handler */
+ bool sensitivity; /* menu item is sensitive */
};
/** Core scaffolding structure. */
@@ -320,12 +321,12 @@ scaffolding_window_delete_event(GtkWidget *widget,
static void scaffolding_update_context(struct nsgtk_scaffolding *g)
{
struct browser_window *bw = nsgtk_get_browser_window(g->top_level);
-#if 0
- g->buttons[BACK_BUTTON]->sensitivity =
- browser_window_history_back_available(bw);
- g->buttons[FORWARD_BUTTON]->sensitivity =
- browser_window_history_forward_available(bw);
-#endif
+
+ g->menus[BACK_BUTTON].sensitivity =
+ browser_window_history_back_available(bw);
+ g->menus[FORWARD_BUTTON].sensitivity =
+ browser_window_history_forward_available(bw);
+
nsgtk_scaffolding_set_sensitivity(g);
/* update the url bar, particularly necessary when tabbing */
@@ -340,61 +341,56 @@ static void scaffolding_update_context(struct nsgtk_scaffolding *g)
/**
* edit the sensitivity of focused widget
*
+ * \todo this needs to update toolbar sensitivity
+ *
* \param g The scaffolding context.
*/
static guint
-nsgtk_scaffolding_update_edit_actions_sensitivity(
- struct nsgtk_scaffolding *g)
+nsgtk_scaffolding_update_edit_actions_sensitivity(struct nsgtk_scaffolding *g)
{
-#if 0
GtkWidget *widget = gtk_window_get_focus(g->window);
- gboolean has_selection;
if (GTK_IS_EDITABLE(widget)) {
+ gboolean has_selection;
has_selection = gtk_editable_get_selection_bounds(
- GTK_EDITABLE (widget), NULL, NULL);
-
- g->buttons[COPY_BUTTON]->sensitivity = has_selection;
- g->buttons[CUT_BUTTON]->sensitivity = has_selection;
- g->buttons[PASTE_BUTTON]->sensitivity = true;
+ GTK_EDITABLE(widget), NULL, NULL);
+ g->menus[COPY_BUTTON].sensitivity = has_selection;
+ g->menus[CUT_BUTTON].sensitivity = has_selection;
+ g->menus[PASTE_BUTTON].sensitivity = true;
} else {
struct browser_window *bw =
- nsgtk_get_browser_window(g->top_level);
+ nsgtk_get_browser_window(g->top_level);
browser_editor_flags edit_f =
- browser_window_get_editor_flags(bw);
+ browser_window_get_editor_flags(bw);
- g->buttons[COPY_BUTTON]->sensitivity =
- edit_f & BW_EDITOR_CAN_COPY;
- g->buttons[CUT_BUTTON]->sensitivity =
- edit_f & BW_EDITOR_CAN_CUT;
- g->buttons[PASTE_BUTTON]->sensitivity =
- edit_f & BW_EDITOR_CAN_PASTE;
+ g->menus[COPY_BUTTON].sensitivity =
+ edit_f & BW_EDITOR_CAN_COPY;
+ g->menus[CUT_BUTTON].sensitivity =
+ edit_f & BW_EDITOR_CAN_CUT;
+ g->menus[PASTE_BUTTON].sensitivity =
+ edit_f & BW_EDITOR_CAN_PASTE;
}
nsgtk_scaffolding_set_sensitivity(g);
- return ((g->buttons[COPY_BUTTON]->sensitivity) |
- (g->buttons[CUT_BUTTON]->sensitivity) |
- (g->buttons[PASTE_BUTTON]->sensitivity));
-#else
- return 0;
-#endif
+ return ((g->menus[COPY_BUTTON].sensitivity) |
+ (g->menus[CUT_BUTTON].sensitivity) |
+ (g->menus[PASTE_BUTTON].sensitivity));
}
/**
* make edit actions sensitive
*
+ * \todo toolbar sensitivity
+ *
* \param g The scaffolding context.
*/
static void
-nsgtk_scaffolding_enable_edit_actions_sensitivity(
- struct nsgtk_scaffolding *g)
+nsgtk_scaffolding_enable_edit_actions_sensitivity(struct nsgtk_scaffolding *g)
{
-#if 0
- g->buttons[PASTE_BUTTON]->sensitivity = true;
- g->buttons[COPY_BUTTON]->sensitivity = true;
- g->buttons[CUT_BUTTON]->sensitivity = true;
-#endif
+ g->menus[PASTE_BUTTON].sensitivity = true;
+ g->menus[COPY_BUTTON].sensitivity = true;
+ g->menus[CUT_BUTTON].sensitivity = true;
nsgtk_scaffolding_set_sensitivity(g);
popup_menu_show(g->menu_popup, false, false, true, false);
@@ -448,30 +444,6 @@ static gboolean nsgtk_window_popup_menu_hidden(GtkWidget *widget,
return TRUE;
}
-/* exported interface documented in gtk/scaffolding.h */
-gboolean nsgtk_window_url_activate_event(GtkWidget *widget, gpointer data)
-{
-#if 0
- struct nsgtk_scaffolding *g = data;
- nserror ret;
- nsurl *url;
-
- ret = search_web_omni(gtk_entry_get_text(GTK_ENTRY(g->url_bar)),
- SEARCH_WEB_OMNI_NONE,
- &url);
- if (ret == NSERROR_OK) {
- ret = browser_window_navigate(nsgtk_get_browser_window(g->top_level),
- url, NULL, BW_NAVIGATE_HISTORY,
- NULL, NULL, NULL);
- nsurl_unref(url);
- }
- if (ret != NSERROR_OK) {
- nsgtk_warning(messages_get_errorcode(ret), 0);
- }
-#endif
- return TRUE;
-}
-
/**
* update handler for URL entry widget
@@ -522,6 +494,9 @@ nsgtk_window_tool_bar_clicked(GtkToolbar *toolbar,
/**
* Update the menus when the number of tabs changes.
*
+ * \todo toolbar sensitivity
+ * \todo next/previous tab ought to only be visible if there is such a tab
+ *
* \param notebook The notebook all the tabs are in
* \param page The newly added page container widget
* \param page_num The index of the newly added page
@@ -535,14 +510,18 @@ nsgtk_window_tabs_add(GtkNotebook *notebook,
{
gboolean visible = gtk_notebook_get_show_tabs(g->notebook);
g_object_set(g->menu_bar->view_submenu->tabs_menuitem,
- "visible", visible, NULL);
+ "visible",
+ visible,
+ NULL);
g_object_set(g->menu_popup->view_submenu->tabs_menuitem,
- "visible", visible, NULL);
-#if 0
- g->buttons[NEXTTAB_BUTTON]->sensitivity = visible;
- g->buttons[PREVTAB_BUTTON]->sensitivity = visible;
- g->buttons[CLOSETAB_BUTTON]->sensitivity = visible;
-#endif
+ "visible",
+ visible,
+ NULL);
+
+ g->menus[NEXTTAB_BUTTON].sensitivity = visible;
+ g->menus[PREVTAB_BUTTON].sensitivity = visible;
+ g->menus[CLOSETAB_BUTTON].sensitivity = visible;
+
nsgtk_scaffolding_set_sensitivity(g);
}
@@ -550,6 +529,8 @@ nsgtk_window_tabs_add(GtkNotebook *notebook,
/**
* Update the menus when the number of tabs changes.
*
+ * \todo toolbar sensitivity
+ *
* \param notebook The notebook all the tabs are in
* \param page The page container widget being removed
* \param page_num The index of the removed page
@@ -578,11 +559,11 @@ nsgtk_window_tabs_remove(GtkNotebook *notebook,
gboolean visible = gtk_notebook_get_show_tabs(gs->notebook);
g_object_set(gs->menu_bar->view_submenu->tabs_menuitem, "visible", visible, NULL);
g_object_set(gs->menu_popup->view_submenu->tabs_menuitem, "visible", visible, NULL);
-#if 0
- gs->buttons[NEXTTAB_BUTTON]->sensitivity = visible;
- gs->buttons[PREVTAB_BUTTON]->sensitivity = visible;
- gs->buttons[CLOSETAB_BUTTON]->sensitivity = visible;
-#endif
+
+ gs->menus[NEXTTAB_BUTTON].sensitivity = visible;
+ gs->menus[PREVTAB_BUTTON].sensitivity = visible;
+ gs->menus[CLOSETAB_BUTTON].sensitivity = visible;
+
nsgtk_scaffolding_set_sensitivity(gs);
}
@@ -1738,7 +1719,7 @@ BUTTONHANDLER(history)
/**
* attach gtk signal handlers for menus
*/
-static void nsgtk_attach_menu_handlers(struct nsgtk_scaffolding *g)
+static void nsgtk_menu_connect_signals(struct nsgtk_scaffolding *g)
{
int idx; /* item index */
for (idx = BACK_BUTTON; idx < PLACEHOLDER_BUTTON; idx++) {
@@ -1859,7 +1840,12 @@ struct nsgtk_scaffolding *nsgtk_current_scaffolding(void)
*/
static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
{
-#define ITEM_MAIN(p, q, r)\
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked) \
+ g->menus[identifier].sensitivity = snstvty;
+#include "gtk/toolbar_items.h"
+#undef TOOLBAR_ITEM
+
+#define ITEM_MAIN(p, q, r) \
g->menus[p##_BUTTON].main = g->menu_bar->q->r##_menuitem;\
g->menus[p##_BUTTON].rclick = g->menu_popup->q->r##_menuitem;\
g->menus[p##_BUTTON].mhandler = nsgtk_on_##r##_activate_menu;
@@ -1869,12 +1855,12 @@ static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
g->menu_bar->q->r##_submenu->s##_menuitem;\
g->menus[p##_BUTTON].rclick =\
g->menu_popup->q->r##_submenu->s##_menuitem;\
- g->menus[p##_BUTTON].mhandler =\
- nsgtk_on_##s##_activate_menu;
+ g->menus[p##_BUTTON].mhandler = nsgtk_on_##s##_activate_menu;
-#define ITEM_POP(p, q) \
+#define ITEM_POP(p, q) \
g->menus[p##_BUTTON].popup = g->menu_popup->q##_menuitem
+
ITEM_MAIN(NEWWINDOW, file_submenu, newwindow);
ITEM_MAIN(NEWTAB, file_submenu, newtab);
ITEM_MAIN(OPENFILE, file_submenu, openfile);
@@ -1939,31 +1925,30 @@ static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
return NSERROR_OK;
}
-#if 0
-static void nsgtk_scaffolding_initial_sensitivity(struct nsgtk_scaffolding *g)
+
+static void nsgtk_menu_set_sensitivity(struct nsgtk_scaffolding *g)
{
+
for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- if (g->buttons[i]->main != NULL)
+ if (g->menus[i].main != NULL) {
gtk_widget_set_sensitive(GTK_WIDGET(
- g->buttons[i]->main),
- g->buttons[i]->sensitivity);
- if (g->buttons[i]->rclick != NULL)
- gtk_widget_set_sensitive(GTK_WIDGET(
- g->buttons[i]->rclick),
- g->buttons[i]->sensitivity);
- if ((g->buttons[i]->location != -1) &&
- (g->buttons[i]->button != NULL))
+ g->menus[i].main),
+ g->menus[i].sensitivity);
+ }
+ if (g->menus[i].rclick != NULL) {
gtk_widget_set_sensitive(GTK_WIDGET(
- g->buttons[i]->button),
- g->buttons[i]->sensitivity);
- if (g->buttons[i]->popup != NULL)
+ g->menus[i].rclick),
+ g->menus[i].sensitivity);
+ }
+ if (g->menus[i].popup != NULL) {
gtk_widget_set_sensitive(GTK_WIDGET(
- g->buttons[i]->popup),
- g->buttons[i]->sensitivity);
+ g->menus[i].popup),
+ g->menus[i].sensitivity);
+ }
}
gtk_widget_set_sensitive(GTK_WIDGET(g->menu_bar->view_submenu->images_menuitem), FALSE);
}
-#endif
+
/**
* update search toolbar size and style
*/
@@ -2363,22 +2348,18 @@ void nsgtk_scaffolding_set_top_level(struct gui_window *gw)
/* exported interface documented in scaffolding.h */
void nsgtk_scaffolding_set_sensitivity(struct nsgtk_scaffolding *g)
{
-#if 0
int i;
-#define SENSITIVITY(q)\
- i = q##_BUTTON;\
- if (g->buttons[i]->main != NULL)\
- gtk_widget_set_sensitive(GTK_WIDGET(\
- g->buttons[i]->main),\
- g->buttons[i]->sensitivity);\
- if (g->buttons[i]->rclick != NULL)\
- gtk_widget_set_sensitive(GTK_WIDGET(\
- g->buttons[i]->rclick),\
- g->buttons[i]->sensitivity);\
- if (g->buttons[i]->popup != NULL)\
- gtk_widget_set_sensitive(GTK_WIDGET(\
- g->buttons[i]->popup),\
- g->buttons[i]->sensitivity);
+#define SENSITIVITY(q) \
+ i = q##_BUTTON; \
+ if (g->menus[i].main != NULL) \
+ gtk_widget_set_sensitive(GTK_WIDGET(g->menus[i].main), \
+ g->menus[i].sensitivity); \
+ if (g->menus[i].rclick != NULL) \
+ gtk_widget_set_sensitive(GTK_WIDGET(g->menus[i].rclick), \
+ g->menus[i].sensitivity); \
+ if (g->menus[i].popup != NULL) \
+ gtk_widget_set_sensitive(GTK_WIDGET(g->menus[i].popup), \
+ g->menus[i].sensitivity);
SENSITIVITY(STOP)
SENSITIVITY(RELOAD)
@@ -2391,7 +2372,7 @@ void nsgtk_scaffolding_set_sensitivity(struct nsgtk_scaffolding *g)
SENSITIVITY(PREVTAB)
SENSITIVITY(CLOSETAB)
#undef SENSITIVITY
-#endif
+
}
@@ -2415,25 +2396,25 @@ void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g,
gtkmenu = g->menu_popup->popup_menu;
nsgtk_scaffolding_update_edit_actions_sensitivity(g);
-#if 0
- if (!(g->buttons[COPY_BUTTON]->sensitivity)) {
+
+ if (!(g->menus[COPY_BUTTON].sensitivity)) {
gtk_widget_hide(GTK_WIDGET(g->menu_popup->copy_menuitem));
} else {
gtk_widget_show(GTK_WIDGET(g->menu_popup->copy_menuitem));
}
- if (!(g->buttons[CUT_BUTTON]->sensitivity)) {
+ if (!(g->menus[CUT_BUTTON].sensitivity)) {
gtk_widget_hide(GTK_WIDGET(g->menu_popup->cut_menuitem));
} else {
gtk_widget_show(GTK_WIDGET(g->menu_popup->cut_menuitem));
}
- if (!(g->buttons[PASTE_BUTTON]->sensitivity)) {
+ if (!(g->menus[PASTE_BUTTON].sensitivity)) {
gtk_widget_hide(GTK_WIDGET(g->menu_popup->paste_menuitem));
} else {
gtk_widget_show(GTK_WIDGET(g->menu_popup->paste_menuitem));
}
-#endif
+
/* hide customise */
popup_menu_hide(g->menu_popup, false, false, false, true);
}
@@ -2441,41 +2422,6 @@ void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g,
nsgtk_menu_popup_at_pointer(gtkmenu, NULL);
}
-/**
- * reallocate width for history button, reallocate buttons right of history;
- * memorise base of history button / toolbar
- */
-void nsgtk_scaffolding_toolbar_size_allocate(GtkWidget *widget,
- GtkAllocation *alloc, gpointer data)
-{
- #if 0
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- int i = nsgtk_toolbar_get_id_from_widget(widget, g);
- if (i == -1)
- return;
- if ((g->toolbarmem == alloc->x) ||
- (g->buttons[i]->location < g->buttons[HISTORY_BUTTON]->location))
- /* no reallocation after first adjustment, no reallocation for buttons
- * left of history button */
- return;
- if (widget == GTK_WIDGET(g->buttons[HISTORY_BUTTON]->button)) {
- if (alloc->width == 20)
- return;
-
- g->toolbarbase = alloc->y + alloc->height;
- g->historybase = alloc->x + 20;
- if (g->offset == 0)
- g->offset = alloc->width - 20;
- alloc->width = 20;
- } else if (g->buttons[i]->location <= g->buttons[URL_BAR_ITEM]->location) {
- alloc->x -= g->offset;
- if (i == URL_BAR_ITEM)
- alloc->width += g->offset;
- }
- g->toolbarmem = alloc->x;
- gtk_widget_size_allocate(widget, alloc);
- #endif
-}
/* exported interface documented in gtk/scaffolding.h */
@@ -2590,10 +2536,8 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
/* set up the menu signal handlers */
nsgtk_menu_initialise(gs);
- //nsgtk_toolbar_connect_all(gs);
- nsgtk_attach_menu_handlers(gs);
-
- //nsgtk_scaffolding_initial_sensitivity(gs);
+ nsgtk_menu_connect_signals(gs);
+ nsgtk_menu_set_sensitivity(gs);
gs->fullscreen = false;
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index 19f8681..261d2f0 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding.h
@@ -153,10 +153,6 @@ void nsgtk_scaffolding_set_sensitivity(struct nsgtk_scaffolding *g);
*/
void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g, gdouble x, gdouble y);
-void nsgtk_scaffolding_toolbar_size_allocate(GtkWidget *widget, GtkAllocation *alloc, gpointer data);
-
-gboolean nsgtk_window_url_activate_event(GtkWidget *, gpointer);
-
gboolean nsgtk_window_url_changed(GtkWidget *, GdkEventKey *, gpointer);
nserror nsgtk_scaffolding_new_tab(struct gui_window *gw);
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 6e3459f..bf7f1ef 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -1475,12 +1475,6 @@ void nsgtk_toolbar_connect_all(struct nsgtk_scaffolding *g)
q = nsgtk_toolbar_get_id_at_location(g, i);
if (q == -1)
continue;
- if (nsgtk_scaffolding_button(g, q)->button != NULL)
- g_signal_connect(
- nsgtk_scaffolding_button(g, q)->button,
- "size-allocate", G_CALLBACK(
- nsgtk_scaffolding_toolbar_size_allocate
- ), g);
}
}
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=c297101c3a7b9b40ff0...
commit c297101c3a7b9b40ff08f120cb92c8a9b4237e5e
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
make menus work again
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index b523645..08dabc3 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -104,9 +104,10 @@ static gboolean nsgtk_on_##q##_activate(GtkButton *widget, gpointer data)
struct nsgtk_menu {
- GtkWidget *main; /* left click menu entry */
+ GtkWidget *main; /* main menu entry */
GtkWidget *rclick; /* right click menu */
GtkWidget *popup; /* popup menu entry */
+ void *mhandler; /* menu item handler */
};
/** Core scaffolding structure. */
@@ -1734,21 +1735,30 @@ BUTTONHANDLER(history)
#undef CHECKHANDLER
#undef BUTTONHANDLER
+/**
+ * attach gtk signal handlers for menus
+ */
static void nsgtk_attach_menu_handlers(struct nsgtk_scaffolding *g)
{
- #if 0
- for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
- if (g->buttons[i]->main != NULL) {
- g_signal_connect(g->buttons[i]->main, "activate",
- G_CALLBACK(g->buttons[i]->mhandler), g);
+ int idx; /* item index */
+ for (idx = BACK_BUTTON; idx < PLACEHOLDER_BUTTON; idx++) {
+ if (g->menus[idx].main != NULL) {
+ g_signal_connect(g->menus[idx].main,
+ "activate",
+ G_CALLBACK(g->menus[idx].mhandler),
+ g);
}
- if (g->buttons[i]->rclick != NULL) {
- g_signal_connect(g->buttons[i]->rclick, "activate",
- G_CALLBACK(g->buttons[i]->mhandler), g);
+ if (g->menus[idx].rclick != NULL) {
+ g_signal_connect(g->menus[idx].rclick,
+ "activate",
+ G_CALLBACK(g->menus[idx].mhandler),
+ g);
}
- if (g->buttons[i]->popup != NULL) {
- g_signal_connect(g->buttons[i]->popup, "activate",
- G_CALLBACK(g->buttons[i]->mhandler), g);
+ if (g->menus[idx].popup != NULL) {
+ g_signal_connect(g->menus[idx].popup,
+ "activate",
+ G_CALLBACK(g->menus[idx].mhandler),
+ g);
}
}
#define CONNECT_CHECK(q)\
@@ -1757,7 +1767,7 @@ static void nsgtk_attach_menu_handlers(struct nsgtk_scaffolding *g)
CONNECT_CHECK(menubar);
CONNECT_CHECK(toolbar);
#undef CONNECT_CHECK
-#endif
+
}
/**
@@ -1843,33 +1853,27 @@ struct nsgtk_scaffolding *nsgtk_current_scaffolding(void)
}
return scaf_current;
}
-#if 0
+
/**
- * init the array g->buttons[]
+ * initialiase the menu signal handlers ready for connection
*/
-static void nsgtk_scaffolding_toolbar_init(struct nsgtk_scaffolding *g)
+static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
{
#define ITEM_MAIN(p, q, r)\
- g->buttons[p##_BUTTON]->main = g->menu_bar->q->r##_menuitem;\
- g->buttons[p##_BUTTON]->rclick = g->menu_popup->q->r##_menuitem;\
- g->buttons[p##_BUTTON]->mhandler = nsgtk_on_##r##_activate_menu;\
- g->buttons[p##_BUTTON]->bhandler = nsgtk_on_##r##_activate_button;
+ g->menus[p##_BUTTON].main = g->menu_bar->q->r##_menuitem;\
+ g->menus[p##_BUTTON].rclick = g->menu_popup->q->r##_menuitem;\
+ g->menus[p##_BUTTON].mhandler = nsgtk_on_##r##_activate_menu;
#define ITEM_SUB(p, q, r, s)\
- g->buttons[p##_BUTTON]->main =\
+ g->menus[p##_BUTTON].main =\
g->menu_bar->q->r##_submenu->s##_menuitem;\
- g->buttons[p##_BUTTON]->rclick =\
+ g->menus[p##_BUTTON].rclick =\
g->menu_popup->q->r##_submenu->s##_menuitem;\
- g->buttons[p##_BUTTON]->mhandler =\
- nsgtk_on_##s##_activate_menu;\
- g->buttons[p##_BUTTON]->bhandler =\
- nsgtk_on_##s##_activate_button;
-
-#define ITEM_BUTTON(p, q)\
- g->buttons[p##_BUTTON]->bhandler =\
- nsgtk_on_##q##_activate;
+ g->menus[p##_BUTTON].mhandler =\
+ nsgtk_on_##s##_activate_menu;
+
#define ITEM_POP(p, q) \
- g->buttons[p##_BUTTON]->popup = g->menu_popup->q##_menuitem
+ g->menus[p##_BUTTON].popup = g->menu_popup->q##_menuitem
ITEM_MAIN(NEWWINDOW, file_submenu, newwindow);
ITEM_MAIN(NEWTAB, file_submenu, newtab);
@@ -1925,7 +1929,6 @@ static void nsgtk_scaffolding_toolbar_init(struct nsgtk_scaffolding *g)
ITEM_SUB(TOGGLEDEBUGGING, tools_submenu, developer, toggledebugging);
ITEM_SUB(SAVEBOXTREE, tools_submenu, developer, debugboxtree);
ITEM_SUB(SAVEDOMTREE, tools_submenu, developer, debugdomtree);
- ITEM_BUTTON(HISTORY, history);
#undef ITEM_MAIN
@@ -1933,9 +1936,10 @@ static void nsgtk_scaffolding_toolbar_init(struct nsgtk_scaffolding *g)
#undef ITEM_BUTTON
#undef ITEM_POP
+ return NSERROR_OK;
}
-
+#if 0
static void nsgtk_scaffolding_initial_sensitivity(struct nsgtk_scaffolding *g)
{
for (int i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
@@ -2585,7 +2589,7 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
gs->link_menu = nsgtk_new_scaffolding_link_popup(gs, group);
/* set up the menu signal handlers */
- //nsgtk_scaffolding_toolbar_init(gs);
+ nsgtk_menu_initialise(gs);
//nsgtk_toolbar_connect_all(gs);
nsgtk_attach_menu_handlers(gs);
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 7a91f04..6e3459f 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -73,7 +73,6 @@ struct nsgtk_toolbar_item {
*/
gboolean (*bhandler)(GtkWidget *widget, gpointer data);
- void *mhandler; /* menu item clicked */
void *dataplus; /* customization -> toolbar */
void *dataminus; /* customization -> store */
};
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=b389dd4116fc5a313a0...
commit b389dd4116fc5a313a015328a068a968223a4daf
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
make web search box work
diff --git a/frontends/gtk/search.c b/frontends/gtk/search.c
index 2983096..40c0253 100644
--- a/frontends/gtk/search.c
+++ b/frontends/gtk/search.c
@@ -17,7 +17,8 @@
*/
- /** \file
+/**
+ * \file
* Free text search (front component)
*/
#include <stdint.h>
@@ -189,50 +190,6 @@ nsgtk_search_entry_key(GtkWidget *widget, GdkEventKey *event, gpointer data)
return FALSE;
}
-/** connected to the websearch entry [return key] */
-
-gboolean nsgtk_websearch_activate(GtkWidget *widget, gpointer data)
-{
- struct nsgtk_scaffolding *g = data;
- nserror ret;
- nsurl *url;
-
- ret = search_web_omni(
- gtk_entry_get_text(GTK_ENTRY(nsgtk_scaffolding_websearch(g))),
- SEARCH_WEB_OMNI_SEARCHONLY,
- &url);
- if (ret == NSERROR_OK) {
- temp_open_background = 0;
- ret = browser_window_create(
- BW_CREATE_HISTORY | BW_CREATE_TAB,
- url,
- NULL,
- nsgtk_get_browser_window(nsgtk_scaffolding_top_level(g)),
- NULL);
- temp_open_background = -1;
- nsurl_unref(url);
- }
- if (ret != NSERROR_OK) {
- nsgtk_warning(messages_get_errorcode(ret), 0);
- }
-
- return TRUE;
-}
-
-/**
- * allows a click in the websearch entry field to clear the name of the
- * provider
- */
-
-gboolean nsgtk_websearch_clear(GtkWidget *widget, GdkEventFocus *f,
- gpointer data)
-{
- struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *)data;
- gtk_editable_select_region(GTK_EDITABLE(
- nsgtk_scaffolding_websearch(g)), 0, -1);
- gtk_widget_grab_focus(GTK_WIDGET(nsgtk_scaffolding_websearch(g)));
- return TRUE;
-}
diff --git a/frontends/gtk/search.h b/frontends/gtk/search.h
index b2162b8..716a60d 100644
--- a/frontends/gtk/search.h
+++ b/frontends/gtk/search.h
@@ -19,6 +19,11 @@
#ifndef _NETSURF_GTK_SEARCH_H_
#define _NETSURF_GTK_SEARCH_H_
+/**
+ * \file
+ * free text page search for gtk interfaces
+ */
+
extern struct gui_search_table *nsgtk_search_table;
struct nsgtk_scaffolding;
@@ -30,7 +35,6 @@ gboolean nsgtk_search_entry_key(GtkWidget *widget, GdkEventKey *event, gpointer
gboolean nsgtk_search_forward_button_clicked(GtkWidget *widget, gpointer data);
gboolean nsgtk_search_back_button_clicked(GtkWidget *widget, gpointer data);
gboolean nsgtk_search_close_button_clicked(GtkWidget *widget, gpointer data);
-gboolean nsgtk_websearch_activate(GtkWidget *widget, gpointer data);
-gboolean nsgtk_websearch_clear(GtkWidget *widget, GdkEventFocus *f, gpointer data);
+
#endif
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index c543eed..7a91f04 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -1465,49 +1465,6 @@ int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget,
}
-/**
- * add handlers to factory widgets
- * \param g the scaffolding to attach handlers to
- * \param i the toolbar item id
- */
-static void
-nsgtk_toolbar_set_handler(struct nsgtk_scaffolding *g, nsgtk_toolbar_button i)
-{
- switch(i) {
- case URL_BAR_ITEM:
- g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_urlbar(g)),
- "activate", G_CALLBACK(
- nsgtk_window_url_activate_event), g);
- g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_urlbar(g)),
- "changed", G_CALLBACK(
- nsgtk_window_url_changed), g);
- break;
-
- case THROBBER_ITEM:
- break;
-
- case WEBSEARCH_ITEM:
- nsgtk_scaffolding_update_websearch_ref(g);
- g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_websearch(g)),
- "activate", G_CALLBACK(
- nsgtk_websearch_activate), g);
- g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_websearch(g)),
- "button-press-event", G_CALLBACK(
- nsgtk_websearch_clear), g);
- break;
-
- default:
- if ((nsgtk_scaffolding_button(g, i)->bhandler != NULL) &&
- (nsgtk_scaffolding_button(g, i)->button != NULL)) {
- g_signal_connect(
- nsgtk_scaffolding_button(g, i)->button,
- "clicked",
- G_CALLBACK(nsgtk_scaffolding_button(
- g, i)->bhandler), g);
- }
- break;
- }
-}
/**
* connect 'normal' handlers to toolbar buttons
@@ -1525,7 +1482,7 @@ void nsgtk_toolbar_connect_all(struct nsgtk_scaffolding *g)
"size-allocate", G_CALLBACK(
nsgtk_scaffolding_toolbar_size_allocate
), g);
- nsgtk_toolbar_set_handler(g, q);
+
}
}
@@ -1786,56 +1743,6 @@ toolbar_item_size_allocate_cb(GtkWidget *widget,
/**
- * callback for url entry widget activation
- *
- * handler connected to url entry widget for the activate signal
- *
- * \param widget The widget the signal is being delivered to.
- * \param data The toolbar context passed when the signal was connected
- * \return TRUE to allow activation.
- */
-static gboolean url_entry_activate_cb(GtkWidget *widget, gpointer data)
-{
- nserror res;
- struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
- struct browser_window *bw;
- nsurl *url;
-
- res = search_web_omni(gtk_entry_get_text(GTK_ENTRY(widget)),
- SEARCH_WEB_OMNI_NONE,
- &url);
- if (res == NSERROR_OK) {
- bw = tb->get_bw(tb->get_bw_ctx);
- res = browser_window_navigate(
- bw, url, NULL, BW_NAVIGATE_HISTORY, NULL, NULL, NULL);
- nsurl_unref(url);
- }
- if (res != NSERROR_OK) {
- nsgtk_warning(messages_get_errorcode(res), 0);
- }
-
- return TRUE;
-}
-
-
-/**
- * callback for url entry widget changing
- *
- * handler connected to url entry widget for the change signal
- *
- * \param widget The widget the signal is being delivered to.
- * \param event The key change event that changed the entry.
- * \param data The toolbar context passed when the signal was connected
- * \return TRUE to allow activation.
- */
-static gboolean
-url_entry_changed_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
-{
- return nsgtk_completion_update(GTK_ENTRY(widget));
-}
-
-
-/**
* handler for back tool bar item clicked signal
*
* \param widget The widget the signal is being delivered to.
@@ -2013,6 +1920,122 @@ home_button_clicked_cb(GtkWidget *widget, gpointer data)
/**
+ * callback for url entry widget activation
+ *
+ * handler connected to url entry widget for the activate signal
+ *
+ * \param widget The widget the signal is being delivered to.
+ * \param data The toolbar context passed when the signal was connected
+ * \return TRUE to allow activation.
+ */
+static gboolean url_entry_activate_cb(GtkWidget *widget, gpointer data)
+{
+ nserror res;
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ nsurl *url;
+
+ res = search_web_omni(gtk_entry_get_text(GTK_ENTRY(widget)),
+ SEARCH_WEB_OMNI_NONE,
+ &url);
+ if (res == NSERROR_OK) {
+ bw = tb->get_bw(tb->get_bw_ctx);
+ res = browser_window_navigate(
+ bw, url, NULL, BW_NAVIGATE_HISTORY, NULL, NULL, NULL);
+ nsurl_unref(url);
+ }
+ if (res != NSERROR_OK) {
+ nsgtk_warning(messages_get_errorcode(res), 0);
+ }
+
+ return TRUE;
+}
+
+
+/**
+ * callback for url entry widget changing
+ *
+ * handler connected to url entry widget for the change signal
+ *
+ * \param widget The widget the signal is being delivered to.
+ * \param event The key change event that changed the entry.
+ * \param data The toolbar context passed when the signal was connected
+ * \return TRUE to allow activation.
+ */
+static gboolean
+url_entry_changed_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
+{
+ return nsgtk_completion_update(GTK_ENTRY(widget));
+}
+
+
+/**
+ * handler for web search tool bar entry item activate signal
+ *
+ * handler connected to web search entry widget for the activate signal
+ *
+ * \todo make this user selectable to switch between opening in new
+ * and navigating current window. Possibly improve core search_web interfaces
+ *
+ * \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 websearch_entry_activate_cb(GtkWidget *widget, gpointer data)
+{
+ nserror res;
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ nsurl *url;
+
+ res = search_web_omni(gtk_entry_get_text(GTK_ENTRY(widget)),
+ SEARCH_WEB_OMNI_SEARCHONLY,
+ &url);
+ if (res == NSERROR_OK) {
+ temp_open_background = 0;
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ res = browser_window_create(
+ BW_CREATE_HISTORY | BW_CREATE_TAB,
+ url,
+ NULL,
+ bw,
+ NULL);
+ temp_open_background = -1;
+ nsurl_unref(url);
+ }
+ if (res != NSERROR_OK) {
+ nsgtk_warning(messages_get_errorcode(res), 0);
+ }
+
+ return TRUE;
+}
+
+/**
+ * handler for web search tool bar item button press signal
+ *
+ * allows a click in the websearch entry field to clear the name of the
+ * provider.
+ *
+ * \todo this does not work well, different behaviour wanted perhaps?
+ *
+ * \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
+websearch_entry_button_press(GtkWidget *widget,
+ GdkEventFocus *f,
+ gpointer data)
+{
+ gtk_editable_select_region(GTK_EDITABLE(widget), 0, -1);
+ gtk_widget_grab_focus(GTK_WIDGET(widget));
+
+ return TRUE;
+}
+
+
+/**
* create a toolbar item
*
* create a toolbar item and set up its default handlers
@@ -2119,6 +2142,7 @@ static nserror
toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
{
struct nsgtk_toolbar_item *item;
+ GtkEntry *entry;
item = tb->buttons[itemid];
@@ -2130,23 +2154,36 @@ toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
}
switch (itemid) {
- case URL_BAR_ITEM: {
- GtkEntry *url_entry;
- url_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(item->button)));
- g_signal_connect(GTK_WIDGET(url_entry),
+ case URL_BAR_ITEM:
+ entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(item->button)));
+
+ g_signal_connect(GTK_WIDGET(entry),
"activate",
G_CALLBACK(url_entry_activate_cb),
tb);
- g_signal_connect(GTK_WIDGET(url_entry),
+ g_signal_connect(GTK_WIDGET(entry),
"changed",
G_CALLBACK(url_entry_changed_cb),
tb);
- nsgtk_completion_connect_signals(url_entry,
- tb->get_bw,
- tb->get_bw_ctx);
+ nsgtk_completion_connect_signals(entry,
+ tb->get_bw,
+ tb->get_bw_ctx);
+ break;
+
+
+ case WEBSEARCH_ITEM:
+ entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(item->button)));
+
+ g_signal_connect(GTK_WIDGET(entry),
+ "activate",
+ G_CALLBACK(websearch_entry_activate_cb),
+ tb);
+ g_signal_connect(GTK_WIDGET(entry),
+ "button-press-event",
+ G_CALLBACK(websearch_entry_button_press),
+ tb);
break;
- }
default:
if ((item->bhandler != NULL) && (item->button != NULL)) {
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=f3a68771e34511a07a4...
commit f3a68771e34511a07a42374c0c0a656ed8d47905
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
add home button clicked handler
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 58611bd..c543eed 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -542,6 +542,108 @@ static char *remove_underscores(const char *s, bool replacespace)
/**
+ * create throbber toolbar item widget
+ *
+ * create a gtk entry widget with a completion attached
+ */
+static GtkToolItem *
+make_toolbar_item_throbber(void)
+{
+ nserror res;
+ GtkToolItem *item;
+ GdkPixbuf *pixbuf;
+ GtkWidget *image;
+
+ res = nsgtk_throbber_get_frame(0, &pixbuf);
+ if (res != NSERROR_OK) {
+ return NULL;
+ }
+
+ if (edit_mode) {
+ item = gtk_tool_button_new(
+ GTK_WIDGET(gtk_image_new_from_pixbuf(pixbuf)),
+ "[throbber]");
+ } else {
+ item = gtk_tool_item_new();
+
+ image = gtk_image_new_from_pixbuf(pixbuf);
+ if (image != NULL) {
+ nsgtk_widget_set_alignment(image,
+ GTK_ALIGN_CENTER,
+ GTK_ALIGN_CENTER);
+ nsgtk_widget_set_margins(image, 3, 0);
+
+ gtk_container_add(GTK_CONTAINER(item), image);
+ }
+ }
+ return item;
+}
+
+/**
+ * create url bar toolbar item widget
+ *
+ * create a gtk entry widget with a completion attached
+ */
+static GtkToolItem *
+make_toolbar_item_url_bar(void)
+{
+ GtkToolItem *item;
+ GtkWidget *entry;
+ GtkEntryCompletion *completion;
+
+ item = gtk_tool_item_new();
+ entry = nsgtk_entry_new();
+ completion = gtk_entry_completion_new();
+
+ if ((entry == NULL) || (completion == NULL) || (item == NULL)) {
+ return NULL;
+ }
+
+ gtk_entry_set_completion(GTK_ENTRY(entry), completion);
+ gtk_container_add(GTK_CONTAINER(item), entry);
+ gtk_tool_item_set_expand(item, TRUE);
+
+ return item;
+}
+
+
+/**
+ * create web search toolbar item widget
+ */
+static GtkToolItem *
+make_toolbar_item_websearch(void)
+{
+ GtkToolItem *item;
+
+ if (edit_mode) {
+ item = gtk_tool_button_new(
+ GTK_WIDGET(nsgtk_image_new_from_stock(
+ NSGTK_STOCK_FIND,
+ GTK_ICON_SIZE_LARGE_TOOLBAR)),
+ "[websearch]");
+ } else {
+ GtkWidget *entry = nsgtk_entry_new();
+
+ item = gtk_tool_item_new();
+
+ if ((entry == NULL) || (item == NULL)) {
+ return NULL;
+ }
+
+ gtk_widget_set_size_request(entry, NSGTK_WEBSEARCH_WIDTH, -1);
+
+ nsgtk_entry_set_icon_from_stock(entry,
+ GTK_ENTRY_ICON_PRIMARY,
+ NSGTK_STOCK_INFO);
+
+ gtk_container_add(GTK_CONTAINER(item), entry);
+ }
+
+ return item;
+}
+
+
+/**
* widget factory for creation of toolbar item widgets
*
* \param i the id of the widget
@@ -585,81 +687,17 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
theme->image[HISTORY_BUTTON]), "H"));
break;
- case URL_BAR_ITEM: {
- /* create a gtk entry widget with a completion attached */
- GtkWidget *entry;
- GtkEntryCompletion *completion;
-
- w = GTK_WIDGET(gtk_tool_item_new());
- entry = nsgtk_entry_new();
- completion = gtk_entry_completion_new();
-
- if ((entry == NULL) || (completion == NULL) || (w == NULL)) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- return NULL;
- }
-
- gtk_entry_set_completion(GTK_ENTRY(entry), completion);
- gtk_container_add(GTK_CONTAINER(w), entry);
- gtk_tool_item_set_expand(GTK_TOOL_ITEM(w), TRUE);
+ case URL_BAR_ITEM:
+ w = GTK_WIDGET(make_toolbar_item_url_bar());
break;
- }
-
- case THROBBER_ITEM: {
- nserror res;
- GdkPixbuf *pixbuf;
- res = nsgtk_throbber_get_frame(0, &pixbuf);
- if (res != NSERROR_OK) {
- return NULL;
- }
-
- if (edit_mode) {
- w = GTK_WIDGET(gtk_tool_button_new(
- GTK_WIDGET(gtk_image_new_from_pixbuf(pixbuf)),
- "[throbber]"));
- } else {
- GtkWidget *image;
-
- w = GTK_WIDGET(gtk_tool_item_new());
-
- image = gtk_image_new_from_pixbuf(pixbuf);
- if (image != NULL) {
- nsgtk_widget_set_alignment(image,
- GTK_ALIGN_CENTER,
- GTK_ALIGN_CENTER);
- nsgtk_widget_set_margins(image, 3, 0);
-
- gtk_container_add(GTK_CONTAINER(w), image);
- }
- }
+ case THROBBER_ITEM:
+ w = GTK_WIDGET(make_toolbar_item_throbber());
break;
- }
-
- case WEBSEARCH_ITEM: {
- if (edit_mode)
- return GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET(
- nsgtk_image_new_from_stock(NSGTK_STOCK_FIND,
- GTK_ICON_SIZE_LARGE_TOOLBAR)),
- "[websearch]"));
-
- GtkWidget *entry = nsgtk_entry_new();
-
- w = GTK_WIDGET(gtk_tool_item_new());
-
- if ((entry == NULL) || (w == NULL)) {
- nsgtk_warning(messages_get("NoMemory"), 0);
- return NULL;
- }
-
- gtk_widget_set_size_request(entry, NSGTK_WEBSEARCH_WIDTH, -1);
-
- nsgtk_entry_set_icon_from_stock(entry, GTK_ENTRY_ICON_PRIMARY,
- NSGTK_STOCK_INFO);
- gtk_container_add(GTK_CONTAINER(w), entry);
+ case WEBSEARCH_ITEM:
+ w = GTK_WIDGET(make_toolbar_item_websearch());
break;
- }
/* gtk_tool_button_new accepts NULL args */
#define MAKE_MENUBUTTON(p, q) \
@@ -723,6 +761,11 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
break;
}
+
+ if (w == NULL) {
+ nsgtk_warning(messages_get("NoMemory"), 0);
+ }
+
return w;
}
@@ -1926,6 +1969,47 @@ reload_button_clicked_cb(GtkWidget *widget, gpointer data)
}
+/**
+ * handler for home 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
+home_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ nserror res;
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ const char *addr;
+ struct browser_window *bw;
+ nsurl *url;
+
+ if (nsoption_charp(homepage_url) != NULL) {
+ addr = nsoption_charp(homepage_url);
+ } else {
+ addr = NETSURF_HOMEPAGE;
+ }
+
+ res = nsurl_create(addr, &url);
+ if (res == NSERROR_OK) {
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ res = browser_window_navigate(bw,
+ url,
+ NULL,
+ BW_NAVIGATE_HISTORY,
+ NULL,
+ NULL,
+ NULL);
+ nsurl_unref(url);
+ }
+ if (res != NSERROR_OK) {
+ nsgtk_warning(messages_get_errorcode(res), 0);
+ }
+
+ return TRUE;
+}
/**
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index d82ca22..5281ab6 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -93,7 +93,7 @@ TOOLBAR_ITEM(HISTORY_BUTTON, history, true, localhistory_button_clicked_cb)
TOOLBAR_ITEM(FORWARD_BUTTON, forward, false, forward_button_clicked_cb)
TOOLBAR_ITEM(STOP_BUTTON, stop, false, stop_button_clicked_cb)
TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, reload_button_clicked_cb)
-TOOLBAR_ITEM(HOME_BUTTON, home, true, NULL)
+TOOLBAR_ITEM(HOME_BUTTON, home, true, home_button_clicked_cb)
TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true, NULL)
TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true, NULL)
TOOLBAR_ITEM(THROBBER_ITEM, throbber, true, NULL)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=305190fe730cf19e055...
commit 305190fe730cf19e0556ff8e24cbf85e63566de0
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
implement several more button press handlers
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 5c57011..b523645 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -54,6 +54,7 @@
#include "gtk/compat.h"
#include "gtk/warn.h"
#include "gtk/cookies.h"
+#include "gtk/completion.h"
#include "gtk/preferences.h"
#include "gtk/about.h"
#include "gtk/viewsource.h"
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 49e0af3..58611bd 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -27,7 +27,9 @@
#include <gtk/gtk.h>
#include "netsurf/browser_window.h"
+#include "desktop/browser_history.h"
#include "desktop/searchweb.h"
+#include "desktop/search.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "utils/nsoption.h"
@@ -46,6 +48,7 @@
#include "gtk/toolbar_items.h"
#include "gtk/toolbar.h"
#include "gtk/schedule.h"
+#include "gtk/local_history.h"
/**
* button location indicating button is not to be shown
@@ -64,8 +67,13 @@ struct nsgtk_toolbar_item {
GtkToolItem *button;
int location; /* in toolbar */
bool sensitivity;
+
+ /**
+ * button clicked handler
+ */
+ gboolean (*bhandler)(GtkWidget *widget, gpointer data);
+
void *mhandler; /* menu item clicked */
- void *bhandler; /* button clicked */
void *dataplus; /* customization -> toolbar */
void *dataminus; /* customization -> store */
};
@@ -1662,6 +1670,28 @@ itemid_from_gtktoolitem(struct nsgtk_toolbar *tb, GtkToolItem *toolitem)
/**
+ * set a toolbar items sensitivity
+ *
+ * note this does not set menu items sensitivity
+ */
+static nserror
+set_item_sensitivity(struct nsgtk_toolbar_item *item, bool sensitivity)
+{
+ if (item->sensitivity != sensitivity) {
+ /* item requires sensitivity changing */
+ item->sensitivity = sensitivity;
+
+ if ((item->location != -1) && (item->button != NULL)) {
+ gtk_widget_set_sensitive(GTK_WIDGET(item->button),
+ item->sensitivity);
+ }
+ }
+
+ return NSERROR_OK;
+}
+
+
+/**
* callback for all toolbar items widget size allocation
*
* handler connected to all toolbar items for the size-allocate signal
@@ -1763,6 +1793,38 @@ url_entry_changed_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
/**
+ * handler for back 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
+back_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_bw_ctx);
+
+ if ((bw != NULL) && browser_window_history_back_available(bw)) {
+ /* clear potential search effects */
+ browser_window_search_clear(bw);
+
+ browser_window_history_back(bw, false);
+
+ set_item_sensitivity(tb->buttons[BACK_BUTTON],
+ browser_window_history_back_available(bw));
+ set_item_sensitivity(tb->buttons[FORWARD_BUTTON],
+ browser_window_history_forward_available(bw));
+
+ nsgtk_local_history_hide();
+ }
+ return TRUE;
+}
+
+
+/**
* handler for local history tool bar item clicked signal
*
* \param widget The widget the signal is being delivered to.
@@ -1777,12 +1839,46 @@ localhistory_button_clicked_cb(GtkWidget *widget, gpointer data)
struct browser_window *bw;
GtkWidget *toplevel;
- toplevel = gtk_widget_get_toplevel(widget);
+ toplevel = gtk_widget_get_ancestor(widget, GTK_TYPE_WINDOW);
+ if (toplevel != NULL) {
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ res = nsgtk_local_history_present(GTK_WINDOW(toplevel), bw);
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, INFO,
+ "Unable to present local history window.");
+ }
+ }
+ return TRUE;
+}
+
+
+/**
+ * handler for forward 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
+forward_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_bw_ctx);
- res = nsgtk_local_history_present(toplevel, bw);
- if (res != NSERROR_OK) {
- NSLOG(netsurf, INFO, "Unable to present local history window.");
+ if ((bw != NULL) && browser_window_history_forward_available(bw)) {
+ /* clear potential search effects */
+ browser_window_search_clear(bw);
+
+ browser_window_history_forward(bw, false);
+
+ set_item_sensitivity(tb->buttons[BACK_BUTTON],
+ browser_window_history_back_available(bw));
+ set_item_sensitivity(tb->buttons[FORWARD_BUTTON],
+ browser_window_history_forward_available(bw));
+ nsgtk_local_history_hide();
}
return TRUE;
}
@@ -1805,6 +1901,33 @@ stop_button_clicked_cb(GtkWidget *widget, gpointer data)
return TRUE;
}
+
+/**
+ * handler for reload 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
+reload_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_bw_ctx);
+
+ /* clear potential search effects */
+ browser_window_search_clear(bw);
+
+ browser_window_reload(bw, true);
+
+ return TRUE;
+}
+
+
+
+
/**
* create a toolbar item
*
@@ -1842,28 +1965,6 @@ toolbar_item_create(nsgtk_toolbar_button id,
return NSERROR_OK;
}
-/**
- * set a toolbar items sensitivity
- *
- * note this does not set menu items sensitivity
- */
-static nserror
-set_item_sensitivity(struct nsgtk_toolbar_item *item, bool sensitivity)
-{
- if (item->sensitivity == sensitivity) {
- /* item does not require sensitivity changing */
- return NSERROR_OK;
- }
- item->sensitivity = sensitivity;
-
- if ((item->location != -1) && (item->button != NULL)) {
- gtk_widget_set_sensitive(GTK_WIDGET(item->button),
- item->sensitivity);
- }
-
- return NSERROR_OK;
-
-}
/**
* set a toolbar item to a throbber frame number
@@ -2121,6 +2222,9 @@ nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb)
nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active)
{
nserror res;
+ struct browser_window *bw;
+
+ bw = tb->get_bw(tb->get_bw_ctx);
/* when activating the throbber simply schedule the next frame update */
if (active) {
@@ -2141,6 +2245,11 @@ nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active)
/* adjust sensitivity of other items */
set_item_sensitivity(tb->buttons[STOP_BUTTON], false);
set_item_sensitivity(tb->buttons[RELOAD_BUTTON], true);
+ set_item_sensitivity(tb->buttons[BACK_BUTTON],
+ browser_window_history_back_available(bw));
+ set_item_sensitivity(tb->buttons[FORWARD_BUTTON],
+ browser_window_history_forward_available(bw));
+ nsgtk_local_history_hide();
return res;
}
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 5c6033c..d82ca22 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -88,11 +88,11 @@ typedef enum {
#define TOOLBAR_ITEM_SET
#endif
-TOOLBAR_ITEM(BACK_BUTTON, back, false, NULL)
+TOOLBAR_ITEM(BACK_BUTTON, back, false, back_button_clicked_cb)
TOOLBAR_ITEM(HISTORY_BUTTON, history, true, localhistory_button_clicked_cb)
-TOOLBAR_ITEM(FORWARD_BUTTON, forward, false, NULL)
+TOOLBAR_ITEM(FORWARD_BUTTON, forward, false, forward_button_clicked_cb)
TOOLBAR_ITEM(STOP_BUTTON, stop, false, stop_button_clicked_cb)
-TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, NULL)
+TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, reload_button_clicked_cb)
TOOLBAR_ITEM(HOME_BUTTON, home, true, NULL)
TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true, NULL)
TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true, NULL)
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=07a9d5b3fb1c8d956d4...
commit 07a9d5b3fb1c8d956d453e998c5903527f99f5e4
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
connect button clicked events for local history and stop buttons
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index a17ffd3..49e0af3 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -92,9 +92,6 @@ struct nsgtk_toolbar {
/** entry widget holding the url of the current displayed page */
GtkWidget *url_bar;
- /** Completions for url_bar */
- GtkEntryCompletion *url_bar_completion;
-
/** Current frame of throbber animation */
int throb_frame;
@@ -173,7 +170,7 @@ struct nsgtk_theme {
/* define data plus and data minus handlers */
-#define TOOLBAR_ITEM(identifier, name, sensitivity) \
+#define TOOLBAR_ITEM(identifier, name, sensitivity, clicked) \
static gboolean \
nsgtk_toolbar_##name##_data_plus(GtkWidget *widget, \
GdkDragContext *cont, \
@@ -594,7 +591,7 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
return NULL;
}
- gtk_entry_set_completion(entry, completion);
+ gtk_entry_set_completion(GTK_ENTRY(entry), completion);
gtk_container_add(GTK_CONTAINER(w), entry);
gtk_tool_item_set_expand(GTK_TOOL_ITEM(w), TRUE);
break;
@@ -658,14 +655,16 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
/* gtk_tool_button_new accepts NULL args */
#define MAKE_MENUBUTTON(p, q) \
- case p##_BUTTON: { \
- char *label = NULL; \
- label = remove_underscores(messages_get(#q), false); \
- w = GTK_WIDGET(gtk_tool_button_new(GTK_WIDGET( \
- theme->image[p##_BUTTON]), label)); \
- if (label != NULL) \
- free(label); \
- break; \
+ case p##_BUTTON: { \
+ char *label = NULL; \
+ label = remove_underscores(messages_get(#q), false); \
+ w = GTK_WIDGET(gtk_tool_button_new( \
+ GTK_WIDGET(theme->image[p##_BUTTON]), \
+ label)); \
+ if (label != NULL) { \
+ free(label); \
+ } \
+ break; \
}
MAKE_MENUBUTTON(NEWWINDOW, gtkNewWindow)
@@ -1414,17 +1413,6 @@ int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget,
return -1;
}
-/* exported interface documented in gtk/scaffolding.h */
-static void nsgtk_scaffolding_update_url_bar_ref(struct nsgtk_scaffolding *g)
-{
- #if 0
- g->url_bar = GTK_WIDGET(gtk_bin_get_child(GTK_BIN(
- g->buttons[URL_BAR_ITEM]->button)));
-
- gtk_entry_set_completion(GTK_ENTRY(g->url_bar),
- g->url_bar_completion);
- #endif
-}
/**
* add handlers to factory widgets
@@ -1436,7 +1424,6 @@ nsgtk_toolbar_set_handler(struct nsgtk_scaffolding *g, nsgtk_toolbar_button i)
{
switch(i) {
case URL_BAR_ITEM:
- nsgtk_scaffolding_update_url_bar_ref(g);
g_signal_connect(GTK_WIDGET(nsgtk_scaffolding_urlbar(g)),
"activate", G_CALLBACK(
nsgtk_window_url_activate_event), g);
@@ -1633,125 +1620,6 @@ static nserror populate_gtk_toolbar_widget(struct nsgtk_toolbar *tb)
return NSERROR_OK;
}
-/**
- * create a toolbar item
- *
- * create a toolbar item and set up its default handlers
- */
-static nserror
-toolbar_item_create(nsgtk_toolbar_button id,
- struct nsgtk_toolbar_item **item_out)
-{
- struct nsgtk_toolbar_item *item;
- item = calloc(1, sizeof(struct nsgtk_toolbar_item));
- if (item == NULL) {
- return NSERROR_NOMEM;
- }
- item->location = INACTIVE_LOCATION;
-
- switch (id) {
-#define TOOLBAR_ITEM(identifier, name, snstvty) \
- case identifier: \
- item->sensitivity = snstvty; \
- item->dataplus = nsgtk_toolbar_##name##_data_plus; \
- item->dataminus = nsgtk_toolbar_##name##_data_minus; \
- break;
-#include "gtk/toolbar_items.h"
-#undef TOOLBAR_ITEM
-
- case PLACEHOLDER_BUTTON:
- free(item);
- return NSERROR_INVALID;
- }
-
- *item_out = item;
- return NSERROR_OK;
-}
-
-/**
- * set a toolbar items sensitivity
- *
- * note this does not set menu items sensitivity
- */
-static nserror
-set_item_sensitivity(struct nsgtk_toolbar_item *item, bool sensitivity)
-{
- if (item->sensitivity == sensitivity) {
- /* item does not require sensitivity changing */
- return NSERROR_OK;
- }
- item->sensitivity = sensitivity;
-
- if ((item->location != -1) && (item->button != NULL)) {
- gtk_widget_set_sensitive(GTK_WIDGET(item->button),
- item->sensitivity);
- }
-
- return NSERROR_OK;
-
-}
-
-/**
- * set a toolbar item to a throbber frame number
- *
- * \param toolbar_item The toolbar item to update
- * \param frame The animation frame number to update to
- * \return NSERROR_OK on success,
- * NSERROR_INVALID if the toolbar item does not contain an image,
- * NSERROR_BAD_SIZE if the frame is out of range.
- */
-static nserror set_throbber_frame(GtkToolItem *toolbar_item, int frame)
-{
- nserror res;
- GdkPixbuf *pixbuf;
- GtkImage *throbber;
-
- if (toolbar_item == NULL) {
- /* no toolbar item */
- return NSERROR_INVALID;
- }
-
- res = nsgtk_throbber_get_frame(frame, &pixbuf);
- if (res != NSERROR_OK) {
- return res;
- }
-
- throbber = GTK_IMAGE(gtk_bin_get_child(GTK_BIN(toolbar_item)));
-
- gtk_image_set_from_pixbuf(throbber, pixbuf);
-
- return NSERROR_OK;
-}
-
-
-/**
- * Make the throbber run.
- *
- * scheduled callback to update the throbber
- *
- * \param p The context passed when scheduled.
- */
-static void next_throbber_frame(void *p)
-{
- struct nsgtk_toolbar *tb = p;
- nserror res;
-
- tb->throb_frame++; /* advance to next frame */
-
- res = set_throbber_frame(tb->buttons[THROBBER_ITEM]->button,
- tb->throb_frame);
- if (res == NSERROR_BAD_SIZE) {
- tb->throb_frame = 1;
- res = set_throbber_frame(tb->buttons[THROBBER_ITEM]->button,
- tb->throb_frame);
- }
-
- /* only schedule next frame if there are no errors */
- if (res == NSERROR_OK) {
- nsgtk_schedule(THROBBER_FRAME_TIME, next_throbber_frame, p);
- }
-}
-
/**
* find the toolbar item with a given location.
@@ -1876,6 +1744,7 @@ static gboolean url_entry_activate_cb(GtkWidget *widget, gpointer data)
return TRUE;
}
+
/**
* callback for url entry widget changing
*
@@ -1893,11 +1762,183 @@ url_entry_changed_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
}
+/**
+ * handler for local history 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
+localhistory_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ nserror res;
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ GtkWidget *toplevel;
+
+ toplevel = gtk_widget_get_toplevel(widget);
+ bw = tb->get_bw(tb->get_bw_ctx);
+
+ res = nsgtk_local_history_present(toplevel, bw);
+ if (res != NSERROR_OK) {
+ NSLOG(netsurf, INFO, "Unable to present local history window.");
+ }
+ return TRUE;
+}
+
+
+/**
+ * handler for 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
+stop_button_clicked_cb(GtkWidget *widget, gpointer data)
+{
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+
+ browser_window_stop(tb->get_bw(tb->get_bw_ctx));
+
+ return TRUE;
+}
+
+/**
+ * create a toolbar item
+ *
+ * create a toolbar item and set up its default handlers
+ */
+static nserror
+toolbar_item_create(nsgtk_toolbar_button id,
+ struct nsgtk_toolbar_item **item_out)
+{
+ struct nsgtk_toolbar_item *item;
+ item = calloc(1, sizeof(struct nsgtk_toolbar_item));
+ if (item == NULL) {
+ return NSERROR_NOMEM;
+ }
+ item->location = INACTIVE_LOCATION;
+
+ /* set item defaults from macro */
+ switch (id) {
+#define TOOLBAR_ITEM(identifier, name, snstvty, clicked) \
+ case identifier: \
+ item->sensitivity = snstvty; \
+ item->dataplus = nsgtk_toolbar_##name##_data_plus; \
+ item->dataminus = nsgtk_toolbar_##name##_data_minus; \
+ item->bhandler = clicked; \
+ break;
+#include "gtk/toolbar_items.h"
+#undef TOOLBAR_ITEM
+
+ case PLACEHOLDER_BUTTON:
+ free(item);
+ return NSERROR_INVALID;
+ }
+
+ *item_out = item;
+ return NSERROR_OK;
+}
+
+/**
+ * set a toolbar items sensitivity
+ *
+ * note this does not set menu items sensitivity
+ */
+static nserror
+set_item_sensitivity(struct nsgtk_toolbar_item *item, bool sensitivity)
+{
+ if (item->sensitivity == sensitivity) {
+ /* item does not require sensitivity changing */
+ return NSERROR_OK;
+ }
+ item->sensitivity = sensitivity;
+
+ if ((item->location != -1) && (item->button != NULL)) {
+ gtk_widget_set_sensitive(GTK_WIDGET(item->button),
+ item->sensitivity);
+ }
+
+ return NSERROR_OK;
+
+}
+
+/**
+ * set a toolbar item to a throbber frame number
+ *
+ * \param toolbar_item The toolbar item to update
+ * \param frame The animation frame number to update to
+ * \return NSERROR_OK on success,
+ * NSERROR_INVALID if the toolbar item does not contain an image,
+ * NSERROR_BAD_SIZE if the frame is out of range.
+ */
+static nserror set_throbber_frame(GtkToolItem *toolbar_item, int frame)
+{
+ nserror res;
+ GdkPixbuf *pixbuf;
+ GtkImage *throbber;
+
+ if (toolbar_item == NULL) {
+ /* no toolbar item */
+ return NSERROR_INVALID;
+ }
+
+ res = nsgtk_throbber_get_frame(frame, &pixbuf);
+ if (res != NSERROR_OK) {
+ return res;
+ }
+
+ throbber = GTK_IMAGE(gtk_bin_get_child(GTK_BIN(toolbar_item)));
+
+ gtk_image_set_from_pixbuf(throbber, pixbuf);
+
+ return NSERROR_OK;
+}
+
+
+/**
+ * Make the throbber run.
+ *
+ * scheduled callback to update the throbber
+ *
+ * \param p The context passed when scheduled.
+ */
+static void next_throbber_frame(void *p)
+{
+ struct nsgtk_toolbar *tb = p;
+ nserror res;
+
+ tb->throb_frame++; /* advance to next frame */
+
+ res = set_throbber_frame(tb->buttons[THROBBER_ITEM]->button,
+ tb->throb_frame);
+ if (res == NSERROR_BAD_SIZE) {
+ tb->throb_frame = 1;
+ res = set_throbber_frame(tb->buttons[THROBBER_ITEM]->button,
+ tb->throb_frame);
+ }
+
+ /* only schedule next frame if there are no errors */
+ if (res == NSERROR_OK) {
+ nsgtk_schedule(THROBBER_FRAME_TIME, next_throbber_frame, p);
+ }
+}
+
+
+/**
+ * connect signal handlers to a gtk toolbar item
+ */
static nserror
toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
{
- if (tb->buttons[itemid]->button != NULL) {
- g_signal_connect(tb->buttons[itemid]->button,
+ struct nsgtk_toolbar_item *item;
+
+ item = tb->buttons[itemid];
+
+ if (item->button != NULL) {
+ g_signal_connect(item->button,
"size-allocate",
G_CALLBACK(toolbar_item_size_allocate_cb),
tb);
@@ -1906,8 +1947,7 @@ toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
switch (itemid) {
case URL_BAR_ITEM: {
GtkEntry *url_entry;
- url_entry = GTK_ENTRY(gtk_bin_get_child(
- GTK_BIN(tb->buttons[itemid]->button)));
+ url_entry = GTK_ENTRY(gtk_bin_get_child(GTK_BIN(item->button)));
g_signal_connect(GTK_WIDGET(url_entry),
"activate",
G_CALLBACK(url_entry_activate_cb),
@@ -1922,6 +1962,16 @@ toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
tb->get_bw_ctx);
break;
}
+
+ default:
+ if ((item->bhandler != NULL) && (item->button != NULL)) {
+ g_signal_connect(item->button,
+ "clicked",
+ G_CALLBACK(item->bhandler),
+ tb);
+ }
+ break;
+
}
return NSERROR_OK;
@@ -1965,8 +2015,11 @@ nsgtk_toolbar_create(GtkBuilder *builder,
tb->get_bw = get_bw;
tb->get_bw_ctx = get_bw_ctx;
+ /* set the throbber start frame. */
+ tb->throb_frame = 0;
tb->widget = GTK_TOOLBAR(gtk_builder_get_object(builder, "toolbar"));
+ gtk_toolbar_set_show_arrow(tb->widget, TRUE);
/* allocate button contexts */
for (bidx = BACK_BUTTON; bidx < PLACEHOLDER_BUTTON; bidx++) {
@@ -1998,7 +2051,6 @@ nsgtk_toolbar_create(GtkBuilder *builder,
return res;
}
- gtk_toolbar_set_show_arrow(tb->widget, TRUE);
gtk_widget_show_all(GTK_WIDGET(tb->widget));
/* if there is a history widget set its size */
@@ -2007,9 +2059,6 @@ nsgtk_toolbar_create(GtkBuilder *builder,
tb->buttons[HISTORY_BUTTON]->button), 20, -1);
}
- /* set the throbber start frame. */
- tb->throb_frame = 0;
-
res = toolbar_connect_signals(tb);
if (res != NSERROR_OK) {
free(tb);
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index 9c410d1..f04d807 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -32,8 +32,7 @@ struct nsgtk_toolbar;
* \param[out] toolbar a pointer to receive the result.
* \return NSERROR_OK and toolbar updated on success else error code
*/
-nserror nsgtk_toolbar_create(GtkBuilder *builder, struct browser_window *(*get_bw)(void *ctx),
- void *get_bw_ctx,struct nsgtk_toolbar **toolbar);
+nserror nsgtk_toolbar_create(GtkBuilder *builder, struct browser_window *(*get_bw)(void *ctx), void *get_bw_ctx,struct nsgtk_toolbar **toolbar);
/**
diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h
index 0e1eae4..5c6033c 100644
--- a/frontends/gtk/toolbar_items.h
+++ b/frontends/gtk/toolbar_items.h
@@ -84,61 +84,61 @@ typedef enum {
*/
#ifndef TOOLBAR_ITEM
-#define TOOLBAR_ITEM(a, b, c)
+#define TOOLBAR_ITEM(a, b, c, d)
#define TOOLBAR_ITEM_SET
#endif
-TOOLBAR_ITEM(BACK_BUTTON, back, false)
-TOOLBAR_ITEM(HISTORY_BUTTON, history, true)
-TOOLBAR_ITEM(FORWARD_BUTTON, forward, false)
-TOOLBAR_ITEM(STOP_BUTTON, stop, false)
-TOOLBAR_ITEM(RELOAD_BUTTON, reload, true)
-TOOLBAR_ITEM(HOME_BUTTON, home, true)
-TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true)
-TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true)
-TOOLBAR_ITEM(THROBBER_ITEM, throbber, true)
-TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true)
-TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true)
-TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true)
-TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false)
-TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true)
-TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true)
-TOOLBAR_ITEM(PDF_BUTTON, pdf, false)
-TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true)
-TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false)
-TOOLBAR_ITEM(POSTSCRIPT_BUTTON, postscript, false)
-TOOLBAR_ITEM(PRINTPREVIEW_BUTTON, printpreview, false)
-TOOLBAR_ITEM(PRINT_BUTTON, print, true)
-TOOLBAR_ITEM(QUIT_BUTTON, quit, true)
-TOOLBAR_ITEM(CUT_BUTTON, cut, true)
-TOOLBAR_ITEM(COPY_BUTTON, copy, true)
-TOOLBAR_ITEM(PASTE_BUTTON, paste, true)
-TOOLBAR_ITEM(DELETE_BUTTON, delete, false)
-TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true)
-TOOLBAR_ITEM(FIND_BUTTON, find, true)
-TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true)
-TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true)
-TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true)
-TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true)
-TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true)
-TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true)
-TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true)
-TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true)
-TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true)
-TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true)
-TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true)
-TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true)
-TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true)
-TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true)
-TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true)
-TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true)
-TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true)
-TOOLBAR_ITEM(NEXTTAB_BUTTON, nexttab, false)
-TOOLBAR_ITEM(PREVTAB_BUTTON, prevtab, false)
-TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true)
-TOOLBAR_ITEM(GUIDE_BUTTON, guide, true)
-TOOLBAR_ITEM(INFO_BUTTON, info, true)
-TOOLBAR_ITEM(ABOUT_BUTTON, about, true)
+TOOLBAR_ITEM(BACK_BUTTON, back, false, NULL)
+TOOLBAR_ITEM(HISTORY_BUTTON, history, true, localhistory_button_clicked_cb)
+TOOLBAR_ITEM(FORWARD_BUTTON, forward, false, NULL)
+TOOLBAR_ITEM(STOP_BUTTON, stop, false, stop_button_clicked_cb)
+TOOLBAR_ITEM(RELOAD_BUTTON, reload, true, NULL)
+TOOLBAR_ITEM(HOME_BUTTON, home, true, NULL)
+TOOLBAR_ITEM(URL_BAR_ITEM, url_bar, true, NULL)
+TOOLBAR_ITEM(WEBSEARCH_ITEM, websearch, true, NULL)
+TOOLBAR_ITEM(THROBBER_ITEM, throbber, true, NULL)
+TOOLBAR_ITEM(NEWWINDOW_BUTTON, newwindow, true, NULL)
+TOOLBAR_ITEM(NEWTAB_BUTTON, newtab, true, NULL)
+TOOLBAR_ITEM(OPENFILE_BUTTON, openfile, true, NULL)
+TOOLBAR_ITEM(CLOSETAB_BUTTON, closetab, false, NULL)
+TOOLBAR_ITEM(CLOSEWINDOW_BUTTON, closewindow, true, NULL)
+TOOLBAR_ITEM(SAVEPAGE_BUTTON, savepage, true, NULL)
+TOOLBAR_ITEM(PDF_BUTTON, pdf, false, NULL)
+TOOLBAR_ITEM(PLAINTEXT_BUTTON, plaintext, true, NULL)
+TOOLBAR_ITEM(DRAWFILE_BUTTON, drawfile, false, NULL)
+TOOLBAR_ITEM(POSTSCRIPT_BUTTON, postscript, false, NULL)
+TOOLBAR_ITEM(PRINTPREVIEW_BUTTON, printpreview, false, NULL)
+TOOLBAR_ITEM(PRINT_BUTTON, print, true, NULL)
+TOOLBAR_ITEM(QUIT_BUTTON, quit, true, NULL)
+TOOLBAR_ITEM(CUT_BUTTON, cut, true, NULL)
+TOOLBAR_ITEM(COPY_BUTTON, copy, true, NULL)
+TOOLBAR_ITEM(PASTE_BUTTON, paste, true, NULL)
+TOOLBAR_ITEM(DELETE_BUTTON, delete, false, NULL)
+TOOLBAR_ITEM(SELECTALL_BUTTON, selectall, true, NULL)
+TOOLBAR_ITEM(FIND_BUTTON, find, true, NULL)
+TOOLBAR_ITEM(PREFERENCES_BUTTON, preferences, true, NULL)
+TOOLBAR_ITEM(ZOOMPLUS_BUTTON, zoomplus, true, NULL)
+TOOLBAR_ITEM(ZOOMMINUS_BUTTON, zoomminus, true, NULL)
+TOOLBAR_ITEM(ZOOMNORMAL_BUTTON, zoomnormal, true, NULL)
+TOOLBAR_ITEM(FULLSCREEN_BUTTON, fullscreen, true, NULL)
+TOOLBAR_ITEM(VIEWSOURCE_BUTTON, viewsource, true, NULL)
+TOOLBAR_ITEM(DOWNLOADS_BUTTON, downloads, true, NULL)
+TOOLBAR_ITEM(SAVEWINDOWSIZE_BUTTON, savewindowsize, true, NULL)
+TOOLBAR_ITEM(TOGGLEDEBUGGING_BUTTON, toggledebugging, true, NULL)
+TOOLBAR_ITEM(SAVEBOXTREE_BUTTON, debugboxtree, true, NULL)
+TOOLBAR_ITEM(SAVEDOMTREE_BUTTON, debugdomtree, true, NULL)
+TOOLBAR_ITEM(LOCALHISTORY_BUTTON, localhistory, true, localhistory_button_clicked_cb)
+TOOLBAR_ITEM(GLOBALHISTORY_BUTTON, globalhistory, true, NULL)
+TOOLBAR_ITEM(ADDBOOKMARKS_BUTTON, addbookmarks, true, NULL)
+TOOLBAR_ITEM(SHOWBOOKMARKS_BUTTON, showbookmarks, true, NULL)
+TOOLBAR_ITEM(SHOWCOOKIES_BUTTON, showcookies, true, NULL)
+TOOLBAR_ITEM(OPENLOCATION_BUTTON, openlocation, true, NULL)
+TOOLBAR_ITEM(NEXTTAB_BUTTON, nexttab, false, NULL)
+TOOLBAR_ITEM(PREVTAB_BUTTON, prevtab, false, NULL)
+TOOLBAR_ITEM(CONTENTS_BUTTON, contents, true, NULL)
+TOOLBAR_ITEM(GUIDE_BUTTON, guide, true, NULL)
+TOOLBAR_ITEM(INFO_BUTTON, info, true, NULL)
+TOOLBAR_ITEM(ABOUT_BUTTON, about, true, NULL)
#ifdef TOOLBAR_ITEM_SET
#undef TOOLBAR_ITEM
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=8b5100a97e302ea11b0...
commit 8b5100a97e302ea11b00c9780c5071703ddf2027
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
fix url enttry completion
diff --git a/frontends/gtk/completion.c b/frontends/gtk/completion.c
index 3da3410..983ecab 100644
--- a/frontends/gtk/completion.c
+++ b/frontends/gtk/completion.c
@@ -37,6 +37,18 @@
GtkListStore *nsgtk_completion_list;
+struct nsgtk_completion_ctx {
+ /**
+ * callback to obtain a browser window for navigation
+ */
+ struct browser_window *(*get_bw)(void *ctx);
+
+ /**
+ * context passed to get_bw function
+ */
+ void *get_bw_ctx;
+};
+
/**
* completion row matcher
*/
@@ -50,7 +62,6 @@ static gboolean nsgtk_completion_match(GtkEntryCompletion *completion,
* are in the list should be shown.
*/
return TRUE;
-
}
@@ -77,14 +88,17 @@ static gboolean
nsgtk_completion_match_select(GtkEntryCompletion *widget,
GtkTreeModel *model,
GtkTreeIter *iter,
- gpointer user_data)
+ gpointer data)
{
+ struct nsgtk_completion_ctx *cb_ctx;
GValue value = G_VALUE_INIT;
- struct nsgtk_scaffolding *g = user_data;
- struct browser_window *bw = nsgtk_get_browser_window(nsgtk_scaffolding_top_level(g));
+ struct browser_window *bw;
nserror ret;
nsurl *url;
+ cb_ctx = data;
+ bw = cb_ctx->get_bw(cb_ctx->get_bw_ctx);
+
gtk_tree_model_get_value(model, iter, 0, &value);
ret = search_web_omni(g_value_get_string(&value),
@@ -127,11 +141,20 @@ gboolean nsgtk_completion_update(GtkEntry *entry)
}
/* exported interface documented in completion.h */
-GtkEntryCompletion *nsgtk_url_entry_completion_new(struct nsgtk_scaffolding *gs)
+nserror
+nsgtk_completion_connect_signals(GtkEntry *entry,
+ struct browser_window *(*get_bw)(void *ctx),
+ void *get_bw_ctx)
{
GtkEntryCompletion *completion;
+ struct nsgtk_completion_ctx *cb_ctx;
+
+ cb_ctx = calloc(1, sizeof(struct nsgtk_completion_ctx));
+ cb_ctx->get_bw = get_bw;
+ cb_ctx->get_bw_ctx = get_bw_ctx;
+
+ completion = gtk_entry_get_completion(entry);
- completion = gtk_entry_completion_new();
gtk_entry_completion_set_match_func(completion,
nsgtk_completion_match, NULL, NULL);
@@ -146,13 +169,15 @@ GtkEntryCompletion *nsgtk_url_entry_completion_new(struct nsgtk_scaffolding *gs)
gtk_entry_completion_set_popup_completion(completion, TRUE);
/* when selected callback */
- g_signal_connect(G_OBJECT(completion), "match-selected",
- G_CALLBACK(nsgtk_completion_match_select), gs);
+ g_signal_connect(G_OBJECT(completion),
+ "match-selected",
+ G_CALLBACK(nsgtk_completion_match_select),
+ cb_ctx);
g_object_set(G_OBJECT(completion),
- "popup-set-width", TRUE,
- "popup-single-match", TRUE,
- NULL);
+ "popup-set-width", TRUE,
+ "popup-single-match", TRUE,
+ NULL);
- return completion;
+ return NSERROR_OK;
}
diff --git a/frontends/gtk/completion.h b/frontends/gtk/completion.h
index 9a1db29..a81f130 100644
--- a/frontends/gtk/completion.h
+++ b/frontends/gtk/completion.h
@@ -37,10 +37,11 @@ void nsgtk_completion_init(void);
gboolean nsgtk_completion_update(GtkEntry *entry);
/**
- * create a new entry completion on a scaffold.
- *
- * \param gs The scaffoliding which the url entry is in.
+ * connect signals on entry completion
*/
-GtkEntryCompletion *nsgtk_url_entry_completion_new(struct nsgtk_scaffolding *gs);
+nserror
+nsgtk_completion_connect_signals(GtkEntry *entry,
+ struct browser_window *(*get_bw)(void *ctx),
+ void *get_bw_ctx);
#endif
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 7ebf2eb..a17ffd3 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -105,6 +105,10 @@ struct nsgtk_toolbar {
* callback to obtain a browser window for navigation
*/
struct browser_window *(*get_bw)(void *ctx);
+
+ /**
+ * context passed to get_bw function
+ */
void *get_bw_ctx;
};
@@ -577,14 +581,20 @@ make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme)
break;
case URL_BAR_ITEM: {
- GtkWidget *entry = nsgtk_entry_new();
+ /* create a gtk entry widget with a completion attached */
+ GtkWidget *entry;
+ GtkEntryCompletion *completion;
+
w = GTK_WIDGET(gtk_tool_item_new());
+ entry = nsgtk_entry_new();
+ completion = gtk_entry_completion_new();
- if ((entry == NULL) || (w == NULL)) {
+ if ((entry == NULL) || (completion == NULL) || (w == NULL)) {
nsgtk_warning(messages_get("NoMemory"), 0);
return NULL;
}
+ gtk_entry_set_completion(entry, completion);
gtk_container_add(GTK_CONTAINER(w), entry);
gtk_tool_item_set_expand(GTK_TOOL_ITEM(w), TRUE);
break;
@@ -1906,9 +1916,13 @@ toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
"changed",
G_CALLBACK(url_entry_changed_cb),
tb);
- }
+
+ nsgtk_completion_connect_signals(url_entry,
+ tb->get_bw,
+ tb->get_bw_ctx);
break;
}
+ }
return NSERROR_OK;
}
@@ -1996,10 +2010,6 @@ nsgtk_toolbar_create(GtkBuilder *builder,
/* set the throbber start frame. */
tb->throb_frame = 0;
- /* set up URL bar completion */
- /** \todo sort out completion */
- //tb->url_bar_completion = nsgtk_url_entry_completion_new(gs);
-
res = toolbar_connect_signals(tb);
if (res != NSERROR_OK) {
free(tb);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=869c16dae60b519013b...
commit 869c16dae60b519013bde67c443ce737bbb20ccf
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
cleanup toolbar warnings
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index b523645..5c57011 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -54,7 +54,6 @@
#include "gtk/compat.h"
#include "gtk/warn.h"
#include "gtk/cookies.h"
-#include "gtk/completion.h"
#include "gtk/preferences.h"
#include "gtk/about.h"
#include "gtk/viewsource.h"
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index 209f8d7..7ebf2eb 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -34,6 +34,7 @@
#include "utils/file.h"
#include "utils/nsurl.h"
+#include "gtk/completion.h"
#include "gtk/gui.h"
#include "gtk/warn.h"
#include "gtk/search.h"
@@ -1905,8 +1906,8 @@ toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
"changed",
G_CALLBACK(url_entry_changed_cb),
tb);
- }
-
+ }
+ break;
}
return NSERROR_OK;
@@ -1915,7 +1916,7 @@ toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
/**
* connect all signals to widgets in a toolbar
*/
-nserror toolbar_connect_signals(struct nsgtk_toolbar *tb)
+static nserror toolbar_connect_signals(struct nsgtk_toolbar *tb)
{
int location; /* location index */
nsgtk_toolbar_button itemid; /* item id */
@@ -2061,7 +2062,6 @@ nserror nsgtk_toolbar_update(struct nsgtk_toolbar *tb)
nserror nsgtk_toolbar_throbber(struct nsgtk_toolbar *tb, bool active)
{
nserror res;
- GdkPixbuf *pixbuf;
/* when activating the throbber simply schedule the next frame update */
if (active) {
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=bd90138b482c8561927...
commit bd90138b482c8561927c2d6a75c172415e583a16
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
make url entry repond to navigate and update signals
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 15a36a4..b523645 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -75,7 +75,6 @@
#include "gtk/gdk.h"
#include "gtk/scaffolding.h"
#include "gtk/tabs.h"
-#include "gtk/schedule.h"
#include "gtk/viewdata.h"
#include "gtk/resources.h"
#include "gtk/layout_pango.h"
diff --git a/frontends/gtk/toolbar.c b/frontends/gtk/toolbar.c
index db43aab..209f8d7 100644
--- a/frontends/gtk/toolbar.c
+++ b/frontends/gtk/toolbar.c
@@ -44,6 +44,7 @@
#include "gtk/resources.h"
#include "gtk/toolbar_items.h"
#include "gtk/toolbar.h"
+#include "gtk/schedule.h"
/**
* button location indicating button is not to be shown
@@ -76,12 +77,17 @@ struct nsgtk_toolbar {
/** gtk toolbar widget */
GtkToolbar *widget;
- struct nsgtk_toolbar_item *buttons[PLACEHOLDER_BUTTON];
+ /* toolbar size allocation context */
int offset;
int toolbarmem;
int toolbarbase;
int historybase;
+ /**
+ * Toolbar item contexts
+ */
+ struct nsgtk_toolbar_item *buttons[PLACEHOLDER_BUTTON];
+
/** entry widget holding the url of the current displayed page */
GtkWidget *url_bar;
@@ -94,6 +100,11 @@ struct nsgtk_toolbar {
/** Web search widget */
GtkWidget *webSearchEntry;
+ /**
+ * callback to obtain a browser window for navigation
+ */
+ struct browser_window *(*get_bw)(void *ctx);
+ void *get_bw_ctx;
};
@@ -1559,7 +1570,7 @@ add_item_to_toolbar(struct nsgtk_toolbar *tb,
make_toolbar_item(bidx, theme));
/* set widgets initial sensitivity */
- gtk_widget_set_sensitive(tb->buttons[bidx]->button,
+ gtk_widget_set_sensitive(GTK_WIDGET(tb->buttons[bidx]->button),
tb->buttons[bidx]->sensitivity);
gtk_toolbar_insert(tb->widget,
@@ -1754,16 +1765,16 @@ itemid_from_location(struct nsgtk_toolbar *tb, int location)
* find the toolbar item with a given gtk widget.
*
* \param tb the toolbar instance
- * \param widget the widget to search for
+ * \param toolitem the tool item widget to search for
* \return the item id matching the widget
*/
static nsgtk_toolbar_button
-itemid_from_gtkwidget(struct nsgtk_toolbar *tb, GtkWidget *widget)
+itemid_from_gtktoolitem(struct nsgtk_toolbar *tb, GtkToolItem *toolitem)
{
int iidx;
for (iidx = BACK_BUTTON; iidx < PLACEHOLDER_BUTTON; iidx++) {
if ((tb->buttons[iidx]->location != INACTIVE_LOCATION) &&
- (tb->buttons[iidx]->button == widget)) {
+ (tb->buttons[iidx]->button == toolitem)) {
break;
}
}
@@ -1772,15 +1783,23 @@ itemid_from_gtkwidget(struct nsgtk_toolbar *tb, GtkWidget *widget)
/**
- * callback for toolbar widgets size allocation
+ * callback for all toolbar items widget size allocation
+ *
+ * handler connected to all toolbar items for the size-allocate signal
+ *
+ * \param widget The widget the signal is being delivered to.
+ * \param alloc The size allocation being set.
+ * \param data The toolbar context passed when the signal was connected
*/
static void
-toolbar_size_allocate_cb(GtkWidget *widget, GtkAllocation *alloc, gpointer data)
+toolbar_item_size_allocate_cb(GtkWidget *widget,
+ GtkAllocation *alloc,
+ gpointer data)
{
struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
nsgtk_toolbar_button itemid;
- itemid = itemid_from_gtkwidget(tb, widget);
+ itemid = itemid_from_gtktoolitem(tb, GTK_TOOL_ITEM(widget));
if ((tb->toolbarmem == alloc->x) ||
(tb->buttons[itemid]->location < tb->buttons[HISTORY_BUTTON]->location)) {
@@ -1814,16 +1833,83 @@ toolbar_size_allocate_cb(GtkWidget *widget, GtkAllocation *alloc, gpointer data)
}
+/**
+ * callback for url entry widget activation
+ *
+ * handler connected to url entry widget for the activate signal
+ *
+ * \param widget The widget the signal is being delivered to.
+ * \param data The toolbar context passed when the signal was connected
+ * \return TRUE to allow activation.
+ */
+static gboolean url_entry_activate_cb(GtkWidget *widget, gpointer data)
+{
+ nserror res;
+ struct nsgtk_toolbar *tb = (struct nsgtk_toolbar *)data;
+ struct browser_window *bw;
+ nsurl *url;
+
+ res = search_web_omni(gtk_entry_get_text(GTK_ENTRY(widget)),
+ SEARCH_WEB_OMNI_NONE,
+ &url);
+ if (res == NSERROR_OK) {
+ bw = tb->get_bw(tb->get_bw_ctx);
+ res = browser_window_navigate(
+ bw, url, NULL, BW_NAVIGATE_HISTORY, NULL, NULL, NULL);
+ nsurl_unref(url);
+ }
+ if (res != NSERROR_OK) {
+ nsgtk_warning(messages_get_errorcode(res), 0);
+ }
+
+ return TRUE;
+}
+
+/**
+ * callback for url entry widget changing
+ *
+ * handler connected to url entry widget for the change signal
+ *
+ * \param widget The widget the signal is being delivered to.
+ * \param event The key change event that changed the entry.
+ * \param data The toolbar context passed when the signal was connected
+ * \return TRUE to allow activation.
+ */
+static gboolean
+url_entry_changed_cb(GtkWidget *widget, GdkEventKey *event, gpointer data)
+{
+ return nsgtk_completion_update(GTK_ENTRY(widget));
+}
+
+
static nserror
toolbar_connect_signal(struct nsgtk_toolbar *tb, nsgtk_toolbar_button itemid)
{
if (tb->buttons[itemid]->button != NULL) {
g_signal_connect(tb->buttons[itemid]->button,
"size-allocate",
- G_CALLBACK(toolbar_size_allocate_cb),
+ G_CALLBACK(toolbar_item_size_allocate_cb),
tb);
}
+ switch (itemid) {
+ case URL_BAR_ITEM: {
+ GtkEntry *url_entry;
+ url_entry = GTK_ENTRY(gtk_bin_get_child(
+ GTK_BIN(tb->buttons[itemid]->button)));
+ g_signal_connect(GTK_WIDGET(url_entry),
+ "activate",
+ G_CALLBACK(url_entry_activate_cb),
+ tb);
+ g_signal_connect(GTK_WIDGET(url_entry),
+ "changed",
+ G_CALLBACK(url_entry_changed_cb),
+ tb);
+ }
+
+ }
+
+ return NSERROR_OK;
}
/**
@@ -1847,7 +1933,11 @@ nserror toolbar_connect_signals(struct nsgtk_toolbar *tb)
}
/* exported interface documented in toolbar.h */
-nserror nsgtk_toolbar_create(GtkBuilder *builder, struct nsgtk_toolbar **tb_out)
+nserror
+nsgtk_toolbar_create(GtkBuilder *builder,
+ struct browser_window *(*get_bw)(void *ctx),
+ void *get_bw_ctx,
+ struct nsgtk_toolbar **tb_out)
{
nserror res;
struct nsgtk_toolbar *tb;
@@ -1858,6 +1948,9 @@ nserror nsgtk_toolbar_create(GtkBuilder *builder, struct nsgtk_toolbar **tb_out)
return NSERROR_NOMEM;
}
+ tb->get_bw = get_bw;
+ tb->get_bw_ctx = get_bw_ctx;
+
tb->widget = GTK_TOOLBAR(gtk_builder_get_object(builder, "toolbar"));
/* allocate button contexts */
diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h
index 57320d3..9c410d1 100644
--- a/frontends/gtk/toolbar.h
+++ b/frontends/gtk/toolbar.h
@@ -32,7 +32,8 @@ struct nsgtk_toolbar;
* \param[out] toolbar a pointer to receive the result.
* \return NSERROR_OK and toolbar updated on success else error code
*/
-nserror nsgtk_toolbar_create(GtkBuilder *builder, struct nsgtk_toolbar **toolbar);
+nserror nsgtk_toolbar_create(GtkBuilder *builder, struct browser_window *(*get_bw)(void *ctx),
+ void *get_bw_ctx,struct nsgtk_toolbar **toolbar);
/**
diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c
index 2ba4b89..ce67004 100644
--- a/frontends/gtk/window.c
+++ b/frontends/gtk/window.c
@@ -706,6 +706,13 @@ static void window_destroy(GtkWidget *widget, gpointer data)
}
+
+static struct browser_window *bw_from_gw(void *data)
+{
+ struct gui_window *gw = data;
+ return gw->bw;
+}
+
/**
* Create and open a gtk container (window or tab) for a browsing context.
*
@@ -779,7 +786,7 @@ gui_window_create(struct browser_window *bw,
g->input_method = gtk_im_multicontext_new();
- res = nsgtk_toolbar_create(tab_builder, &g->toolbar);
+ res = nsgtk_toolbar_create(tab_builder, bw_from_gw, g, &g->toolbar);
if (res != NSERROR_OK) {
free(g);
g_object_unref(tab_builder);
commitdiff http://git.netsurf-browser.org/netsurf.git/commit/?id=dd767acfee416a65e67...
commit dd767acfee416a65e67193a9740d2b636b868e11
Author: Vincent Sanders <vince(a)kyllikki.org>
Commit: Daniel Silverstone <dsilvers(a)digital-scurf.org>
make toolbar url entry display url
diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c
index 6ff62a1..15a36a4 100644
--- a/frontends/gtk/scaffolding.c
+++ b/frontends/gtk/scaffolding.c
@@ -2074,29 +2074,6 @@ void nsgtk_window_set_title(struct gui_window *gw, const char *title)
}
-nserror gui_window_set_url(struct gui_window *gw, nsurl *url)
-{
- struct nsgtk_scaffolding *g;
- size_t idn_url_l;
- char *idn_url_s = NULL;
-
- g = nsgtk_get_scaffold(gw);
- if (g->top_level == gw) {
- if (nsoption_bool(display_decoded_idn) == true) {
- if (nsurl_get_utf8(url, &idn_url_s, &idn_url_l) != NSERROR_OK)
- idn_url_s = NULL;
- }
-#if 0
- gtk_entry_set_text(GTK_ENTRY(g->url_bar), idn_url_s ? idn_url_s : nsurl_access(url));
-#endif
-
- if(idn_url_s)
- free(idn_url_s);
-
- //gtk_editable_set_position(GTK_EDITABLE(g->url_bar), -1);
- }
- return NSERROR_OK;
-}
#if 0
diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h
index c5f8a47..19f8681 100644
--- a/frontends/gtk/scaffolding.h
+++ b/frontends/gtk/scaffolding