[nautilus/wip/antoniof/gtk4-preparation-step-event-controllers: 18/35] list-view: Separate column event and menu code




commit b393881f9b95a9626ed71c9ea4a8d86b883bc43e
Author: António Fernandes <antoniof gnome org>
Date:   Fri Dec 17 12:18:09 2021 +0000

    list-view: Separate column event and menu code
    
    This is a preparation for the next commit, in order to avoid
    conflict between branches.

 src/nautilus-list-view.c | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 655315745..1188f42dd 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -98,7 +98,9 @@ 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,
+                                      gdouble           x,
+                                      gdouble           y);
 
 G_DEFINE_TYPE (NautilusListView, nautilus_list_view, NAUTILUS_TYPE_FILES_VIEW);
 
@@ -1380,15 +1382,6 @@ on_column_header_event (GtkWidget *widget,
 {
     NautilusListView *list_view;
     guint button;
-    NautilusFile *file;
-    char **visible_columns;
-    char **column_order;
-    GList *all_columns;
-    GHashTable *visible_columns_hash;
-    int i;
-    GList *l;
-    GtkWidget *menu;
-    GtkWidget *menu_item;
 
     list_view = NAUTILUS_LIST_VIEW (user_data);
 
@@ -1404,6 +1397,26 @@ on_column_header_event (GtkWidget *widget,
         return GDK_EVENT_PROPAGATE;
     }
 
+    popup_column_header_menu (list_view, (&event->button)->x, (&event->button)->y);
+
+    return GDK_EVENT_STOP;
+}
+
+static void
+popup_column_header_menu (NautilusListView *list_view,
+                          gdouble           x,
+                          gdouble           y)
+{
+    NautilusFile *file;
+    char **visible_columns;
+    char **column_order;
+    GList *all_columns;
+    GHashTable *visible_columns_hash;
+    int i;
+    GList *l;
+    GtkWidget *menu;
+    GtkWidget *menu_item;
+
     file = nautilus_files_view_get_directory_as_file (NAUTILUS_FILES_VIEW (list_view));
 
     visible_columns = get_visible_columns (list_view);
@@ -1482,14 +1495,12 @@ on_column_header_event (GtkWidget *widget,
                       list_view);
 
     gtk_widget_show_all (menu);
-    gtk_menu_popup_at_pointer (GTK_MENU (menu), event);
+    gtk_menu_popup_at_pointer (GTK_MENU (menu), NULL);
 
     g_hash_table_destroy (visible_columns_hash);
     nautilus_column_list_free (all_columns);
     g_strfreev (column_order);
     g_strfreev (visible_columns);
-
-    return GDK_EVENT_STOP;
 }
 
 static void


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