[nautilus/antonioffix-menus-and-popovers: 9/20] Revert "nautilus-canvas-view, nautilus-view-icon-controller: Add longpress gesture to open context p



commit e6b2175ae09270ed21df2ba1e0b82b139e413db0
Author: António Fernandes <antoniof gnome org>
Date:   Fri Jan 26 21:59:51 2018 +0000

    Revert "nautilus-canvas-view, nautilus-view-icon-controller: Add longpress gesture to open context popup 
menu"
    
    This reverts commit e874ae70604de5f4893f011b0bf1c2eb339dd356.
    
    It has an incomplete commit message and didn't actually add the
    gesture to view-icon-controller.
    
    We will reimplement the gesture later in files-view.

 src/nautilus-canvas-container.c     |  6 ++---
 src/nautilus-canvas-view.c          | 45 ++++---------------------------------
 src/nautilus-files-view.c           | 15 +++++--------
 src/nautilus-files-view.h           |  4 ++--
 src/nautilus-list-view.c            | 38 +++----------------------------
 src/nautilus-pathbar.c              |  4 ++--
 src/nautilus-ui-utilities.c         |  4 ++--
 src/nautilus-ui-utilities.h         |  2 +-
 src/nautilus-view-icon-controller.c |  4 ++--
 9 files changed, 24 insertions(+), 98 deletions(-)
---
diff --git a/src/nautilus-canvas-container.c b/src/nautilus-canvas-container.c
index 923046142..0f69bdf68 100644
--- a/src/nautilus-canvas-container.c
+++ b/src/nautilus-canvas-container.c
@@ -3621,13 +3621,13 @@ nautilus_canvas_container_get_icon_text (NautilusCanvasContainer  *container,
 
 static gboolean
 handle_popups (NautilusCanvasContainer *container,
-               GdkEvent                *event,
+               GdkEventKey             *event,
                const char              *signal)
 {
     /* ensure we clear the drag state before showing the menu */
     clear_drag_state (container);
 
-    g_signal_emit_by_name (container, signal, event);
+    g_signal_emit_by_name (container, signal, NULL);
 
     return TRUE;
 }
@@ -3723,7 +3723,7 @@ key_press_event (GtkWidget   *widget,
              */
             if (event->state & GDK_CONTROL_MASK)
             {
-                handled = handle_popups (container, (GdkEvent *) event,
+                handled = handle_popups (container, event,
                                          "context_click_background");
             }
         }
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index fc3111728..f00fa5064 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -1134,26 +1134,24 @@ selection_changed_callback (NautilusCanvasContainer *container,
 
 static void
 canvas_container_context_click_selection_callback (NautilusCanvasContainer *container,
-                                                   const GdkEvent          *event,
+                                                   GdkEventButton          *event,
                                                    NautilusCanvasView      *canvas_view)
 {
     g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container));
     g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view));
 
-    nautilus_files_view_pop_up_selection_context_menu (NAUTILUS_FILES_VIEW (canvas_view),
-                                                       (GdkEvent *) event);
+    nautilus_files_view_pop_up_selection_context_menu (NAUTILUS_FILES_VIEW (canvas_view), event);
 }
 
 static void
 canvas_container_context_click_background_callback (NautilusCanvasContainer *container,
-                                                    const GdkEvent          *event,
+                                                    GdkEventButton          *event,
                                                     NautilusCanvasView      *canvas_view)
 {
     g_assert (NAUTILUS_IS_CANVAS_CONTAINER (container));
     g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view));
 
-    nautilus_files_view_pop_up_background_context_menu (NAUTILUS_FILES_VIEW (canvas_view),
-                                                        (GdkEvent *) event);
+    nautilus_files_view_pop_up_background_context_menu (NAUTILUS_FILES_VIEW (canvas_view), event);
 }
 
 static char *
@@ -1297,52 +1295,17 @@ nautilus_canvas_view_update_click_mode (NautilusCanvasView *canvas_view)
                                                      click_mode == NAUTILUS_CLICK_POLICY_SINGLE);
 }
 
-static void
-canvas_container_longpress_gesture_pressed_callback (GtkGestureLongPress *gesture,
-                                                     gdouble              x,
-                                                     gdouble              y,
-                                                     gpointer             user_data)
-{
-    GdkEventSequence *event_sequence;
-    GdkEvent *event;
-    NautilusCanvasView *view = NAUTILUS_CANVAS_VIEW (user_data);
-
-    event_sequence = gtk_gesture_get_last_updated_sequence (GTK_GESTURE (gesture));
-    event = (GdkEvent *) gtk_gesture_get_last_event (GTK_GESTURE (gesture), event_sequence);
-
-    if (nautilus_view_get_selection (NAUTILUS_VIEW (view)))
-    {
-        nautilus_files_view_pop_up_selection_context_menu (NAUTILUS_FILES_VIEW (view),
-                                                           event);
-    }
-    else
-    {
-        nautilus_files_view_pop_up_background_context_menu (NAUTILUS_FILES_VIEW (view),
-                                                           (GdkEvent *) event);
-    }
-}
-
 static void
 initialize_canvas_container (NautilusCanvasView      *canvas_view,
                              NautilusCanvasContainer *canvas_container)
 {
     GtkWidget *content_widget;
-    GtkGesture *longpress_gesture;
 
     content_widget = nautilus_files_view_get_content_widget (NAUTILUS_FILES_VIEW (canvas_view));
     canvas_view->canvas_container = GTK_WIDGET (canvas_container);
     g_object_add_weak_pointer (G_OBJECT (canvas_container),
                                (gpointer *) &canvas_view->canvas_container);
 
-    longpress_gesture = gtk_gesture_long_press_new (GTK_WIDGET (content_widget));
-    gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (longpress_gesture),
-                                                GTK_PHASE_CAPTURE);
-    gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (longpress_gesture),
-                                       TRUE);
-    g_signal_connect (longpress_gesture, "pressed",
-                      (GCallback) canvas_container_longpress_gesture_pressed_callback,
-                      canvas_view);
-
     gtk_widget_set_can_focus (GTK_WIDGET (canvas_container), TRUE);
 
     g_signal_connect_object (canvas_container, "activate",
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index ee9f8bc98..e74123a7a 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -4734,7 +4734,7 @@ open_one_in_new_window (gpointer data,
 
 static void
 update_context_menu_position_from_event (NautilusFilesView *view,
-                                         const GdkEvent    *event)
+                                         GdkEventButton    *event)
 {
     NautilusFilesViewPrivate *priv;
 
@@ -4743,13 +4743,8 @@ update_context_menu_position_from_event (NautilusFilesView *view,
     priv = nautilus_files_view_get_instance_private (view);
     if (event != NULL)
     {
-        gdouble x;
-        gdouble y;
-
-        gdk_event_get_coords (event, &x, &y);
-
-        priv->context_menu_position.x = x;
-        priv->context_menu_position.y = y;
+        priv->context_menu_position.x = event->x;
+        priv->context_menu_position.y = event->y;
     }
     else
     {
@@ -8139,7 +8134,7 @@ nautilus_files_view_update_toolbar_menus (NautilusFilesView *view)
  **/
 void
 nautilus_files_view_pop_up_selection_context_menu  (NautilusFilesView *view,
-                                                    GdkEvent          *event)
+                                                    GdkEventButton    *event)
 {
     NautilusFilesViewPrivate *priv;
 
@@ -8166,7 +8161,7 @@ nautilus_files_view_pop_up_selection_context_menu  (NautilusFilesView *view,
  **/
 void
 nautilus_files_view_pop_up_background_context_menu (NautilusFilesView *view,
-                                                    GdkEvent          *event)
+                                                    GdkEventButton    *event)
 {
     NautilusFilesViewPrivate *priv;
 
diff --git a/src/nautilus-files-view.h b/src/nautilus-files-view.h
index 1f386b400..80384f27d 100644
--- a/src/nautilus-files-view.h
+++ b/src/nautilus-files-view.h
@@ -272,9 +272,9 @@ void                nautilus_files_view_notify_selection_changed         (Nautil
 NautilusDirectory  *nautilus_files_view_get_model                        (NautilusFilesView *view);
 NautilusFile       *nautilus_files_view_get_directory_as_file            (NautilusFilesView *view);
 void                nautilus_files_view_pop_up_background_context_menu   (NautilusFilesView *view,
-                                                                          GdkEvent          *event);
+                                                                          GdkEventButton    *event);
 void                nautilus_files_view_pop_up_selection_context_menu    (NautilusFilesView *view,
-                                                                          GdkEvent          *event);
+                                                                          GdkEventButton    *event);
 gboolean            nautilus_files_view_should_show_file                 (NautilusFilesView *view,
                                                                           NautilusFile      *file);
 gboolean            nautilus_files_view_should_sort_directories_first    (NautilusFilesView *view);
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 6976e0764..c39d2ca33 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -436,7 +436,7 @@ enter_notify_callback (GtkWidget        *widget,
 static void
 do_popup_menu (GtkWidget        *widget,
                NautilusListView *view,
-               GdkEvent         *event)
+               GdkEventButton   *event)
 {
     if (tree_view_has_selection (GTK_TREE_VIEW (widget)))
     {
@@ -634,7 +634,7 @@ button_press_callback (GtkWidget      *widget,
 
         if (event->button == 3)
         {
-            do_popup_menu (widget, view, (GdkEvent *) event);
+            do_popup_menu (widget, view, event);
         }
 
         return TRUE;
@@ -790,7 +790,7 @@ button_press_callback (GtkWidget      *widget,
 
         if (event->button == 3)
         {
-            do_popup_menu (widget, view, (GdkEvent *) event);
+            do_popup_menu (widget, view, event);
         }
     }
 
@@ -2000,27 +2000,6 @@ get_icon_scale_callback (NautilusListModel *model,
     return gtk_widget_get_scale_factor (GTK_WIDGET (view->details->tree_view));
 }
 
-static void
-on_longpress_gesture_pressed_event (GtkGestureLongPress *gesture,
-                                    gdouble              x,
-                                    gdouble              y,
-                                    gpointer             user_data)
-{
-    GdkEventSequence *event_sequence;
-    GdkEvent *event;
-    NautilusListView *view = user_data;
-
-    event_sequence = gtk_gesture_get_last_updated_sequence (GTK_GESTURE (gesture));
-    if (event_sequence == NULL)
-    {
-        return;
-    }
-
-    event = (GdkEvent *) gtk_gesture_get_last_event (GTK_GESTURE (gesture), event_sequence);
-
-    do_popup_menu (GTK_WIDGET (view->details->tree_view), view, event);
-}
-
 static void
 create_and_set_up_tree_view (NautilusListView *view)
 {
@@ -2034,7 +2013,6 @@ create_and_set_up_tree_view (NautilusListView *view)
     NautilusDirectory *directory = NULL;
     NautilusQuery *query = NULL;
     NautilusQuerySearchContent content;
-    GtkGesture *longpress_gesture;
 
     content_widget = nautilus_files_view_get_content_widget (NAUTILUS_FILES_VIEW (view));
     view->details->tree_view = GTK_TREE_VIEW (gtk_tree_view_new ());
@@ -2112,16 +2090,6 @@ create_and_set_up_tree_view (NautilusListView *view)
     g_signal_connect_object (view->details->model, "get-icon-scale",
                              G_CALLBACK (get_icon_scale_callback), view, 0);
 
-    longpress_gesture = gtk_gesture_long_press_new (GTK_WIDGET (content_widget));
-    gtk_event_controller_set_propagation_phase (GTK_EVENT_CONTROLLER (longpress_gesture),
-                                                GTK_PHASE_CAPTURE);
-    gtk_gesture_single_set_touch_only (GTK_GESTURE_SINGLE (longpress_gesture),
-                                       TRUE);
-    g_signal_connect (longpress_gesture,
-                      "pressed",
-                      (GCallback) on_longpress_gesture_pressed_event,
-                      view);
-
     gtk_tree_selection_set_mode (gtk_tree_view_get_selection (view->details->tree_view), 
GTK_SELECTION_MULTIPLE);
 
     g_settings_bind (nautilus_list_view_preferences, NAUTILUS_PREFERENCES_LIST_VIEW_USE_TREE,
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index 695f36268..dc8ee6dbe 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -102,7 +102,7 @@ typedef struct
 
     GMenu *context_menu;
     NautilusFile *context_menu_file;
-    GdkEvent *context_menu_event;
+    GdkEventButton *context_menu_event;
 } NautilusPathBarPrivate;
 
 
@@ -1680,7 +1680,7 @@ schedule_pop_up_context_menu (NautilusPathBar *self,
     {
         gdk_event_free ((GdkEvent *) priv->context_menu_event);
     }
-    priv->context_menu_event = gdk_event_copy ((GdkEvent *) event);
+    priv->context_menu_event = (GdkEventButton *) gdk_event_copy ((GdkEvent *) event);
 
     if (file == priv->context_menu_file)
     {
diff --git a/src/nautilus-ui-utilities.c b/src/nautilus-ui-utilities.c
index 68c42138b..58958e5e4 100644
--- a/src/nautilus-ui-utilities.c
+++ b/src/nautilus-ui-utilities.c
@@ -171,7 +171,7 @@ nautilus_gmenu_add_item_in_submodel (GMenu       *menu,
 void
 nautilus_pop_up_context_menu (GtkWidget      *parent,
                               GMenu          *menu,
-                              GdkEvent       *event)
+                              GdkEventButton *button_event)
 {
     GtkWidget *gtk_menu;
 
@@ -182,7 +182,7 @@ nautilus_pop_up_context_menu (GtkWidget      *parent,
     gtk_menu_attach_to_widget (GTK_MENU (gtk_menu), parent, NULL);
 
     gtk_menu_popup_at_pointer (GTK_MENU (gtk_menu),
-                               event ? (GdkEvent *) event :
+                               button_event ? (GdkEvent *) button_event :
                                gtk_get_current_event ());
 
     g_object_ref_sink (gtk_menu);
diff --git a/src/nautilus-ui-utilities.h b/src/nautilus-ui-utilities.h
index 36dfbdb9e..0dfd31ca9 100644
--- a/src/nautilus-ui-utilities.h
+++ b/src/nautilus-ui-utilities.h
@@ -36,7 +36,7 @@ void nautilus_gmenu_merge                          (GMenu             *original,
                                                    gboolean           prepend);
 void nautilus_pop_up_context_menu                  (GtkWidget         *parent,
                                                     GMenu             *menu,
-                                                    GdkEvent          *event);
+                                                    GdkEventButton    *button_event);
 
 void   nautilus_ui_frame_image                     (GdkPixbuf        **pixbuf);
 void   nautilus_ui_frame_video                     (GdkPixbuf        **pixbuf);
diff --git a/src/nautilus-view-icon-controller.c b/src/nautilus-view-icon-controller.c
index 353f48572..1b7007982 100644
--- a/src/nautilus-view-icon-controller.c
+++ b/src/nautilus-view-icon-controller.c
@@ -669,7 +669,7 @@ on_button_press_event (GtkWidget *widget,
         if (event_button->button == GDK_BUTTON_SECONDARY)
         {
             nautilus_files_view_pop_up_selection_context_menu (NAUTILUS_FILES_VIEW (self),
-                                                               event);
+                                                               event_button);
         }
     }
     else
@@ -678,7 +678,7 @@ on_button_press_event (GtkWidget *widget,
         if (event_button->button == GDK_BUTTON_SECONDARY)
         {
             nautilus_files_view_pop_up_background_context_menu (NAUTILUS_FILES_VIEW (self),
-                                                                event);
+                                                                event_button);
         }
     }
 


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