Make the gtk menus fully translatable
clean up the macro madness a bit in gtk_menu.c svn path=/trunk/netsurf/; revision=10796
This commit is contained in:
parent
300d094f2f
commit
ae4339a970
|
@ -449,6 +449,13 @@ gtkUnknownSize:unknown
|
|||
# gtk Menu / Button labels
|
||||
#
|
||||
|
||||
gtkFile:_File
|
||||
gtkEdit:_Edit
|
||||
gtkView:_View
|
||||
gtkNavigate:_Navigate
|
||||
gtkTabs:_Tabs
|
||||
gtkHelp:_Help
|
||||
|
||||
gtkNewTab:New _Tab
|
||||
gtkNewTabAccel:<ctrl>t
|
||||
gtkNewWindow:_New Window
|
||||
|
|
288
gtk/gtk_menu.c
288
gtk/gtk_menu.c
|
@ -56,7 +56,7 @@ static bool nsgtk_menu_add_image_item(GtkMenu *menu,
|
|||
|
||||
#define IMAGE_ITEM(p, q, r, s, t)\
|
||||
nsgtk_menu_add_image_item(s->p##_menu, &(s->q##_menuitem), #r,\
|
||||
#r "Accel", t);
|
||||
#r "Accel", t)
|
||||
|
||||
#define CHECK_ITEM(p, q, r, s)\
|
||||
s->q##_menuitem = GTK_CHECK_MENU_ITEM(\
|
||||
|
@ -68,20 +68,38 @@ static bool nsgtk_menu_add_image_item(GtkMenu *menu,
|
|||
gtk_widget_show(GTK_WIDGET(s->q##_menuitem));\
|
||||
}
|
||||
|
||||
#define SET_SUBMENU(q, r)\
|
||||
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));\
|
||||
}
|
||||
#define SET_SUBMENU(q, r) \
|
||||
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)
|
||||
|
||||
#define ADD_SEP(q, r)\
|
||||
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);\
|
||||
}
|
||||
#define ADD_SEP(q, r) \
|
||||
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)
|
||||
|
||||
#define ATTACH_PARENT(parent, msgname, menuv, group) \
|
||||
do { \
|
||||
if (parent != NULL) { \
|
||||
/* 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)
|
||||
|
||||
/**
|
||||
* creates an export submenu
|
||||
|
@ -102,10 +120,10 @@ static struct nsgtk_export_submenu *nsgtk_menu_export_submenu(GtkAccelGroup *gro
|
|||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
IMAGE_ITEM(export, plaintext, gtkPlainText, ret, group)
|
||||
IMAGE_ITEM(export, drawfile, gtkDrawFile, ret, group)
|
||||
IMAGE_ITEM(export, postscript, gtkPostScript, ret, group)
|
||||
IMAGE_ITEM(export, pdf, gtkPDF, ret, group)
|
||||
IMAGE_ITEM(export, plaintext, gtkPlainText, ret, group);
|
||||
IMAGE_ITEM(export, drawfile, gtkDrawFile, ret, group);
|
||||
IMAGE_ITEM(export, postscript, gtkPostScript, ret, group);
|
||||
IMAGE_ITEM(export, pdf, gtkPDF, ret, group);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -129,9 +147,9 @@ static struct nsgtk_scaleview_submenu *nsgtk_menu_scaleview_submenu(
|
|||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
IMAGE_ITEM(scaleview, zoomplus, gtkZoomPlus, ret, group)
|
||||
IMAGE_ITEM(scaleview, zoomnormal, gtkZoomNormal, ret, group)
|
||||
IMAGE_ITEM(scaleview, zoomminus, gtkZoomMinus, ret, group)
|
||||
IMAGE_ITEM(scaleview, zoomplus, gtkZoomPlus, ret, group);
|
||||
IMAGE_ITEM(scaleview, zoomnormal, gtkZoomNormal, ret, group);
|
||||
IMAGE_ITEM(scaleview, zoomminus, gtkZoomMinus, ret, group);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -208,44 +226,52 @@ static struct nsgtk_debugging_submenu *nsgtk_menu_debugging_submenu(
|
|||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
IMAGE_ITEM(debugging, toggledebugging, gtkToggleDebugging, ret, group)
|
||||
IMAGE_ITEM(debugging, saveboxtree, gtkSaveBoxTree, ret, group)
|
||||
IMAGE_ITEM(debugging, savedomtree, gtkSaveDomTree, ret, group)
|
||||
IMAGE_ITEM(debugging, toggledebugging, gtkToggleDebugging, ret, group);
|
||||
IMAGE_ITEM(debugging, saveboxtree, gtkSaveBoxTree, ret, group);
|
||||
IMAGE_ITEM(debugging, savedomtree, gtkSaveDomTree, ret, group);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates the a file menu
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
* creates the file menu
|
||||
* \param group The gtk 'global' accelerator reference
|
||||
* \param parent The parent menu to attach to or NULL
|
||||
*/
|
||||
static struct nsgtk_file_menu *nsgtk_menu_file_menu(GtkAccelGroup *group)
|
||||
static struct nsgtk_file_menu *nsgtk_menu_file_menu(GtkAccelGroup *group,
|
||||
GtkMenuShell *parent)
|
||||
{
|
||||
GtkWidget *w;
|
||||
struct nsgtk_file_menu *ret = malloc(sizeof(struct nsgtk_file_menu));
|
||||
if (ret == NULL) {
|
||||
struct nsgtk_file_menu *fmenu;
|
||||
|
||||
fmenu = malloc(sizeof(struct nsgtk_file_menu));
|
||||
if (fmenu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
return NULL;
|
||||
}
|
||||
ret->file_menu = GTK_MENU(gtk_menu_new());
|
||||
if (ret->file_menu == NULL) {
|
||||
|
||||
fmenu->file_menu = GTK_MENU(gtk_menu_new());
|
||||
if (fmenu->file_menu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
free(ret);
|
||||
free(fmenu);
|
||||
return NULL;
|
||||
}
|
||||
IMAGE_ITEM(file, newwindow, gtkNewWindow, ret, group)
|
||||
IMAGE_ITEM(file, newtab, gtkNewTab, ret, group)
|
||||
IMAGE_ITEM(file, openfile, gtkOpenFile, ret, group)
|
||||
IMAGE_ITEM(file, closewindow, gtkCloseWindow, ret, group)
|
||||
ADD_SEP(file, ret)
|
||||
IMAGE_ITEM(file, savepage, gtkSavePage, ret, group)
|
||||
IMAGE_ITEM(file, export, gtkExport, ret, group)
|
||||
ADD_SEP(file, ret)
|
||||
IMAGE_ITEM(file, printpreview, gtkPrintPreview, ret, group)
|
||||
IMAGE_ITEM(file, print, gtkPrint, ret, group)
|
||||
ADD_SEP(file, ret)
|
||||
IMAGE_ITEM(file, quit, gtkQuitMenu, ret, group)
|
||||
SET_SUBMENU(export, ret)
|
||||
return ret;
|
||||
|
||||
IMAGE_ITEM(file, newwindow, gtkNewWindow, fmenu, group);
|
||||
IMAGE_ITEM(file, newtab, gtkNewTab, fmenu, group);
|
||||
IMAGE_ITEM(file, openfile, gtkOpenFile, fmenu, group);
|
||||
IMAGE_ITEM(file, closewindow, gtkCloseWindow, fmenu, group);
|
||||
ADD_SEP(file, fmenu);
|
||||
IMAGE_ITEM(file, savepage, gtkSavePage, fmenu, group);
|
||||
IMAGE_ITEM(file, export, gtkExport, fmenu, group);
|
||||
ADD_SEP(file, fmenu);
|
||||
IMAGE_ITEM(file, printpreview, gtkPrintPreview, fmenu, group);
|
||||
IMAGE_ITEM(file, print, gtkPrint, fmenu, group);
|
||||
ADD_SEP(file, fmenu);
|
||||
IMAGE_ITEM(file, quit, gtkQuitMenu, fmenu, group);
|
||||
SET_SUBMENU(export, fmenu);
|
||||
|
||||
ATTACH_PARENT(parent, gtkFile, fmenu->file, group);
|
||||
|
||||
return fmenu;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -253,9 +279,9 @@ static struct nsgtk_file_menu *nsgtk_menu_file_menu(GtkAccelGroup *group)
|
|||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
static struct nsgtk_edit_menu *nsgtk_menu_edit_menu(GtkAccelGroup *group)
|
||||
static struct nsgtk_edit_menu *nsgtk_menu_edit_menu(GtkAccelGroup *group,
|
||||
GtkMenuShell *parent)
|
||||
{
|
||||
GtkWidget *w;
|
||||
struct nsgtk_edit_menu *ret = malloc(sizeof(struct nsgtk_edit_menu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
|
@ -267,16 +293,19 @@ static struct nsgtk_edit_menu *nsgtk_menu_edit_menu(GtkAccelGroup *group)
|
|||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
IMAGE_ITEM(edit, cut, gtkCut, ret, group)
|
||||
IMAGE_ITEM(edit, copy, gtkCopy, ret, group)
|
||||
IMAGE_ITEM(edit, paste, gtkPaste, ret, group)
|
||||
IMAGE_ITEM(edit, delete, gtkDelete, ret, group)
|
||||
ADD_SEP(edit, ret)
|
||||
IMAGE_ITEM(edit, selectall, gtkSelectAll, ret, group)
|
||||
ADD_SEP(edit, ret)
|
||||
IMAGE_ITEM(edit, find, gtkFind, ret, group)
|
||||
ADD_SEP(edit, ret)
|
||||
IMAGE_ITEM(edit, preferences, gtkPreferences, ret, group)
|
||||
IMAGE_ITEM(edit, cut, gtkCut, ret, group);
|
||||
IMAGE_ITEM(edit, copy, gtkCopy, ret, group);
|
||||
IMAGE_ITEM(edit, paste, gtkPaste, ret, group);
|
||||
IMAGE_ITEM(edit, delete, gtkDelete, ret, group);
|
||||
ADD_SEP(edit, ret);
|
||||
IMAGE_ITEM(edit, selectall, gtkSelectAll, ret, group);
|
||||
ADD_SEP(edit, ret);
|
||||
IMAGE_ITEM(edit, find, gtkFind, ret, group);
|
||||
ADD_SEP(edit, ret);
|
||||
IMAGE_ITEM(edit, preferences, gtkPreferences, ret, group);
|
||||
|
||||
ATTACH_PARENT(parent, gtkEdit, ret->edit, group);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -285,9 +314,9 @@ static struct nsgtk_edit_menu *nsgtk_menu_edit_menu(GtkAccelGroup *group)
|
|||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
static struct nsgtk_view_menu *nsgtk_menu_view_menu(GtkAccelGroup *group)
|
||||
static struct nsgtk_view_menu *nsgtk_menu_view_menu(GtkAccelGroup *group,
|
||||
GtkMenuShell *parent)
|
||||
{
|
||||
GtkWidget *w;
|
||||
struct nsgtk_view_menu *ret = malloc(sizeof(struct nsgtk_view_menu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
|
@ -299,23 +328,26 @@ static struct nsgtk_view_menu *nsgtk_menu_view_menu(GtkAccelGroup *group)
|
|||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
IMAGE_ITEM(view, stop, gtkStop, ret, group)
|
||||
IMAGE_ITEM(view, reload, gtkReload, ret, group)
|
||||
ADD_SEP(view, ret)
|
||||
IMAGE_ITEM(view, scaleview, gtkScaleView, ret, group)
|
||||
IMAGE_ITEM(view, fullscreen, gtkFullScreen, ret, group)
|
||||
IMAGE_ITEM(view, viewsource, gtkViewSource, ret, group)
|
||||
ADD_SEP(view, ret)
|
||||
IMAGE_ITEM(view, images, gtkImages, ret, group)
|
||||
IMAGE_ITEM(view, toolbars, gtkToolbars, ret, group)
|
||||
ADD_SEP(view, ret)
|
||||
IMAGE_ITEM(view, downloads, gtkDownloads, ret, group)
|
||||
IMAGE_ITEM(view, savewindowsize, gtkSaveWindowSize, ret, group)
|
||||
IMAGE_ITEM(view, debugging, gtkDebugging, ret, group)
|
||||
SET_SUBMENU(scaleview, ret)
|
||||
SET_SUBMENU(images, ret)
|
||||
SET_SUBMENU(toolbars, ret)
|
||||
SET_SUBMENU(debugging, ret)
|
||||
IMAGE_ITEM(view, stop, gtkStop, ret, group);
|
||||
IMAGE_ITEM(view, reload, gtkReload, ret, group);
|
||||
ADD_SEP(view, ret);
|
||||
IMAGE_ITEM(view, scaleview, gtkScaleView, ret, group);
|
||||
IMAGE_ITEM(view, fullscreen, gtkFullScreen, ret, group);
|
||||
IMAGE_ITEM(view, viewsource, gtkViewSource, ret, group);
|
||||
ADD_SEP(view, ret);
|
||||
IMAGE_ITEM(view, images, gtkImages, ret, group);
|
||||
IMAGE_ITEM(view, toolbars, gtkToolbars, ret, group);
|
||||
ADD_SEP(view, ret);
|
||||
IMAGE_ITEM(view, downloads, gtkDownloads, ret, group);
|
||||
IMAGE_ITEM(view, savewindowsize, gtkSaveWindowSize, ret, group);
|
||||
IMAGE_ITEM(view, debugging, gtkDebugging, ret, group);
|
||||
SET_SUBMENU(scaleview, ret);
|
||||
SET_SUBMENU(images, ret);
|
||||
SET_SUBMENU(toolbars, ret);
|
||||
SET_SUBMENU(debugging, ret);
|
||||
|
||||
ATTACH_PARENT(parent, gtkView, ret->view, group);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -324,9 +356,9 @@ static struct nsgtk_view_menu *nsgtk_menu_view_menu(GtkAccelGroup *group)
|
|||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
static struct nsgtk_nav_menu *nsgtk_menu_nav_menu(GtkAccelGroup *group)
|
||||
static struct nsgtk_nav_menu *nsgtk_menu_nav_menu(GtkAccelGroup *group,
|
||||
GtkMenuShell *parent)
|
||||
{
|
||||
GtkWidget *w;
|
||||
struct nsgtk_nav_menu *ret = malloc(sizeof(struct nsgtk_nav_menu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
|
@ -338,17 +370,20 @@ static struct nsgtk_nav_menu *nsgtk_menu_nav_menu(GtkAccelGroup *group)
|
|||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
IMAGE_ITEM(nav, back, gtkBack, ret, group)
|
||||
IMAGE_ITEM(nav, forward, gtkForward, ret, group)
|
||||
IMAGE_ITEM(nav, home, gtkHome, ret, group)
|
||||
ADD_SEP(nav, ret)
|
||||
IMAGE_ITEM(nav, localhistory, gtkLocalHistory, ret, group)
|
||||
IMAGE_ITEM(nav, globalhistory, gtkGlobalHistory, ret, group)
|
||||
ADD_SEP(nav, ret)
|
||||
IMAGE_ITEM(nav, addbookmarks, gtkAddBookMarks, ret, group)
|
||||
IMAGE_ITEM(nav, showbookmarks, gtkShowBookMarks, ret, group)
|
||||
ADD_SEP(nav, ret)
|
||||
IMAGE_ITEM(nav, openlocation, gtkOpenLocation, ret, group)
|
||||
IMAGE_ITEM(nav, back, gtkBack, ret, group);
|
||||
IMAGE_ITEM(nav, forward, gtkForward, ret, group);
|
||||
IMAGE_ITEM(nav, home, gtkHome, ret, group);
|
||||
ADD_SEP(nav, ret);
|
||||
IMAGE_ITEM(nav, localhistory, gtkLocalHistory, ret, group);
|
||||
IMAGE_ITEM(nav, globalhistory, gtkGlobalHistory, ret, group);
|
||||
ADD_SEP(nav, ret);
|
||||
IMAGE_ITEM(nav, addbookmarks, gtkAddBookMarks, ret, group);
|
||||
IMAGE_ITEM(nav, showbookmarks, gtkShowBookMarks, ret, group);
|
||||
ADD_SEP(nav, ret);
|
||||
IMAGE_ITEM(nav, openlocation, gtkOpenLocation, ret, group);
|
||||
|
||||
ATTACH_PARENT(parent, gtkNavigate, ret->nav, group);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -357,7 +392,8 @@ static struct nsgtk_nav_menu *nsgtk_menu_nav_menu(GtkAccelGroup *group)
|
|||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
static struct nsgtk_tabs_menu *nsgtk_menu_tabs_menu(GtkAccelGroup *group)
|
||||
static struct nsgtk_tabs_menu *nsgtk_menu_tabs_menu(GtkAccelGroup *group,
|
||||
GtkMenuShell *parent)
|
||||
{
|
||||
struct nsgtk_tabs_menu *ret = malloc(sizeof(struct nsgtk_tabs_menu));
|
||||
if (ret == NULL) {
|
||||
|
@ -370,9 +406,12 @@ static struct nsgtk_tabs_menu *nsgtk_menu_tabs_menu(GtkAccelGroup *group)
|
|||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
IMAGE_ITEM(tabs, nexttab, gtkNextTab, ret, group)
|
||||
IMAGE_ITEM(tabs, prevtab, gtkPrevTab, ret, group)
|
||||
IMAGE_ITEM(tabs, closetab, gtkCloseTab, ret, group)
|
||||
IMAGE_ITEM(tabs, nexttab, gtkNextTab, ret, group);
|
||||
IMAGE_ITEM(tabs, prevtab, gtkPrevTab, ret, group);
|
||||
IMAGE_ITEM(tabs, closetab, gtkCloseTab, ret, group);
|
||||
|
||||
ATTACH_PARENT(parent, gtkTabs, ret->tabs, group);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -381,9 +420,9 @@ static struct nsgtk_tabs_menu *nsgtk_menu_tabs_menu(GtkAccelGroup *group)
|
|||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
static struct nsgtk_help_menu *nsgtk_menu_help_menu(GtkAccelGroup *group)
|
||||
static struct nsgtk_help_menu *nsgtk_menu_help_menu(GtkAccelGroup *group,
|
||||
GtkMenuShell *parent)
|
||||
{
|
||||
GtkWidget *w;
|
||||
struct nsgtk_help_menu *ret = malloc(sizeof(struct nsgtk_help_menu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
|
@ -395,53 +434,44 @@ static struct nsgtk_help_menu *nsgtk_menu_help_menu(GtkAccelGroup *group)
|
|||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
IMAGE_ITEM(help, contents, gtkContents, ret, group)
|
||||
IMAGE_ITEM(help, guide, gtkGuide, ret, group)
|
||||
IMAGE_ITEM(help, info, gtkUserInformation, ret, group)
|
||||
ADD_SEP(help, ret)
|
||||
IMAGE_ITEM(help, about, gtkAbout, ret, group)
|
||||
IMAGE_ITEM(help, contents, gtkContents, ret, group);
|
||||
IMAGE_ITEM(help, guide, gtkGuide, ret, group);
|
||||
IMAGE_ITEM(help, info, gtkUserInformation, ret, group);
|
||||
ADD_SEP(help, ret);
|
||||
IMAGE_ITEM(help, about, gtkAbout, ret, group);
|
||||
|
||||
ATTACH_PARENT(parent, gtkHelp, ret->help, group);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define MENUBAR_MENU(p, q, r) \
|
||||
p->q = nsgtk_menu_##q##_menu(group, GTK_MENU_SHELL(r)); \
|
||||
p->rclick_##q = nsgtk_menu_##q##_menu(group, NULL)
|
||||
|
||||
|
||||
struct nsgtk_menu *nsgtk_menu_create(GladeXML *xml, GtkWindow *window)
|
||||
{
|
||||
GtkAccelGroup *group;
|
||||
struct nsgtk_menu *g;
|
||||
struct nsgtk_menu *nmenu;
|
||||
GtkMenuBar *menubar;
|
||||
|
||||
g = malloc(sizeof(struct nsgtk_menu));
|
||||
if (g == NULL) {
|
||||
nmenu = malloc(sizeof(struct nsgtk_menu));
|
||||
if (nmenu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
group = gtk_accel_group_new();
|
||||
gtk_window_add_accel_group(window, group);
|
||||
menubar = GTK_MENU_BAR(glade_xml_get_widget(xml, "menubar"));
|
||||
|
||||
#define MAKE_MENUS(q)\
|
||||
g->q##_menu = nsgtk_menu_##q##_menu(group);\
|
||||
g->rclick_##q##_menu = nsgtk_menu_##q##_menu(group);\
|
||||
gtk_menu_item_set_submenu(GTK_MENU_ITEM(\
|
||||
glade_xml_get_widget(xml, "menuitem_" #q)), \
|
||||
GTK_WIDGET(g->q##_menu->q##_menu));\
|
||||
gtk_menu_set_accel_group(g->q##_menu->q##_menu, group)
|
||||
MAKE_MENUS(file);
|
||||
MAKE_MENUS(edit);
|
||||
MAKE_MENUS(view);
|
||||
MAKE_MENUS(nav);
|
||||
MAKE_MENUS(tabs);
|
||||
MAKE_MENUS(help);
|
||||
#undef MAKE_MENUS
|
||||
g->edit_menu_item = GTK_MENU_ITEM(glade_xml_get_widget(xml, "menuitem_edit"));
|
||||
g->tabs_menu_item = GTK_MENU_ITEM(glade_xml_get_widget(xml, "menuitem_tabs"));
|
||||
MENUBAR_MENU(nmenu, file, menubar);
|
||||
MENUBAR_MENU(nmenu, edit, menubar);
|
||||
MENUBAR_MENU(nmenu, view, menubar);
|
||||
MENUBAR_MENU(nmenu, nav, menubar);
|
||||
MENUBAR_MENU(nmenu, tabs, menubar);
|
||||
MENUBAR_MENU(nmenu, help, menubar);
|
||||
|
||||
return g;
|
||||
return nmenu;
|
||||
}
|
||||
|
||||
|
||||
#undef CHECK_ITEM
|
||||
#undef IMAGE_ITEM
|
||||
#undef SET_SUBMENU
|
||||
#undef ADD_SEP
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
struct nsgtk_file_menu {
|
||||
GtkMenuItem *file; /* File menu item on menubar */
|
||||
GtkMenu *file_menu;
|
||||
GtkImageMenuItem *newwindow_menuitem;
|
||||
GtkImageMenuItem *newtab_menuitem;
|
||||
|
@ -35,6 +36,7 @@ struct nsgtk_file_menu {
|
|||
};
|
||||
|
||||
struct nsgtk_edit_menu {
|
||||
GtkMenuItem *edit; /* Edit menu item on menubar */
|
||||
GtkMenu *edit_menu;
|
||||
GtkImageMenuItem *cut_menuitem;
|
||||
GtkImageMenuItem *copy_menuitem;
|
||||
|
@ -46,7 +48,8 @@ struct nsgtk_edit_menu {
|
|||
};
|
||||
|
||||
struct nsgtk_view_menu {
|
||||
GtkMenu *view_menu;
|
||||
GtkMenuItem *view; /* View menu item on menubar */
|
||||
GtkMenu *view_menu; /* gtk menu attached to menu item */
|
||||
GtkImageMenuItem *stop_menuitem;
|
||||
GtkImageMenuItem *reload_menuitem;
|
||||
GtkImageMenuItem *scaleview_menuitem;
|
||||
|
@ -64,6 +67,7 @@ struct nsgtk_view_menu {
|
|||
};
|
||||
|
||||
struct nsgtk_nav_menu {
|
||||
GtkMenuItem *nav; /* Nav menu item on menubar */
|
||||
GtkMenu *nav_menu;
|
||||
GtkImageMenuItem *back_menuitem;
|
||||
GtkImageMenuItem *forward_menuitem;
|
||||
|
@ -76,6 +80,7 @@ struct nsgtk_nav_menu {
|
|||
};
|
||||
|
||||
struct nsgtk_tabs_menu {
|
||||
GtkMenuItem *tabs; /* Tabs menu item on menubar */
|
||||
GtkMenu *tabs_menu;
|
||||
GtkImageMenuItem *nexttab_menuitem;
|
||||
GtkImageMenuItem *prevtab_menuitem;
|
||||
|
@ -83,6 +88,7 @@ struct nsgtk_tabs_menu {
|
|||
};
|
||||
|
||||
struct nsgtk_help_menu {
|
||||
GtkMenuItem *help; /* Help menu item on menubar */
|
||||
GtkMenu *help_menu;
|
||||
GtkImageMenuItem *contents_menuitem;
|
||||
GtkImageMenuItem *guide_menuitem;
|
||||
|
@ -126,20 +132,18 @@ struct nsgtk_debugging_submenu {
|
|||
|
||||
|
||||
struct nsgtk_menu {
|
||||
struct nsgtk_file_menu *file_menu;
|
||||
struct nsgtk_file_menu *rclick_file_menu;
|
||||
struct nsgtk_edit_menu *edit_menu;
|
||||
struct nsgtk_edit_menu *rclick_edit_menu;
|
||||
struct nsgtk_view_menu *view_menu;
|
||||
struct nsgtk_view_menu *rclick_view_menu;
|
||||
struct nsgtk_nav_menu *nav_menu;
|
||||
struct nsgtk_nav_menu *rclick_nav_menu;
|
||||
struct nsgtk_tabs_menu *tabs_menu;
|
||||
struct nsgtk_tabs_menu *rclick_tabs_menu;
|
||||
struct nsgtk_help_menu *help_menu;
|
||||
struct nsgtk_help_menu *rclick_help_menu;
|
||||
GtkMenuItem *edit_menu_item;
|
||||
GtkMenuItem *tabs_menu_item;
|
||||
struct nsgtk_file_menu *file;
|
||||
struct nsgtk_file_menu *rclick_file;
|
||||
struct nsgtk_edit_menu *edit;
|
||||
struct nsgtk_edit_menu *rclick_edit;
|
||||
struct nsgtk_view_menu *view;
|
||||
struct nsgtk_view_menu *rclick_view;
|
||||
struct nsgtk_nav_menu *nav;
|
||||
struct nsgtk_nav_menu *rclick_nav;
|
||||
struct nsgtk_tabs_menu *tabs;
|
||||
struct nsgtk_tabs_menu *rclick_tabs;
|
||||
struct nsgtk_help_menu *help;
|
||||
struct nsgtk_help_menu *rclick_help;
|
||||
};
|
||||
|
||||
struct nsgtk_menu *nsgtk_menu_create(GladeXML *xml, GtkWindow *window);
|
||||
|
|
|
@ -178,9 +178,9 @@ void nsgtk_attach_menu_handlers(struct gtk_scaffolding *g)
|
|||
}
|
||||
}
|
||||
#define CONNECT_CHECK(q)\
|
||||
g_signal_connect(g->menus->view_menu->toolbars_submenu->q##_menuitem,\
|
||||
g_signal_connect(g->menus->view->toolbars_submenu->q##_menuitem,\
|
||||
"toggled", G_CALLBACK(nsgtk_on_##q##_activate), g);\
|
||||
g_signal_connect(g->menus->rclick_view_menu->toolbars_submenu->q##_menuitem,\
|
||||
g_signal_connect(g->menus->rclick_view->toolbars_submenu->q##_menuitem,\
|
||||
"toggled", G_CALLBACK(nsgtk_on_##q##_activate), g)
|
||||
CONNECT_CHECK(menubar);
|
||||
CONNECT_CHECK(toolbar);
|
||||
|
@ -365,7 +365,7 @@ void nsgtk_window_tabs_num_changed(GtkNotebook *notebook, GtkWidget *page,
|
|||
guint page_num, struct gtk_scaffolding *g)
|
||||
{
|
||||
gboolean visible = gtk_notebook_get_show_tabs(g->notebook);
|
||||
g_object_set(g->menus->tabs_menu_item, "visible", visible, NULL);
|
||||
g_object_set(g->menus->tabs->tabs, "visible", visible, NULL);
|
||||
g->buttons[NEXTTAB_BUTTON]->sensitivity = visible;
|
||||
g->buttons[PREVTAB_BUTTON]->sensitivity = visible;
|
||||
g->buttons[CLOSETAB_BUTTON]->sensitivity = visible;
|
||||
|
@ -934,13 +934,13 @@ MENUHANDLER(menubar)
|
|||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
|
||||
/* need to synchronise menus as gtk grumbles when one menu
|
||||
* is attached to both headers */
|
||||
w = GTK_WIDGET(g->menus->rclick_view_menu->
|
||||
w = GTK_WIDGET(g->menus->rclick_view->
|
||||
toolbars_submenu->menubar_menuitem);
|
||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
|
||||
== FALSE)
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
|
||||
TRUE);
|
||||
w = GTK_WIDGET(g->menus->view_menu->
|
||||
w = GTK_WIDGET(g->menus->view->
|
||||
toolbars_submenu->menubar_menuitem);
|
||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
|
||||
== FALSE)
|
||||
|
@ -958,13 +958,12 @@ MENUHANDLER(menubar)
|
|||
gtk_widget_hide(GTK_WIDGET(widgets->data));
|
||||
|
||||
} else {
|
||||
w = GTK_WIDGET(g->menus->rclick_view_menu->
|
||||
w = GTK_WIDGET(g->menus->rclick_view->
|
||||
toolbars_submenu->menubar_menuitem);
|
||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
|
||||
FALSE);
|
||||
w = GTK_WIDGET(g->menus->view_menu->
|
||||
toolbars_submenu->menubar_menuitem);
|
||||
w = GTK_WIDGET(g->menus->view->toolbars_submenu->menubar_menuitem);
|
||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
|
||||
FALSE);
|
||||
|
@ -987,13 +986,13 @@ MENUHANDLER(toolbar)
|
|||
struct gtk_scaffolding *g = (struct gtk_scaffolding *)data;
|
||||
|
||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) {
|
||||
w = GTK_WIDGET(g->menus->rclick_view_menu->
|
||||
w = GTK_WIDGET(g->menus->rclick_view->
|
||||
toolbars_submenu->toolbar_menuitem);
|
||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
|
||||
== FALSE)
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
|
||||
TRUE);
|
||||
w = GTK_WIDGET(g->menus->view_menu->
|
||||
w = GTK_WIDGET(g->menus->view->
|
||||
toolbars_submenu->toolbar_menuitem);
|
||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
|
||||
== FALSE)
|
||||
|
@ -1001,12 +1000,12 @@ MENUHANDLER(toolbar)
|
|||
TRUE);
|
||||
gtk_widget_show(GTK_WIDGET(g->tool_bar));
|
||||
} else {
|
||||
w = GTK_WIDGET(g->menus->rclick_view_menu->
|
||||
w = GTK_WIDGET(g->menus->rclick_view->
|
||||
toolbars_submenu->toolbar_menuitem);
|
||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
|
||||
FALSE);
|
||||
w = GTK_WIDGET(g->menus->view_menu->
|
||||
w = GTK_WIDGET(g->menus->view->
|
||||
toolbars_submenu->toolbar_menuitem);
|
||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)))
|
||||
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(w),
|
||||
|
@ -1623,8 +1622,8 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
|
|||
CONNECT(g->window, "delete-event", nsgtk_window_delete_event, g);
|
||||
|
||||
/* toolbar URL bar menu bar search bar signal handlers */
|
||||
CONNECT(g->menus->edit_menu_item, "show", nsgtk_window_edit_menu_clicked, g);
|
||||
CONNECT(g->menus->edit_menu_item, "hide", nsgtk_window_edit_menu_hidden, g);
|
||||
CONNECT(g->menus->edit->edit, "show", nsgtk_window_edit_menu_clicked, g);
|
||||
CONNECT(g->menus->edit->edit, "hide", nsgtk_window_edit_menu_hidden, g);
|
||||
CONNECT(g->search->buttons[1], "clicked",
|
||||
nsgtk_search_forward_button_clicked, g);
|
||||
CONNECT(g->search->buttons[0], "clicked",
|
||||
|
@ -1666,7 +1665,7 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
|
|||
|
||||
#define POPUP_ATTACH(q) gtk_menu_item_set_submenu( \
|
||||
GTK_MENU_ITEM(glade_xml_get_widget(g->popup_xml,\
|
||||
"menupopup_" #q)), GTK_WIDGET(g->menus->rclick_##q##_menu->q##_menu));\
|
||||
"menupopup_" #q)), GTK_WIDGET(g->menus->rclick_##q->q##_menu));\
|
||||
|
||||
POPUP_ATTACH(file);
|
||||
POPUP_ATTACH(edit);
|
||||
|
@ -2143,7 +2142,7 @@ void nsgtk_scaffolding_initial_sensitivity(struct gtk_scaffolding *g)
|
|||
g->buttons[i]->popup),
|
||||
g->buttons[i]->sensitivity);
|
||||
}
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(g->menus->view_menu->images_menuitem),
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(g->menus->view->images_menuitem),
|
||||
FALSE);
|
||||
}
|
||||
|
||||
|
@ -2333,9 +2332,9 @@ void nsgtk_scaffolding_toolbar_init(struct gtk_scaffolding *g)
|
|||
{
|
||||
#define ITEM_MAIN(p, q, r)\
|
||||
g->buttons[p##_BUTTON]->main =\
|
||||
g->menus->q##_menu->r##_menuitem;\
|
||||
g->menus->q->r##_menuitem;\
|
||||
g->buttons[p##_BUTTON]->rclick =\
|
||||
g->menus->rclick_##q##_menu->r##_menuitem;\
|
||||
g->menus->rclick_##q->r##_menuitem;\
|
||||
g->buttons[p##_BUTTON]->mhandler =\
|
||||
nsgtk_on_##r##_activate_menu;\
|
||||
g->buttons[p##_BUTTON]->bhandler =\
|
||||
|
@ -2346,11 +2345,9 @@ void nsgtk_scaffolding_toolbar_init(struct gtk_scaffolding *g)
|
|||
nsgtk_toolbar_##r##_toolbar_button_data
|
||||
#define ITEM_SUB(p, q, r, s)\
|
||||
g->buttons[p##_BUTTON]->main =\
|
||||
g->menus->q##_menu->\
|
||||
r##_submenu->s##_menuitem;\
|
||||
g->menus->q->r##_submenu->s##_menuitem;\
|
||||
g->buttons[p##_BUTTON]->rclick =\
|
||||
g->menus->rclick_##q##_menu->\
|
||||
r##_submenu->s##_menuitem;\
|
||||
g->menus->rclick_##q->r##_submenu->s##_menuitem;\
|
||||
g->buttons[p##_BUTTON]->mhandler =\
|
||||
nsgtk_on_##s##_activate_menu;\
|
||||
g->buttons[p##_BUTTON]->bhandler =\
|
||||
|
|
|
@ -11,48 +11,6 @@
|
|||
<child>
|
||||
<widget class="GtkMenuBar" id="menubar">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem_file">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_File</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem_edit">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Edit</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem_view">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_View</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem_nav">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Navigate</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem_tabs">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Tabs</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkMenuItem" id="menuitem_help">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">_Help</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
|
Loading…
Reference in New Issue