mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-28 09:13:08 +03:00
move the gtk menu creation into gtk_menu.c from gtk_scaffolding.c
This causes the menu creation to be concentrated in one place removing the need for numerous external linkages svn path=/trunk/netsurf/; revision=10794
This commit is contained in:
parent
9ad74ad786
commit
dd43ea0830
314
gtk/gtk_menu.c
314
gtk/gtk_menu.c
@ -16,25 +16,16 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <stdlib.h>
|
||||
#include <glade/glade-xml.h>
|
||||
|
||||
#include "gtk/gtk_menu.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
static struct nsgtk_export_submenu *nsgtk_menu_export_submenu(GtkAccelGroup *);
|
||||
static struct nsgtk_scaleview_submenu *nsgtk_menu_scaleview_submenu(
|
||||
GtkAccelGroup *);
|
||||
static struct nsgtk_images_submenu *nsgtk_menu_images_submenu(GtkAccelGroup *);
|
||||
static struct nsgtk_toolbars_submenu *nsgtk_menu_toolbars_submenu(
|
||||
GtkAccelGroup *);
|
||||
static struct nsgtk_debugging_submenu *nsgtk_menu_debugging_submenu(
|
||||
GtkAccelGroup *);
|
||||
static bool nsgtk_menu_add_image_item(GtkMenu *menu,
|
||||
GtkImageMenuItem **item, const char *message,
|
||||
const char *messageAccel, GtkAccelGroup *group);
|
||||
|
||||
/**
|
||||
* adds image menu item to specified menu
|
||||
* \param menu the menu to add the item to
|
||||
@ -44,7 +35,7 @@ static bool nsgtk_menu_add_image_item(GtkMenu *menu,
|
||||
* \param group the 'global' in a gtk sense accelerator group
|
||||
*/
|
||||
|
||||
bool nsgtk_menu_add_image_item(GtkMenu *menu,
|
||||
static bool nsgtk_menu_add_image_item(GtkMenu *menu,
|
||||
GtkImageMenuItem **item, const char *message,
|
||||
const char *messageAccel, GtkAccelGroup *group)
|
||||
{
|
||||
@ -91,12 +82,143 @@ bool nsgtk_menu_add_image_item(GtkMenu *menu,
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(r->q##_menu), w);\
|
||||
gtk_widget_show(w);\
|
||||
}
|
||||
|
||||
/**
|
||||
* creates an export submenu
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
static struct nsgtk_export_submenu *nsgtk_menu_export_submenu(GtkAccelGroup *group)
|
||||
{
|
||||
struct nsgtk_export_submenu *ret = malloc(sizeof(struct
|
||||
nsgtk_export_submenu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
return NULL;
|
||||
}
|
||||
ret->export_menu = GTK_MENU(gtk_menu_new());
|
||||
if (ret->export_menu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
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)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a scaleview submenu
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
static struct nsgtk_scaleview_submenu *nsgtk_menu_scaleview_submenu(
|
||||
GtkAccelGroup *group)
|
||||
{
|
||||
struct nsgtk_scaleview_submenu *ret =
|
||||
malloc(sizeof(struct nsgtk_scaleview_submenu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
return NULL;
|
||||
}
|
||||
ret->scaleview_menu = GTK_MENU(gtk_menu_new());
|
||||
if (ret->scaleview_menu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
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)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates an images submenu
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
static struct nsgtk_images_submenu *nsgtk_menu_images_submenu(GtkAccelGroup *group)
|
||||
{
|
||||
struct nsgtk_images_submenu *ret =
|
||||
malloc(sizeof(struct nsgtk_images_submenu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
return NULL;
|
||||
}
|
||||
ret->images_menu = GTK_MENU(gtk_menu_new());
|
||||
if (ret->images_menu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
CHECK_ITEM(images, foregroundimages, gtkForegroundImages, ret)
|
||||
CHECK_ITEM(images, backgroundimages, gtkBackgroundImages, ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a toolbars submenu
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
static struct nsgtk_toolbars_submenu *nsgtk_menu_toolbars_submenu(
|
||||
GtkAccelGroup *group)
|
||||
{
|
||||
struct nsgtk_toolbars_submenu *ret =
|
||||
malloc(sizeof(struct nsgtk_toolbars_submenu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
return NULL;
|
||||
}
|
||||
ret->toolbars_menu = GTK_MENU(gtk_menu_new());
|
||||
if (ret->toolbars_menu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
CHECK_ITEM(toolbars, menubar, gtkMenuBar, ret)
|
||||
if (ret->menubar_menuitem != NULL)
|
||||
gtk_check_menu_item_set_active(ret->menubar_menuitem, TRUE);
|
||||
CHECK_ITEM(toolbars, toolbar, gtkToolBar, ret)
|
||||
if (ret->toolbar_menuitem != NULL)
|
||||
gtk_check_menu_item_set_active(ret->toolbar_menuitem, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a debugging submenu
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
static struct nsgtk_debugging_submenu *nsgtk_menu_debugging_submenu(
|
||||
GtkAccelGroup *group)
|
||||
{
|
||||
struct nsgtk_debugging_submenu *ret =
|
||||
malloc(sizeof(struct nsgtk_debugging_submenu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
return NULL;
|
||||
}
|
||||
ret->debugging_menu = GTK_MENU(gtk_menu_new());
|
||||
if (ret->debugging_menu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
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)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates the a file menu
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
struct nsgtk_file_menu *nsgtk_menu_file_menu(GtkAccelGroup *group)
|
||||
static struct nsgtk_file_menu *nsgtk_menu_file_menu(GtkAccelGroup *group)
|
||||
{
|
||||
GtkWidget *w;
|
||||
struct nsgtk_file_menu *ret = malloc(sizeof(struct nsgtk_file_menu));
|
||||
@ -131,7 +253,7 @@ struct nsgtk_file_menu *nsgtk_menu_file_menu(GtkAccelGroup *group)
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
struct nsgtk_edit_menu *nsgtk_menu_edit_menu(GtkAccelGroup *group)
|
||||
static struct nsgtk_edit_menu *nsgtk_menu_edit_menu(GtkAccelGroup *group)
|
||||
{
|
||||
GtkWidget *w;
|
||||
struct nsgtk_edit_menu *ret = malloc(sizeof(struct nsgtk_edit_menu));
|
||||
@ -163,7 +285,7 @@ struct nsgtk_edit_menu *nsgtk_menu_edit_menu(GtkAccelGroup *group)
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
struct nsgtk_view_menu *nsgtk_menu_view_menu(GtkAccelGroup *group)
|
||||
static struct nsgtk_view_menu *nsgtk_menu_view_menu(GtkAccelGroup *group)
|
||||
{
|
||||
GtkWidget *w;
|
||||
struct nsgtk_view_menu *ret = malloc(sizeof(struct nsgtk_view_menu));
|
||||
@ -202,7 +324,7 @@ struct nsgtk_view_menu *nsgtk_menu_view_menu(GtkAccelGroup *group)
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
struct nsgtk_nav_menu *nsgtk_menu_nav_menu(GtkAccelGroup *group)
|
||||
static struct nsgtk_nav_menu *nsgtk_menu_nav_menu(GtkAccelGroup *group)
|
||||
{
|
||||
GtkWidget *w;
|
||||
struct nsgtk_nav_menu *ret = malloc(sizeof(struct nsgtk_nav_menu));
|
||||
@ -235,7 +357,7 @@ struct nsgtk_nav_menu *nsgtk_menu_nav_menu(GtkAccelGroup *group)
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
struct nsgtk_tabs_menu *nsgtk_menu_tabs_menu(GtkAccelGroup *group)
|
||||
static struct nsgtk_tabs_menu *nsgtk_menu_tabs_menu(GtkAccelGroup *group)
|
||||
{
|
||||
struct nsgtk_tabs_menu *ret = malloc(sizeof(struct nsgtk_tabs_menu));
|
||||
if (ret == NULL) {
|
||||
@ -259,7 +381,7 @@ struct nsgtk_tabs_menu *nsgtk_menu_tabs_menu(GtkAccelGroup *group)
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
struct nsgtk_help_menu *nsgtk_menu_help_menu(GtkAccelGroup *group)
|
||||
static struct nsgtk_help_menu *nsgtk_menu_help_menu(GtkAccelGroup *group)
|
||||
{
|
||||
GtkWidget *w;
|
||||
struct nsgtk_help_menu *ret = malloc(sizeof(struct nsgtk_help_menu));
|
||||
@ -281,136 +403,42 @@ struct nsgtk_help_menu *nsgtk_menu_help_menu(GtkAccelGroup *group)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates an export submenu
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
struct nsgtk_export_submenu *nsgtk_menu_export_submenu(GtkAccelGroup *group)
|
||||
|
||||
struct nsgtk_menu *nsgtk_menu_create(GladeXML *xml, GtkWindow *window)
|
||||
{
|
||||
struct nsgtk_export_submenu *ret = malloc(sizeof(struct
|
||||
nsgtk_export_submenu));
|
||||
if (ret == NULL) {
|
||||
GtkAccelGroup *group;
|
||||
struct nsgtk_menu *g;
|
||||
|
||||
g = malloc(sizeof(struct nsgtk_menu));
|
||||
if (g == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
return NULL;
|
||||
}
|
||||
ret->export_menu = GTK_MENU(gtk_menu_new());
|
||||
if (ret->export_menu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
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)
|
||||
return ret;
|
||||
|
||||
group = gtk_accel_group_new();
|
||||
gtk_window_add_accel_group(window, group);
|
||||
|
||||
#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"));
|
||||
|
||||
return g;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a scaleview submenu
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
struct nsgtk_scaleview_submenu *nsgtk_menu_scaleview_submenu(
|
||||
GtkAccelGroup *group)
|
||||
{
|
||||
struct nsgtk_scaleview_submenu *ret =
|
||||
malloc(sizeof(struct nsgtk_scaleview_submenu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
return NULL;
|
||||
}
|
||||
ret->scaleview_menu = GTK_MENU(gtk_menu_new());
|
||||
if (ret->scaleview_menu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
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)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates an images submenu
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
struct nsgtk_images_submenu *nsgtk_menu_images_submenu(GtkAccelGroup *group)
|
||||
{
|
||||
struct nsgtk_images_submenu *ret =
|
||||
malloc(sizeof(struct nsgtk_images_submenu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
return NULL;
|
||||
}
|
||||
ret->images_menu = GTK_MENU(gtk_menu_new());
|
||||
if (ret->images_menu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
CHECK_ITEM(images, foregroundimages, gtkForegroundImages, ret)
|
||||
CHECK_ITEM(images, backgroundimages, gtkBackgroundImages, ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a toolbars submenu
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
struct nsgtk_toolbars_submenu *nsgtk_menu_toolbars_submenu(
|
||||
GtkAccelGroup *group)
|
||||
{
|
||||
struct nsgtk_toolbars_submenu *ret =
|
||||
malloc(sizeof(struct nsgtk_toolbars_submenu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
return NULL;
|
||||
}
|
||||
ret->toolbars_menu = GTK_MENU(gtk_menu_new());
|
||||
if (ret->toolbars_menu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
CHECK_ITEM(toolbars, menubar, gtkMenuBar, ret)
|
||||
if (ret->menubar_menuitem != NULL)
|
||||
gtk_check_menu_item_set_active(ret->menubar_menuitem, TRUE);
|
||||
CHECK_ITEM(toolbars, toolbar, gtkToolBar, ret)
|
||||
if (ret->toolbar_menuitem != NULL)
|
||||
gtk_check_menu_item_set_active(ret->toolbar_menuitem, TRUE);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a debugging submenu
|
||||
* \param group the 'global' in a gtk sense accelerator reference
|
||||
*/
|
||||
|
||||
struct nsgtk_debugging_submenu *nsgtk_menu_debugging_submenu(
|
||||
GtkAccelGroup *group)
|
||||
{
|
||||
struct nsgtk_debugging_submenu *ret =
|
||||
malloc(sizeof(struct nsgtk_debugging_submenu));
|
||||
if (ret == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
return NULL;
|
||||
}
|
||||
ret->debugging_menu = GTK_MENU(gtk_menu_new());
|
||||
if (ret->debugging_menu == NULL) {
|
||||
warn_user(messages_get("NoMemory"), 0);
|
||||
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)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#undef CHECK_ITEM
|
||||
#undef IMAGE_ITEM
|
||||
|
@ -124,11 +124,24 @@ struct nsgtk_debugging_submenu {
|
||||
GtkImageMenuItem *savedomtree_menuitem;
|
||||
};
|
||||
|
||||
struct nsgtk_file_menu *nsgtk_menu_file_menu(GtkAccelGroup *group);
|
||||
struct nsgtk_edit_menu *nsgtk_menu_edit_menu(GtkAccelGroup *group);
|
||||
struct nsgtk_view_menu *nsgtk_menu_view_menu(GtkAccelGroup *group);
|
||||
struct nsgtk_nav_menu *nsgtk_menu_nav_menu(GtkAccelGroup *group);
|
||||
struct nsgtk_tabs_menu *nsgtk_menu_tabs_menu(GtkAccelGroup *group);
|
||||
struct nsgtk_help_menu *nsgtk_menu_help_menu(GtkAccelGroup *group);
|
||||
|
||||
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_menu *nsgtk_menu_create(GladeXML *xml, GtkWindow *window);
|
||||
|
||||
#endif
|
||||
|
@ -86,20 +86,7 @@ struct gtk_scaffolding {
|
||||
GtkNotebook *notebook;
|
||||
GtkWidget *url_bar;
|
||||
GtkEntryCompletion *url_bar_completion;
|
||||
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_menu *menus; /* menu hierarchy */
|
||||
GtkToolbar *tool_bar;
|
||||
struct nsgtk_button_connect *buttons[PLACEHOLDER_BUTTON];
|
||||
GtkMenuBar *menu_bar;
|
||||
@ -191,9 +178,9 @@ void nsgtk_attach_menu_handlers(struct gtk_scaffolding *g)
|
||||
}
|
||||
}
|
||||
#define CONNECT_CHECK(q)\
|
||||
g_signal_connect(g->view_menu->toolbars_submenu->q##_menuitem,\
|
||||
g_signal_connect(g->menus->view_menu->toolbars_submenu->q##_menuitem,\
|
||||
"toggled", G_CALLBACK(nsgtk_on_##q##_activate), g);\
|
||||
g_signal_connect(g->rclick_view_menu->toolbars_submenu->q##_menuitem,\
|
||||
g_signal_connect(g->menus->rclick_view_menu->toolbars_submenu->q##_menuitem,\
|
||||
"toggled", G_CALLBACK(nsgtk_on_##q##_activate), g)
|
||||
CONNECT_CHECK(menubar);
|
||||
CONNECT_CHECK(toolbar);
|
||||
@ -378,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->tabs_menu_item, "visible", visible, NULL);
|
||||
g_object_set(g->menus->tabs_menu_item, "visible", visible, NULL);
|
||||
g->buttons[NEXTTAB_BUTTON]->sensitivity = visible;
|
||||
g->buttons[PREVTAB_BUTTON]->sensitivity = visible;
|
||||
g->buttons[CLOSETAB_BUTTON]->sensitivity = visible;
|
||||
@ -947,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->rclick_view_menu->
|
||||
w = GTK_WIDGET(g->menus->rclick_view_menu->
|
||||
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->view_menu->
|
||||
w = GTK_WIDGET(g->menus->view_menu->
|
||||
toolbars_submenu->menubar_menuitem);
|
||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
|
||||
== FALSE)
|
||||
@ -971,12 +958,12 @@ MENUHANDLER(menubar)
|
||||
gtk_widget_hide(GTK_WIDGET(widgets->data));
|
||||
|
||||
} else {
|
||||
w = GTK_WIDGET(g->rclick_view_menu->
|
||||
w = GTK_WIDGET(g->menus->rclick_view_menu->
|
||||
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->view_menu->
|
||||
w = GTK_WIDGET(g->menus->view_menu->
|
||||
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),
|
||||
@ -1000,13 +987,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->rclick_view_menu->
|
||||
w = GTK_WIDGET(g->menus->rclick_view_menu->
|
||||
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->view_menu->
|
||||
w = GTK_WIDGET(g->menus->view_menu->
|
||||
toolbars_submenu->toolbar_menuitem);
|
||||
if (gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w))
|
||||
== FALSE)
|
||||
@ -1014,12 +1001,12 @@ MENUHANDLER(toolbar)
|
||||
TRUE);
|
||||
gtk_widget_show(GTK_WIDGET(g->tool_bar));
|
||||
} else {
|
||||
w = GTK_WIDGET(g->rclick_view_menu->
|
||||
w = GTK_WIDGET(g->menus->rclick_view_menu->
|
||||
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->view_menu->
|
||||
w = GTK_WIDGET(g->menus->view_menu->
|
||||
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),
|
||||
@ -1455,8 +1442,6 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
|
||||
g->search->checkAll = GTK_CHECK_BUTTON(GET_WIDGET("checkAllSearch"));
|
||||
g->search->caseSens = GTK_CHECK_BUTTON(GET_WIDGET("caseSensButton"));
|
||||
|
||||
GtkAccelGroup *group = gtk_accel_group_new();
|
||||
gtk_window_add_accel_group(g->window, group);
|
||||
|
||||
|
||||
for (i = BACK_BUTTON; i < PLACEHOLDER_BUTTON; i++) {
|
||||
@ -1483,21 +1468,8 @@ nsgtk_scaffolding *nsgtk_new_scaffolding(struct gui_window *toplevel)
|
||||
g->historybase = 0;
|
||||
nsgtk_toolbar_customization_load(g);
|
||||
nsgtk_toolbar_set_physical(g);
|
||||
#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(GET_WIDGET("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(GET_WIDGET("menuitem_edit"));
|
||||
g->tabs_menu_item = GTK_MENU_ITEM(GET_WIDGET("menuitem_tabs"));
|
||||
|
||||
g->menus = nsgtk_menu_create(g->xml, g->window);
|
||||
|
||||
g->preferences_dialog = NULL;
|
||||
|
||||
@ -1651,8 +1623,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->edit_menu_item, "show", nsgtk_window_edit_menu_clicked, g);
|
||||
CONNECT(g->edit_menu_item, "hide", nsgtk_window_edit_menu_hidden, g);
|
||||
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->search->buttons[1], "clicked",
|
||||
nsgtk_search_forward_button_clicked, g);
|
||||
CONNECT(g->search->buttons[0], "clicked",
|
||||
@ -1694,7 +1666,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->rclick_##q##_menu->q##_menu));\
|
||||
"menupopup_" #q)), GTK_WIDGET(g->menus->rclick_##q##_menu->q##_menu));\
|
||||
|
||||
POPUP_ATTACH(file);
|
||||
POPUP_ATTACH(edit);
|
||||
@ -2171,7 +2143,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->view_menu->images_menuitem),
|
||||
gtk_widget_set_sensitive(GTK_WIDGET(g->menus->view_menu->images_menuitem),
|
||||
FALSE);
|
||||
}
|
||||
|
||||
@ -2361,9 +2333,9 @@ void nsgtk_scaffolding_toolbar_init(struct gtk_scaffolding *g)
|
||||
{
|
||||
#define ITEM_MAIN(p, q, r)\
|
||||
g->buttons[p##_BUTTON]->main =\
|
||||
g->q##_menu->r##_menuitem;\
|
||||
g->menus->q##_menu->r##_menuitem;\
|
||||
g->buttons[p##_BUTTON]->rclick =\
|
||||
g->rclick_##q##_menu->r##_menuitem;\
|
||||
g->menus->rclick_##q##_menu->r##_menuitem;\
|
||||
g->buttons[p##_BUTTON]->mhandler =\
|
||||
nsgtk_on_##r##_activate_menu;\
|
||||
g->buttons[p##_BUTTON]->bhandler =\
|
||||
@ -2374,10 +2346,10 @@ 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->q##_menu->\
|
||||
g->menus->q##_menu->\
|
||||
r##_submenu->s##_menuitem;\
|
||||
g->buttons[p##_BUTTON]->rclick =\
|
||||
g->rclick_##q##_menu->\
|
||||
g->menus->rclick_##q##_menu->\
|
||||
r##_submenu->s##_menuitem;\
|
||||
g->buttons[p##_BUTTON]->mhandler =\
|
||||
nsgtk_on_##s##_activate_menu;\
|
||||
|
Loading…
Reference in New Issue
Block a user