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




commit a16a12cf9198f1abe3c4c8813499c44199ea24ab
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 b8f472b2e..3403a6837 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);
 
@@ -1390,15 +1392,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);
 
@@ -1414,6 +1407,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);
@@ -1492,14 +1505,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]