From 4765c68a15545a2c5465781f2957d771e5c7eb77 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 26 Aug 2018 10:12:35 +0100 Subject: fix gtk 3 deprication warnings --- frontends/gtk/compat.c | 24 +++++++++++++++++++++++- frontends/gtk/compat.h | 19 +++++++++++++++++++ frontends/gtk/scaffolding.c | 6 ++---- frontends/gtk/tabs.c | 2 +- frontends/gtk/window.c | 4 +--- 5 files changed, 46 insertions(+), 9 deletions(-) diff --git a/frontends/gtk/compat.c b/frontends/gtk/compat.c index 65ef51dd5..a75fdafdc 100644 --- a/frontends/gtk/compat.c +++ b/frontends/gtk/compat.c @@ -215,6 +215,17 @@ GtkWidget *nsgtk_button_new_from_stock(const gchar *stock_id) #endif } +/* exported interface documented in gtk/compat.h */ +void nsgtk_button_set_focus_on_click(GtkButton *button, gboolean focus_on_click) +{ +#if GTK_CHECK_VERSION(3,20,0) + gtk_widget_set_focus_on_click(GTK_WIDGET(button), focus_on_click); +#else + gtk_button_set_focus_on_click(button, focus_on_click); +#endif +} + + /* exported interface documented in gtk/compat.h */ gboolean nsgtk_stock_lookup(const gchar *stock_id, GtkStockItem *item) { @@ -235,7 +246,7 @@ void nsgtk_widget_override_background_color(GtkWidget *widget, { #if GTK_CHECK_VERSION(3,0,0) #if GTK_CHECK_VERSION(3,16,0) - /* do nothing - deprecated - must use css styling */ + /* do nothing - deprecated - must use css styling */ return; #else GdkRGBA colour; @@ -546,6 +557,17 @@ void nsgtk_image_menu_item_set_image(GtkWidget *image_menu_item, GtkWidget *imag #endif } +/* exported interface documented in gtk/compat.h */ +void nsgtk_menu_popup_at_pointer(GtkMenu *menu, const GdkEvent *trigger_event) +{ +#if GTK_CHECK_VERSION(3,22,0) + gtk_menu_popup_at_pointer(menu, trigger_event); +#else + gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 0, + gtk_get_current_event_time()); +#endif +} + /* exported interface documented in gtk/compat.h */ gboolean nsgtk_icon_size_lookup_for_settings(GtkSettings *settings, GtkIconSize size, diff --git a/frontends/gtk/compat.h b/frontends/gtk/compat.h index 9554b0cba..d822e2dee 100644 --- a/frontends/gtk/compat.h +++ b/frontends/gtk/compat.h @@ -209,6 +209,16 @@ GtkWidget *nsgtk_button_new_from_stock(const gchar *stock_id); */ gboolean nsgtk_stock_lookup(const gchar *stock_id, GtkStockItem *item); +/** + * Sets whether the button will grab focus when it is clicked with the mouse. + * + * Compatability interface for original deprecated in GTK 3.20 + * + * \param button The button alter + * \param focus_on_click whether the button grabs focus when clicked with the mouse + */ +void nsgtk_button_set_focus_on_click(GtkButton *button, gboolean focus_on_click); + void nsgtk_window_set_opacity(GtkWindow *window, gdouble opacity); void nsgtk_scrolled_window_add_with_viewport(GtkScrolledWindow *window, GtkWidget *child); @@ -268,6 +278,15 @@ GtkWidget *nsgtk_image_menu_item_new_with_mnemonic(const gchar *label); */ void nsgtk_image_menu_item_set_image(GtkWidget *image_menu_item, GtkWidget *image); +/** + * Displays menu and makes it available for selection + * + * Compatability interface for gtk_menu_popup deprecated in GTK 3.22. + * + * \param image_menu_item The image menu entry item. + * \param trigger_event the GdkEvent that initiated this request or NULL if it's the current event. + */ +void nsgtk_menu_popup_at_pointer(GtkMenu *menu, const GdkEvent *trigger_event); /** * Parses a resource file containing a GtkBuilder UI definition and diff --git a/frontends/gtk/scaffolding.c b/frontends/gtk/scaffolding.c index bedad9140..8c46fd884 100644 --- a/frontends/gtk/scaffolding.c +++ b/frontends/gtk/scaffolding.c @@ -534,8 +534,7 @@ nsgtk_window_tool_bar_clicked(GtkToolbar *toolbar, popup_menu_hide(g->menu_popup, true, false, true, false); popup_menu_show(g->menu_popup, false, false, false, true); - gtk_menu_popup(g->menu_popup->popup_menu, NULL, NULL, NULL, NULL, 0, - gtk_get_current_event_time()); + nsgtk_menu_popup_at_pointer(g->menu_popup->popup_menu, NULL); return TRUE; } @@ -2751,8 +2750,7 @@ void nsgtk_scaffolding_context_menu(struct nsgtk_scaffolding *g, popup_menu_hide(g->menu_popup, false, false, false, true); } - gtk_menu_popup(gtkmenu, NULL, NULL, NULL, NULL, 0, - gtk_get_current_event_time()); + nsgtk_menu_popup_at_pointer(gtkmenu, NULL); } /** diff --git a/frontends/gtk/tabs.c b/frontends/gtk/tabs.c index dbe9d405b..f99b2403b 100644 --- a/frontends/gtk/tabs.c +++ b/frontends/gtk/tabs.c @@ -82,7 +82,7 @@ static GtkWidget *nsgtk_tab_label_setup(struct gui_window *window) close = nsgtk_image_new_from_stock(NSGTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); gtk_container_add(GTK_CONTAINER(button), close); - gtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE); + nsgtk_button_set_focus_on_click(GTK_BUTTON(button), FALSE); gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); gtk_widget_set_tooltip_text(button, "Close this tab."); diff --git a/frontends/gtk/window.c b/frontends/gtk/window.c index 7f24d40ac..d0443a296 100644 --- a/frontends/gtk/window.c +++ b/frontends/gtk/window.c @@ -1295,9 +1295,7 @@ static void gui_window_create_form_select_menu(struct gui_window *g, gtk_widget_show_all(select_menu); - gtk_menu_popup(GTK_MENU(select_menu), NULL, NULL, NULL, - NULL /* data */, 0, gtk_get_current_event_time()); - + nsgtk_menu_popup_at_pointer(GTK_MENU(select_menu), NULL); } static void -- cgit v1.2.3