56 gboolean (*
mhandler)(GtkMenuItem *widget, gpointer data);
192 NSLOG(netsurf, INFO,
"scaffold:%p", gs);
200 if (gs->
prev != NULL) {
202 }
else if (gs->
next != NULL) {
208 if (gs->
prev != NULL) {
213 if (gs->
next != NULL) {
254 gtk_widget_destroy(GTK_WIDGET(g->
window));
292 GtkWidget *widget = gtk_window_get_focus(g->
window);
294 if (GTK_IS_EDITABLE(widget)) {
295 gboolean has_selection;
296 has_selection = gtk_editable_get_selection_bounds(
297 GTK_EDITABLE(widget), NULL, NULL);
408 gboolean visible = gtk_notebook_get_show_tabs(g->
notebook);
453 if (gtk_notebook_get_n_pages(notebook) == 1) {
454 gtk_widget_destroy(GTK_WIDGET(gs->
window));
458 visible = gtk_notebook_get_show_tabs(gs->
notebook);
460 "visible", visible, NULL);
462 "visible", visible, NULL);
477#define TOOLBAR_ITEM_p(identifier, name) \
479nsgtk_on_##name##_activate_menu(GtkMenuItem *widget, gpointer data) \
481 struct nsgtk_scaffolding *gs = (struct nsgtk_scaffolding *)data;\
482 nsgtk_window_item_activate(gs->top_level, identifier); \
485#define TOOLBAR_ITEM_y(identifier, name)
486#define TOOLBAR_ITEM_n(identifier, name)
487#define TOOLBAR_ITEM(identifier, name, sensitivity, clicked, activate, label, iconame) \
488 TOOLBAR_ITEM_ ## activate(identifier, name)
598 clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
617 const char *cur_bar_show;
623 if (cur_bar_show != NULL) {
624 if (strcmp(cur_bar_show,
"menu/tool") == 0) {
627 }
else if (strcmp(cur_bar_show,
"menu") == 0) {
629 }
else if (strcmp(cur_bar_show,
"tool") == 0) {
641 const char *new_bar_show;
645 if (strcmp(bar,
"menu") == 0) {
647 }
else if (strcmp(bar,
"tool") == 0) {
651 if ((menu ==
true) && (tool ==
true)) {
652 new_bar_show =
"menu/tool";
653 }
else if (menu ==
true) {
654 new_bar_show =
"menu";
655 }
else if (tool ==
true) {
656 new_bar_show =
"tool";
658 new_bar_show =
"none";
669 GtkCheckMenuItem *bmcmi;
670 GtkCheckMenuItem *mbcmi;
671 GtkCheckMenuItem *tbcmi;
678 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
679 if (gtk_check_menu_item_get_active(bmcmi) == FALSE) {
680 gtk_check_menu_item_set_active(bmcmi, TRUE);
683 if (gtk_check_menu_item_get_active(mbcmi) == FALSE) {
684 gtk_check_menu_item_set_active(mbcmi, TRUE);
687 if (gtk_check_menu_item_get_active(tbcmi) == FALSE) {
688 gtk_check_menu_item_set_active(tbcmi, TRUE);
694 if (gtk_check_menu_item_get_active(bmcmi) == TRUE) {
695 gtk_check_menu_item_set_active(bmcmi, FALSE);
698 if (gtk_check_menu_item_get_active(mbcmi) == TRUE) {
699 gtk_check_menu_item_set_active(mbcmi, FALSE);
702 if (gtk_check_menu_item_get_active(tbcmi) == TRUE) {
703 gtk_check_menu_item_set_active(tbcmi, FALSE);
717 GtkCheckMenuItem *bmcmi;
718 GtkCheckMenuItem *mbcmi;
719 GtkCheckMenuItem *tbcmi;
726 if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
727 if (gtk_check_menu_item_get_active(bmcmi) == FALSE) {
728 gtk_check_menu_item_set_active(bmcmi, TRUE);
731 if (gtk_check_menu_item_get_active(mbcmi) == FALSE) {
732 gtk_check_menu_item_set_active(mbcmi, TRUE);
735 if (gtk_check_menu_item_get_active(tbcmi) == FALSE) {
736 gtk_check_menu_item_set_active(tbcmi, TRUE);
742 if (gtk_check_menu_item_get_active(bmcmi) == TRUE) {
743 gtk_check_menu_item_set_active(bmcmi, FALSE);
746 if (gtk_check_menu_item_get_active(mbcmi) == TRUE) {
747 gtk_check_menu_item_set_active(mbcmi, FALSE);
750 if (gtk_check_menu_item_get_active(tbcmi) == TRUE) {
751 gtk_check_menu_item_set_active(tbcmi, FALSE);
838 GtkAccelGroup *group,
842 GtkMenuShell *menushell;
845 menushell = GTK_MENU_SHELL(gtk_builder_get_object(gs->
builder,
855 gtk_widget_show(GTK_WIDGET(nmenu->
bar_menu));
857 gtk_widget_hide(GTK_WIDGET(nmenu->
bar_menu));
904 GtkAccelGroup *group,
943 GtkAccelGroup *group,
1031#define TOOLBAR_ITEM_p(identifier, name, iconame) \
1032 g->menus[identifier].mhandler = nsgtk_on_##name##_activate_menu; \
1033 g->menus[identifier].iconname = iconame;
1034#define TOOLBAR_ITEM_y(identifier, name, iconame) \
1035 g->menus[identifier].mhandler = nsgtk_on_##name##_activate_menu; \
1036 g->menus[identifier].iconname = iconame;
1037#define TOOLBAR_ITEM_n(identifier, name, iconame) \
1038 g->menus[identifier].mhandler = NULL; \
1039 g->menus[identifier].iconname = iconame;
1040#define TOOLBAR_ITEM(identifier, name, snstvty, clicked, activate, label, iconame) \
1041 g->menus[identifier].sensitivity = snstvty; \
1042 TOOLBAR_ITEM_ ## activate(identifier, name, iconame)
1044#undef TOOLBAR_ITEM_y
1045#undef TOOLBAR_ITEM_n
1049#define ITEM_MB(p, q, r) \
1050 g->menus[p##_BUTTON].main = g->menu_bar->r##_submenu->q##_menuitem; \
1051 g->menus[p##_BUTTON].burger = g->burger_menu->r##_submenu->q##_menuitem
1054#define ITEM_MBP(p, q, r) \
1055 g->menus[p##_BUTTON].main = g->menu_bar->r##_submenu->q##_menuitem; \
1056 g->menus[p##_BUTTON].burger = g->burger_menu->r##_submenu->q##_menuitem; \
1057 g->menus[p##_BUTTON].popup = g->popup_menu->r##_submenu->q##_menuitem
1060#define ITEM_MBp(p, q, r) \
1061 g->menus[p##_BUTTON].main = g->menu_bar->r##_submenu->q##_menuitem; \
1062 g->menus[p##_BUTTON].burger = g->burger_menu->r##_submenu->q##_menuitem; \
1063 g->menus[p##_BUTTON].popup = g->popup_menu->q##_menuitem
1067 ITEM_MB(NEWWINDOW, newwindow, file);
1068 ITEM_MB(NEWTAB, newtab, file);
1069 ITEM_MB(OPENFILE, openfile, file);
1070 ITEM_MB(CLOSEWINDOW, closewindow, file);
1071 ITEM_MB(PRINTPREVIEW, printpreview, file);
1075 ITEM_MB(SAVEPAGE, savepage, file_submenu->export);
1076 ITEM_MB(PLAINTEXT, plaintext, file_submenu->export);
1077 ITEM_MB(PDF, pdf, file_submenu->export);
1083 ITEM_MB(DELETE,
delete, edit);
1084 ITEM_MB(SELECTALL, selectall, edit);
1086 ITEM_MB(PREFERENCES, preferences, edit);
1092 ITEM_MB(ZOOMPLUS, zoomplus, view_submenu->scaleview);
1093 ITEM_MB(ZOOMMINUS, zoomminus, view_submenu->scaleview);
1094 ITEM_MB(ZOOMNORMAL, zoomnormal, view_submenu->scaleview);
1096 ITEM_MB(NEXTTAB, nexttab, view_submenu->tabs);
1097 ITEM_MB(PREVTAB, prevtab, view_submenu->tabs);
1098 ITEM_MB(CLOSETAB, closetab, view_submenu->tabs);
1100 ITEM_MB(CUSTOMIZE, customize, view_submenu->toolbars);
1109 ITEM_MB(LOCALHISTORY, localhistory, nav);
1110 ITEM_MB(GLOBALHISTORY, globalhistory, nav);
1111 ITEM_MB(ADDBOOKMARKS, addbookmarks, nav);
1112 ITEM_MB(SHOWBOOKMARKS, showbookmarks, nav);
1113 ITEM_MB(OPENLOCATION, openlocation, nav);
1116 ITEM_MBP(DOWNLOADS, downloads, tools);
1117 ITEM_MBP(SHOWCOOKIES, showcookies, tools);
1119 ITEM_MBP(VIEWSOURCE, viewsource, tools_submenu->developer);
1120 ITEM_MBP(TOGGLEDEBUGGING, toggledebugging, tools_submenu->developer);
1121 ITEM_MBP(SAVEBOXTREE, debugboxtree, tools_submenu->developer);
1122 ITEM_MBP(SAVEDOMTREE, debugdomtree, tools_submenu->developer);
1125 ITEM_MB(CONTENTS, contents, help);
1144 gtk_widget_set_sensitive(GTK_WIDGET(
1149 gtk_widget_set_sensitive(GTK_WIDGET(
1154 gtk_widget_set_sensitive(GTK_WIDGET(
1174 GTK_ICON_SIZE_MENU);
1179 GTK_ICON_SIZE_MENU);
1184 GTK_ICON_SIZE_MENU);
1213 GtkAccelGroup *group;
1219 group = gtk_accel_group_new();
1221 gtk_window_add_accel_group(gs->
window, group);
1250 if (title == NULL || title[0] ==
'\0') {
1251 gtk_window_set_title(gs->
window,
"NetSurf");
1255 title_len = strlen(title) +
SLEN(
" - NetSurf") + 1;
1256 newtitle = malloc(title_len);
1257 if (newtitle == NULL) {
1261 snprintf(newtitle, title_len,
"%s - NetSurf", title);
1263 gtk_window_set_title(gs->
window, newtitle);
1300 while (gs != NULL) {
1302 gtk_widget_destroy(GTK_WIDGET(gs->
window));
1379#define SENSITIVITY(q) \
1381 if (g->menus[i].main != NULL) \
1382 gtk_widget_set_sensitive(GTK_WIDGET(g->menus[i].main), \
1383 g->menus[i].sensitivity); \
1384 if (g->menus[i].burger != NULL) \
1385 gtk_widget_set_sensitive(GTK_WIDGET(g->menus[i].burger), \
1386 g->menus[i].sensitivity); \
1387 if (g->menus[i].popup != NULL) \
1388 gtk_widget_set_sensitive(GTK_WIDGET(g->menus[i].popup), \
1389 g->menus[i].sensitivity);
1486 while (gs != NULL) {
1501 gs = calloc(1,
sizeof(*gs));
1506 NSLOG(netsurf, INFO,
1507 "Constructing a scaffold of %p for gui_window %p", gs, toplevel);
1517 gtk_builder_connect_signals(gs->
builder, NULL);
1528 gtk_window_move(gs->
window,
1531 gtk_window_resize(gs->
window,
1539 gtk_window_set_default_size(gs->
window, 1000, 700);
1542 g_signal_connect(gs->
window,
1547 g_signal_connect(gs->
window,
1560 g_signal_connect_after(gs->
notebook,
1585 gtk_widget_show(GTK_WIDGET(gs->
window));
1587 NSLOG(netsurf, INFO,
"creation complete");
static struct s_view view
bool browser_window_history_forward_available(struct browser_window *bw)
Check whether it is pssible to go forwards in the history.
bool browser_window_history_back_available(struct browser_window *bw)
Check whether it is pssible to go back in the history.
Interface to browser history operations.
Browser window creation and manipulation interface.
nserror browser_window_get_features(struct browser_window *bw, int x, int y, struct browser_window_features *data)
Get access to any page features at the given coordinates.
nserror browser_window_navigate(struct browser_window *bw, struct nsurl *url, struct nsurl *referrer, enum browser_window_nav_flags flags, char *post_urlenc, struct fetch_multipart_data *post_multipart, struct hlcache_handle *parent)
Start fetching a page in a browser window.
@ BW_EDITOR_CAN_PASTE
Can paste, input.
@ BW_EDITOR_CAN_CUT
Selection not read-only.
@ BW_EDITOR_CAN_COPY
Have selection.
const char * browser_window_get_title(struct browser_window *bw)
Get the title of a browser_window.
nserror browser_window_create(enum browser_window_create_flags flags, struct nsurl *url, struct nsurl *referrer, struct browser_window *existing, struct browser_window **bw)
Create and open a new root browser window with the given page.
browser_editor_flags browser_window_get_editor_flags(struct browser_window *bw)
Check whether browser window can accept a cut/copy/paste, or has a selection that could be saved.
@ BW_CREATE_HISTORY
this will form a new history node (don't set for back/reload/etc)
@ BW_CREATE_TAB
New gui_window to be tab in same window as "existing" gui_window.
@ BW_CREATE_CLONE
New gui_window to be clone of "existing" gui_window.
@ BW_NAVIGATE_DOWNLOAD
download rather than render the uri
void nsgtk_image_menu_item_set_image(GtkWidget *image_menu_item, GtkWidget *image)
Sets the image of image_menu_item to the given widget.
void nsgtk_menu_popup_at_pointer(GtkMenu *menu, const GdkEvent *trigger_event)
Displays menu and makes it available for selection.
Compatibility functions for older GTK versions (interface)
#define gtk_widget_in_destruction(widget)
nserror hotlist_add_url(nsurl *url)
Add an entry to the hotlist for given URL.
nserror
Enumeration of error codes.
@ NSERROR_INVALID
Invalid data.
bool nsgtk_check_for_downloads(GtkWindow *parent)
Check with user if download is in progress they want to complete.
nserror nsgtk_local_history_hide(void)
hide the local history window from being visible.
Interface to GTK local history manager.
static GtkClipboard * clipboard
bool nsgtk_complete
set when no windows remain open.
nserror nsgtk_warning(const char *warning, const char *detail)
Warn the user of an event.
nserror nsgtk_window_search_toggle(struct gui_window *gw)
toggle search visibility
nserror nsgtk_window_position_local_history(struct gui_window *gw)
position local_history appropriately
struct nsgtk_scaffolding * nsgtk_get_scaffold(struct gui_window *g)
get containing nsgtk scaffolding handle from gui window handle
nserror nsgtk_window_position_page_info(struct gui_window *gw, struct nsgtk_pi_window *win)
position page_info appropriately
nserror nsgtk_window_toolbar_show(struct nsgtk_scaffolding *gs, bool show)
Windows associated with a scaffold will have their toolbar show state set.
struct browser_window * nsgtk_get_browser_window(struct gui_window *g)
get core browsing context from gui window handle
struct fbtk_bitmap reload
#define NSLOG(catname, level, logmsg, args...)
const char * messages_get_errorcode(nserror code)
lookup of a message by errorcode from the standard Messages hash.
Localised message support (interface).
NetSurf URL handling (interface).
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
nserror nsgtk_builder_new_from_resname(const char *resname, GtkBuilder **builder_out)
Create gtk builder object for the named ui resource.
Interface to gtk builtin resource handling.
void nsgtk_scaffolding_set_top_level(struct gui_window *gw)
Set the current active top level gui window.
static struct nsgtk_link_menu * create_scaffolding_link_menu(struct nsgtk_scaffolding *g, GtkAccelGroup *group)
Create and connect handlers to link popup menu.
static gboolean nsgtk_on_link_bookmark_activate_menu(GtkMenuItem *widget, gpointer data)
Handler for bookmarking a link.
nserror nsgtk_scaffolding_toolbar_context_menu(struct nsgtk_scaffolding *gs)
open the toolbar context menu
static struct nsgtk_burger_menu * create_scaffolding_burger_menu(struct nsgtk_scaffolding *gs, GtkAccelGroup *group, bool showbar, bool showtool)
Create and connect handlers to burger menu.
static void nsgtk_window_tabs_add(GtkNotebook *notebook, GtkWidget *page, guint page_num, struct nsgtk_scaffolding *g)
Update the menus when the number of tabs changes.
static gboolean nsgtk_window_edit_menu_shown(GtkWidget *widget, struct nsgtk_scaffolding *g)
gtk event for edit menu being show
void nsgtk_scaffolding_set_title(struct gui_window *gw, const char *title)
set the title in the window
static struct nsgtk_popup_menu * create_scaffolding_popup_menu(struct nsgtk_scaffolding *gs, GtkAccelGroup *group, bool showbar, bool showtool)
Create and connect handlers to popup menu.
#define ITEM_MBp(p, q, r)
static gboolean nsgtk_on_find_activate_menu(GtkMenuItem *widget, gpointer data)
struct nsgtk_scaffolding * nsgtk_new_scaffolding(struct gui_window *toplevel)
create a new scaffolding for a window.
static void nsgtk_menu_set_sensitivity(struct nsgtk_scaffolding *g)
static gboolean nsgtk_on_savelink_activate_menu(GtkMenuItem *widget, gpointer data)
static struct browser_window_features current_menu_features
holds the context data for what's under the pointer, when the contextual menu is opened.
static void nsgtk_window_tabs_remove(GtkNotebook *notebook, GtkWidget *page, guint page_num, struct nsgtk_scaffolding *gs)
Update the menus when the number of tabs changes.
static gboolean nsgtk_window_edit_menu_hidden(GtkWidget *widget, struct nsgtk_scaffolding *g)
gtk event handler for edit menu being hidden
static void popup_menu_hide(struct nsgtk_popup_menu *menu, bool nav, bool cnp)
Helper to hide popup menu entries by grouping.
static nserror nsgtk_menu_initialise(struct nsgtk_scaffolding *g)
initialiase the menu signal handlers ready for connection
nserror nsgtk_scaffolding_burger_menu(struct nsgtk_scaffolding *gs)
open the burger menu
GtkNotebook * nsgtk_scaffolding_notebook(struct nsgtk_scaffolding *g)
Get the gtk notebook from a scaffold.
static gboolean nsgtk_on_link_copy_activate_menu(GtkMenuItem *widget, gpointer data)
Handler for copying a link.
static void scaffolding_window_destroy(GtkWidget *widget, gpointer data)
resource cleanup function for window destruction.
void nsgtk_scaffolding_set_sensitivity(struct nsgtk_scaffolding *g)
update the sensitivity of context sensitive UI elements
static gboolean scaffolding_window_delete_event(GtkWidget *widget, GdkEvent *event, gpointer data)
gtk event callback on window delete event.
GtkMenuBar * nsgtk_scaffolding_menu_bar(struct nsgtk_scaffolding *gs)
#define ITEM_MBP(p, q, r)
static gboolean nsgtk_on_link_opentab_activate_menu(GtkMenuItem *widget, gpointer data)
Handler for opening new tab from a link.
nserror nsgtk_scaffolding_position_local_history(struct nsgtk_scaffolding *gs)
Position the local-history popup in the right place.
static gboolean nsgtk_on_prevtab_activate_menu(GtkMenuItem *widget, gpointer data)
static void nsgtk_menu_set_icons(struct nsgtk_scaffolding *g)
static struct nsgtk_scaffolding * scaf_list
global list for interface changes
static nserror set_bar_show(const char *bar, bool show)
static gboolean nsgtk_on_menubar_activate_menu(GtkMenuItem *widget, gpointer data)
static void nsgtk_scaffolding_enable_edit_actions_sensitivity(struct nsgtk_scaffolding *g)
make edit actions sensitive
static guint nsgtk_scaffolding_update_edit_actions_sensitivity(struct nsgtk_scaffolding *g)
edit the sensitivity of focused widget
static struct nsgtk_scaffolding * scaf_current
current scaffold for model dialogue use
static gboolean nsgtk_on_link_openwin_activate_menu(GtkMenuItem *widget, gpointer data)
Handler for opening new window from a link.
static void popup_menu_show(struct nsgtk_popup_menu *menu, bool nav, bool cnp)
Helper to show popup menu entries by grouping.
static gboolean nsgtk_window_popup_menu_hidden(GtkWidget *widget, struct nsgtk_scaffolding *g)
gtk event handler for popup menu being hidden.
nserror nsgtk_scaffolding_throbber(struct gui_window *gw, bool active)
Update scaffolding window when throbber state changes.
static gboolean nsgtk_on_closetab_activate_menu(GtkMenuItem *widget, gpointer data)
menu signal handler for activation on close tab item
struct gui_window * nsgtk_scaffolding_top_level(struct nsgtk_scaffolding *g)
static struct nsgtk_bar_submenu * create_scaffolding_bar_menu(struct nsgtk_scaffolding *gs, GtkAccelGroup *group, bool showmenu, bool showtool)
Create and connect handlers to bar menu.
GtkWindow * nsgtk_scaffolding_window(struct nsgtk_scaffolding *g)
Get the gtk window for a scaffolding.
static gboolean nsgtk_on_toolbar_activate_menu(GtkMenuItem *widget, gpointer data)
nserror nsgtk_scaffolding_destroy_all(void)
causes all scaffolding windows to be destroyed.
nserror nsgtk_scaffolding_position_page_info(struct nsgtk_scaffolding *gs, struct nsgtk_pi_window *win)
Position the page-info popup in the right place.
struct nsgtk_scaffolding * nsgtk_scaffolding_from_notebook(GtkNotebook *notebook)
find which scaffolding contains a gtk notebook
static gboolean nsgtk_on_nexttab_activate_menu(GtkMenuItem *widget, gpointer data)
void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g, gdouble x, gdouble y)
Open a context sensitive menu.
static nserror get_bar_show(bool *menu, bool *tool)
static void nsgtk_menu_connect_signals(struct nsgtk_scaffolding *g)
attach gtk signal handlers for menus
static void scaffolding_update_context(struct nsgtk_scaffolding *g)
Update the scaffolding controls.
struct nsgtk_scaffolding * nsgtk_current_scaffolding(void)
Obtain the most recently used scaffolding element.
struct nsgtk_scaffolding * nsgtk_scaffolding_iterate(struct nsgtk_scaffolding *g)
Iterate through available scaffolding.
static nserror nsgtk_menus_create(struct nsgtk_scaffolding *gs)
create and initialise menus
Interface to utility string handling.
Page features at a specific spatial location.
struct nsurl * link
URL of a link or NULL.
struct browser_window * bw
first entry in window list
GTK certificate viewing window context.
Core scaffolding structure.
GtkWindow * window
scaffold container window
struct nsgtk_scaffolding * next
global linked list of scaffolding for gui interface adjustments
struct nsgtk_burger_menu * burger_menu
burger menu hierarchy
struct nsgtk_menu menus[PLACEHOLDER_BUTTON]
menu entries widgets for sensitivity adjustment
struct nsgtk_link_menu * link_menu
link popup menu
gulong tabs_remove_handler_id
handler id for tabs remove callback
struct nsgtk_scaffolding * prev
struct nsgtk_popup_menu * popup_menu
right click popup menu hierarchy
GtkBuilder * builder
Builder object scaffold was created from.
struct gui_window * top_level
currently active gui browsing context
GtkNotebook * notebook
tab widget holding displayed pages
struct nsgtk_bar_submenu * menu_bar
menu bar hierarchy
nserror nsgtk_tab_next(GtkNotebook *notebook)
nserror nsgtk_notebook_create(GtkBuilder *builder, GtkNotebook **notebook_out)
create notebook
nserror nsgtk_tab_close_current(GtkNotebook *notebook)
nserror nsgtk_tab_prev(GtkNotebook *notebook)
Option reading and saving interface.
#define nsoption_charp(OPTION)
Get the value of a string option.
#define nsoption_int(OPTION)
Get the value of an integer option.
#define nsoption_set_charp(OPTION, VALUE)
set string option in default table
Interface to a number of general purpose functionality.
#define SLEN(x)
Calculate length of constant C string.