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



commit f1d4dde36a7b2293fef6e60f4cc5b55e1605d5fb
Author: Michael Natterer <mitch gimp org>
Date:   Sun Oct 2 16:23:59 2011 +0200

    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.

 app/display/gimpdisplayshell-callbacks.c   |    2 +-
 app/display/gimpdisplayshell-tool-events.c |    4 +-
 app/widgets/gimpcolorpanel.c               |    2 +-
 app/widgets/gimpcomponenteditor.c          |    2 +-
 app/widgets/gimpcontainergridview.c        |    2 +-
 app/widgets/gimpcontainertreeview.c        |    4 +-
 app/widgets/gimperrorconsole.c             |    2 +-
 app/widgets/gimpgradienteditor.c           |    2 +-
 app/widgets/gimppaletteview.c              |    2 +-
 app/widgets/gimpview.c                     |    2 +-
 libgimpwidgets/gimp3migration.c            |   28 +++++++++++++++++++++
 libgimpwidgets/gimp3migration.h            |   10 +++++++
 libgimpwidgets/gimpcolorbutton.c           |    4 +-
 libgimpwidgets/gimpwidgets.c               |   37 ----------------------------
 libgimpwidgets/gimpwidgets.def             |    6 ++++-
 libgimpwidgets/gimpwidgets.h               |    2 -
 plug-ins/common/animation-play.c           |    2 +-
 plug-ins/common/colormap-remap.c           |    2 +-
 plug-ins/help-browser/dialog.c             |    2 +-
 plug-ins/ifs-compose/ifs-compose.c         |    2 +-
 plug-ins/imagemap/imap_main.c              |    6 +++-
 21 files changed, 65 insertions(+), 60 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c
index 0397707..1a2ea7e 100644
--- a/app/display/gimpdisplayshell-callbacks.c
+++ b/app/display/gimpdisplayshell-callbacks.c
@@ -320,7 +320,7 @@ gimp_display_shell_quick_mask_button_press (GtkWidget        *widget,
   if (! gimp_display_get_image (shell->display))
     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);
 
diff --git a/app/display/gimpdisplayshell-tool-events.c b/app/display/gimpdisplayshell-tool-events.c
index 2593e19..4c4edaf 100644
--- a/app/display/gimpdisplayshell-tool-events.c
+++ b/app/display/gimpdisplayshell-tool-events.c
@@ -244,7 +244,7 @@ gimp_display_shell_canvas_no_image_events (GtkWidget        *canvas,
       {
         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,
                                       "/dummy-menubar/image-popup",
@@ -536,7 +536,7 @@ gimp_display_shell_canvas_tool_events (GtkWidget        *canvas,
             gimp_display_shell_start_scrolling (shell, bevent->x, bevent->y);
             break;
 
-            /* FIXME: use gimp_button_event_triggers_context_menu() */
+            /* FIXME: use gdk_event_triggers_context_menu() */
           case 3:
             {
               GimpUIManager *ui_manager;
diff --git a/app/widgets/gimpcolorpanel.c b/app/widgets/gimpcolorpanel.c
index 669a20a..dd67589 100644
--- a/app/widgets/gimpcolorpanel.c
+++ b/app/widgets/gimpcolorpanel.c
@@ -98,7 +98,7 @@ static gboolean
 gimp_color_panel_button_press (GtkWidget      *widget,
                                GdkEventButton *bevent)
 {
-  if (gimp_button_event_triggers_context_menu (bevent))
+  if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
     {
       GimpColorButton *color_button;
       GimpColorPanel  *color_panel;
diff --git a/app/widgets/gimpcomponenteditor.c b/app/widgets/gimpcomponenteditor.c
index c440d83..a7f266d 100644
--- a/app/widgets/gimpcomponenteditor.c
+++ b/app/widgets/gimpcomponenteditor.c
@@ -502,7 +502,7 @@ gimp_component_editor_button_press (GtkWidget           *widget,
 
       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);
         }
diff --git a/app/widgets/gimpcontainergridview.c b/app/widgets/gimpcontainergridview.c
index e81b4fc..786eef0 100644
--- a/app/widgets/gimpcontainergridview.c
+++ b/app/widgets/gimpcontainergridview.c
@@ -728,7 +728,7 @@ gimp_container_grid_view_button_press (GtkWidget             *widget,
                                        GdkEventButton        *bevent,
                                        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);
     }
diff --git a/app/widgets/gimpcontainertreeview.c b/app/widgets/gimpcontainertreeview.c
index e0c801b..42a12a0 100644
--- a/app/widgets/gimpcontainertreeview.c
+++ b/app/widgets/gimpcontainertreeview.c
@@ -1018,7 +1018,7 @@ gimp_container_tree_view_button_press (GtkWidget             *widget,
 
       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,
                                                  renderer->viewable))
@@ -1163,7 +1163,7 @@ gimp_container_tree_view_button_press (GtkWidget             *widget,
     }
   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);
         }
diff --git a/app/widgets/gimperrorconsole.c b/app/widgets/gimperrorconsole.c
index 8d8002d..a9f60b9 100644
--- a/app/widgets/gimperrorconsole.c
+++ b/app/widgets/gimperrorconsole.c
@@ -230,7 +230,7 @@ gimp_error_console_button_press (GtkWidget        *widget,
                                  GdkEventButton   *bevent,
                                  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);
     }
diff --git a/app/widgets/gimpgradienteditor.c b/app/widgets/gimpgradienteditor.c
index 61d8a5f..debf850 100644
--- a/app/widgets/gimpgradienteditor.c
+++ b/app/widgets/gimpgradienteditor.c
@@ -836,7 +836,7 @@ view_events (GtkWidget          *widget,
       {
         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);
           }
diff --git a/app/widgets/gimppaletteview.c b/app/widgets/gimppaletteview.c
index cb4a7d6..a34dd50 100644
--- a/app/widgets/gimppaletteview.c
+++ b/app/widgets/gimppaletteview.c
@@ -234,7 +234,7 @@ gimp_palette_view_button_press (GtkWidget      *widget,
     g_signal_emit (view, view_signals[ENTRY_CLICKED], 0,
                    entry, bevent->state);
 
-  if (gimp_button_event_triggers_context_menu (bevent))
+  if (gdk_event_triggers_context_menu ((GdkEvent *) bevent))
     {
       if (entry != view->selected)
         gimp_palette_view_select_entry (view, entry);
diff --git a/app/widgets/gimpview.c b/app/widgets/gimpview.c
index 5e94061..d4f53cd 100644
--- a/app/widgets/gimpview.c
+++ b/app/widgets/gimpview.c
@@ -441,7 +441,7 @@ gimp_view_button_press_event (GtkWidget      *widget,
 
   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;
 
diff --git a/libgimpwidgets/gimp3migration.c b/libgimpwidgets/gimp3migration.c
index ac9a80a..529b125 100644
--- a/libgimpwidgets/gimp3migration.c
+++ b/libgimpwidgets/gimp3migration.c
@@ -84,3 +84,31 @@ gtk_separator_new (GtkOrientation  orientation)
   else
     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 */
diff --git a/libgimpwidgets/gimp3migration.h b/libgimpwidgets/gimp3migration.h
index 5b0cab2..82270f9 100644
--- a/libgimpwidgets/gimp3migration.h
+++ b/libgimpwidgets/gimp3migration.h
@@ -44,4 +44,14 @@ GtkWidget * gtk_scrollbar_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__ */
diff --git a/libgimpwidgets/gimpcolorbutton.c b/libgimpwidgets/gimpcolorbutton.c
index a3aa25c..a235512 100644
--- a/libgimpwidgets/gimpcolorbutton.c
+++ b/libgimpwidgets/gimpcolorbutton.c
@@ -36,8 +36,8 @@
 #include "gimpdialog.h"
 #include "gimphelpui.h"
 #include "gimpstock.h"
-#include "gimpwidgets.h" /* remove in 3.0 */
 #include "gimpwidgets-private.h"
+#include "gimp3migration.h"
 
 #include "libgimp/libgimp-intl.h"
 
@@ -488,7 +488,7 @@ gimp_color_button_button_press (GtkWidget      *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,
                                                    "/color-button-popup");
diff --git a/libgimpwidgets/gimpwidgets.c b/libgimpwidgets/gimpwidgets.c
index d13227f..88edfbb 100644
--- a/libgimpwidgets/gimpwidgets.c
+++ b/libgimpwidgets/gimpwidgets.c
@@ -1239,40 +1239,3 @@ gimp_label_set_attributes (GtkLabel *label,
   gtk_label_set_attributes (label, 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;
-}
diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def
index 1da5fbf..63b2a81 100644
--- a/libgimpwidgets/gimpwidgets.def
+++ b/libgimpwidgets/gimpwidgets.def
@@ -5,7 +5,6 @@ EXPORTS
 	gimp_browser_new
 	gimp_browser_set_widget
 	gimp_browser_show_message
-	gimp_button_event_triggers_context_menu
 	gimp_button_extended_clicked
 	gimp_button_get_type
 	gimp_button_new
@@ -389,5 +388,10 @@ EXPORTS
 	gimp_zoom_model_zoom
 	gimp_zoom_model_zoom_step
 	gimp_zoom_type_get_type
+	gdk_event_triggers_context_menu
 	gtk_box_new
 	gtk_button_box_new
+	gtk_paned_new
+	gtk_scale_new
+	gtk_scrollbar_new
+	gtk_separator_new
diff --git a/libgimpwidgets/gimpwidgets.h b/libgimpwidgets/gimpwidgets.h
index 4316dfb..8bc0659 100644
--- a/libgimpwidgets/gimpwidgets.h
+++ b/libgimpwidgets/gimpwidgets.h
@@ -263,8 +263,6 @@ GtkWidget * gimp_table_attach_aligned    (GtkTable        *table,
 void        gimp_label_set_attributes    (GtkLabel        *label,
                                           ...);
 
-gboolean    gimp_button_event_triggers_context_menu (GdkEventButton *event);
-
 
 G_END_DECLS
 
diff --git a/plug-ins/common/animation-play.c b/plug-ins/common/animation-play.c
index a4d17d3..2aded2c 100644
--- a/plug-ins/common/animation-play.c
+++ b/plug-ins/common/animation-play.c
@@ -261,7 +261,7 @@ static gboolean
 button_press (GtkWidget      *widget,
               GdkEventButton *event)
 {
-  if (gimp_button_event_triggers_context_menu (event))
+  if (gdk_event_triggers_context_menu ((GdkEvent *) event))
     return popup_menu (widget, event);
 
   return FALSE;
diff --git a/plug-ins/common/colormap-remap.c b/plug-ins/common/colormap-remap.c
index a7d3ea5..abf24d7 100644
--- a/plug-ins/common/colormap-remap.c
+++ b/plug-ins/common/colormap-remap.c
@@ -549,7 +549,7 @@ static gboolean
 remap_button_press (GtkWidget      *widget,
                     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 FALSE;
diff --git a/plug-ins/help-browser/dialog.c b/plug-ins/help-browser/dialog.c
index 20307bd..0a52912 100644
--- a/plug-ins/help-browser/dialog.c
+++ b/plug-ins/help-browser/dialog.c
@@ -1078,7 +1078,7 @@ static gboolean
 view_button_press (GtkWidget      *widget,
                    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 FALSE;
diff --git a/plug-ins/ifs-compose/ifs-compose.c b/plug-ins/ifs-compose/ifs-compose.c
index 8363bd5..529de9a 100644
--- a/plug-ins/ifs-compose/ifs-compose.c
+++ b/plug-ins/ifs-compose/ifs-compose.c
@@ -1602,7 +1602,7 @@ design_area_button_press (GtkWidget      *widget,
 
   gtk_widget_grab_focus (widget);
 
-  if (gimp_button_event_triggers_context_menu (event))
+  if (gdk_event_triggers_context_menu ((GdkEvent *) event))
     {
       GtkWidget *menu =
         gtk_ui_manager_get_widget (ifsDesign->ui_manager,
diff --git a/plug-ins/imagemap/imap_main.c b/plug-ins/imagemap/imap_main.c
index 51bb4cb..65514bf 100644
--- a/plug-ins/imagemap/imap_main.c
+++ b/plug-ins/imagemap/imap_main.c
@@ -378,9 +378,11 @@ get_filename(void)
 }
 
 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);
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]