mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-26 16:29:36 +03:00
make popup context menu work on toolbar
This commit is contained in:
parent
e36338b617
commit
e84990bc89
@ -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;
|
||||
}
|
||||
|
||||
|
||||
@ -573,6 +533,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
|
||||
*/
|
||||
@ -623,117 +595,6 @@ MENUHANDLER(closewindow, CLOSEWINDOW_BUTTON);
|
||||
*/
|
||||
MENUHANDLER(quit, QUIT_BUTTON);
|
||||
|
||||
|
||||
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;
|
||||
struct browser_window *bw = nsgtk_get_browser_window(gui);
|
||||
nserror err;
|
||||
|
||||
if (current_menu_features.link == NULL)
|
||||
return FALSE;
|
||||
|
||||
err = browser_window_navigate(bw,
|
||||
current_menu_features.link,
|
||||
NULL,
|
||||
BW_NAVIGATE_DOWNLOAD,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
if (err != NSERROR_OK) {
|
||||
nsgtk_warning(messages_get_errorcode(err), 0);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for opening new window from a link. attached to the popup menu.
|
||||
*/
|
||||
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;
|
||||
struct browser_window *bw = nsgtk_get_browser_window(gui);
|
||||
nserror err;
|
||||
|
||||
if (current_menu_features.link == NULL)
|
||||
return FALSE;
|
||||
|
||||
err = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY,
|
||||
current_menu_features.link, NULL, bw, NULL);
|
||||
if (err != NSERROR_OK) {
|
||||
nsgtk_warning(messages_get_errorcode(err), 0);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for opening new tab from a link. attached to the popup menu.
|
||||
*/
|
||||
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;
|
||||
struct browser_window *bw = nsgtk_get_browser_window(gui);
|
||||
nserror err;
|
||||
|
||||
if (current_menu_features.link == NULL)
|
||||
return FALSE;
|
||||
|
||||
temp_open_background = 1;
|
||||
|
||||
err = browser_window_create(BW_CREATE_CLONE |
|
||||
BW_CREATE_HISTORY |
|
||||
BW_CREATE_TAB,
|
||||
current_menu_features.link, NULL, bw, NULL);
|
||||
if (err != NSERROR_OK) {
|
||||
nsgtk_warning(messages_get_errorcode(err), 0);
|
||||
}
|
||||
|
||||
temp_open_background = -1;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for bookmarking a link. attached to the popup menu.
|
||||
*/
|
||||
static gboolean
|
||||
nsgtk_on_link_bookmark_activate_menu(GtkMenuItem *widget, gpointer data)
|
||||
{
|
||||
if (current_menu_features.link == NULL)
|
||||
return FALSE;
|
||||
|
||||
hotlist_add_url(current_menu_features.link);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler for copying a link. attached to the popup menu.
|
||||
*/
|
||||
static gboolean
|
||||
nsgtk_on_link_copy_activate_menu(GtkMenuItem *widget, gpointer data)
|
||||
{
|
||||
GtkClipboard *clipboard;
|
||||
|
||||
if (current_menu_features.link == NULL)
|
||||
return FALSE;
|
||||
|
||||
clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
|
||||
gtk_clipboard_set_text(clipboard,
|
||||
nsurl_access(current_menu_features.link), -1);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* menu signal handler for activation on cut item
|
||||
*/
|
||||
@ -755,26 +616,12 @@ MENUHANDLER(paste, PASTE_BUTTON);
|
||||
MENUHANDLER(delete, DELETE_BUTTON);
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* menu signal handler for activation on selectall item
|
||||
*/
|
||||
MENUHANDLER(selectall, SELECTALL_BUTTON);
|
||||
|
||||
|
||||
MULTIHANDLER(find)
|
||||
{
|
||||
nsgtk_scaffolding_toggle_search_bar_visibility(g);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* menu signal handler for activation on preferences item
|
||||
*/
|
||||
@ -805,6 +652,240 @@ MENUHANDLER(fullscreen, FULLSCREEN_BUTTON);
|
||||
*/
|
||||
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)
|
||||
{
|
||||
struct nsgtk_scaffolding *g = (struct nsgtk_scaffolding *) data;
|
||||
struct gui_window *gui = g->top_level;
|
||||
struct browser_window *bw = nsgtk_get_browser_window(gui);
|
||||
nserror err;
|
||||
|
||||
if (current_menu_features.link == NULL)
|
||||
return FALSE;
|
||||
|
||||
err = browser_window_navigate(bw,
|
||||
current_menu_features.link,
|
||||
NULL,
|
||||
BW_NAVIGATE_DOWNLOAD,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
if (err != NSERROR_OK) {
|
||||
nsgtk_warning(messages_get_errorcode(err), 0);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handler for opening new window from a link. attached to the popup menu.
|
||||
*/
|
||||
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;
|
||||
struct browser_window *bw = nsgtk_get_browser_window(gui);
|
||||
nserror err;
|
||||
|
||||
if (current_menu_features.link == NULL)
|
||||
return FALSE;
|
||||
|
||||
err = browser_window_create(BW_CREATE_CLONE | BW_CREATE_HISTORY,
|
||||
current_menu_features.link, NULL, bw, NULL);
|
||||
if (err != NSERROR_OK) {
|
||||
nsgtk_warning(messages_get_errorcode(err), 0);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handler for opening new tab from a link. attached to the popup menu.
|
||||
*/
|
||||
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;
|
||||
struct browser_window *bw = nsgtk_get_browser_window(gui);
|
||||
nserror err;
|
||||
|
||||
if (current_menu_features.link == NULL)
|
||||
return FALSE;
|
||||
|
||||
temp_open_background = 1;
|
||||
|
||||
err = browser_window_create(BW_CREATE_CLONE |
|
||||
BW_CREATE_HISTORY |
|
||||
BW_CREATE_TAB,
|
||||
current_menu_features.link, NULL, bw, NULL);
|
||||
if (err != NSERROR_OK) {
|
||||
nsgtk_warning(messages_get_errorcode(err), 0);
|
||||
}
|
||||
|
||||
temp_open_background = -1;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handler for bookmarking a link. attached to the popup menu.
|
||||
*/
|
||||
static gboolean
|
||||
nsgtk_on_link_bookmark_activate_menu(GtkMenuItem *widget, gpointer data)
|
||||
{
|
||||
if (current_menu_features.link == NULL)
|
||||
return FALSE;
|
||||
|
||||
hotlist_add_url(current_menu_features.link);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handler for copying a link. attached to the popup menu.
|
||||
*/
|
||||
static gboolean
|
||||
nsgtk_on_link_copy_activate_menu(GtkMenuItem *widget, gpointer data)
|
||||
{
|
||||
GtkClipboard *clipboard;
|
||||
|
||||
if (current_menu_features.link == NULL)
|
||||
return FALSE;
|
||||
|
||||
clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
|
||||
gtk_clipboard_set_text(clipboard,
|
||||
nsurl_access(current_menu_features.link), -1);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
||||
nsgtk_scaffolding_toggle_search_bar_visibility(g);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
nsgtk_tab_close_current(g->notebook);
|
||||
|
||||
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);
|
||||
|
||||
|
||||
#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);
|
||||
g_signal_connect(gs->menu_bar->edit_submenu->edit,
|
||||
"show",
|
||||
G_CALLBACK(nsgtk_window_edit_menu_shown),
|
||||
gs);
|
||||
|
||||
CONNECT(gs->search->buttons[1], "clicked",
|
||||
nsgtk_search_forward_button_clicked, gs);
|
||||
g_signal_connect(gs->menu_bar->edit_submenu->edit,
|
||||
"hide",
|
||||
G_CALLBACK(nsgtk_window_edit_menu_hidden),
|
||||
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);
|
||||
|
||||
/** \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);
|
||||
|
@ -68,6 +68,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.
|
||||
*
|
||||
|
@ -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,
|
||||
@ -2260,24 +2261,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
|
||||
*
|
||||
@ -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) {
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user