mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-31 06:35:44 +03:00
cope with deprication of image menus in GTK 3.10
This commit is contained in:
parent
1922eb1e2a
commit
267fb0b00e
16
gtk/compat.c
16
gtk/compat.c
@ -505,3 +505,19 @@ void nsgtk_scrolled_window_add_with_viewport(GtkScrolledWindow *window,
|
||||
gtk_scrolled_window_add_with_viewport(window, child);
|
||||
#endif
|
||||
}
|
||||
|
||||
GtkWidget *nsgtk_image_menu_item_new_with_mnemonic(const gchar *label)
|
||||
{
|
||||
#if GTK_CHECK_VERSION(3,10,0)
|
||||
return gtk_menu_item_new_with_mnemonic(label);
|
||||
#else
|
||||
return gtk_image_menu_item_new_with_mnemonic(label);
|
||||
#endif
|
||||
}
|
||||
|
||||
void nsgtk_image_menu_item_set_image(GtkWidget *image_menu_item, GtkWidget *image)
|
||||
{
|
||||
#if !GTK_CHECK_VERSION(3,10,0)
|
||||
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(image_menu_item), image);
|
||||
#endif
|
||||
}
|
||||
|
24
gtk/compat.h
24
gtk/compat.h
@ -191,5 +191,29 @@ gdouble nsgtk_adjustment_get_upper(GtkAdjustment *adjustment);
|
||||
gdouble nsgtk_adjustment_get_lower(GtkAdjustment *adjustment);
|
||||
gdouble nsgtk_adjustment_get_page_increment(GtkAdjustment *adjustment);
|
||||
|
||||
/* menu compatability */
|
||||
|
||||
/**
|
||||
* Creates a new GtkImageMenuItem containing a label.
|
||||
*
|
||||
* Compatability interface for original deprecated in GTK 3.10.
|
||||
* @note post 3.10 this creates a GtkMenuItem.
|
||||
*
|
||||
* \param label The text of the button, with an underscore in front of
|
||||
* the mnemonic character.
|
||||
* \return a new GtkMenuItem
|
||||
*/
|
||||
GtkWidget *nsgtk_image_menu_item_new_with_mnemonic(const gchar *label);
|
||||
|
||||
/**
|
||||
* Sets the image of image_menu_item to the given widget.
|
||||
*
|
||||
* Compatability interface for original deprecated in GTK 3.10.
|
||||
* @note post 3.10 this is empty as menu creation generates GtkMenuItem.
|
||||
*
|
||||
* \param image_menu_item The image menu entry item.
|
||||
* \param image The image to set.
|
||||
*/
|
||||
void nsgtk_image_menu_item_set_image(GtkWidget *image_menu_item, GtkWidget *image);
|
||||
|
||||
#endif /* NETSURF_GTK_COMPAT_H */
|
||||
|
35
gtk/menu.c
35
gtk/menu.c
@ -21,35 +21,46 @@
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "gtk/menu.h"
|
||||
#include "utils/messages.h"
|
||||
#include "utils/utils.h"
|
||||
|
||||
#include "gtk/compat.h"
|
||||
#include "gtk/menu.h"
|
||||
|
||||
/**
|
||||
* adds image menu item to specified menu
|
||||
* Adds image menu item to a menu.
|
||||
*
|
||||
* \param menu the menu to add the item to
|
||||
* \param item a pointer to the item's location in the menu struct
|
||||
* \param item_out a pointer to the item's location in the menu struct
|
||||
* \param message the menu item I18n lookup value
|
||||
* \param messageAccel the menu item accelerator I18n lookup value
|
||||
* \param group the 'global' in a gtk sense accelerator group
|
||||
* \return true if sucessful and \a item_out updated else false.
|
||||
*/
|
||||
|
||||
static bool nsgtk_menu_add_image_item(GtkMenu *menu,
|
||||
GtkImageMenuItem **item, const char *message,
|
||||
GtkWidget **item_out, const char *message,
|
||||
const char *messageAccel, GtkAccelGroup *group)
|
||||
{
|
||||
unsigned int key;
|
||||
GdkModifierType mod;
|
||||
*item = GTK_IMAGE_MENU_ITEM(gtk_image_menu_item_new_with_mnemonic(
|
||||
messages_get(message)));
|
||||
if (*item == NULL)
|
||||
GtkWidget *item;
|
||||
|
||||
item = nsgtk_image_menu_item_new_with_mnemonic(messages_get(message));
|
||||
if (item == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
gtk_accelerator_parse(messages_get(messageAccel), &key, &mod);
|
||||
if (key > 0)
|
||||
gtk_widget_add_accelerator(GTK_WIDGET(*item), "activate",
|
||||
group, key, mod, GTK_ACCEL_VISIBLE);
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), GTK_WIDGET(*item));
|
||||
gtk_widget_show(GTK_WIDGET(*item));
|
||||
if (key > 0) {
|
||||
gtk_widget_add_accelerator(item, "activate", group, key, mod,
|
||||
GTK_ACCEL_VISIBLE);
|
||||
}
|
||||
gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
|
||||
gtk_widget_show(item);
|
||||
|
||||
*item_out = item;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
148
gtk/menu.h
148
gtk/menu.h
@ -23,100 +23,100 @@
|
||||
struct nsgtk_file_menu {
|
||||
GtkMenuItem *file; /* File menu item on menubar */
|
||||
GtkMenu *file_menu;
|
||||
GtkImageMenuItem *newwindow_menuitem;
|
||||
GtkImageMenuItem *newtab_menuitem;
|
||||
GtkImageMenuItem *openfile_menuitem;
|
||||
GtkImageMenuItem *closewindow_menuitem;
|
||||
GtkImageMenuItem *savepage_menuitem;
|
||||
GtkImageMenuItem *export_menuitem;
|
||||
GtkWidget *newwindow_menuitem;
|
||||
GtkWidget *newtab_menuitem;
|
||||
GtkWidget *openfile_menuitem;
|
||||
GtkWidget *closewindow_menuitem;
|
||||
GtkWidget *savepage_menuitem;
|
||||
GtkWidget *export_menuitem;
|
||||
struct nsgtk_export_submenu *export_submenu;
|
||||
GtkImageMenuItem *printpreview_menuitem;
|
||||
GtkImageMenuItem *print_menuitem;
|
||||
GtkImageMenuItem *quit_menuitem;
|
||||
GtkWidget *printpreview_menuitem;
|
||||
GtkWidget *print_menuitem;
|
||||
GtkWidget *quit_menuitem;
|
||||
};
|
||||
|
||||
struct nsgtk_edit_menu {
|
||||
GtkMenuItem *edit; /* Edit menu item on menubar */
|
||||
GtkMenu *edit_menu;
|
||||
GtkImageMenuItem *cut_menuitem;
|
||||
GtkImageMenuItem *copy_menuitem;
|
||||
GtkImageMenuItem *paste_menuitem;
|
||||
GtkImageMenuItem *delete_menuitem;
|
||||
GtkImageMenuItem *selectall_menuitem;
|
||||
GtkImageMenuItem *find_menuitem;
|
||||
GtkImageMenuItem *preferences_menuitem;
|
||||
GtkWidget *cut_menuitem;
|
||||
GtkWidget *copy_menuitem;
|
||||
GtkWidget *paste_menuitem;
|
||||
GtkWidget *delete_menuitem;
|
||||
GtkWidget *selectall_menuitem;
|
||||
GtkWidget *find_menuitem;
|
||||
GtkWidget *preferences_menuitem;
|
||||
};
|
||||
|
||||
struct nsgtk_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;
|
||||
GtkWidget *stop_menuitem;
|
||||
GtkWidget *reload_menuitem;
|
||||
GtkWidget *scaleview_menuitem;
|
||||
struct nsgtk_scaleview_submenu *scaleview_submenu;
|
||||
GtkImageMenuItem *fullscreen_menuitem;
|
||||
GtkImageMenuItem *images_menuitem;
|
||||
GtkWidget *fullscreen_menuitem;
|
||||
GtkWidget *images_menuitem;
|
||||
struct nsgtk_images_submenu *images_submenu;
|
||||
GtkImageMenuItem *toolbars_menuitem;
|
||||
GtkWidget *toolbars_menuitem;
|
||||
struct nsgtk_toolbars_submenu *toolbars_submenu;
|
||||
GtkImageMenuItem *tabs_menuitem;
|
||||
GtkWidget *tabs_menuitem;
|
||||
struct nsgtk_tabs_submenu *tabs_submenu;
|
||||
GtkImageMenuItem *savewindowsize_menuitem;
|
||||
GtkWidget *savewindowsize_menuitem;
|
||||
};
|
||||
|
||||
struct nsgtk_nav_menu {
|
||||
GtkMenuItem *nav; /* Nav menu item on menubar */
|
||||
GtkMenu *nav_menu;
|
||||
GtkImageMenuItem *back_menuitem;
|
||||
GtkImageMenuItem *forward_menuitem;
|
||||
GtkImageMenuItem *home_menuitem;
|
||||
GtkImageMenuItem *localhistory_menuitem;
|
||||
GtkImageMenuItem *globalhistory_menuitem;
|
||||
GtkImageMenuItem *addbookmarks_menuitem;
|
||||
GtkImageMenuItem *showbookmarks_menuitem;
|
||||
GtkImageMenuItem *openlocation_menuitem;
|
||||
GtkWidget *back_menuitem;
|
||||
GtkWidget *forward_menuitem;
|
||||
GtkWidget *home_menuitem;
|
||||
GtkWidget *localhistory_menuitem;
|
||||
GtkWidget *globalhistory_menuitem;
|
||||
GtkWidget *addbookmarks_menuitem;
|
||||
GtkWidget *showbookmarks_menuitem;
|
||||
GtkWidget *openlocation_menuitem;
|
||||
};
|
||||
|
||||
struct nsgtk_tools_menu {
|
||||
GtkMenuItem *tools; /* Tools menu item on menubar */
|
||||
GtkMenu *tools_menu;
|
||||
|
||||
GtkImageMenuItem *showcookies_menuitem;
|
||||
GtkImageMenuItem *downloads_menuitem;
|
||||
GtkImageMenuItem *developer_menuitem;
|
||||
GtkWidget *showcookies_menuitem;
|
||||
GtkWidget *downloads_menuitem;
|
||||
GtkWidget *developer_menuitem;
|
||||
struct nsgtk_developer_submenu *developer_submenu;
|
||||
};
|
||||
|
||||
struct nsgtk_help_menu {
|
||||
GtkMenuItem *help; /* Help menu item on menubar */
|
||||
GtkMenu *help_menu;
|
||||
GtkImageMenuItem *contents_menuitem;
|
||||
GtkImageMenuItem *guide_menuitem;
|
||||
GtkImageMenuItem *info_menuitem;
|
||||
GtkImageMenuItem *about_menuitem;
|
||||
GtkWidget *contents_menuitem;
|
||||
GtkWidget *guide_menuitem;
|
||||
GtkWidget *info_menuitem;
|
||||
GtkWidget *about_menuitem;
|
||||
};
|
||||
|
||||
|
||||
struct nsgtk_export_submenu {
|
||||
GtkMenu *export_menu;
|
||||
GtkImageMenuItem *plaintext_menuitem;
|
||||
GtkImageMenuItem *drawfile_menuitem;
|
||||
GtkImageMenuItem *postscript_menuitem;
|
||||
GtkImageMenuItem *pdf_menuitem;
|
||||
GtkWidget *plaintext_menuitem;
|
||||
GtkWidget *drawfile_menuitem;
|
||||
GtkWidget *postscript_menuitem;
|
||||
GtkWidget *pdf_menuitem;
|
||||
};
|
||||
|
||||
struct nsgtk_scaleview_submenu {
|
||||
GtkMenu *scaleview_menu;
|
||||
GtkImageMenuItem *zoomplus_menuitem;
|
||||
GtkImageMenuItem *zoomminus_menuitem;
|
||||
GtkImageMenuItem *zoomnormal_menuitem;
|
||||
GtkWidget *zoomplus_menuitem;
|
||||
GtkWidget *zoomminus_menuitem;
|
||||
GtkWidget *zoomnormal_menuitem;
|
||||
};
|
||||
|
||||
struct nsgtk_tabs_submenu {
|
||||
GtkMenu *tabs_menu;
|
||||
GtkImageMenuItem *nexttab_menuitem;
|
||||
GtkImageMenuItem *prevtab_menuitem;
|
||||
GtkImageMenuItem *closetab_menuitem;
|
||||
GtkWidget *nexttab_menuitem;
|
||||
GtkWidget *prevtab_menuitem;
|
||||
GtkWidget *closetab_menuitem;
|
||||
};
|
||||
|
||||
struct nsgtk_images_submenu {
|
||||
@ -132,12 +132,12 @@ struct nsgtk_toolbars_submenu {
|
||||
};
|
||||
|
||||
struct nsgtk_developer_submenu {
|
||||
GtkMenu *developer_menu;
|
||||
GtkMenu *developer_menu;
|
||||
|
||||
GtkImageMenuItem *viewsource_menuitem;
|
||||
GtkImageMenuItem *toggledebugging_menuitem;
|
||||
GtkImageMenuItem *debugboxtree_menuitem;
|
||||
GtkImageMenuItem *debugdomtree_menuitem;
|
||||
GtkWidget *viewsource_menuitem;
|
||||
GtkWidget *toggledebugging_menuitem;
|
||||
GtkWidget *debugboxtree_menuitem;
|
||||
GtkWidget *debugdomtree_menuitem;
|
||||
};
|
||||
|
||||
|
||||
@ -155,55 +155,55 @@ struct nsgtk_bar_submenu {
|
||||
struct nsgtk_popup_menu {
|
||||
GtkMenu *popup_menu;
|
||||
|
||||
GtkImageMenuItem *file_menuitem;
|
||||
GtkWidget *file_menuitem;
|
||||
struct nsgtk_file_menu *file_submenu;
|
||||
|
||||
GtkImageMenuItem *edit_menuitem;
|
||||
GtkWidget *edit_menuitem;
|
||||
struct nsgtk_edit_menu *edit_submenu;
|
||||
|
||||
GtkImageMenuItem *view_menuitem;
|
||||
GtkWidget *view_menuitem;
|
||||
struct nsgtk_view_menu *view_submenu;
|
||||
|
||||
GtkImageMenuItem *nav_menuitem;
|
||||
GtkWidget *nav_menuitem;
|
||||
struct nsgtk_nav_menu *nav_submenu;
|
||||
|
||||
GtkImageMenuItem *tabs_menuitem;
|
||||
GtkWidget *tabs_menuitem;
|
||||
struct nsgtk_tabs_submenu *tabs_submenu;
|
||||
|
||||
GtkImageMenuItem *tools_menuitem;
|
||||
GtkWidget *tools_menuitem;
|
||||
struct nsgtk_tools_menu *tools_submenu;
|
||||
|
||||
GtkImageMenuItem *help_menuitem;
|
||||
GtkWidget *help_menuitem;
|
||||
struct nsgtk_help_menu *help_submenu;
|
||||
|
||||
GtkWidget *first_separator;
|
||||
|
||||
/* navigation entries */
|
||||
GtkImageMenuItem *back_menuitem;
|
||||
GtkImageMenuItem *forward_menuitem;
|
||||
GtkWidget *back_menuitem;
|
||||
GtkWidget *forward_menuitem;
|
||||
|
||||
GtkWidget *third_separator;
|
||||
|
||||
/* view entries */
|
||||
GtkImageMenuItem *stop_menuitem;
|
||||
GtkImageMenuItem *reload_menuitem;
|
||||
GtkWidget *stop_menuitem;
|
||||
GtkWidget *reload_menuitem;
|
||||
|
||||
GtkImageMenuItem *cut_menuitem;
|
||||
GtkImageMenuItem *copy_menuitem;
|
||||
GtkImageMenuItem *paste_menuitem;
|
||||
GtkImageMenuItem *customize_menuitem;
|
||||
GtkWidget *cut_menuitem;
|
||||
GtkWidget *copy_menuitem;
|
||||
GtkWidget *paste_menuitem;
|
||||
GtkWidget *customize_menuitem;
|
||||
|
||||
};
|
||||
|
||||
struct nsgtk_link_menu {
|
||||
GtkMenu *link_menu;
|
||||
|
||||
GtkImageMenuItem *opentab_menuitem;
|
||||
GtkImageMenuItem *openwin_menuitem;
|
||||
GtkWidget *opentab_menuitem;
|
||||
GtkWidget *openwin_menuitem;
|
||||
|
||||
GtkImageMenuItem *save_menuitem;
|
||||
GtkImageMenuItem *bookmark_menuitem;
|
||||
GtkImageMenuItem *copy_menuitem;
|
||||
GtkWidget *save_menuitem;
|
||||
GtkWidget *bookmark_menuitem;
|
||||
GtkWidget *copy_menuitem;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -1846,8 +1846,7 @@ static void nsgtk_scaffolding_toolbar_init(struct nsgtk_scaffolding *g)
|
||||
nsgtk_toolbar_##q##_toolbar_button_data
|
||||
|
||||
#define ITEM_POP(p, q) \
|
||||
g->buttons[p##_BUTTON]->popup = GTK_IMAGE_MENU_ITEM(\
|
||||
g->menu_popup->q##_menuitem)
|
||||
g->buttons[p##_BUTTON]->popup = g->menu_popup->q##_menuitem
|
||||
|
||||
#define SENSITIVITY(q) \
|
||||
g->buttons[q##_BUTTON]->sensitivity = false
|
||||
|
@ -101,16 +101,16 @@ struct gtk_search {
|
||||
};
|
||||
|
||||
struct nsgtk_button_connect {
|
||||
GtkToolItem *button;
|
||||
int location; /* in toolbar */
|
||||
bool sensitivity;
|
||||
GtkImageMenuItem *main;
|
||||
GtkImageMenuItem *rclick;
|
||||
GtkImageMenuItem *popup;
|
||||
void *mhandler; /* menu item clicked */
|
||||
void *bhandler; /* button clicked */
|
||||
void *dataplus; /* customization -> toolbar */
|
||||
void *dataminus; /* customization -> store */
|
||||
GtkToolItem *button;
|
||||
int location; /* in toolbar */
|
||||
bool sensitivity;
|
||||
GtkWidget *main; /* left click menu entry */
|
||||
GtkWidget *rclick; /* right click menu */
|
||||
GtkWidget *popup; /* popup menu entry */
|
||||
void *mhandler; /* menu item clicked */
|
||||
void *bhandler; /* button clicked */
|
||||
void *dataplus; /* customization -> toolbar */
|
||||
void *dataminus; /* customization -> store */
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -319,7 +319,7 @@ void nsgtk_theme_implement(struct nsgtk_scaffolding *g)
|
||||
/* gtk_image_menu_item_set_image accepts NULL image */
|
||||
if ((button->main != NULL) &&
|
||||
(theme[IMAGE_SET_MAIN_MENU] != NULL)) {
|
||||
gtk_image_menu_item_set_image(button->main,
|
||||
nsgtk_image_menu_item_set_image(GTK_WIDGET(button->main),
|
||||
GTK_WIDGET(
|
||||
theme[IMAGE_SET_MAIN_MENU]->
|
||||
image[i]));
|
||||
@ -327,7 +327,7 @@ void nsgtk_theme_implement(struct nsgtk_scaffolding *g)
|
||||
}
|
||||
if ((button->rclick != NULL) &&
|
||||
(theme[IMAGE_SET_RCLICK_MENU] != NULL)) {
|
||||
gtk_image_menu_item_set_image(button->rclick,
|
||||
nsgtk_image_menu_item_set_image(GTK_WIDGET(button->rclick),
|
||||
GTK_WIDGET(
|
||||
theme[IMAGE_SET_RCLICK_MENU]->
|
||||
image[i]));
|
||||
@ -335,7 +335,7 @@ void nsgtk_theme_implement(struct nsgtk_scaffolding *g)
|
||||
}
|
||||
if ((button->popup != NULL) &&
|
||||
(theme[IMAGE_SET_POPUP_MENU] != NULL)) {
|
||||
gtk_image_menu_item_set_image(button->popup,
|
||||
nsgtk_image_menu_item_set_image(GTK_WIDGET(button->popup),
|
||||
GTK_WIDGET(
|
||||
theme[IMAGE_SET_POPUP_MENU]->
|
||||
image[i]));
|
||||
|
Loading…
x
Reference in New Issue
Block a user