[nautilus/wip/antoniof/gtk4-preparation-discontinued-api: 68/73] program-choosing: Replace GdkScreen with GdkDisplay




commit e975a173e7e77c347e7b6c7fcad0120f85465165
Author: António Fernandes <antoniof gnome org>
Date:   Thu Dec 16 00:33:08 2021 +0000

    program-choosing: Replace GdkScreen with GdkDisplay
    
    They are assumed to have a 1-to-1 correspondence these days.

 src/nautilus-files-view.c       | 22 +++++++++++-----------
 src/nautilus-mime-actions.c     |  8 ++++----
 src/nautilus-program-choosing.c | 20 +++++++-------------
 src/nautilus-program-choosing.h |  9 ++++-----
 4 files changed, 26 insertions(+), 33 deletions(-)
---
diff --git a/src/nautilus-files-view.c b/src/nautilus-files-view.c
index cf71deccf..731c488a0 100644
--- a/src/nautilus-files-view.c
+++ b/src/nautilus-files-view.c
@@ -5247,7 +5247,7 @@ run_script (GSimpleAction *action,
     g_autofree gchar *old_working_dir = NULL;
     g_autolist (NautilusFile) selection = NULL;
     g_auto (GStrv) parameters = NULL;
-    GdkScreen *screen;
+    GdkDisplay *display;
 
     launch_parameters = (ScriptLaunchParameters *) user_data;
     priv = nautilus_files_view_get_instance_private (launch_parameters->directory_view);
@@ -5264,12 +5264,12 @@ run_script (GSimpleAction *action,
 
     parameters = get_file_names_as_parameter_array (selection, priv->model);
 
-    screen = gtk_widget_get_screen (GTK_WIDGET (launch_parameters->directory_view));
+    display = gtk_widget_get_display (GTK_WIDGET (launch_parameters->directory_view));
 
     DEBUG ("run_script, script_path=“%s” (omitting script parameters)",
            local_file_path);
 
-    nautilus_launch_application_from_command_array (screen, quoted_path, FALSE,
+    nautilus_launch_application_from_command_array (display, quoted_path, FALSE,
                                                     (const char * const *) parameters);
 
     unset_script_environment_variables ();
@@ -6469,7 +6469,7 @@ action_run_in_terminal (GSimpleAction *action,
     g_autofree char *executable_path = NULL;
     g_autofree char *quoted_path = NULL;
     GtkWindow *parent_window;
-    GdkScreen *screen;
+    GdkDisplay *display;
 
     g_assert (NAUTILUS_IS_FILES_VIEW (user_data));
 
@@ -6489,11 +6489,11 @@ action_run_in_terminal (GSimpleAction *action,
     quoted_path = g_shell_quote (executable_path);
 
     parent_window = nautilus_files_view_get_containing_window (view);
-    screen = gtk_widget_get_screen (GTK_WIDGET (parent_window));
+    display = gtk_widget_get_display (GTK_WIDGET (parent_window));
 
     DEBUG ("Launching in terminal %s", quoted_path);
 
-    nautilus_launch_application_from_command (screen, quoted_path, TRUE, NULL);
+    nautilus_launch_application_from_command (display, quoted_path, TRUE, NULL);
 
     g_chdir (old_working_dir);
 }
@@ -8922,7 +8922,7 @@ nautilus_files_view_move_copy_items (NautilusFilesView *view,
     {
         char *command, *quoted_uri, *tmp;
         const GList *l;
-        GdkScreen *screen;
+        GdkDisplay *display;
 
         /* Handle dropping onto a file-roller archiver file, instead of starting a move/copy */
 
@@ -8943,13 +8943,13 @@ nautilus_files_view_move_copy_items (NautilusFilesView *view,
             g_free (quoted_uri);
         }
 
-        screen = gtk_widget_get_screen (GTK_WIDGET (view));
-        if (screen == NULL)
+        display = gtk_widget_get_display (GTK_WIDGET (view));
+        if (display == NULL)
         {
-            screen = gdk_screen_get_default ();
+            display = gdk_display_get_default ();
         }
 
-        nautilus_launch_application_from_command (screen, command, FALSE, NULL);
+        nautilus_launch_application_from_command (display, command, FALSE, NULL);
         g_free (command);
 
         return;
diff --git a/src/nautilus-mime-actions.c b/src/nautilus-mime-actions.c
index 4c2fede9a..255055b7d 100644
--- a/src/nautilus-mime-actions.c
+++ b/src/nautilus-mime-actions.c
@@ -1605,7 +1605,7 @@ activate_files_internal (ActivateParameters *parameters)
     NautilusFile *file;
     ApplicationLaunchParameters *one_parameters;
     g_autofree char *old_working_dir = NULL;
-    GdkScreen *screen;
+    GdkDisplay *display;
     GList *l;
 
     if (parameters->activation_directory &&
@@ -1616,7 +1616,7 @@ activate_files_internal (ActivateParameters *parameters)
         g_chdir (parameters->activation_directory);
     }
 
-    screen = gtk_widget_get_screen (GTK_WIDGET (parameters->parent_window));
+    display = gtk_widget_get_display (GTK_WIDGET (parameters->parent_window));
     for (l = g_queue_peek_head_link (parameters->launch_files); l != NULL; l = l->next)
     {
         g_autofree char *uri = NULL;
@@ -1631,7 +1631,7 @@ activate_files_internal (ActivateParameters *parameters)
 
         DEBUG ("Launching file path %s", quoted_path);
 
-        nautilus_launch_application_from_command (screen, quoted_path, FALSE, NULL);
+        nautilus_launch_application_from_command (display, quoted_path, FALSE, NULL);
     }
 
     for (l = g_queue_peek_head_link (parameters->launch_in_terminal_files); l != NULL; l = l->next)
@@ -1648,7 +1648,7 @@ activate_files_internal (ActivateParameters *parameters)
 
         DEBUG ("Launching in terminal file quoted path %s", quoted_path);
 
-        nautilus_launch_application_from_command (screen, quoted_path, TRUE, NULL);
+        nautilus_launch_application_from_command (display, quoted_path, TRUE, NULL);
     }
 
     if (old_working_dir != NULL)
diff --git a/src/nautilus-program-choosing.c b/src/nautilus-program-choosing.c
index 47362a3f7..715ac00e4 100644
--- a/src/nautilus-program-choosing.c
+++ b/src/nautilus-program-choosing.c
@@ -237,7 +237,7 @@ nautilus_launch_application_by_uri (GAppInfo  *application,
 
 static void
 launch_application_from_command_internal (const gchar *full_command,
-                                          GdkScreen   *screen,
+                                          GdkDisplay  *display,
                                           gboolean     use_terminal)
 {
     GAppInfoCreateFlags flags;
@@ -251,14 +251,11 @@ launch_application_from_command_internal (const gchar *full_command,
     }
 
     app = g_app_info_create_from_commandline (full_command, NULL, flags, &error);
-    if (app != NULL && !(use_terminal && screen == NULL))
+    if (app != NULL && !(use_terminal && display == NULL))
     {
-        GdkDisplay *display;
         g_autoptr (GdkAppLaunchContext) context = NULL;
 
-        display = gdk_screen_get_display (screen);
         context = gdk_display_get_app_launch_context (display);
-        gdk_app_launch_context_set_screen (context, screen);
 
         g_app_info_launch (app, NULL, G_APP_LAUNCH_CONTEXT (context), &error);
     }
@@ -280,7 +277,7 @@ launch_application_from_command_internal (const gchar *full_command,
  * @...: Passed as parameters to the application after quoting each of them.
  */
 void
-nautilus_launch_application_from_command (GdkScreen  *screen,
+nautilus_launch_application_from_command (GdkDisplay *display,
                                           const char *command_string,
                                           gboolean    use_terminal,
                                           ...)
@@ -306,7 +303,7 @@ nautilus_launch_application_from_command (GdkScreen  *screen,
 
     va_end (ap);
 
-    launch_application_from_command_internal (full_command, screen, use_terminal);
+    launch_application_from_command_internal (full_command, display, use_terminal);
 
     g_free (full_command);
 }
@@ -322,7 +319,7 @@ nautilus_launch_application_from_command (GdkScreen  *screen,
  * @parameters: Passed as parameters to the application after quoting each of them.
  */
 void
-nautilus_launch_application_from_command_array (GdkScreen          *screen,
+nautilus_launch_application_from_command_array (GdkDisplay         *display,
                                                 const char         *command_string,
                                                 gboolean            use_terminal,
                                                 const char * const *parameters)
@@ -346,14 +343,13 @@ nautilus_launch_application_from_command_array (GdkScreen          *screen,
         }
     }
 
-    launch_application_from_command_internal (full_command, screen, use_terminal);
+    launch_application_from_command_internal (full_command, display, use_terminal);
 
     g_free (full_command);
 }
 
 void
-nautilus_launch_desktop_file (GdkScreen   *screen,
-                              const char  *desktop_file_uri,
+nautilus_launch_desktop_file (const char  *desktop_file_uri,
                               const GList *parameter_uris,
                               GtkWindow   *parent_window)
 {
@@ -442,8 +438,6 @@ nautilus_launch_desktop_file (GdkScreen   *screen,
     context = gdk_display_get_app_launch_context (gtk_widget_get_display (GTK_WIDGET (parent_window)));
     /* TODO: Ideally we should accept a timestamp here instead of using GDK_CURRENT_TIME */
     gdk_app_launch_context_set_timestamp (context, GDK_CURRENT_TIME);
-    gdk_app_launch_context_set_screen (context,
-                                       gtk_window_get_screen (parent_window));
     if (count == total)
     {
         /* All files are local, so we can use g_app_info_launch () with
diff --git a/src/nautilus-program-choosing.h b/src/nautilus-program-choosing.h
index 51881ff17..00ac6fe3b 100644
--- a/src/nautilus-program-choosing.h
+++ b/src/nautilus-program-choosing.h
@@ -39,16 +39,15 @@ void nautilus_launch_application_by_uri             (GAppInfo
 void nautilus_launch_application_for_mount          (GAppInfo                          *app_info,
                                                      GMount                            *mount,
                                                      GtkWindow                         *parent_window);
-void nautilus_launch_application_from_command       (GdkScreen                         *screen,
+void nautilus_launch_application_from_command       (GdkDisplay                        *display,
                                                      const char                        *command_string,
                                                      gboolean                           use_terminal,
                                                      ...) G_GNUC_NULL_TERMINATED;
-void nautilus_launch_application_from_command_array (GdkScreen                         *screen,
+void nautilus_launch_application_from_command_array (GdkDisplay                        *display,
                                                      const char                        *command_string,
                                                      gboolean                           use_terminal,
                                                      const char * const *               parameters);
-void nautilus_launch_desktop_file                   (GdkScreen                         *screen,
-                                                     const char                        *desktop_file_uri,
+void nautilus_launch_desktop_file                   (const char                        *desktop_file_uri,
                                                      const GList                       *parameter_uris,
                                                      GtkWindow                         *parent_window);
 void nautilus_launch_default_for_uri_async          (const char                        *uri,
@@ -57,4 +56,4 @@ void nautilus_launch_default_for_uri_async          (const char
                                                      GAsyncReadyCallback                callback,
                                                      gpointer                           callback_data);
 gboolean nautilus_launch_default_for_uri_finish     (GAsyncResult                      *result,
-                                                     GError                           **error);
\ No newline at end of file
+                                                     GError                           **error);


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