NetSurf
Macros | Functions | Variables
tabs.c File Reference
#include <stdint.h>
#include <string.h>
#include "utils/nsoption.h"
#include "utils/log.h"
#include "netsurf/browser_window.h"
#include "desktop/search.h"
#include "gtk/compat.h"
#include "gtk/toolbar_items.h"
#include "gtk/scaffolding.h"
#include "gtk/window.h"
#include "gtk/search.h"
#include "gtk/tabs.h"
Include dependency graph for tabs.c:

Go to the source code of this file.

Macros

#define TAB_WIDTH_N_CHARS   15
 

Functions

static void nsgtk_tab_update_size (GtkWidget *hbox, GtkStyle *previous_style, GtkWidget *close_button)
 callback to update sizes when style-set gtk signal More...
 
static gboolean nsgtk_tab_button_release (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
 gtk event handler for button release on tab hbox More...
 
static GtkWidget * nsgtk_tab_label_setup (GtkWidget *page, const char *title, GdkPixbuf *icon_pixbuf)
 Create a notebook tab label. More...
 
static void nsgtk_tab_switch_page (GtkNotebook *notebook, GtkWidget *page, guint selpagenum, gpointer user_data)
 The before switch-page gtk signal handler. More...
 
static void nsgtk_tab_switch_page_after (GtkNotebook *notebook, GtkWidget *selpage, guint selpagenum, gpointer user_data)
 The after switch-page gtk signal handler. More...
 
static void nsgtk_tab_page_reordered (GtkNotebook *notebook, GtkWidget *child, guint page_num, gpointer user_data)
 The tab reordered gtk signal handler. More...
 
static void nsgtk_tab_orientation (GtkNotebook *notebook)
 The tab orientation signal handler. More...
 
static GtkWidget * nsgtk_tab_add_newtab (GtkNotebook *notebook)
 adds a "new tab" tab More...
 
static void nsgtk_tab_visibility_update (GtkNotebook *notebook, GtkWidget *child, guint page)
 callback to alter tab visibility when pages are added or removed More...
 
void nsgtk_tab_options_changed (GtkNotebook *notebook)
 
nserror nsgtk_notebook_create (GtkBuilder *builder, GtkNotebook **notebook_out)
 create notebook More...
 
nserror nsgtk_tab_add_page (GtkNotebook *notebook, GtkWidget *tab_contents, bool background, const char *title, GdkPixbuf *icon_pixbuf)
 Add new page to a notebook. More...
 
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. More...
 
nserror nsgtk_tab_set_icon (GtkWidget *page, GdkPixbuf *pixbuf)
 set the tab icon More...
 
nserror nsgtk_tab_set_title (GtkWidget *page, const char *title)
 set the tab title More...
 
nserror nsgtk_tab_close_current (GtkNotebook *notebook)
 
nserror nsgtk_tab_prev (GtkNotebook *notebook)
 
nserror nsgtk_tab_next (GtkNotebook *notebook)
 

Variables

static gint srcpagenum
 

Macro Definition Documentation

◆ TAB_WIDTH_N_CHARS

#define TAB_WIDTH_N_CHARS   15

Definition at line 34 of file tabs.c.

Function Documentation

◆ nsgtk_notebook_create()

nserror nsgtk_notebook_create ( GtkBuilder *  builder,
GtkNotebook **  notebook_out 
)

create notebook

creates a notebook for use inside a window, creates the special add page(tab) and attaches all signals.

Parameters
builderthe gtk builder object to create notbook from
notebook_outreciveds the created notebook
Returns
NSERROR_OK and notebook_out updated else error code

Definition at line 380 of file tabs.c.

References NSERROR_OK, nsgtk_tab_add_newtab(), nsgtk_tab_options_changed(), nsgtk_tab_page_reordered(), nsgtk_tab_switch_page(), nsgtk_tab_switch_page_after(), and nsgtk_tab_visibility_update().

Referenced by nsgtk_new_scaffolding().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_tab_add()

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.

Definition at line 452 of file tabs.c.

References nsgtk_get_scaffold(), nsgtk_scaffolding_notebook(), nsgtk_tab_add_page(), and gui_window::title.

Referenced by gui_window_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_tab_add_newtab()

static GtkWidget * nsgtk_tab_add_newtab ( GtkNotebook *  notebook)
static

adds a "new tab" tab

Definition at line 312 of file tabs.c.

References nsgtk_hbox_new(), and NSGTK_STOCK_ADD.

Referenced by nsgtk_notebook_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_tab_add_page()

nserror nsgtk_tab_add_page ( GtkNotebook *  notebook,
GtkWidget *  tab_contents,
bool  background,
const char *  title,
GdkPixbuf *  icon_pixbuf 
)

Add new page to a notebook.

Definition at line 418 of file tabs.c.

References NSERROR_OK, nsgtk_tab_label_setup(), and gui_window::title.

Referenced by cutomize_button_clicked_cb(), and nsgtk_tab_add().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_tab_button_release()

static gboolean nsgtk_tab_button_release ( GtkWidget *  widget,
GdkEventButton *  event,
gpointer  user_data 
)
static

gtk event handler for button release on tab hbox

Definition at line 78 of file tabs.c.

Referenced by nsgtk_tab_label_setup().

Here is the caller graph for this function:

◆ nsgtk_tab_close_current()

nserror nsgtk_tab_close_current ( GtkNotebook *  notebook)

Definition at line 527 of file tabs.c.

References NSERROR_OK, and nsgtk_window_destroy_browser().

Referenced by nsgtk_on_closetab_activate_menu().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_tab_label_setup()

static GtkWidget * nsgtk_tab_label_setup ( GtkWidget *  page,
const char *  title,
GdkPixbuf *  icon_pixbuf 
)
static

Create a notebook tab label.

Parameters
pageThe page content widget
titleThe title of the page
icon_pixbufThe icon of the page

Definition at line 101 of file tabs.c.

References GTK_ALIGN_CENTER, GTK_ALIGN_START, nsgtk_button_set_focus_on_click(), nsgtk_hbox_new(), nsgtk_image_new_from_stock(), NSGTK_STOCK_CLOSE, nsgtk_tab_button_release(), nsgtk_tab_update_size(), nsgtk_widget_set_alignment(), and nsgtk_widget_set_margins().

Referenced by nsgtk_tab_add_page().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_tab_next()

nserror nsgtk_tab_next ( GtkNotebook *  notebook)

Definition at line 568 of file tabs.c.

References NSERROR_OK.

Referenced by nsgtk_on_nexttab_activate_menu().

Here is the caller graph for this function:

◆ nsgtk_tab_options_changed()

void nsgtk_tab_options_changed ( GtkNotebook *  notebook)

Definition at line 372 of file tabs.c.

References nsgtk_tab_orientation(), and nsgtk_tab_visibility_update().

Referenced by nsgtk_notebook_create(), and nsgtk_window_update_all().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_tab_orientation()

static void nsgtk_tab_orientation ( GtkNotebook *  notebook)
static

The tab orientation signal handler.

Parameters
notebookThe notebook being changed
page_numThe currently selected page number
user_dataUnused

Definition at line 286 of file tabs.c.

References nsoption_int.

Referenced by nsgtk_tab_options_changed().

Here is the caller graph for this function:

◆ nsgtk_tab_page_reordered()

static void nsgtk_tab_page_reordered ( GtkNotebook *  notebook,
GtkWidget *  child,
guint  page_num,
gpointer  user_data 
)
static

The tab reordered gtk signal handler.

Parameters
notebookThe notebook being changed
page_numThe currently selected page number
user_dataUnused

Definition at line 260 of file tabs.c.

Referenced by nsgtk_notebook_create().

Here is the caller graph for this function:

◆ nsgtk_tab_prev()

nserror nsgtk_tab_prev ( GtkNotebook *  notebook)

Definition at line 560 of file tabs.c.

References NSERROR_OK.

Referenced by nsgtk_on_prevtab_activate_menu().

Here is the caller graph for this function:

◆ nsgtk_tab_set_icon()

nserror nsgtk_tab_set_icon ( GtkWidget *  page,
GdkPixbuf *  pixbuf 
)

set the tab icon

The tab icon will be set to the pixbuf parameter

Parameters
pageThe page widget that was added to the notebook
pixbufThe pixbuf to set the icon to.
Returns
NSERROR_OK on sucess else appropriate code.

Definition at line 470 of file tabs.c.

References gui_window::favicon, NSERROR_BAD_PARAMETER, NSERROR_INVALID, and NSERROR_OK.

Referenced by gui_window_set_icon(), next_throbber_frame(), and throbber().

Here is the caller graph for this function:

◆ nsgtk_tab_set_title()

nserror nsgtk_tab_set_title ( GtkWidget *  page,
const char *  title 
)

set the tab title

The tab title will be set to the parameter

Note
currently only called from nsgtk_window_set_title()
Parameters
pageThe page widget that was added to the notebook
titleThe title text which may not be NULL.
Returns
NSERROR_OK on sucess else appropriate code.

Definition at line 498 of file tabs.c.

References NSERROR_BAD_PARAMETER, NSERROR_INVALID, NSERROR_OK, and gui_window::title.

Referenced by gui_window_set_title().

Here is the caller graph for this function:

◆ nsgtk_tab_switch_page()

static void nsgtk_tab_switch_page ( GtkNotebook *  notebook,
GtkWidget *  page,
guint  selpagenum,
gpointer  user_data 
)
static

The before switch-page gtk signal handler.

This signal is handled both before and after delivery to work round issue that setting the selected tab during the switch-page signal fails

Parameters
notebookThe notebook being changed
pageThe notebook page being switched to
selpagenumThe currently selected page number
user_dataUnused

Definition at line 183 of file tabs.c.

References srcpagenum.

Referenced by nsgtk_notebook_create().

Here is the caller graph for this function:

◆ nsgtk_tab_switch_page_after()

static void nsgtk_tab_switch_page_after ( GtkNotebook *  notebook,
GtkWidget *  selpage,
guint  selpagenum,
gpointer  user_data 
)
static

The after switch-page gtk signal handler.

Parameters
notebookThe notebook being changed
selpageThe notebook page selected
selpagenumThe currently selected page number
user_dataUnused

Definition at line 201 of file tabs.c.

References NEWTAB_BUTTON, NSERROR_INVALID, NSERROR_OK, nsgtk_scaffolding_from_notebook(), nsgtk_scaffolding_menu_bar(), nsgtk_scaffolding_set_top_level(), nsgtk_window_item_activate(), NSLOG, and srcpagenum.

Referenced by nsgtk_notebook_create().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_tab_update_size()

static void nsgtk_tab_update_size ( GtkWidget *  hbox,
GtkStyle *  previous_style,
GtkWidget *  close_button 
)
static

callback to update sizes when style-set gtk signal

Definition at line 42 of file tabs.c.

References nsgtk_icon_size_lookup_for_settings(), nsgtk_style_context_get_font(), nsgtk_widget_get_state_flags(), nsgtk_widget_get_style_context(), and TAB_WIDTH_N_CHARS.

Referenced by nsgtk_tab_label_setup().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsgtk_tab_visibility_update()

static void nsgtk_tab_visibility_update ( GtkNotebook *  notebook,
GtkWidget *  child,
guint  page 
)
static

callback to alter tab visibility when pages are added or removed

Definition at line 345 of file tabs.c.

References nsoption_bool.

Referenced by nsgtk_notebook_create(), and nsgtk_tab_options_changed().

Here is the caller graph for this function:

Variable Documentation

◆ srcpagenum

gint srcpagenum
static

Definition at line 36 of file tabs.c.

Referenced by nsgtk_tab_switch_page(), and nsgtk_tab_switch_page_after().