34#define TAB_WIDTH_N_CHARS 15
43 GtkStyle *previous_style,
44 GtkWidget *close_button)
46 PangoFontMetrics *metrics;
47 PangoContext *context;
55 context = gtk_widget_get_pango_context(hbox);
56 metrics = pango_context_get_metrics(context,
58 pango_context_get_language(context));
60 char_width = pango_font_metrics_get_approximate_digit_width(metrics);
61 pango_font_metrics_unref(metrics);
64 GTK_ICON_SIZE_MENU, &w, &h);
66 gtk_widget_set_size_request(hbox,
70 gtk_widget_set_size_request(close_button, w + 4, h + 4);
79 GdkEventButton *event,
84 if ((event->type == GDK_BUTTON_RELEASE) && (event->button == 2)) {
85 page = (GtkWidget *)user_data;
86 gtk_widget_destroy(page);
103 GdkPixbuf *icon_pixbuf)
105 GtkWidget *ebox, *hbox, *favicon, *label, *button, *close;
111 ebox = gtk_event_box_new();
112 gtk_widget_set_events(ebox, GDK_BUTTON_PRESS_MASK);
113 gtk_container_add(GTK_CONTAINER(ebox), hbox);
116 favicon = gtk_image_new();
117 if (icon_pixbuf != NULL) {
118 gtk_image_set_from_pixbuf(GTK_IMAGE(favicon), icon_pixbuf);
122 label = gtk_label_new(title);
123 gtk_label_set_ellipsize(GTK_LABEL(label), PANGO_ELLIPSIZE_END);
124 gtk_label_set_single_line_mode(GTK_LABEL(label), TRUE);
127 gtk_widget_show(label);
130 button = gtk_button_new();
133 GTK_ICON_SIZE_LARGE_TOOLBAR);
134 gtk_container_add(GTK_CONTAINER(button), close);
136 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);
137 gtk_widget_set_tooltip_text(button,
"Close this tab.");
140 gtk_box_pack_start(GTK_BOX(hbox), favicon, FALSE, FALSE, 0);
141 gtk_box_pack_start(GTK_BOX(hbox), label, TRUE, TRUE, 0);
142 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0);
145 g_object_set_data(G_OBJECT(ebox),
"favicon", favicon);
146 g_object_set_data(G_OBJECT(ebox),
"label", label);
149 g_signal_connect_swapped(button,
151 G_CALLBACK(gtk_widget_destroy), page);
153 g_signal_connect(hbox,
158 g_signal_connect(ebox,
159 "button-release-event",
164 gtk_widget_show_all(ebox);
188 srcpagenum = gtk_notebook_get_current_page(notebook);
212 addpage = g_object_get_data(G_OBJECT(notebook),
"addtab");
215 if (selpage != addpage) {
216 NSLOG(netsurf, INFO,
"sel %d", selpagenum);
218 gw = g_object_get_data(G_OBJECT(selpage),
"gui_window");
222 gtk_widget_show(GTK_WIDGET(addpage));
223 gtk_widget_set_sensitive(GTK_WIDGET(menubar),
true);
226 gtk_widget_hide(GTK_WIDGET(addpage));
227 gtk_widget_set_sensitive(GTK_WIDGET(menubar),
false);
239 srcpage = gtk_notebook_get_nth_page(notebook,
srcpagenum);
241 gw = g_object_get_data(G_OBJECT(srcpage),
"gui_window");
247 NSLOG(netsurf, INFO,
"Failed to open new tab.");
268 pages = gtk_notebook_get_n_pages(notebook);
269 addpage = g_object_get_data(G_OBJECT(notebook),
"addtab");
271 if (((gint)page_num == (pages - 1)) &&
272 (child != addpage)) {
274 gtk_notebook_reorder_child(notebook, addpage, -1);
290 gtk_notebook_set_tab_pos(notebook, GTK_POS_TOP);
294 gtk_notebook_set_tab_pos(notebook, GTK_POS_LEFT);
298 gtk_notebook_set_tab_pos(notebook, GTK_POS_RIGHT);
302 gtk_notebook_set_tab_pos(notebook, GTK_POS_BOTTOM);
315 GtkWidget *tabcontents;
322 GTK_ICON_SIZE_LARGE_TOOLBAR);
323 gtk_widget_set_tooltip_text(add,
"New Tab");
325 gtk_box_pack_start(GTK_BOX(tablabel), add, FALSE, FALSE, 0);
327 gtk_widget_show_all(tablabel);
329 gtk_notebook_append_page(notebook, tabcontents, tablabel);
331 gtk_notebook_set_tab_reorderable(notebook, tabcontents,
false);
333 gtk_widget_show_all(tabcontents);
335 g_object_set_data(G_OBJECT(notebook),
"addtab", tabcontents);
350 pagec = gtk_notebook_get_n_pages(notebook);
352 addpage = g_object_get_data(G_OBJECT(notebook),
"addtab");
353 if (addpage != NULL) {
355 if ((gint)page == pagec) {
357 gtk_notebook_set_current_page(notebook,
363 if ((
nsoption_bool(show_single_tab) ==
true) || (pagec > 1)) {
364 gtk_notebook_set_show_tabs(notebook, TRUE);
366 gtk_notebook_set_show_tabs(notebook, FALSE);
382 GtkNotebook *notebook;
384 notebook = GTK_NOTEBOOK(gtk_builder_get_object(builder,
"notebook"));
388 g_signal_connect(notebook,
392 g_signal_connect_after(notebook,
396 g_signal_connect(notebook,
400 g_signal_connect(notebook,
404 g_signal_connect(notebook,
411 *notebook_out = notebook;
419 GtkWidget *tab_contents,
422 GdkPixbuf *icon_pixbuf)
431 remember = gtk_notebook_get_current_page(notebook);
433 pages = gtk_notebook_get_n_pages(notebook);
435 newpage = gtk_notebook_insert_page(notebook, tab_contents, tabBox, pages - 1);
437 gtk_notebook_set_tab_reorderable(notebook, tab_contents,
true);
439 gtk_widget_show_all(tab_contents);
442 gtk_notebook_set_current_page(notebook, remember);
444 gtk_notebook_set_current_page(notebook, newpage);
453 GtkWidget *tab_contents,
456 GdkPixbuf *icon_pixbuf)
458 GtkNotebook *notebook;
460 g_object_set_data(G_OBJECT(tab_contents),
"gui_window", gw);
473 GtkWidget *tab_label;
474 GtkNotebook *notebook;
476 if (pixbuf == NULL) {
479 notebook = GTK_NOTEBOOK(gtk_widget_get_ancestor(page, GTK_TYPE_NOTEBOOK));
480 if (notebook == NULL) {
484 tab_label = gtk_notebook_get_tab_label(notebook, page);
485 if (tab_label == NULL) {
489 favicon = GTK_IMAGE(g_object_get_data(G_OBJECT(tab_label),
"favicon"));
491 gtk_image_set_from_pixbuf(
favicon, pixbuf);
501 GtkWidget *tab_label;
502 GtkNotebook *notebook;
508 notebook = GTK_NOTEBOOK(gtk_widget_get_ancestor(page, GTK_TYPE_NOTEBOOK));
509 if (notebook == NULL) {
513 tab_label = gtk_notebook_get_tab_label(notebook, page);
514 if (tab_label == NULL) {
518 label = GTK_LABEL(g_object_get_data(G_OBJECT(tab_label),
"label"));
520 gtk_label_set_text(label,
title);
521 gtk_widget_set_tooltip_text(tab_label,
title);
534 pagen = gtk_notebook_get_current_page(notebook);
539 page = gtk_notebook_get_nth_page(notebook, pagen);
544 addpage = g_object_get_data(G_OBJECT(notebook),
"addtab");
545 if (page == addpage) {
550 gw = g_object_get_data(G_OBJECT(page),
"gui_window");
562 gtk_notebook_prev_page(notebook);
574 pagen = gtk_notebook_get_current_page(notebook);
579 page = gtk_notebook_get_nth_page(notebook, pagen + 1);
584 addpage = g_object_get_data(G_OBJECT(notebook),
"addtab");
585 if (page == addpage) {
590 gtk_notebook_set_current_page(notebook, pagen + 1);
Browser window creation and manipulation interface.
GtkStateFlags nsgtk_widget_get_state_flags(GtkWidget *widget)
void nsgtk_button_set_focus_on_click(GtkButton *button, gboolean focus_on_click)
Sets whether the button will grab focus when it is clicked with the mouse.
GtkWidget * nsgtk_image_new_from_stock(const gchar *id, GtkIconSize size)
Creates a GtkImage displaying a stock icon.
void nsgtk_widget_set_margins(GtkWidget *widget, gint hmargin, gint vmargin)
Set the margins of a widget.
const PangoFontDescription * nsgtk_style_context_get_font(GtkStyleContext *style, GtkStateFlags state)
GtkWidget * nsgtk_hbox_new(gboolean homogeneous, gint spacing)
GtkStyleContext * nsgtk_widget_get_style_context(GtkWidget *widget)
void nsgtk_widget_set_alignment(GtkWidget *widget, GtkAlign halign, GtkAlign valign)
Set the alignment of a widget.
gboolean nsgtk_icon_size_lookup_for_settings(GtkSettings *settings, GtkIconSize size, gint *width, gint *height)
Compatibility functions for older GTK versions (interface)
#define NSGTK_STOCK_CLOSE
GtkStateType GtkStateFlags
Browseing window text search interface.
nserror
Enumeration of error codes.
@ NSERROR_BAD_PARAMETER
Bad Parameter.
@ NSERROR_INVALID
Invalid data.
free text page search for gtk interface
void nsgtk_window_destroy_browser(struct gui_window *gw)
destroy browsing context
struct nsgtk_scaffolding * nsgtk_get_scaffold(struct gui_window *g)
get containing nsgtk scaffolding handle from gui window handle
nserror nsgtk_window_item_activate(struct gui_window *gw, nsgtk_toolbar_button itemid)
activate the handler for a item in a toolbar of a gui window
#define NSLOG(catname, level, logmsg, args...)
void nsgtk_scaffolding_set_top_level(struct gui_window *gw)
Set the current active top level gui window.
GtkNotebook * nsgtk_scaffolding_notebook(struct nsgtk_scaffolding *g)
Get the gtk notebook from a scaffold.
GtkMenuBar * nsgtk_scaffolding_menu_bar(struct nsgtk_scaffolding *gs)
struct nsgtk_scaffolding * nsgtk_scaffolding_from_notebook(GtkNotebook *notebook)
find which scaffolding contains a gtk notebook
Interface to utility string handling.
first entry in window list
struct hlcache_handle * favicon
#define TAB_WIDTH_N_CHARS
nserror nsgtk_tab_set_title(GtkWidget *page, const char *title)
set the tab title
nserror nsgtk_tab_set_icon(GtkWidget *page, GdkPixbuf *pixbuf)
set the tab icon
static GtkWidget * nsgtk_tab_add_newtab(GtkNotebook *notebook)
adds a "new tab" tab
nserror nsgtk_tab_next(GtkNotebook *notebook)
static gboolean nsgtk_tab_button_release(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
gtk event handler for button release on tab hbox
nserror nsgtk_tab_add_page(GtkNotebook *notebook, GtkWidget *tab_contents, bool background, const char *title, GdkPixbuf *icon_pixbuf)
Add new page to a notebook.
static GtkWidget * nsgtk_tab_label_setup(GtkWidget *page, const char *title, GdkPixbuf *icon_pixbuf)
Create a notebook tab label.
static void nsgtk_tab_orientation(GtkNotebook *notebook)
The tab orientation signal handler.
nserror nsgtk_notebook_create(GtkBuilder *builder, GtkNotebook **notebook_out)
create notebook
static void nsgtk_tab_visibility_update(GtkNotebook *notebook, GtkWidget *child, guint page)
callback to alter tab visibility when pages are added or removed
static void nsgtk_tab_switch_page(GtkNotebook *notebook, GtkWidget *page, guint selpagenum, gpointer user_data)
The before switch-page gtk signal handler.
static void nsgtk_tab_update_size(GtkWidget *hbox, GtkStyle *previous_style, GtkWidget *close_button)
callback to update sizes when style-set gtk signal
nserror nsgtk_tab_close_current(GtkNotebook *notebook)
static void nsgtk_tab_page_reordered(GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer user_data)
The tab reordered gtk signal handler.
static void nsgtk_tab_switch_page_after(GtkNotebook *notebook, GtkWidget *selpage, guint selpagenum, gpointer user_data)
The after switch-page gtk signal handler.
nserror nsgtk_tab_prev(GtkNotebook *notebook)
void nsgtk_tab_options_changed(GtkNotebook *notebook)
void nsgtk_tab_add(struct gui_window *gw, GtkWidget *tab_contents, bool background, const char *title, GdkPixbuf *icon_pixbuf)
Add new gui window page to notebook.
Option reading and saving interface.
#define nsoption_int(OPTION)
Get the value of an integer option.
#define nsoption_bool(OPTION)
Get the value of a boolean option.