Commit f1d4dde3 authored by Michael Natterer's avatar Michael Natterer 😴

libgimpwidgets: add gdk_event_triggers_context_menu() to gimp3migration.[ch]

and remove gimp_button_event_triggers_context_menu() again. Update
all callers to use the new function.
parent fb6fea3b
...@@ -320,7 +320,7 @@ gimp_display_shell_quick_mask_button_press (GtkWidget *widget, ...@@ -320,7 +320,7 @@ gimp_display_shell_quick_mask_button_press (GtkWidget *widget,
if (! gimp_display_get_image (shell->display)) if (! gimp_display_get_image (shell->display))
return TRUE; return TRUE;
if (gimp_button_event_triggers_context_menu (bevent)) if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
{ {
GimpImageWindow *window = gimp_display_shell_get_window (shell); GimpImageWindow *window = gimp_display_shell_get_window (shell);
......
...@@ -244,7 +244,7 @@ gimp_display_shell_canvas_no_image_events (GtkWidget *canvas, ...@@ -244,7 +244,7 @@ gimp_display_shell_canvas_no_image_events (GtkWidget *canvas,
{ {
GdkEventButton *bevent = (GdkEventButton *) event; GdkEventButton *bevent = (GdkEventButton *) event;
if (gimp_button_event_triggers_context_menu (bevent)) if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
{ {
gimp_ui_manager_ui_popup (shell->popup_manager, gimp_ui_manager_ui_popup (shell->popup_manager,
"/dummy-menubar/image-popup", "/dummy-menubar/image-popup",
...@@ -536,7 +536,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas, ...@@ -536,7 +536,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget *canvas,
gimp_display_shell_start_scrolling (shell, bevent->x, bevent->y); gimp_display_shell_start_scrolling (shell, bevent->x, bevent->y);
break; break;
/* FIXME: use gimp_button_event_triggers_context_menu() */ /* FIXME: use gdk_event_triggers_context_menu() */
case 3: case 3:
{ {
GimpUIManager *ui_manager; GimpUIManager *ui_manager;
......
...@@ -98,7 +98,7 @@ static gboolean ...@@ -98,7 +98,7 @@ static gboolean
gimp_color_panel_button_press (GtkWidget *widget, gimp_color_panel_button_press (GtkWidget *widget,
GdkEventButton *bevent) GdkEventButton *bevent)
{ {
if (gimp_button_event_triggers_context_menu (bevent)) if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
{ {
GimpColorButton *color_button; GimpColorButton *color_button;
GimpColorPanel *color_panel; GimpColorPanel *color_panel;
......
...@@ -502,7 +502,7 @@ gimp_component_editor_button_press (GtkWidget *widget, ...@@ -502,7 +502,7 @@ gimp_component_editor_button_press (GtkWidget *widget,
editor->clicked_component = channel; editor->clicked_component = channel;
if (gimp_button_event_triggers_context_menu (bevent)) if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
{ {
gimp_editor_popup_menu (GIMP_EDITOR (editor), NULL, NULL); gimp_editor_popup_menu (GIMP_EDITOR (editor), NULL, NULL);
} }
......
...@@ -728,7 +728,7 @@ gimp_container_grid_view_button_press (GtkWidget *widget, ...@@ -728,7 +728,7 @@ gimp_container_grid_view_button_press (GtkWidget *widget,
GdkEventButton *bevent, GdkEventButton *bevent,
GimpContainerGridView *grid_view) GimpContainerGridView *grid_view)
{ {
if (gimp_button_event_triggers_context_menu (bevent)) if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
{ {
gimp_editor_popup_menu (GIMP_EDITOR (grid_view), NULL, NULL); gimp_editor_popup_menu (GIMP_EDITOR (grid_view), NULL, NULL);
} }
......
...@@ -1018,7 +1018,7 @@ gimp_container_tree_view_button_press (GtkWidget *widget, ...@@ -1018,7 +1018,7 @@ gimp_container_tree_view_button_press (GtkWidget *widget,
g_object_ref (tree_view); g_object_ref (tree_view);
if (gimp_button_event_triggers_context_menu (bevent)) if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
{ {
if (gimp_container_view_item_selected (container_view, if (gimp_container_view_item_selected (container_view,
renderer->viewable)) renderer->viewable))
...@@ -1163,7 +1163,7 @@ gimp_container_tree_view_button_press (GtkWidget *widget, ...@@ -1163,7 +1163,7 @@ gimp_container_tree_view_button_press (GtkWidget *widget,
} }
else else
{ {
if (gimp_button_event_triggers_context_menu (bevent)) if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
{ {
gimp_editor_popup_menu (GIMP_EDITOR (tree_view), NULL, NULL); gimp_editor_popup_menu (GIMP_EDITOR (tree_view), NULL, NULL);
} }
......
...@@ -230,7 +230,7 @@ gimp_error_console_button_press (GtkWidget *widget, ...@@ -230,7 +230,7 @@ gimp_error_console_button_press (GtkWidget *widget,
GdkEventButton *bevent, GdkEventButton *bevent,
GimpErrorConsole *console) GimpErrorConsole *console)
{ {
if (gimp_button_event_triggers_context_menu (bevent)) if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
{ {
return gimp_editor_popup_menu (GIMP_EDITOR (console), NULL, NULL); return gimp_editor_popup_menu (GIMP_EDITOR (console), NULL, NULL);
} }
......
...@@ -836,7 +836,7 @@ view_events (GtkWidget *widget, ...@@ -836,7 +836,7 @@ view_events (GtkWidget *widget,
{ {
GdkEventButton *bevent = (GdkEventButton *) event; GdkEventButton *bevent = (GdkEventButton *) event;
if (gimp_button_event_triggers_context_menu (bevent)) if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
{ {
gimp_editor_popup_menu (GIMP_EDITOR (editor), NULL, NULL); gimp_editor_popup_menu (GIMP_EDITOR (editor), NULL, NULL);
} }
......
...@@ -234,7 +234,7 @@ gimp_palette_view_button_press (GtkWidget *widget, ...@@ -234,7 +234,7 @@ gimp_palette_view_button_press (GtkWidget *widget,
g_signal_emit (view, view_signals[ENTRY_CLICKED], 0, g_signal_emit (view, view_signals[ENTRY_CLICKED], 0,
entry, bevent->state); entry, bevent->state);
if (gimp_button_event_triggers_context_menu (bevent)) if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
{ {
if (entry != view->selected) if (entry != view->selected)
gimp_palette_view_select_entry (view, entry); gimp_palette_view_select_entry (view, entry);
......
...@@ -441,7 +441,7 @@ gimp_view_button_press_event (GtkWidget *widget, ...@@ -441,7 +441,7 @@ gimp_view_button_press_event (GtkWidget *widget,
if (bevent->type == GDK_BUTTON_PRESS) if (bevent->type == GDK_BUTTON_PRESS)
{ {
if (gimp_button_event_triggers_context_menu (bevent)) if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
{ {
view->press_state = 0; view->press_state = 0;
......
...@@ -84,3 +84,31 @@ gtk_separator_new (GtkOrientation orientation) ...@@ -84,3 +84,31 @@ gtk_separator_new (GtkOrientation orientation)
else else
return gtk_vseparator_new (); return gtk_vseparator_new ();
} }
#if ! GTK_CHECK_VERSION (3, 3, 0)
gboolean
gdk_event_triggers_context_menu (const GdkEvent *event)
{
g_return_val_if_fail (event != NULL, FALSE);
if (event->type == GDK_BUTTON_PRESS)
{
GdkEventButton *bevent = (GdkEventButton *) event;
if (bevent->button == 3 &&
! (bevent->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK)))
return TRUE;
#ifdef GDK_WINDOWING_QUARTZ
if (bevent->button == 1 &&
! (bevent->state & (GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) &&
(bevent->state & GDK_CONTROL_MASK))
return TRUE;
#endif
}
return FALSE;
}
#endif /* GTK+ 3.3 */
...@@ -44,4 +44,14 @@ GtkWidget * gtk_scrollbar_new (GtkOrientation orientation, ...@@ -44,4 +44,14 @@ GtkWidget * gtk_scrollbar_new (GtkOrientation orientation,
GtkWidget * gtk_separator_new (GtkOrientation orientation); GtkWidget * gtk_separator_new (GtkOrientation orientation);
/* These functions are even more evil. They exist only since GTK+ 3.3
* and need to be taken care of carefully when building against GTK+
* 3.x. This is not an issue as long as we don't have any GIMP 3.x
* release, and this file will be gone until then.
*/
#if ! GTK_CHECK_VERSION (3, 3, 0)
gboolean gdk_event_triggers_context_menu (const GdkEvent *event);
#endif
#endif /* __GIMP_3_MIGRATION_H__ */ #endif /* __GIMP_3_MIGRATION_H__ */
...@@ -36,8 +36,8 @@ ...@@ -36,8 +36,8 @@
#include "gimpdialog.h" #include "gimpdialog.h"
#include "gimphelpui.h" #include "gimphelpui.h"
#include "gimpstock.h" #include "gimpstock.h"
#include "gimpwidgets.h" /* remove in 3.0 */
#include "gimpwidgets-private.h" #include "gimpwidgets-private.h"
#include "gimp3migration.h"
#include "libgimp/libgimp-intl.h" #include "libgimp/libgimp-intl.h"
...@@ -488,7 +488,7 @@ gimp_color_button_button_press (GtkWidget *widget, ...@@ -488,7 +488,7 @@ gimp_color_button_button_press (GtkWidget *widget,
{ {
GimpColorButton *button = GIMP_COLOR_BUTTON (widget); GimpColorButton *button = GIMP_COLOR_BUTTON (widget);
if (gimp_button_event_triggers_context_menu (bevent)) if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
{ {
GtkWidget *menu = gtk_ui_manager_get_widget (button->popup_menu, GtkWidget *menu = gtk_ui_manager_get_widget (button->popup_menu,
"/color-button-popup"); "/color-button-popup");
......
...@@ -1239,40 +1239,3 @@ gimp_label_set_attributes (GtkLabel *label, ...@@ -1239,40 +1239,3 @@ gimp_label_set_attributes (GtkLabel *label,
gtk_label_set_attributes (label, attrs); gtk_label_set_attributes (label, attrs);
pango_attr_list_unref (attrs); pango_attr_list_unref (attrs);
} }
/**
* gimp_button_event_triggers_context_menu:
* @event: a #GdkEventButton
*
* Use this function instead of checking for event->button == 3.
*
* Note that this function is a temporary solution, GTK+ 3.4 will
* include a similar function which GIMP will use and this function
* will be deprecated/removed.
*
* Returns: #TRUE if the passed @event triggers a context menu, which
* is a platform-dependent decision.
*
* Since: GIMP 2.8
**/
gboolean
gimp_button_event_triggers_context_menu (GdkEventButton *event)
{
g_return_val_if_fail (event != NULL, FALSE);
if (event->type == GDK_BUTTON_PRESS)
{
if (event->button == 3 &&
! (event->state & (GDK_BUTTON1_MASK | GDK_BUTTON2_MASK)))
return TRUE;
#ifdef GDK_WINDOWING_QUARTZ
if (event->button == 1 &&
! (event->state & (GDK_BUTTON2_MASK | GDK_BUTTON3_MASK)) &&
(event->state & GDK_CONTROL_MASK))
return TRUE;
#endif
}
return FALSE;
}
...@@ -5,7 +5,6 @@ EXPORTS ...@@ -5,7 +5,6 @@ EXPORTS
gimp_browser_new gimp_browser_new
gimp_browser_set_widget gimp_browser_set_widget
gimp_browser_show_message gimp_browser_show_message
gimp_button_event_triggers_context_menu
gimp_button_extended_clicked gimp_button_extended_clicked
gimp_button_get_type gimp_button_get_type
gimp_button_new gimp_button_new
...@@ -389,5 +388,10 @@ EXPORTS ...@@ -389,5 +388,10 @@ EXPORTS
gimp_zoom_model_zoom gimp_zoom_model_zoom
gimp_zoom_model_zoom_step gimp_zoom_model_zoom_step
gimp_zoom_type_get_type gimp_zoom_type_get_type
gdk_event_triggers_context_menu
gtk_box_new gtk_box_new
gtk_button_box_new gtk_button_box_new
gtk_paned_new
gtk_scale_new
gtk_scrollbar_new
gtk_separator_new
...@@ -263,8 +263,6 @@ GtkWidget * gimp_table_attach_aligned (GtkTable *table, ...@@ -263,8 +263,6 @@ GtkWidget * gimp_table_attach_aligned (GtkTable *table,
void gimp_label_set_attributes (GtkLabel *label, void gimp_label_set_attributes (GtkLabel *label,
...); ...);
gboolean gimp_button_event_triggers_context_menu (GdkEventButton *event);
G_END_DECLS G_END_DECLS
......
...@@ -261,7 +261,7 @@ static gboolean ...@@ -261,7 +261,7 @@ static gboolean
button_press (GtkWidget *widget, button_press (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event)
{ {
if (gimp_button_event_triggers_context_menu (event)) if (gdk_event_triggers_context_menu ((GdkEvent *) event))
return popup_menu (widget, event); return popup_menu (widget, event);
return FALSE; return FALSE;
......
...@@ -549,7 +549,7 @@ static gboolean ...@@ -549,7 +549,7 @@ static gboolean
remap_button_press (GtkWidget *widget, remap_button_press (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event)
{ {
if (gimp_button_event_triggers_context_menu (event)) if (gdk_event_triggers_context_menu ((GdkEvent *) event))
return remap_popup_menu (widget, event); return remap_popup_menu (widget, event);
return FALSE; return FALSE;
......
...@@ -1078,7 +1078,7 @@ static gboolean ...@@ -1078,7 +1078,7 @@ static gboolean
view_button_press (GtkWidget *widget, view_button_press (GtkWidget *widget,
GdkEventButton *event) GdkEventButton *event)
{ {
if (gimp_button_event_triggers_context_menu (event)) if (gdk_event_triggers_context_menu ((GdkEvent *) event))
return view_popup_menu (widget, event); return view_popup_menu (widget, event);
return FALSE; return FALSE;
......
...@@ -1602,7 +1602,7 @@ design_area_button_press (GtkWidget *widget, ...@@ -1602,7 +1602,7 @@ design_area_button_press (GtkWidget *widget,
gtk_widget_grab_focus (widget); gtk_widget_grab_focus (widget);
if (gimp_button_event_triggers_context_menu (event)) if (gdk_event_triggers_context_menu ((GdkEvent *) event))
{ {
GtkWidget *menu = GtkWidget *menu =
gtk_ui_manager_get_widget (ifsDesign->ui_manager, gtk_ui_manager_get_widget (ifsDesign->ui_manager,
......
...@@ -378,9 +378,11 @@ get_filename(void) ...@@ -378,9 +378,11 @@ get_filename(void)
} }
static gboolean static gboolean
arrow_on_button_press(GtkWidget *widget, GdkEventButton *event, gpointer data) arrow_on_button_press (GtkWidget *widget,
GdkEventButton *event,
gpointer data)
{ {
if (gimp_button_event_triggers_context_menu (event)) if (gdk_event_triggers_context_menu ((GdkEvent *) event))
{ {
do_popup_menu (event); do_popup_menu (event);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment