NetSurf
Macros | Functions
menu.c File Reference
#include <stdlib.h>
#include <stdbool.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "utils/messages.h"
#include "gtk/compat.h"
#include "gtk/menu.h"
#include "gtk/warn.h"
#include "gtk/accelerator.h"
Include dependency graph for menu.c:

Go to the source code of this file.

Macros

#define NEW_MENU(n, m)
 
#define IMAGE_ITEM(p, q, r, s, t)    nsgtk_menu_add_image_item(s->p##_menu, &(s->q##_menuitem), #r, t)
 
#define CHECK_ITEM(p, q, r, s)
 
#define SET_SUBMENU(q, r)
 
#define ADD_NAMED_SEP(q, r, s)
 
#define ADD_SEP(q, r)
 
#define ATTACH_PARENT(parent, msgname, menuv, group)
 

Functions

static bool nsgtk_menu_add_image_item (GtkMenu *menu, GtkWidget **item_out, const char *message, GtkAccelGroup *group)
 Adds image menu item to a menu. More...
 
static struct nsgtk_export_submenunsgtk_menu_export_submenu (GtkAccelGroup *group)
 creates an export submenu More...
 
static struct nsgtk_scaleview_submenunsgtk_menu_scaleview_submenu (GtkAccelGroup *group)
 creates a scaleview submenu More...
 
static struct nsgtk_tabs_submenunsgtk_menu_tabs_submenu (GtkAccelGroup *group)
 creates a tab navigation submenu More...
 
static struct nsgtk_toolbars_submenunsgtk_menu_toolbars_submenu (GtkAccelGroup *group)
 creates a toolbars submenu More...
 
static struct nsgtk_developer_submenunsgtk_menu_developer_submenu (GtkAccelGroup *group)
 creates a debugging submenu More...
 
static struct nsgtk_file_menunsgtk_menu_file_submenu (GtkAccelGroup *group)
 creates the file menu More...
 
static struct nsgtk_edit_menunsgtk_menu_edit_submenu (GtkAccelGroup *group)
 creates an edit menu More...
 
static struct nsgtk_view_menunsgtk_menu_view_submenu (GtkAccelGroup *group)
 creates a view menu More...
 
static struct nsgtk_nav_menunsgtk_menu_nav_submenu (GtkAccelGroup *group)
 creates a nav menu More...
 
static struct nsgtk_tools_menunsgtk_menu_tools_submenu (GtkAccelGroup *group)
 creates the tools menu More...
 
static struct nsgtk_help_menunsgtk_menu_help_submenu (GtkAccelGroup *group)
 creates a help menu More...
 
struct nsgtk_bar_submenunsgtk_menu_bar_create (GtkMenuShell *menubar, GtkAccelGroup *group)
 Generate menubar menus. More...
 
struct nsgtk_burger_menunsgtk_burger_menu_create (GtkAccelGroup *group)
 Generate burger menu. More...
 
struct nsgtk_popup_menunsgtk_popup_menu_create (GtkAccelGroup *group)
 Generate right click popup menu. More...
 
struct nsgtk_link_menunsgtk_link_menu_create (GtkAccelGroup *group)
 Generate context sensitive link popup menu. More...
 
nserror nsgtk_menu_bar_destroy (struct nsgtk_bar_submenu *menu)
 destroy bar menu More...
 
nserror nsgtk_burger_menu_destroy (struct nsgtk_burger_menu *menu)
 destroy burger menu More...
 
nserror nsgtk_popup_menu_destroy (struct nsgtk_popup_menu *menu)
 destroy popup menu More...
 
nserror nsgtk_link_menu_destroy (struct nsgtk_link_menu *menu)
 destroy link menu More...
 

Macro Definition Documentation

◆ ADD_NAMED_SEP

#define ADD_NAMED_SEP (   q,
  r,
 
)
Value:
do { \
s->r##_separator = gtk_separator_menu_item_new(); \
if ((s->r##_separator != NULL) && (s->q##_menu != NULL)) { \
gtk_menu_shell_append(GTK_MENU_SHELL(s->q##_menu), s->r##_separator); \
gtk_widget_show(s->r##_separator); \
} \
} while(0)

Definition at line 111 of file menu.c.

◆ ADD_SEP

#define ADD_SEP (   q,
 
)
Value:
do { \
GtkWidget *w = gtk_separator_menu_item_new(); \
if ((w != NULL) && (r->q##_menu != NULL)) { \
gtk_menu_shell_append(GTK_MENU_SHELL(r->q##_menu), w); \
gtk_widget_show(w); \
} \
} while(0)

Definition at line 120 of file menu.c.

◆ ATTACH_PARENT

#define ATTACH_PARENT (   parent,
  msgname,
  menuv,
  group 
)
Value:
do { \
/* create top level menu entry and attach to parent */ \
menuv = GTK_MENU_ITEM(gtk_menu_item_new_with_mnemonic(messages_get(#msgname))); \
gtk_menu_shell_append(parent, GTK_WIDGET(menuv)); \
gtk_widget_show(GTK_WIDGET(menuv)); \
/* attach submenu to parent */ \
gtk_menu_item_set_submenu(menuv, GTK_WIDGET(menuv##_menu)); \
gtk_menu_set_accel_group(menuv##_menu, group); \
} while(0)
wimp_w parent
Definition: dialog.c:88
const char * messages_get(const char *key)
Fast lookup of a message by key from the standard Messages hash.
Definition: messages.c:241

Definition at line 129 of file menu.c.

◆ CHECK_ITEM

#define CHECK_ITEM (   p,
  q,
  r,
 
)
Value:
do { \
s->q##_menuitem = GTK_CHECK_MENU_ITEM( \
gtk_check_menu_item_new_with_mnemonic(\
messages_get(#r)));\
if ((s->q##_menuitem != NULL) && (s->p##_menu != NULL)) { \
gtk_menu_shell_append(GTK_MENU_SHELL(s->p##_menu), \
GTK_WIDGET(s->q##_menuitem)); \
gtk_widget_show(GTK_WIDGET(s->q##_menuitem)); \
} \
} while(0)

Definition at line 88 of file menu.c.

◆ IMAGE_ITEM

#define IMAGE_ITEM (   p,
  q,
  r,
  s,
 
)     nsgtk_menu_add_image_item(s->p##_menu, &(s->q##_menuitem), #r, t)

Definition at line 85 of file menu.c.

◆ NEW_MENU

#define NEW_MENU (   n,
 
)
Value:
n = malloc(sizeof(*n)); \
if (n == NULL) { \
return NULL; \
} \
n->m##_menu = GTK_MENU(gtk_menu_new())

Definition at line 78 of file menu.c.

◆ SET_SUBMENU

#define SET_SUBMENU (   q,
 
)
Value:
do { \
r->q##_submenu = nsgtk_menu_##q##_submenu(group); \
if ((r->q##_submenu != NULL) && \
(r->q##_submenu->q##_menu != NULL) && \
(r->q##_menuitem != NULL)) { \
gtk_menu_item_set_submenu(GTK_MENU_ITEM(r->q##_menuitem), \
GTK_WIDGET(r->q##_submenu->q##_menu)); \
} \
} while(0)

Definition at line 100 of file menu.c.

Function Documentation

◆ nsgtk_burger_menu_create()

struct nsgtk_burger_menu * nsgtk_burger_menu_create ( GtkAccelGroup *  group)

Generate burger menu.

Parameters
acceleratorgroup to use with menu
Returns
new menu structure or NULL on error

Definition at line 522 of file menu.c.

References IMAGE_ITEM, NEW_MENU, SET_SUBMENU, and view.

Referenced by create_scaffolding_burger_menu().

Here is the caller graph for this function:

◆ nsgtk_burger_menu_destroy()

nserror nsgtk_burger_menu_destroy ( struct nsgtk_burger_menu menu)

destroy burger menu

destroys the gtk widgets associated with menu and frees all storage.

Parameters
menumenu to destroy
Returns
NSERROR_OK and menu destroyed on success else error code

Definition at line 623 of file menu.c.

References nsgtk_burger_menu::burger_menu, nsgtk_tools_menu::developer_submenu, nsgtk_burger_menu::edit_submenu, nsgtk_file_menu::export_submenu, nsgtk_burger_menu::file_submenu, nsgtk_burger_menu::help_submenu, nsgtk_burger_menu::nav_submenu, NSERROR_OK, nsgtk_view_menu::scaleview_submenu, nsgtk_view_menu::tabs_submenu, nsgtk_view_menu::toolbars_submenu, nsgtk_burger_menu::tools_submenu, and nsgtk_burger_menu::view_submenu.

Referenced by scaffolding_window_destroy().

Here is the caller graph for this function:

◆ nsgtk_link_menu_create()

struct nsgtk_link_menu * nsgtk_link_menu_create ( GtkAccelGroup *  group)

Generate context sensitive link popup menu.

Parameters
acceleratorgroup to use with menu
Returns
new menu structure or NULL on error

Definition at line 582 of file menu.c.

References ADD_SEP, IMAGE_ITEM, and NEW_MENU.

Referenced by create_scaffolding_link_menu().

Here is the caller graph for this function:

◆ nsgtk_link_menu_destroy()

nserror nsgtk_link_menu_destroy ( struct nsgtk_link_menu menu)

destroy link menu

destroys the gtk widgets associated with menu and frees all storage.

Parameters
menumenu to destroy
Returns
NSERROR_OK and menu destroyed on success else error code

Definition at line 659 of file menu.c.

References nsgtk_link_menu::link_menu, and NSERROR_OK.

Referenced by scaffolding_window_destroy().

Here is the caller graph for this function:

◆ nsgtk_menu_add_image_item()

static bool nsgtk_menu_add_image_item ( GtkMenu *  menu,
GtkWidget **  item_out,
const char *  message,
GtkAccelGroup *  group 
)
static

Adds image menu item to a menu.

Parameters
menuthe menu to add the item to
item_outa pointer to the item's location in the menu struct
messagethe menu item I18n lookup value
groupthe 'global' in a gtk sense accelerator group
Returns
true if sucessful and item_out updated else false.

Definition at line 43 of file menu.c.

References messages_get(), nsgtk_accelerator_get_desc(), and nsgtk_image_menu_item_new_with_mnemonic().

Here is the call graph for this function:

◆ nsgtk_menu_bar_create()

struct nsgtk_bar_submenu * nsgtk_menu_bar_create ( GtkMenuShell *  menubar,
GtkAccelGroup *  group 
)

Generate menubar menus.

Create main menubar menu.

Generate the main menu structure and attach it to a menubar widget.

Definition at line 488 of file menu.c.

References ATTACH_PARENT, nsgtk_bar_submenu::bar_menu, nsgtk_edit_menu::edit, nsgtk_bar_submenu::edit_submenu, nsgtk_file_menu::file, nsgtk_bar_submenu::file_submenu, nsgtk_help_menu::help, nsgtk_bar_submenu::help_submenu, nsgtk_nav_menu::nav, nsgtk_bar_submenu::nav_submenu, nsgtk_menu_edit_submenu(), nsgtk_menu_file_submenu(), nsgtk_menu_help_submenu(), nsgtk_menu_nav_submenu(), nsgtk_menu_tools_submenu(), nsgtk_menu_view_submenu(), nsgtk_tools_menu::tools, nsgtk_bar_submenu::tools_submenu, nsgtk_view_menu::view, and nsgtk_bar_submenu::view_submenu.

Referenced by create_scaffolding_bar_menu().

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

◆ nsgtk_menu_bar_destroy()

nserror nsgtk_menu_bar_destroy ( struct nsgtk_bar_submenu menu)

destroy bar menu

destroys the gtk widgets associated with menu and frees all storage.

Parameters
menumenu to destroy
Returns
NSERROR_OK and menu destroyed on success else error code

Definition at line 602 of file menu.c.

References nsgtk_bar_submenu::bar_menu, nsgtk_tools_menu::developer_submenu, nsgtk_bar_submenu::edit_submenu, nsgtk_file_menu::export_submenu, nsgtk_bar_submenu::file_submenu, nsgtk_bar_submenu::help_submenu, nsgtk_bar_submenu::nav_submenu, NSERROR_OK, nsgtk_view_menu::scaleview_submenu, nsgtk_view_menu::tabs_submenu, nsgtk_view_menu::toolbars_submenu, nsgtk_bar_submenu::tools_submenu, and nsgtk_bar_submenu::view_submenu.

Referenced by scaffolding_window_destroy().

Here is the caller graph for this function:

◆ nsgtk_menu_developer_submenu()

static struct nsgtk_developer_submenu * nsgtk_menu_developer_submenu ( GtkAccelGroup *  group)
static

creates a debugging submenu

Parameters
groupthe 'global' in a gtk sense accelerator reference

Definition at line 267 of file menu.c.

References nsgtk_developer_submenu::developer_menu, IMAGE_ITEM, messages_get(), and nsgtk_warning().

Here is the call graph for this function:

◆ nsgtk_menu_edit_submenu()

static struct nsgtk_edit_menu * nsgtk_menu_edit_submenu ( GtkAccelGroup *  group)
static

creates an edit menu

Parameters
groupthe 'global' in a gtk sense accelerator reference

Definition at line 334 of file menu.c.

References ADD_SEP, nsgtk_edit_menu::edit, nsgtk_edit_menu::edit_menu, IMAGE_ITEM, messages_get(), and nsgtk_warning().

Referenced by nsgtk_menu_bar_create().

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

◆ nsgtk_menu_export_submenu()

static struct nsgtk_export_submenu * nsgtk_menu_export_submenu ( GtkAccelGroup *  group)
static

creates an export submenu

Parameters
groupthe 'global' in a gtk sense accelerator reference

Definition at line 145 of file menu.c.

References nsgtk_export_submenu::export_menu, IMAGE_ITEM, messages_get(), and nsgtk_warning().

Here is the call graph for this function:

◆ nsgtk_menu_file_submenu()

static struct nsgtk_file_menu * nsgtk_menu_file_submenu ( GtkAccelGroup *  group)
static

creates the file menu

Parameters
groupThe gtk 'global' accelerator reference
Returns
The new file menu or NULL on error

Definition at line 296 of file menu.c.

References ADD_SEP, nsgtk_file_menu::file, nsgtk_file_menu::file_menu, IMAGE_ITEM, messages_get(), nsgtk_warning(), and SET_SUBMENU.

Referenced by nsgtk_menu_bar_create().

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

◆ nsgtk_menu_help_submenu()

static struct nsgtk_help_menu * nsgtk_menu_help_submenu ( GtkAccelGroup *  group)
static

creates a help menu

Parameters
groupthe 'global' in a gtk sense accelerator reference

Definition at line 459 of file menu.c.

References ADD_SEP, nsgtk_help_menu::help, nsgtk_help_menu::help_menu, IMAGE_ITEM, messages_get(), and nsgtk_warning().

Referenced by nsgtk_menu_bar_create().

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

◆ nsgtk_menu_nav_submenu()

static struct nsgtk_nav_menu * nsgtk_menu_nav_submenu ( GtkAccelGroup *  group)
static

creates a nav menu

Parameters
groupthe 'global' in a gtk sense accelerator reference

Definition at line 398 of file menu.c.

References ADD_SEP, IMAGE_ITEM, messages_get(), nsgtk_nav_menu::nav, nsgtk_nav_menu::nav_menu, nsgtk_warning(), and reload.

Referenced by nsgtk_menu_bar_create().

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

◆ nsgtk_menu_scaleview_submenu()

static struct nsgtk_scaleview_submenu * nsgtk_menu_scaleview_submenu ( GtkAccelGroup *  group)
static

creates a scaleview submenu

Parameters
groupthe 'global' in a gtk sense accelerator reference

Definition at line 174 of file menu.c.

References IMAGE_ITEM, messages_get(), nsgtk_warning(), and nsgtk_scaleview_submenu::scaleview_menu.

Here is the call graph for this function:

◆ nsgtk_menu_tabs_submenu()

static struct nsgtk_tabs_submenu * nsgtk_menu_tabs_submenu ( GtkAccelGroup *  group)
static

creates a tab navigation submenu

Parameters
groupthe 'global' in a gtk sense accelerator reference

Definition at line 199 of file menu.c.

References IMAGE_ITEM, messages_get(), nsgtk_warning(), tabs, and nsgtk_tabs_submenu::tabs_menu.

Here is the call graph for this function:

◆ nsgtk_menu_toolbars_submenu()

static struct nsgtk_toolbars_submenu * nsgtk_menu_toolbars_submenu ( GtkAccelGroup *  group)
static

creates a toolbars submenu

Parameters
groupthe 'global' in a gtk sense accelerator reference

Definition at line 227 of file menu.c.

References ADD_SEP, CHECK_ITEM, IMAGE_ITEM, nsgtk_toolbars_submenu::menubar_menuitem, messages_get(), nsgtk_warning(), nsgtk_toolbars_submenu::toolbar_menuitem, toolbars, and nsgtk_toolbars_submenu::toolbars_menu.

Here is the call graph for this function:

◆ nsgtk_menu_tools_submenu()

static struct nsgtk_tools_menu * nsgtk_menu_tools_submenu ( GtkAccelGroup *  group)
static

creates the tools menu

Parameters
groupthe 'global' in a gtk sense accelerator reference

Definition at line 433 of file menu.c.

References IMAGE_ITEM, messages_get(), nsgtk_warning(), SET_SUBMENU, nsgtk_tools_menu::tools, and nsgtk_tools_menu::tools_menu.

Referenced by nsgtk_menu_bar_create().

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

◆ nsgtk_menu_view_submenu()

static struct nsgtk_view_menu * nsgtk_menu_view_submenu ( GtkAccelGroup *  group)
static

creates a view menu

Parameters
groupthe 'global' in a gtk sense accelerator reference

Definition at line 366 of file menu.c.

References ADD_SEP, IMAGE_ITEM, messages_get(), nsgtk_warning(), SET_SUBMENU, tabs, toolbars, view, and nsgtk_view_menu::view_menu.

Referenced by nsgtk_menu_bar_create().

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

◆ nsgtk_popup_menu_create()

struct nsgtk_popup_menu * nsgtk_popup_menu_create ( GtkAccelGroup *  group)

Generate right click popup menu.

Parameters
acceleratorgroup to use with menu
Returns
new menu structure or NULL on error

Definition at line 551 of file menu.c.

References ADD_NAMED_SEP, IMAGE_ITEM, NEW_MENU, reload, SET_SUBMENU, and toolbars.

Referenced by create_scaffolding_popup_menu().

Here is the caller graph for this function:

◆ nsgtk_popup_menu_destroy()

nserror nsgtk_popup_menu_destroy ( struct nsgtk_popup_menu menu)

destroy popup menu

destroys the gtk widgets associated with menu and frees all storage.

Parameters
menumenu to destroy
Returns
NSERROR_OK and menu destroyed on success else error code

Definition at line 645 of file menu.c.

References nsgtk_tools_menu::developer_submenu, NSERROR_OK, nsgtk_popup_menu::popup_menu, nsgtk_popup_menu::toolbars_submenu, and nsgtk_popup_menu::tools_submenu.

Referenced by scaffolding_window_destroy().

Here is the caller graph for this function: