diff options
Diffstat (limited to 'frontends/gtk')
-rw-r--r-- | frontends/gtk/gui.c | 36 | ||||
-rw-r--r-- | frontends/gtk/preferences.c | 2 | ||||
-rw-r--r-- | frontends/gtk/res/tabcontents.gtk3.ui | 238 | ||||
-rw-r--r-- | frontends/gtk/scaffolding.c | 279 | ||||
-rw-r--r-- | frontends/gtk/scaffolding.h | 75 | ||||
-rw-r--r-- | frontends/gtk/toolbar.c | 881 | ||||
-rw-r--r-- | frontends/gtk/toolbar.h | 98 | ||||
-rw-r--r-- | frontends/gtk/toolbar_items.h | 136 |
8 files changed, 1049 insertions, 696 deletions
diff --git a/frontends/gtk/gui.c b/frontends/gtk/gui.c index f0bee4eec..7f3331571 100644 --- a/frontends/gtk/gui.c +++ b/frontends/gtk/gui.c @@ -159,12 +159,15 @@ nsgtk_init_resource_path(const char *config_home) /** * Set option defaults for gtk frontend. * - * @param defaults The option table to update. - * @return error status. + * \param defaults The option table to update. + * \return error status. */ static nserror set_defaults(struct nsoption_s *defaults) { char *fname; + GtkSettings *settings; + GtkIconSize tooliconsize; + GtkToolbarStyle toolbarstyle; /* cookie file default */ fname = NULL; @@ -217,6 +220,35 @@ static nserror set_defaults(struct nsoption_s *defaults) nsoption_set_charp(font_cursive, strdup("Serif")); nsoption_set_charp(font_fantasy, strdup("Serif")); + /* Default toolbar button type to system defaults */ + + settings = gtk_settings_get_default(); + g_object_get(settings, + "gtk-toolbar-icon-size", &tooliconsize, + "gtk-toolbar-style", &toolbarstyle, NULL); + + switch (toolbarstyle) { + case GTK_TOOLBAR_ICONS: + if (tooliconsize == GTK_ICON_SIZE_SMALL_TOOLBAR) { + nsoption_set_int(button_type, 1); + } else { + nsoption_set_int(button_type, 2); + } + break; + + case GTK_TOOLBAR_TEXT: + nsoption_set_int(button_type, 4); + break; + + case GTK_TOOLBAR_BOTH: + case GTK_TOOLBAR_BOTH_HORIZ: + /* no labels in default configuration */ + default: + /* No system default, so use large icons */ + nsoption_set_int(button_type, 2); + break; + } + return NSERROR_OK; } diff --git a/frontends/gtk/preferences.c b/frontends/gtk/preferences.c index dac4a559d..652075cac 100644 --- a/frontends/gtk/preferences.c +++ b/frontends/gtk/preferences.c @@ -799,7 +799,7 @@ nsgtk_preferences_comboButtonType_changed(GtkComboBox *widget, while (current != NULL) { nsgtk_scaffolding_reset_offset(current); - nsgtk_scaffolding_toolbars(current, nsoption_int(button_type)); + nsgtk_scaffolding_toolbars(current); current = nsgtk_scaffolding_iterate(current); } diff --git a/frontends/gtk/res/tabcontents.gtk3.ui b/frontends/gtk/res/tabcontents.gtk3.ui index 23328b3b7..607d511a5 100644 --- a/frontends/gtk/res/tabcontents.gtk3.ui +++ b/frontends/gtk/res/tabcontents.gtk3.ui @@ -1,6 +1,7 @@ <?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="GtkAdjustment" id="layouthadjustment"> <property name="upper">100</property> <property name="step_increment">1</property> @@ -11,82 +12,233 @@ <property name="step_increment">1</property> <property name="page_increment">10</property> </object> - <object class="GtkGrid" id="tabContents"> + <object class="GtkBox" id="tabBox"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="row_spacing">2</property> - <property name="column_spacing">2</property> + <property name="orientation">vertical</property> <child> - <object class="GtkLayout" id="layout"> + <object class="GtkToolbar" id="toolbar"> <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> + <property name="toolbar_style">both</property> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> </packing> </child> <child> - <object class="GtkScrollbar" id="vscrollbar"> - <property name="visible">True</property> + <object class="GtkToolbar" id="searchbar"> <property name="can_focus">False</property> - <property name="vexpand">True</property> - <property name="orientation">vertical</property> - <property name="adjustment">layoutvadjustment</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"> + <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"> + <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> + <property name="homogeneous">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="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="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> + <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="xalign">0</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="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> + <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="xalign">0</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="left_attach">1</property> - <property name="top_attach">0</property> - <property name="width">1</property> - <property name="height">1</property> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> </packing> </child> <child> - <object class="GtkPaned" id="hpaned1"> + <object class="GtkGrid" id="tabContents"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="hexpand">True</property> + <property name="can_focus">False</property> + <property name="row_spacing">2</property> + <property name="column_spacing">2</property> <child> - <object class="GtkLabel" id="status_bar"> + <object class="GtkLayout" id="layout"> <property name="visible">True</property> + <property name="app_paintable">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> - <property name="single_line_mode">True</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> </object> <packing> - <property name="resize">False</property> - <property name="shrink">True</property> + <property name="left_attach">0</property> + <property name="top_attach">0</property> </packing> </child> <child> - <object class="GtkScrollbar" id="hscrollbar"> + <object class="GtkScrollbar" id="vscrollbar"> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="adjustment">layouthadjustment</property> + <property name="vexpand">True</property> + <property name="orientation">vertical</property> + <property name="adjustment">layoutvadjustment</property> </object> <packing> - <property name="resize">True</property> - <property name="shrink">True</property> + <property name="left_attach">1</property> + <property name="top_attach">0</property> </packing> </child> + <child> + <object class="GtkPaned" id="hpaned1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hexpand">True</property> + <child> + <object class="GtkLabel" id="status_bar"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="xpad">4</property> + <property name="label" translatable="yes">Status</property> + <property name="single_line_mode">True</property> + <property name="xalign">0</property> + </object> + <packing> + <property name="resize">False</property> + <property name="shrink">True</property> + </packing> + </child> + <child> + <object class="GtkScrollbar" id="hscrollbar"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="adjustment">layouthadjustment</property> + </object> + <packing> + <property name="resize">True</property> + <property name="shrink">True</property> + </packing> + </child> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <placeholder/> + </child> </object> <packing> - <property name="left_attach">0</property> - <property name="top_attach">1</property> - <property name="width">1</property> - <property name="height">1</property> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">3</property> </packing> </child> - <child> - <placeholder/> - </child> </object> </interface> diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c index ee08cc187..c739b3e9c 100644 --- a/frontends/gtk/scaffolding.c +++ b/frontends/gtk/scaffolding.c @@ -115,30 +115,17 @@ struct nsgtk_scaffolding { /** scaffold container window */ GtkWindow *window; - bool fullscreen; /**< flag for the scaffold window fullscreen status */ + /** flag for the scaffold window fullscreen status */ + bool fullscreen; /** tab widget holding displayed pages */ GtkNotebook *notebook; - /** entry widget holding the url of the current displayed page */ - GtkWidget *url_bar; - GtkEntryCompletion *url_bar_completion; /**< Completions for url_bar */ - - /** Activity throbber */ - GtkImage *throbber; - int throb_frame; /**< Current frame of throbber animation */ - + /** In page text search context */ struct gtk_search *search; - /** Web search widget */ - GtkWidget *webSearchEntry; - /** controls toolbar */ - GtkToolbar *tool_bar; - struct nsgtk_button_connect *buttons[PLACEHOLDER_BUTTON]; - int offset; - int toolbarmem; - int toolbarbase; - int historybase; + /** controls toolbar context */ + struct nsgtk_toolbar *toolbar; /** menu bar hierarchy */ struct nsgtk_bar_submenu *menu_bar; @@ -1868,9 +1855,7 @@ static void nsgtk_scaffolding_toolbar_init(struct nsgtk_scaffolding *g) 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->buttons[p##_BUTTON]->dataplus = nsgtk_toolbar_##r##_button_data;\ - g->buttons[p##_BUTTON]->dataminus = nsgtk_toolbar_##r##_toolbar_button_data + g->buttons[p##_BUTTON]->bhandler = nsgtk_on_##r##_activate_button; #define ITEM_SUB(p, q, r, s)\ g->buttons[p##_BUTTON]->main =\ @@ -1880,34 +1865,14 @@ static void nsgtk_scaffolding_toolbar_init(struct nsgtk_scaffolding *g) g->buttons[p##_BUTTON]->mhandler =\ nsgtk_on_##s##_activate_menu;\ g->buttons[p##_BUTTON]->bhandler =\ - nsgtk_on_##s##_activate_button;\ - g->buttons[p##_BUTTON]->dataplus =\ - nsgtk_toolbar_##s##_button_data;\ - g->buttons[p##_BUTTON]->dataminus =\ - nsgtk_toolbar_##s##_toolbar_button_data + nsgtk_on_##s##_activate_button; #define ITEM_BUTTON(p, q)\ g->buttons[p##_BUTTON]->bhandler =\ - nsgtk_on_##q##_activate;\ - g->buttons[p##_BUTTON]->dataplus =\ - nsgtk_toolbar_##q##_button_data;\ - g->buttons[p##_BUTTON]->dataminus =\ - nsgtk_toolbar_##q##_toolbar_button_data - + nsgtk_on_##q##_activate; #define ITEM_POP(p, q) \ g->buttons[p##_BUTTON]->popup = g->menu_popup->q##_menuitem -#define SENSITIVITY(q) \ - g->buttons[q##_BUTTON]->sensitivity = false - -#define ITEM_ITEM(p, q)\ - g->buttons[p##_ITEM]->dataplus =\ - nsgtk_toolbar_##q##_button_data;\ - g->buttons[p##_ITEM]->dataminus =\ - nsgtk_toolbar_##q##_toolbar_button_data - - ITEM_ITEM(WEBSEARCH, websearch); - ITEM_ITEM(THROBBER, throbber); ITEM_MAIN(NEWWINDOW, file_submenu, newwindow); ITEM_MAIN(NEWTAB, file_submenu, newtab); ITEM_MAIN(OPENFILE, file_submenu, openfile); @@ -1964,27 +1929,11 @@ static void nsgtk_scaffolding_toolbar_init(struct nsgtk_scaffolding *g) ITEM_SUB(SAVEDOMTREE, tools_submenu, developer, debugdomtree); ITEM_BUTTON(HISTORY, history); - /* disable items that make no sense initially, as well as - * as-yet-unimplemented items */ - SENSITIVITY(BACK); - SENSITIVITY(FORWARD); - SENSITIVITY(STOP); - SENSITIVITY(PRINTPREVIEW); - SENSITIVITY(DELETE); - SENSITIVITY(DRAWFILE); - SENSITIVITY(POSTSCRIPT); - SENSITIVITY(NEXTTAB); - SENSITIVITY(PREVTAB); - SENSITIVITY(CLOSETAB); -#ifndef WITH_PDF_EXPORT - SENSITIVITY(PDF); -#endif #undef ITEM_MAIN #undef ITEM_SUB #undef ITEM_BUTTON #undef ITEM_POP -#undef SENSITIVITY } @@ -2012,64 +1961,87 @@ static void nsgtk_scaffolding_initial_sensitivity(struct nsgtk_scaffolding *g) gtk_widget_set_sensitive(GTK_WIDGET(g->menu_bar->view_submenu->images_menuitem), FALSE); } - -void nsgtk_scaffolding_toolbars(struct nsgtk_scaffolding *g, int tbi) +/** + * update search toolbar size and style + */ +static nserror nsgtk_search_update(struct gtk_search *search) { - switch (tbi) { - /* case 0 is 'unset' [from fresh install / clearing options] - * see above */ + switch (nsoption_int(button_type)) { case 1: /* Small icons */ - /* main toolbar */ - gtk_toolbar_set_style(GTK_TOOLBAR(g->tool_bar), + gtk_toolbar_set_style(GTK_TOOLBAR(search->bar), GTK_TOOLBAR_ICONS); - gtk_toolbar_set_icon_size(GTK_TOOLBAR(g->tool_bar), - GTK_ICON_SIZE_SMALL_TOOLBAR); - /* search toolbar */ - gtk_toolbar_set_style(GTK_TOOLBAR(g->search->bar), - GTK_TOOLBAR_ICONS); - gtk_toolbar_set_icon_size(GTK_TOOLBAR(g->search->bar), + 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(g->tool_bar), + gtk_toolbar_set_style(GTK_TOOLBAR(search->bar), GTK_TOOLBAR_ICONS); - gtk_toolbar_set_icon_size(GTK_TOOLBAR(g->tool_bar), - GTK_ICON_SIZE_LARGE_TOOLBAR); - /* search toolbar */ - gtk_toolbar_set_style(GTK_TOOLBAR(g->search->bar), - GTK_TOOLBAR_ICONS); - gtk_toolbar_set_icon_size(GTK_TOOLBAR(g->search->bar), + 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(g->tool_bar), + gtk_toolbar_set_style(GTK_TOOLBAR(search->bar), GTK_TOOLBAR_BOTH); - gtk_toolbar_set_icon_size(GTK_TOOLBAR(g->tool_bar), - GTK_ICON_SIZE_LARGE_TOOLBAR); - /* search toolbar */ - gtk_toolbar_set_style(GTK_TOOLBAR(g->search->bar), - GTK_TOOLBAR_BOTH); - gtk_toolbar_set_icon_size(GTK_TOOLBAR(g->search->bar), + 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(g->tool_bar), - GTK_TOOLBAR_TEXT); - /* search toolbar */ - gtk_toolbar_set_style(GTK_TOOLBAR(g->search->bar), + gtk_toolbar_set_style(GTK_TOOLBAR(search->bar), GTK_TOOLBAR_TEXT); default: break; } + return NSERROR_OK; } + +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; +} + + +/* 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 interface documented in gtk/scaffolding.h */ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) { + nserror res; struct nsgtk_scaffolding *gs; int i; GtkAccelGroup *group; @@ -2092,58 +2064,26 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) gtk_builder_connect_signals(gs->builder, NULL); -/** Obtain a GTK widget handle from UI builder object */ -#define GET_WIDGET(x) GTK_WIDGET (gtk_builder_get_object(gs->builder, (x))) - - gs->window = GTK_WINDOW(GET_WIDGET("wndBrowser")); - gs->notebook = GTK_NOTEBOOK(GET_WIDGET("notebook")); - gs->tool_bar = GTK_TOOLBAR(GET_WIDGET("toolbar")); + gs->window = GTK_WINDOW(gtk_builder_get_object(builder, "wndBrowser")); + gs->notebook = GTK_NOTEBOOK(gtk_builder_get_object(builder, "notebook")); - gs->search = malloc(sizeof(struct gtk_search)); - if (gs->search == NULL) { + res = nsgtk_toolbar_create(&gs->toolbar); + if (res != NSERROR_OK) { free(gs); return NULL; } - gs->search->bar = GTK_TOOLBAR(GET_WIDGET("searchbar")); - gs->search->entry = GTK_ENTRY(GET_WIDGET("searchEntry")); - - gs->search->buttons[0] = GTK_TOOL_BUTTON(GET_WIDGET("searchBackButton")); - gs->search->buttons[1] = GTK_TOOL_BUTTON(GET_WIDGET("searchForwardButton")); - gs->search->buttons[2] = GTK_TOOL_BUTTON(GET_WIDGET("closeSearchButton")); - gs->search->checkAll = GTK_CHECK_BUTTON(GET_WIDGET("checkAllSearch")); - gs->search->caseSens = GTK_CHECK_BUTTON(GET_WIDGET("caseSensButton")); - -#undef GET_WIDGET - - /* allocate buttons */ - for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { - gs->buttons[i] = calloc(1, sizeof(struct nsgtk_button_connect)); - if (gs->buttons[i] == NULL) { - for (i-- ; i >= BACK_BUTTON; i--) { - free(gs->buttons[i]); - } - free(gs); - return NULL; - } - gs->buttons[i]->location = -1; - gs->buttons[i]->sensitivity = true; + res = nsgtk_search_create(&gs->search); + if (res != NSERROR_OK) { + free(gs); + return NULL; } - - /* here custom toolbutton adding code */ - gs->offset = 0; - gs->toolbarmem = 0; - gs->toolbarbase = 0; - gs->historybase = 0; - nsgtk_toolbar_customization_load(gs); - nsgtk_toolbar_set_physical(gs); - + 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. */ @@ -2162,64 +2102,20 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) gtk_window_set_default_size(gs->window, 1000, 700); } - /* Default toolbar button type uses system defaults */ - if (nsoption_int(button_type) == 0) { - GtkSettings *settings = gtk_settings_get_default(); - GtkIconSize tooliconsize; - GtkToolbarStyle toolbarstyle; - - g_object_get(settings, - "gtk-toolbar-icon-size", &tooliconsize, - "gtk-toolbar-style", &toolbarstyle, NULL); - - switch (toolbarstyle) { - case GTK_TOOLBAR_ICONS: - if (tooliconsize == GTK_ICON_SIZE_SMALL_TOOLBAR) { - nsoption_set_int(button_type, 1); - } else { - nsoption_set_int(button_type, 2); - } - break; - - case GTK_TOOLBAR_TEXT: - nsoption_set_int(button_type, 4); - break; - - case GTK_TOOLBAR_BOTH: - case GTK_TOOLBAR_BOTH_HORIZ: - /* no labels in default configuration */ - default: - /* No system default, so use large icons */ - nsoption_set_int(button_type, 2); - break; - } - } - - nsgtk_scaffolding_toolbars(gs, nsoption_int(button_type)); - gtk_toolbar_set_show_arrow(gs->tool_bar, TRUE); - gtk_widget_show_all(GTK_WIDGET(gs->tool_bar)); nsgtk_tab_init(gs); - gtk_widget_set_size_request(GTK_WIDGET( - gs->buttons[HISTORY_BUTTON]->button), 20, -1); - - /* set up URL bar completion */ - gs->url_bar_completion = nsgtk_url_entry_completion_new(gs); - /* set up the throbber. */ - gs->throb_frame = 0; - - -#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); +#define CONNECT(obj, sig, callback, ptr) \ + 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); @@ -2251,8 +2147,9 @@ struct nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel) CONNECT(gs->search->caseSens, "toggled", nsgtk_search_entry_changed, gs); - CONNECT(gs->tool_bar, "popup-context-menu", - nsgtk_window_tool_bar_clicked, gs); + /** \todo fix popup menu */ + //CONNECT(gs->tool_bar, "popup-context-menu", + // nsgtk_window_tool_bar_clicked, gs); /* create popup menu */ gs->menu_popup = nsgtk_new_scaffolding_popup(gs, group); @@ -2547,13 +2444,6 @@ GtkToolbar *nsgtk_scaffolding_toolbar(struct nsgtk_scaffolding *g) } /* exported interface documented in gtk/scaffolding.h */ -struct nsgtk_button_connect * -nsgtk_scaffolding_button(struct nsgtk_scaffolding *g, int i) -{ - return g->buttons[i]; -} - -/* exported interface documented in gtk/scaffolding.h */ struct gtk_search *nsgtk_scaffolding_search(struct nsgtk_scaffolding *g) { return g->search; @@ -2580,15 +2470,6 @@ void nsgtk_scaffolding_reset_offset(struct nsgtk_scaffolding *g) g->offset = 0; } -/* exported interface documented in gtk/scaffolding.h */ -void nsgtk_scaffolding_update_url_bar_ref(struct nsgtk_scaffolding *g) -{ - g->url_bar = GTK_WIDGET(gtk_bin_get_child(GTK_BIN( - nsgtk_scaffolding_button(g, URL_BAR_ITEM)->button))); - - gtk_entry_set_completion(GTK_ENTRY(g->url_bar), - g->url_bar_completion); -} /* exported interface documented in gtk/scaffolding.h */ void nsgtk_scaffolding_update_throbber_ref(struct nsgtk_scaffolding *g) @@ -2753,8 +2634,7 @@ void nsgtk_scaffolding_toolbar_size_allocate(GtkWidget *widget, if (i == -1) return; if ((g->toolbarmem == alloc->x) || - (g->buttons[i]->location < - g->buttons[HISTORY_BUTTON]->location)) + (g->buttons[i]->location < g->buttons[HISTORY_BUTTON]->location)) /* no reallocation after first adjustment, no reallocation for buttons * left of history button */ return; @@ -2767,8 +2647,7 @@ void nsgtk_scaffolding_toolbar_size_allocate(GtkWidget *widget, if (g->offset == 0) g->offset = alloc->width - 20; alloc->width = 20; - } else if (g->buttons[i]->location <= - g->buttons[URL_BAR_ITEM]->location) { + } 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; diff --git a/frontends/gtk/scaffolding.h b/frontends/gtk/scaffolding.h index 7f7657e1b..a3e6155ed 100644 --- a/frontends/gtk/scaffolding.h +++ b/frontends/gtk/scaffolding.h @@ -30,60 +30,6 @@ struct nsurl; extern struct gui_search_web_table *nsgtk_search_web_table; -typedef enum { - BACK_BUTTON = 0, - HISTORY_BUTTON, - FORWARD_BUTTON, - STOP_BUTTON, - RELOAD_BUTTON, - HOME_BUTTON, - URL_BAR_ITEM, - WEBSEARCH_ITEM, - THROBBER_ITEM, - NEWWINDOW_BUTTON, - NEWTAB_BUTTON, - OPENFILE_BUTTON, - CLOSETAB_BUTTON, - CLOSEWINDOW_BUTTON, - SAVEPAGE_BUTTON, - PDF_BUTTON, - PLAINTEXT_BUTTON, - DRAWFILE_BUTTON, - POSTSCRIPT_BUTTON, - PRINTPREVIEW_BUTTON, - PRINT_BUTTON, - QUIT_BUTTON, - CUT_BUTTON, - COPY_BUTTON, - PASTE_BUTTON, - DELETE_BUTTON, - SELECTALL_BUTTON, - FIND_BUTTON, - PREFERENCES_BUTTON, - ZOOMPLUS_BUTTON, - ZOOMMINUS_BUTTON, - ZOOMNORMAL_BUTTON, - FULLSCREEN_BUTTON, - VIEWSOURCE_BUTTON, - DOWNLOADS_BUTTON, - SAVEWINDOWSIZE_BUTTON, - TOGGLEDEBUGGING_BUTTON, - SAVEBOXTREE_BUTTON, - SAVEDOMTREE_BUTTON, - LOCALHISTORY_BUTTON, - GLOBALHISTORY_BUTTON, - ADDBOOKMARKS_BUTTON, - SHOWBOOKMARKS_BUTTON, - SHOWCOOKIES_BUTTON, - OPENLOCATION_BUTTON, - NEXTTAB_BUTTON, - PREVTAB_BUTTON, - CONTENTS_BUTTON, - GUIDE_BUTTON, - INFO_BUTTON, - ABOUT_BUTTON, - PLACEHOLDER_BUTTON /* size indicator; array maximum indices */ -} nsgtk_toolbar_button; /* PLACEHOLDER_BUTTON - 1 */ struct gtk_history_window { struct nsgtk_scaffolding *g; @@ -100,18 +46,6 @@ struct gtk_search { GtkCheckButton *caseSens; }; -struct nsgtk_button_connect { - GtkToolItem *button; - int location; /* in toolbar */ - bool sensitivity; - GtkWidget *main; /* left click menu entry */ - GtkWidget *rclick; /* right click menu */ - GtkWidget *popup; /* popup menu entry */ - void *mhandler; /* menu item clicked */ - void *bhandler; /* button clicked */ - void *dataplus; /* customization -> toolbar */ - void *dataminus; /* customization -> store */ -}; /** * create a new scaffolding for a window. @@ -156,8 +90,6 @@ GtkWidget *nsgtk_scaffolding_websearch(struct nsgtk_scaffolding *g); GtkToolbar *nsgtk_scaffolding_toolbar(struct nsgtk_scaffolding *g); -struct nsgtk_button_connect *nsgtk_scaffolding_button(struct nsgtk_scaffolding *g, int i); - struct gtk_search *nsgtk_scaffolding_search(struct nsgtk_scaffolding *g); GtkMenuBar *nsgtk_scaffolding_menu_bar(struct nsgtk_scaffolding *g); @@ -180,8 +112,6 @@ void nsgtk_scaffolding_reset_offset(struct nsgtk_scaffolding *g); */ struct nsgtk_scaffolding *nsgtk_scaffolding_iterate(struct nsgtk_scaffolding *g); -void nsgtk_scaffolding_update_url_bar_ref(struct nsgtk_scaffolding *g); - void nsgtk_scaffolding_update_throbber_ref(struct nsgtk_scaffolding *g); void nsgtk_scaffolding_update_websearch_ref(struct nsgtk_scaffolding *g); @@ -245,6 +175,9 @@ nserror gui_window_set_url(struct gui_window *g, struct nsurl *url); void gui_window_start_throbber(struct gui_window *g); void gui_window_stop_throbber(struct gui_window *g); -void nsgtk_scaffolding_toolbars(struct nsgtk_scaffolding *g, int tbi); +/** + * 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 4ca03a1ea..02b1e66d4 100644 --- a/frontends/gtk/toolbar.c +++ b/frontends/gtk/toolbar.c @@ -16,6 +16,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ +/** + * \file + * implementatio of toolbar to control browsing context + */ + #include <stdlib.h> #include <string.h> #include <unistd.h> @@ -36,13 +41,68 @@ #include "gtk/window.h" #include "gtk/compat.h" #include "gtk/resources.h" +#include "gtk/toolbar_items.h" #include "gtk/toolbar.h" +/** button location indicating button is not to be shown */ +#define INACTIVE_LOCATION (-1) + +/** + * toolbar item context + */ +struct nsgtk_toolbar_item { + GtkToolItem *button; + int location; /* in toolbar */ + bool sensitivity; + GtkWidget *main; /* left click menu entry */ + GtkWidget *rclick; /* right click menu */ + GtkWidget *popup; /* popup menu entry */ + void *mhandler; /* menu item clicked */ + void *bhandler; /* button clicked */ + void *dataplus; /* customization -> toolbar */ + void *dataminus; /* customization -> store */ +}; + + +/** + * control toolbar context + */ +struct nsgtk_toolbar { + /** gtk toolbar widget */ + GtkToolbar *widget; + + struct nsgtk_toolbar_item *buttons[PLACEHOLDER_BUTTON]; + int offset; + int toolbarmem; + int toolbarbase; + int historybase; + + /** entry widget holding the url of the current displayed page */ + GtkWidget *url_bar; + + /** Completions for url_bar */ + GtkEntryCompletion *url_bar_completion; + + /** Activity throbber */ + GtkImage *throbber; + + /** Current frame of throbber animation */ + int throb_frame; + + /** Web search widget */ + GtkWidget *webSearchEntry; + +}; + + static GtkTargetEntry entry = {(char *)"nsgtk_button_data", GTK_TARGET_SAME_APP, 0}; static bool edit_mode = false; +/** + * toolbar customization window context + */ struct nsgtk_toolbar_custom_store { GtkWidget *window; GtkWidget *store_buttons[PLACEHOLDER_BUTTON]; @@ -54,6 +114,7 @@ struct nsgtk_toolbar_custom_store { int currentbutton; bool fromstore; }; + /* the number of buttons that fit in the width of the store window */ #define NSGTK_STORE_WIDTH 6 @@ -93,6 +154,495 @@ struct nsgtk_theme { /* apng throbber element */ }; + +/* define data plus and data minus handlers */ +#define TOOLBAR_ITEM(identifier, name, sensitivity) \ +static gboolean \ +nsgtk_toolbar_##name##_data_plus(GtkWidget *widget, \ + GdkDragContext *cont, \ + GtkSelectionData *selection, \ + guint info, \ + guint time, \ + gpointer data) \ +{ \ + window->currentbutton = identifier; \ + window->fromstore = true; \ + return TRUE; \ +} \ +static gboolean \ +nsgtk_toolbar_##name##_data_minus(GtkWidget *widget, \ + GdkDragContext *cont, \ + GtkSelectionData *selection, \ + guint info, \ + guint time, \ + gpointer data) \ +{ \ + window->currentbutton = identifier; \ + window->fromstore = false; \ + return TRUE; \ +} + +#include "gtk/toolbar_items.h" + +#undef TOOLBAR_ITEM + + +/** + * Apply the user toolbar button settings from configuration + * + * 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 NSERROR_OK on success else error code. + */ +static nserror +apply_user_button_customization(struct nsgtk_toolbar *tb) +{ + int i, ii; + char *buffer; + char *buffer1, *subbuffer, *ptr = NULL, *pter = NULL; + + /* set all button locations to inactive */ + for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { + tb->buttons[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; + + return NSERROR_OK; + } + + buffer = strdup(nsoption_charp(toolbar_order)); + if (buffer == NULL) { + return NSERROR_NOMEM; + } + + 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->buttons[i]->location = ii; + } + } + } + buffer1 = strtok_r(NULL, "|", &ptr); + } + + free(buffer); + return NSERROR_OK; +} + + +/** + * widget factory for creation of toolbar item widgets + * + * \param i the id of the widget + * \param theme the theme to make the widgets from + * \return gtk widget + */ +static GtkWidget * +make_toolbar_item(nsgtk_toolbar_button i, struct nsgtk_theme *theme) +{ + GtkWidget *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_WIDGET(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)); \ + } \ + 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_WIDGET(gtk_tool_button_new(GTK_WIDGET( + theme->image[HISTORY_BUTTON]), "H")); + break; + + case URL_BAR_ITEM: { + 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_container_add(GTK_CONTAINER(w), entry); + gtk_tool_item_set_expand(GTK_TOOL_ITEM(w), TRUE); + 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); + } + } + 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); + break; + } + +/* 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; \ + } + + 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) +#undef MAKE_MENUBUTTON + + default: + break; + + } + return w; +} + + +/** + * append item to gtk toolbar container + * + * \param tb toolbar + * \param theme in use + * \param location item location being appended + * \return NSERROR_OK on success else error code. + */ +static nserror +append_item_to_toolbar(struct nsgtk_toolbar *tb, + struct nsgtk_theme *theme, + int location) +{ + int bidx; /* button index */ + + for (bidx = BACK_BUTTON; bidx < PLACEHOLDER_BUTTON; bidx++) { + + if (tb->buttons[bidx]->location == location) { + + tb->buttons[bidx]->button = GTK_TOOL_ITEM( + make_toolbar_item(bidx, theme)); + + gtk_toolbar_insert(tb->widget, + tb->buttons[bidx]->button, + location); + break; + } + } + return NSERROR_OK; +} + + +/** + * 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 the gtk toolbar container with widgets in correct order + */ +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, + tb->widget); + + /* add widgets to toolbar */ + for (lidx = 0; lidx < PLACEHOLDER_BUTTON; lidx++) { + add_item_to_toolbar(tb, theme, lidx); + } + + gtk_widget_show_all(GTK_WIDGET(tb->widget)); + free(theme); + + 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 + } + + *item_out = item; + return NSERROR_OK; +} + +/* exported interface documented in toolbar.h */ +nserror nsgtk_toolbar_create(GtkBuilder *builder, struct nsgtk_toolbar **tb_out) +{ + nserror res; + struct nsgtk_toolbar *tb; + int bidx; /* button index */ + + tb = calloc(1, sizeof(struct nsgtk_toolbar)); + if (tb == NULL) { + return NSERROR_NOMEM; + } + + tb->widget = GTK_TOOLBAR(gtk_builder_get_object(builder, "toolbar")); + + /* allocate button contexts */ + for (bidx = BACK_BUTTON; bidx < PLACEHOLDER_BUTTON; bidx++) { + res = toolbar_item_create(bidx, &tb->buttons[bidx]); + if (res != NSERROR_OK) { + for (bidx-- ; bidx >= BACK_BUTTON; bidx--) { + free(tb->buttons[bidx]); + } + free(tb); + return res; + } + } + + res = apply_user_button_customization(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; + } + + 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 */ + if (tb->buttons[HISTORY_BUTTON]->button != NULL) { + gtk_widget_set_size_request(GTK_WIDGET( + tb->buttons[HISTORY_BUTTON]->button), 20, -1); + } + + /* set up the throbber. */ + tb->throb_frame = 0; + + /* set up URL bar completion */ + tb->url_bar_completion = nsgtk_url_entry_completion_new(gs); + + *tb_out = tb; + return NSERROR_OK; +} + + +/* 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_update(struct nsgtk_toolbar *tb) +{ + switch (nsoption_int(button_type)) { + + case 1: /* Small icons */ + gtk_toolbar_set_style(GTK_TOOLBAR(tb->widget), + GTK_TOOLBAR_ICONS); + gtk_toolbar_set_icon_size(GTK_TOOLBAR(tb->widget), + GTK_ICON_SIZE_SMALL_TOOLBAR); + break; + + case 2: /* Large icons */ + gtk_toolbar_set_style(GTK_TOOLBAR(g->tool_bar), + GTK_TOOLBAR_ICONS); + gtk_toolbar_set_icon_size(GTK_TOOLBAR(g->tool_bar), + GTK_ICON_SIZE_LARGE_TOOLBAR); + break; + + case 3: /* Large icons with text */ + gtk_toolbar_set_style(GTK_TOOLBAR(g->tool_bar), + GTK_TOOLBAR_BOTH); + gtk_toolbar_set_icon_size(GTK_TOOLBAR(g->tool_bar), + GTK_ICON_SIZE_LARGE_TOOLBAR); + break; + + case 4: /* Text icons only */ + gtk_toolbar_set_style(GTK_TOOLBAR(g->tool_bar), + GTK_TOOLBAR_TEXT); + break; + + default: + break; + } + + return NSERROR_OK; +} + + /** * returns a string without its underscores * @@ -277,7 +827,7 @@ void nsgtk_theme_implement(struct nsgtk_scaffolding *g) { struct nsgtk_theme *theme[IMAGE_SET_COUNT]; int i; - struct nsgtk_button_connect *button; + struct nsgtk_toolbar_item *button; struct gtk_search *search; theme[IMAGE_SET_MAIN_MENU] = nsgtk_theme_load(GTK_ICON_SIZE_MENU, false); @@ -387,7 +937,7 @@ static void nsgtk_toolbar_clear_toolbar(GtkWidget *widget, gpointer data) static void nsgtk_toolbar_temp_connect(struct nsgtk_scaffolding *g, nsgtk_toolbar_button bi) { - struct nsgtk_button_connect *bc; + struct nsgtk_toolbar_item *bc; if (bi != URL_BAR_ITEM) { bc = nsgtk_scaffolding_button(g, bi); @@ -418,182 +968,6 @@ nsgtk_toolbar_get_id_at_location(struct nsgtk_scaffolding *g, int i) return -1; } -/** - * widget factory for creation of toolbar item widgets - * \param g the reference scaffolding - * \param i the id of the widget - * \param theme the theme to make the widgets from - */ -static GtkWidget * -nsgtk_toolbar_make_widget(struct nsgtk_scaffolding *g, - nsgtk_toolbar_button i, - struct nsgtk_theme *theme) -{ - GtkWidget *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_WIDGET(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)); \ - } \ - 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_WIDGET(gtk_tool_button_new(GTK_WIDGET( - theme->image[HISTORY_BUTTON]), "H")); - break; - - case URL_BAR_ITEM: { - 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_container_add(GTK_CONTAINER(w), entry); - gtk_tool_item_set_expand(GTK_TOOL_ITEM(w), TRUE); - 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); - } - } - 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); - break; - } - -/* 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; \ - } - - 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) -#undef MAKE_MENUBUTTON - - default: - break; - - } - return w; -} /** * called when a widget is dropped onto the toolbar @@ -641,8 +1015,7 @@ nsgtk_toolbar_data(GtkWidget *widget, location = -1; } nsgtk_scaffolding_button(g, window->currentbutton)->button = - GTK_TOOL_ITEM(nsgtk_toolbar_make_widget(g, - window->currentbutton, theme)); + GTK_TOOL_ITEM(make_toolbar_item(window->currentbutton, theme)); free(theme); if (nsgtk_scaffolding_button(g, window->currentbutton)->button == NULL) { @@ -744,8 +1117,7 @@ nsgtk_toolbar_add_item_to_toolbar(struct nsgtk_scaffolding *g, int i, 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( - nsgtk_toolbar_make_widget(g, q, - theme)); + make_toolbar_item(q, theme)); gtk_toolbar_insert(nsgtk_scaffolding_toolbar(g), nsgtk_scaffolding_button(g, q)->button, i); @@ -899,51 +1271,6 @@ static void nsgtk_toolbar_cast(struct nsgtk_scaffolding *g) } -/** - * load toolbar settings from file; file is a set of fields arranged as - * [itemreference];[itemlocation]|[itemreference];[itemlocation]| etc - */ -void nsgtk_toolbar_customization_load(struct nsgtk_scaffolding *g) -{ - int i, ii; - char *buffer; - char *buffer1, *subbuffer, *ptr = NULL, *pter = NULL; - - /* default toolbar button order */ - for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) { - nsgtk_scaffolding_button(g, i)->location = - (i <= THROBBER_ITEM) ? i : -1; - } - - /* ensure the option is actually set */ - if (nsoption_charp(toolbar_order) == NULL) { - return; - } - buffer = strdup(nsoption_charp(toolbar_order)); - - 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)) { - nsgtk_scaffolding_button(g, i)->location = ii; - } - } - } - buffer1 = strtok_r(NULL, "|", &ptr); - } - - free(buffer); -} /** @@ -1163,7 +1490,7 @@ static void nsgtk_toolbar_window_open(struct nsgtk_scaffolding *g) if (i == URL_BAR_ITEM) continue; window->store_buttons[i] = - nsgtk_toolbar_make_widget(g, i, theme); + make_toolbar_item(i, theme); if (window->store_buttons[i] == NULL) { nsgtk_warning(messages_get("NoMemory"), 0); continue; @@ -1333,6 +1660,15 @@ int nsgtk_toolbar_get_id_from_widget(GtkWidget *widget, return -1; } +/* exported interface documented in gtk/scaffolding.h */ +void nsgtk_scaffolding_update_url_bar_ref(struct nsgtk_scaffolding *g) +{ + 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); +} /** * add handlers to factory widgets @@ -1401,92 +1737,3 @@ void nsgtk_toolbar_connect_all(struct nsgtk_scaffolding *g) } -#define DATAHANDLER(p, q, r)\ -gboolean nsgtk_toolbar_##p##_button_data(GtkWidget *widget, GdkDragContext\ - *cont, GtkSelectionData *selection, guint info, guint time,\ - gpointer data)\ -{\ - r->currentbutton = q##_BUTTON;\ - r->fromstore = true;\ - return TRUE;\ -}\ -gboolean nsgtk_toolbar_##p##_toolbar_button_data(GtkWidget *widget,\ - GdkDragContext *cont, GtkSelectionData *selection, guint info,\ - guint time, gpointer data)\ -{\ - r->currentbutton = q##_BUTTON;\ - r->fromstore = false;\ - return TRUE;\ -} - -DATAHANDLER(home, HOME, window) -DATAHANDLER(forward, FORWARD, window) -DATAHANDLER(back, BACK, window) -DATAHANDLER(stop, STOP, window) -DATAHANDLER(reload, RELOAD, window) -DATAHANDLER(history, HISTORY, window) -DATAHANDLER(newwindow, NEWWINDOW, window) -DATAHANDLER(newtab, NEWTAB, window) -DATAHANDLER(openfile, OPENFILE, window) -DATAHANDLER(closetab, CLOSETAB, window) -DATAHANDLER(closewindow, CLOSEWINDOW, window) -DATAHANDLER(savepage, SAVEPAGE, window) -DATAHANDLER(printpreview, PRINTPREVIEW, window) -DATAHANDLER(print, PRINT, window) -DATAHANDLER(quit, QUIT, window) -DATAHANDLER(cut, CUT, window) -DATAHANDLER(copy, COPY, window) -DATAHANDLER(paste, PASTE, window) -DATAHANDLER(delete, DELETE, window) -DATAHANDLER(selectall, SELECTALL, window) -DATAHANDLER(preferences, PREFERENCES, window) -DATAHANDLER(zoomplus, ZOOMPLUS, window) -DATAHANDLER(zoomminus, ZOOMMINUS, window) -DATAHANDLER(zoomnormal, ZOOMNORMAL, window) -DATAHANDLER(fullscreen, FULLSCREEN, window) -DATAHANDLER(viewsource, VIEWSOURCE, window) -DATAHANDLER(contents, CONTENTS, window) -DATAHANDLER(about, ABOUT, window) -DATAHANDLER(pdf, PDF, window) -DATAHANDLER(plaintext, PLAINTEXT, window) -DATAHANDLER(drawfile, DRAWFILE, window) -DATAHANDLER(postscript, POSTSCRIPT, window) -DATAHANDLER(find, FIND, window) -DATAHANDLER(downloads, DOWNLOADS, window) -DATAHANDLER(savewindowsize, SAVEWINDOWSIZE, window) -DATAHANDLER(toggledebugging, TOGGLEDEBUGGING, window) -DATAHANDLER(debugboxtree, SAVEBOXTREE, window) -DATAHANDLER(debugdomtree, SAVEDOMTREE, window) -DATAHANDLER(localhistory, LOCALHISTORY, window) -DATAHANDLER(globalhistory, GLOBALHISTORY, window) -DATAHANDLER(addbookmarks, ADDBOOKMARKS, window) -DATAHANDLER(showbookmarks, SHOWBOOKMARKS, window) -DATAHANDLER(showcookies, SHOWCOOKIES, window) -DATAHANDLER(openlocation, OPENLOCATION, window) -DATAHANDLER(nexttab, NEXTTAB, window) -DATAHANDLER(prevtab, PREVTAB, window) -DATAHANDLER(guide, GUIDE, window) -DATAHANDLER(info, INFO, window) -#undef DATAHANDLER - -#define DATAHANDLER(p, q, r) \ -gboolean nsgtk_toolbar_##p##_button_data(GtkWidget *widget, GdkDragContext\ - *cont, GtkSelectionData *selection, guint info, guint time,\ - gpointer data)\ -{\ - r->currentbutton = q##_ITEM;\ - r->fromstore = true;\ - return TRUE;\ -}\ -gboolean nsgtk_toolbar_##p##_toolbar_button_data(GtkWidget *widget,\ - GdkDragContext *cont, GtkSelectionData *selection, guint info,\ - guint time, gpointer data)\ -{\ - r->currentbutton = q##_ITEM;\ - r->fromstore = false;\ - return TRUE;\ -} - -DATAHANDLER(throbber, THROBBER, window) -DATAHANDLER(websearch, WEBSEARCH, window) -#undef DATAHANDLER diff --git a/frontends/gtk/toolbar.h b/frontends/gtk/toolbar.h index 4286fe3f0..afce22eeb 100644 --- a/frontends/gtk/toolbar.h +++ b/frontends/gtk/toolbar.h @@ -16,8 +16,42 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef _NETSURF_GTK_TOOLBAR_H_ -#define _NETSURF_GTK_TOOLBAR_H_ +#ifndef NETSURF_GTK_TOOLBAR_H_ +#define NETSURF_GTK_TOOLBAR_H_ + +/** + * control toolbar context + */ +struct nsgtk_toolbar; + + +/** + * create a control toolbar + * + * \param[in] builder The gtk builder object the toolbar is being created from + * \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); + + +/** + * 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 toolbar style and size 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); + /** * sets up the images for scaffolding. @@ -25,68 +59,8 @@ void nsgtk_theme_implement(struct nsgtk_scaffolding *g); void nsgtk_toolbar_customization_init(struct nsgtk_scaffolding *g); -void nsgtk_toolbar_init(struct nsgtk_scaffolding *g); -void nsgtk_toolbar_customization_load(struct nsgtk_scaffolding *g); -void nsgtk_toolbar_set_physical(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); -#define TOOLPROTO(q) gboolean nsgtk_toolbar_##q##_button_data(\ - GtkWidget *widget, GdkDragContext *cont, GtkSelectionData\ - *selection, guint info, guint time, gpointer data);\ -gboolean nsgtk_toolbar_##q##_toolbar_button_data(GtkWidget *widget,\ - GdkDragContext *cont, GtkSelectionData *selection, guint info,\ - guint time, gpointer data) -TOOLPROTO(home); -TOOLPROTO(back); -TOOLPROTO(forward); -TOOLPROTO(reload); -TOOLPROTO(stop); -TOOLPROTO(throbber); -TOOLPROTO(websearch); -TOOLPROTO(history); -TOOLPROTO(newwindow); -TOOLPROTO(newtab); -TOOLPROTO(openfile); -TOOLPROTO(closetab); -TOOLPROTO(closewindow); -TOOLPROTO(savepage); -TOOLPROTO(pdf); -TOOLPROTO(plaintext); -TOOLPROTO(drawfile); -TOOLPROTO(postscript); -TOOLPROTO(printpreview); -TOOLPROTO(print); -TOOLPROTO(quit); -TOOLPROTO(cut); -TOOLPROTO(copy); -TOOLPROTO(paste); -TOOLPROTO(delete); -TOOLPROTO(selectall); -TOOLPROTO(find); -TOOLPROTO(preferences); -TOOLPROTO(zoomplus); -TOOLPROTO(zoomminus); -TOOLPROTO(zoomnormal); -TOOLPROTO(fullscreen); -TOOLPROTO(viewsource); -TOOLPROTO(downloads); -TOOLPROTO(localhistory); -TOOLPROTO(globalhistory); -TOOLPROTO(addbookmarks); -TOOLPROTO(showbookmarks); -TOOLPROTO(showcookies); -TOOLPROTO(openlocation); -TOOLPROTO(nexttab); -TOOLPROTO(prevtab); -TOOLPROTO(savewindowsize); -TOOLPROTO(toggledebugging); -TOOLPROTO(debugboxtree); -TOOLPROTO(debugdomtree); -TOOLPROTO(contents); -TOOLPROTO(guide); -TOOLPROTO(info); -TOOLPROTO(about); -#undef TOOLPROTO #endif diff --git a/frontends/gtk/toolbar_items.h b/frontends/gtk/toolbar_items.h new file mode 100644 index 000000000..fd01103d8 --- /dev/null +++ b/frontends/gtk/toolbar_items.h @@ -0,0 +1,136 @@ +/* + * Copyright 2012 Vincent Sanders <vince@netsurf-browser.org> + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * NetSurf is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * 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_TOOLBAR_ITEMS_H +#define NETSURF_GTK_TOOLBAR_ITEMS_H + +typedef enum { + BACK_BUTTON = 0, + HISTORY_BUTTON, + FORWARD_BUTTON, + STOP_BUTTON, + RELOAD_BUTTON, + HOME_BUTTON, + URL_BAR_ITEM, + WEBSEARCH_ITEM, + THROBBER_ITEM, + NEWWINDOW_BUTTON, + NEWTAB_BUTTON, + OPENFILE_BUTTON, + CLOSETAB_BUTTON, + CLOSEWINDOW_BUTTON, + SAVEPAGE_BUTTON, + PDF_BUTTON, + PLAINTEXT_BUTTON, + DRAWFILE_BUTTON, + POSTSCRIPT_BUTTON, + PRINTPREVIEW_BUTTON, + PRINT_BUTTON, + QUIT_BUTTON, + CUT_BUTTON, + COPY_BUTTON, + PASTE_BUTTON, + DELETE_BUTTON, + SELECTALL_BUTTON, + FIND_BUTTON, + PREFERENCES_BUTTON, + ZOOMPLUS_BUTTON, + ZOOMMINUS_BUTTON, + ZOOMNORMAL_BUTTON, + FULLSCREEN_BUTTON, + VIEWSOURCE_BUTTON, + DOWNLOADS_BUTTON, + SAVEWINDOWSIZE_BUTTON, + TOGGLEDEBUGGING_BUTTON, + SAVEBOXTREE_BUTTON, + SAVEDOMTREE_BUTTON, + LOCALHISTORY_BUTTON, + GLOBALHISTORY_BUTTON, + ADDBOOKMARKS_BUTTON, + SHOWBOOKMARKS_BUTTON, + SHOWCOOKIES_BUTTON, + OPENLOCATION_BUTTON, + NEXTTAB_BUTTON, + PREVTAB_BUTTON, + CONTENTS_BUTTON, + GUIDE_BUTTON, + INFO_BUTTON, + ABOUT_BUTTON, + PLACEHOLDER_BUTTON /* size indicator; array maximum indices */ +} nsgtk_toolbar_button; /* PLACEHOLDER_BUTTON - 1 */ + +#endif + +/* + * Item fields are: + * item identifier enum + * item name + * item initial visibility + */ + +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) |