[nautilus/antonioffix-menus-and-popovers: 6/7] files-view: Avoid futile casting



commit f164cb6d4eb335976be543dd3f2092e16aba87a4
Author: António Fernandes <antoniof gnome org>
Date:   Sun Jan 28 22:58:23 2018 +0000

    files-view: Avoid futile casting
    
    We are casting (cost GdkEvent *) to (GdkEvent *)
    back and forth, all because some files-view functions
    don't take a pointer to const GdkEvent as argument.
    
    But those functions don't actually change the event,
    so, make them take a pointer to const GdkEvent instead
    and drop unnecessary casting.

 src/nautilus-canvas-view.c  | 10 +++++-----
 src/nautilus-files-view.c   |  4 ++--
 src/nautilus-files-view.h   |  4 ++--
 src/nautilus-list-view.c    |  4 ++--
 src/nautilus-ui-utilities.c |  2 +-
 5 files changed, 12 insertions(+), 12 deletions(-)
---
diff --git a/src/nautilus-canvas-view.c b/src/nautilus-canvas-view.c
index 90275dab4..ab5673a39 100644
--- a/src/nautilus-canvas-view.c
+++ b/src/nautilus-canvas-view.c
@@ -1189,7 +1189,7 @@ canvas_container_context_click_selection_callback (NautilusCanvasContainer *cont
     g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view));
 
     nautilus_files_view_pop_up_selection_context_menu (NAUTILUS_FILES_VIEW (canvas_view),
-                                                       (GdkEvent *) event);
+                                                       event);
 }
 
 static void
@@ -1201,7 +1201,7 @@ canvas_container_context_click_background_callback (NautilusCanvasContainer *con
     g_assert (NAUTILUS_IS_CANVAS_VIEW (canvas_view));
 
     nautilus_files_view_pop_up_background_context_menu (NAUTILUS_FILES_VIEW (canvas_view),
-                                                        (GdkEvent *) event);
+                                                        event);
 }
 
 static char *
@@ -1352,11 +1352,11 @@ canvas_container_longpress_gesture_pressed_callback (GtkGestureLongPress *gestur
                                                      gpointer             user_data)
 {
     GdkEventSequence *event_sequence;
-    GdkEvent *event;
+    const 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);
+    event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), event_sequence);
 
     if (nautilus_view_get_selection (NAUTILUS_VIEW (view)))
     {
@@ -1366,7 +1366,7 @@ canvas_container_longpress_gesture_pressed_callback (GtkGestureLongPress *gestur
     else
     {
         nautilus_files_view_pop_up_background_context_menu (NAUTILUS_FILES_VIEW (view),
-                                                           (GdkEvent *) event);
+                                                           event);
     }
 }
 
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 59f625e16..7937bed31 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -8122,7 +8122,7 @@ nautilus_files_view_reveal_for_selection_context_menu (NautilusFilesView *view)
  **/
 void
 nautilus_files_view_pop_up_selection_context_menu  (NautilusFilesView *view,
-                                                    GdkEvent          *event)
+                                                    const GdkEvent    *event)
 {
     NautilusFilesViewPrivate *priv;
 
@@ -8172,7 +8172,7 @@ nautilus_files_view_pop_up_selection_context_menu  (NautilusFilesView *view,
  **/
 void
 nautilus_files_view_pop_up_background_context_menu (NautilusFilesView *view,
-                                                    GdkEvent          *event)
+                                                    const GdkEvent    *event)
 {
     NautilusFilesViewPrivate *priv;
 
diff --git a/src/nautilus-files-view.h b/src/nautilus-files-view.h
index e7c317f74..f9775b6f4 100644
--- a/src/nautilus-files-view.h
+++ b/src/nautilus-files-view.h
@@ -274,9 +274,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);
+                                                                          const GdkEvent    *event);
 void                nautilus_files_view_pop_up_selection_context_menu    (NautilusFilesView *view,
-                                                                          GdkEvent          *event);
+                                                                          const GdkEvent    *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 889f849e8..6ad2a4260 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -1946,7 +1946,7 @@ on_longpress_gesture_pressed_event (GtkGestureLongPress *gesture,
                                     gpointer             user_data)
 {
     GdkEventSequence *event_sequence;
-    GdkEvent *event;
+    const GdkEvent *event;
     NautilusListView *view = user_data;
     GList *selection;
 
@@ -1956,7 +1956,7 @@ on_longpress_gesture_pressed_event (GtkGestureLongPress *gesture,
         return;
     }
 
-    event = (GdkEvent *) gtk_gesture_get_last_event (GTK_GESTURE (gesture), event_sequence);
+    event = gtk_gesture_get_last_event (GTK_GESTURE (gesture), event_sequence);
 
     selection = nautilus_view_get_selection (NAUTILUS_VIEW (view));
     if (selection != NULL)
diff --git a/src/nautilus-ui-utilities.c b/src/nautilus-ui-utilities.c
index 022a71d6b..765097f9e 100644
--- a/src/nautilus-ui-utilities.c
+++ b/src/nautilus-ui-utilities.c
@@ -187,7 +187,7 @@ nautilus_pop_up_context_menu_at_pointer (GtkWidget      *parent,
     gtk_menu = gtk_menu_new_from_model (G_MENU_MODEL (menu));
     gtk_menu_attach_to_widget (GTK_MENU (gtk_menu), parent, NULL);
 
-    gtk_menu_popup_at_pointer (GTK_MENU (gtk_menu), (GdkEvent *) event);
+    gtk_menu_popup_at_pointer (GTK_MENU (gtk_menu), event);
 
     g_object_ref_sink (gtk_menu);
 }


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