[nautilus/wip/antoniof/gtk4-preparation-step-event-controllers: 5/21] list-view: Stop connecting to header button ::event




commit ff7935c4184aaf028e5b299e870554df26051c47
Author: António Fernandes <antoniof gnome org>
Date:   Sun Aug 8 20:54:55 2021 +0100

    list-view: Stop connecting to header button ::event
    
    The ::event signal is gone in GTK4.
    
    We already have a gesture for clicks, use it instead.

 src/nautilus-list-view.c | 46 ++++++++++++++--------------------------------
 1 file changed, 14 insertions(+), 32 deletions(-)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 2d7e55c77..e606f6ffd 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -97,6 +97,8 @@ static char **get_default_column_order (NautilusListView *list_view);
 static void on_clipboard_owner_changed (GtkClipboard *clipboard,
                                         GdkEvent     *event,
                                         gpointer      user_data);
+static void popup_column_header_menu (NautilusListView *list_view,
+                                      const GdkEvent   *event);
 
 
 G_DEFINE_TYPE (NautilusListView, nautilus_list_view, NAUTILUS_TYPE_FILES_VIEW);
@@ -565,6 +567,15 @@ on_tree_view_multi_press_gesture_pressed (GtkGestureMultiPress *gesture,
     /* Column headers lie above bin_window, hence negative y coordinate. */
     if (bin_y < 0)
     {
+        if (button == GDK_BUTTON_SECONDARY)
+        {
+            popup_column_header_menu (view, event);
+            gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_CLAIMED);
+        }
+        else
+        {
+            gtk_gesture_set_state (GTK_GESTURE (gesture), GTK_EVENT_SEQUENCE_DENIED);
+        }
         return;
     }
 
@@ -1382,13 +1393,10 @@ column_header_menu_use_default (GtkMenuItem      *menu_item,
     g_strfreev (default_order);
 }
 
-static gboolean
-on_column_header_event (GtkWidget *widget,
-                        GdkEvent  *event,
-                        gpointer   user_data)
+static void
+popup_column_header_menu (NautilusListView *list_view,
+                          const GdkEvent   *event)
 {
-    NautilusListView *list_view;
-    guint button;
     NautilusFile *file;
     char **visible_columns;
     char **column_order;
@@ -1399,20 +1407,6 @@ on_column_header_event (GtkWidget *widget,
     GtkWidget *menu;
     GtkWidget *menu_item;
 
-    list_view = NAUTILUS_LIST_VIEW (user_data);
-
-    if (gdk_event_get_event_type (event) != GDK_BUTTON_PRESS)
-    {
-        return GDK_EVENT_PROPAGATE;
-    }
-
-    g_assert (gdk_event_get_button (event, &button));
-
-    if (button != GDK_BUTTON_SECONDARY)
-    {
-        return GDK_EVENT_PROPAGATE;
-    }
-
     file = nautilus_files_view_get_directory_as_file (NAUTILUS_FILES_VIEW (list_view));
 
     visible_columns = get_visible_columns (list_view);
@@ -1497,8 +1491,6 @@ on_column_header_event (GtkWidget *widget,
     nautilus_column_list_free (all_columns);
     g_strfreev (column_order);
     g_strfreev (visible_columns);
-
-    return GDK_EVENT_STOP;
 }
 
 static void
@@ -2187,11 +2179,6 @@ create_and_set_up_tree_view (NautilusListView *view)
                                  g_strdup ("name"),
                                  view->details->file_name_column);
 
-            g_signal_connect (gtk_tree_view_column_get_button (view->details->file_name_column),
-                              "event",
-                              G_CALLBACK (on_column_header_event),
-                              view);
-
             gtk_tree_view_set_search_column (view->details->tree_view, column_num);
 
             gtk_tree_view_column_set_sort_column_id (view->details->file_name_column, column_num);
@@ -2282,11 +2269,6 @@ create_and_set_up_tree_view (NautilusListView *view)
                                  g_strdup (name),
                                  column);
 
-            g_signal_connect (gtk_tree_view_column_get_button (column),
-                              "event",
-                              G_CALLBACK (on_column_header_event),
-                              view);
-
             gtk_tree_view_column_set_resizable (column, TRUE);
             gtk_tree_view_column_set_sort_order (column, sort_order);
 


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