[nautilus/wip/antoniof/switch-to-gtk4: 14/33] general: Use new cursor API




commit a05cfebc01a5730ac90aa3531915853af9558d66
Author: António Fernandes <antoniof gnome org>
Date:   Fri Dec 24 00:46:44 2021 +0000

    general: Use new cursor API
    
    There is no need to go through GDK anymore.

 src/nautilus-batch-rename-dialog.c | 19 ++++---------------
 src/nautilus-files-view.c          | 12 ++++--------
 src/nautilus-list-view.c           | 12 +++++-------
 src/nautilus-properties-window.c   |  9 ++-------
 src/nautilus-window.c              |  9 ++-------
 5 files changed, 17 insertions(+), 44 deletions(-)
---
diff --git a/src/nautilus-batch-rename-dialog.c b/src/nautilus-batch-rename-dialog.c
index 097f89207..72344e56c 100644
--- a/src/nautilus-batch-rename-dialog.c
+++ b/src/nautilus-batch-rename-dialog.c
@@ -472,7 +472,7 @@ begin_batch_rename (NautilusBatchRenameDialog *dialog,
     /* do the actual rename here */
     nautilus_file_batch_rename (dialog->selection, new_names, NULL, NULL);
 
-    gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (dialog->window)), NULL);
+    gtk_widget_set_cursor (GTK_WIDGET (dialog->window), NULL);
 }
 
 static void
@@ -635,9 +635,6 @@ create_arrow (NautilusBatchRenameDialog *dialog,
 static void
 prepare_batch_rename (NautilusBatchRenameDialog *dialog)
 {
-    GdkCursor *cursor;
-    GdkDisplay *display;
-
     /* wait for checking conflicts to finish, to be sure that
      * the rename can actually take place */
     if (dialog->directories_pending_conflict_check != NULL)
@@ -651,17 +648,9 @@ prepare_batch_rename (NautilusBatchRenameDialog *dialog)
         return;
     }
 
-    display = gtk_widget_get_display (GTK_WIDGET (dialog->window));
-    cursor = gdk_cursor_new_from_name (display, "progress");
-    gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (dialog->window)),
-                           cursor);
-    g_object_unref (cursor);
+    gtk_widget_set_cursor_from_name (GTK_WIDGET (dialog->window), "progress");
 
-    display = gtk_widget_get_display (GTK_WIDGET (dialog));
-    cursor = gdk_cursor_new_from_name (display, "progress");
-    gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (dialog)),
-                           cursor);
-    g_object_unref (cursor);
+    gtk_widget_set_cursor_from_name (GTK_WIDGET (dialog), "progress");
 
     gtk_widget_hide (GTK_WIDGET (dialog));
     begin_batch_rename (dialog, dialog->new_names);
@@ -1991,7 +1980,7 @@ nautilus_batch_rename_dialog_new (GList             *selection,
 
     fill_display_listbox (dialog);
 
-    gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), NULL);
+    gtk_widget_set_cursor (GTK_WIDGET (window), NULL);
 
     g_string_free (dialog_title, TRUE);
 
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index 6128b9e6d..0ad43213d 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -6115,18 +6115,14 @@ real_action_rename (NautilusFilesView *view)
         /* If there is more than one file selected, invoke a batch renamer */
         if (selection->next != NULL)
         {
-            GdkCursor *cursor;
-            GdkDisplay *display;
+            NautilusWindow *window;
 
-            display = gtk_widget_get_display (GTK_WIDGET (nautilus_files_view_get_window (view)));
-            cursor = gdk_cursor_new_from_name (display, "progress");
-            gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (nautilus_files_view_get_window 
(view))),
-                                   cursor);
-            g_object_unref (cursor);
+            window = nautilus_files_view_get_window (view);
+            gtk_widget_set_cursor_from_name (GTK_WIDGET (window), "progress");
 
             dialog = nautilus_batch_rename_dialog_new (selection,
                                                        nautilus_files_view_get_model (view),
-                                                       nautilus_files_view_get_window (view));
+                                                       window);
 
             gtk_widget_show (GTK_WIDGET (dialog));
         }
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index f10c9b80e..6961b8705 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -278,11 +278,11 @@ on_event_controller_motion_motion (GtkEventControllerMotion *controller,
     {
         if (view->details->hover_path != NULL)
         {
-            gdk_window_set_cursor (gtk_widget_get_window (widget), hand_cursor);
+            gtk_widget_set_cursor (widget, hand_cursor);
         }
         else
         {
-            gdk_window_set_cursor (gtk_widget_get_window (widget), NULL);
+            gtk_widget_set_cursor (widget, NULL);
         }
     }
 
@@ -343,7 +343,7 @@ on_event_controller_motion_enter (GtkEventControllerMotion *controller,
 
     if (view->details->hover_path != NULL)
     {
-        gdk_window_set_cursor (gtk_widget_get_window (widget), hand_cursor);
+        gtk_widget_set_cursor (widget, hand_cursor);
     }
 }
 
@@ -3429,7 +3429,6 @@ nautilus_list_view_is_zoom_level_default (NautilusFilesView *view)
 static void
 nautilus_list_view_click_policy_changed (NautilusFilesView *directory_view)
 {
-    GdkWindow *win;
     GdkDisplay *display;
     NautilusListView *view;
     GtkTreeIter iter;
@@ -3457,8 +3456,7 @@ nautilus_list_view_click_policy_changed (NautilusFilesView *directory_view)
         tree = view->details->tree_view;
         if (gtk_widget_get_realized (GTK_WIDGET (tree)))
         {
-            win = gtk_widget_get_window (GTK_WIDGET (tree));
-            gdk_window_set_cursor (win, NULL);
+            gtk_widget_set_cursor (GTK_WIDGET (tree), NULL);
 
             if (display != NULL)
             {
@@ -3472,7 +3470,7 @@ nautilus_list_view_click_policy_changed (NautilusFilesView *directory_view)
     {
         if (hand_cursor == NULL)
         {
-            hand_cursor = gdk_cursor_new_from_name (display, "pointer");
+            hand_cursor = gdk_cursor_new_from_name ("pointer", NULL);
         }
     }
 }
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index a3dc72b3f..92d5dba4a 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -2871,12 +2871,7 @@ start_long_operation (NautilusPropertiesWindow *self)
     if (self->long_operation_underway == 0)
     {
         /* start long operation */
-        GdkDisplay *display;
-        g_autoptr (GdkCursor) cursor = NULL;
-
-        display = gtk_widget_get_display (GTK_WIDGET (self));
-        cursor = gdk_cursor_new_from_name (display, "wait");
-        gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self)), cursor);
+        gtk_widget_set_cursor_from_name (GTK_WIDGET (self), "wait");
     }
     self->long_operation_underway++;
 }
@@ -2888,7 +2883,7 @@ end_long_operation (NautilusPropertiesWindow *self)
         self->long_operation_underway == 1)
     {
         /* finished !! */
-        gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self)), NULL);
+        gtk_widget_set_cursor (GTK_WIDGET (self), NULL);
     }
     self->long_operation_underway--;
 }
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index c270a677f..03356a66e 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -748,16 +748,11 @@ update_cursor (NautilusWindow *window)
     if (slot != NULL &&
         nautilus_window_slot_get_allow_stop (slot))
     {
-        GdkDisplay *display;
-        g_autoptr (GdkCursor) cursor = NULL;
-
-        display = gtk_widget_get_display (GTK_WIDGET (window));
-        cursor = gdk_cursor_new_from_name (display, "progress");
-        gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), cursor);
+        gtk_widget_set_cursor_from_name (GTK_WIDGET (window), "progress");
     }
     else
     {
-        gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), NULL);
+        gtk_widget_set_cursor (GTK_WIDGET (window), NULL);
     }
 }
 


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