summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntónio Fernandes <antoniof@gnome.org>2021-12-16 00:05:47 +0000
committerAntónio Fernandes <antoniof@gnome.org>2022-01-01 21:58:06 +0000
commitfff35bdc36222a0f36927a99b2c6baf4aa1e96a0 (patch)
treeb3555523c96da2df6ea2aeaebed2fa9f675363b7
parent4f62b302e8f4fad06c00ccb93964e4faba306e01 (diff)
downloadnautilus-fff35bdc36222a0f36927a99b2c6baf4aa1e96a0.tar.gz
window: Drop GdkScreen parameter from ::new()
GdkScreen is obsolete, and gone in GTK 4. Also, most of the time it's just the default screen anyway. For the 2 cases where we actually want to set a display, do it separately using wrapers with the same signatures as the GTK 4 API.
-rw-r--r--src/nautilus-application.c21
-rw-r--r--src/nautilus-application.h3
-rw-r--r--src/nautilus-gtk4-helpers.c17
-rw-r--r--src/nautilus-gtk4-helpers.h6
-rw-r--r--src/nautilus-window.c8
-rw-r--r--src/nautilus-window.h2
6 files changed, 40 insertions, 17 deletions
diff --git a/src/nautilus-application.c b/src/nautilus-application.c
index 89a26615f..348dae188 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -66,6 +66,7 @@
#include "nautilus-view.h"
#include "nautilus-window-slot.h"
#include "nautilus-window.h"
+#include "nautilus-gtk4-helpers.h"
typedef struct
{
@@ -240,8 +241,7 @@ menu_provider_init_callback (void)
}
NautilusWindow *
-nautilus_application_create_window (NautilusApplication *self,
- GdkScreen *screen)
+nautilus_application_create_window (NautilusApplication *self)
{
NautilusWindow *window;
gboolean maximized;
@@ -252,7 +252,7 @@ nautilus_application_create_window (NautilusApplication *self,
g_return_val_if_fail (NAUTILUS_IS_APPLICATION (self), NULL);
nautilus_profile_start (NULL);
- window = nautilus_window_new (screen);
+ window = nautilus_window_new ();
maximized = g_settings_get_boolean
(nautilus_window_state, NAUTILUS_WINDOW_STATE_MAXIMIZED);
@@ -369,7 +369,7 @@ real_open_location_full (NautilusApplication *self,
GFile *old_location = NULL;
char *old_uri, *new_uri;
gboolean use_same;
- GdkScreen *screen;
+ GdkDisplay *display;
use_same = TRUE;
/* FIXME: We are having problems on getting the current focused window with
@@ -441,12 +441,13 @@ real_open_location_full (NautilusApplication *self,
}
else
{
- screen = active_window != NULL ?
- gtk_window_get_screen (GTK_WINDOW (active_window)) :
- gdk_screen_get_default ();
+ display = active_window != NULL ?
+ gtk_root_get_display (GTK_ROOT (active_window)) :
+ gdk_display_get_default ();
- target_window = nautilus_application_create_window (self, screen);
+ target_window = nautilus_application_create_window (self);
/* Whatever the caller says, the slot won't be the same */
+ gtk_window_set_display (GTK_WINDOW (target_window), display);
target_slot = NULL;
}
@@ -465,7 +466,7 @@ open_window (NautilusApplication *self,
NautilusWindow *window;
nautilus_profile_start (NULL);
- window = nautilus_application_create_window (self, gdk_screen_get_default ());
+ window = nautilus_application_create_window (self);
if (location != NULL)
{
@@ -506,7 +507,7 @@ nautilus_application_open_location (NautilusApplication *self,
if (!slot)
{
- window = nautilus_application_create_window (self, gdk_screen_get_default ());
+ window = nautilus_application_create_window (self);
}
else
{
diff --git a/src/nautilus-application.h b/src/nautilus-application.h
index cbef12312..76d741a50 100644
--- a/src/nautilus-application.h
+++ b/src/nautilus-application.h
@@ -43,8 +43,7 @@ struct _NautilusApplicationClass {
NautilusApplication * nautilus_application_new (void);
-NautilusWindow * nautilus_application_create_window (NautilusApplication *application,
- GdkScreen *screen);
+NautilusWindow * nautilus_application_create_window (NautilusApplication *application);
void nautilus_application_set_accelerator (GApplication *app,
const gchar *action_name,
diff --git a/src/nautilus-gtk4-helpers.c b/src/nautilus-gtk4-helpers.c
index b81c955dc..cd89a4423 100644
--- a/src/nautilus-gtk4-helpers.c
+++ b/src/nautilus-gtk4-helpers.c
@@ -97,3 +97,20 @@ gtk_widget_get_first_child (GtkWidget *widget)
return NULL;
}
+
+GdkDisplay *
+gtk_root_get_display (GtkRoot *root)
+{
+ g_assert (GTK_IS_WINDOW (root));
+
+ return gdk_screen_get_display (gtk_window_get_screen (GTK_WINDOW (root)));
+}
+
+void
+gtk_window_set_display (GtkWindow *window,
+ GdkDisplay *display)
+{
+ g_assert (GTK_IS_WINDOW (window));
+
+ gtk_window_set_screen (window, gdk_display_get_default_screen (display));
+}
diff --git a/src/nautilus-gtk4-helpers.h b/src/nautilus-gtk4-helpers.h
index ff1e0049f..2e8e4817b 100644
--- a/src/nautilus-gtk4-helpers.h
+++ b/src/nautilus-gtk4-helpers.h
@@ -28,5 +28,11 @@ void gtk_revealer_set_child (GtkRevealer *revealer,
GtkWidget *gtk_widget_get_first_child (GtkWidget *widget);
+#define GTK_ROOT(root) ((GtkRoot *) GTK_WINDOW (root))
+typedef GtkWindow GtkRoot;
+GdkDisplay *gtk_root_get_display (GtkRoot *root);
+void gtk_window_set_display (GtkWindow *window,
+ GdkDisplay *display);
+
#endif
G_END_DECLS
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index ad5e74e85..8b5225310 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1977,8 +1977,9 @@ notebook_create_window_cb (GtkNotebook *notebook,
}
app = NAUTILUS_APPLICATION (g_application_get_default ());
- new_window = nautilus_application_create_window
- (app, gtk_widget_get_screen (GTK_WIDGET (notebook)));
+ new_window = nautilus_application_create_window (app);
+ gtk_window_set_display (GTK_WINDOW (new_window),
+ gtk_widget_get_display (GTK_WIDGET (notebook)));
slot = NAUTILUS_WINDOW_SLOT (page);
g_object_set_data (G_OBJECT (slot), "dnd-window-slot",
@@ -2822,11 +2823,10 @@ nautilus_window_class_init (NautilusWindowClass *class)
}
NautilusWindow *
-nautilus_window_new (GdkScreen *screen)
+nautilus_window_new (void)
{
return g_object_new (NAUTILUS_TYPE_WINDOW,
"icon-name", APPLICATION_ID,
- "screen", screen,
NULL);
}
diff --git a/src/nautilus-window.h b/src/nautilus-window.h
index dfb810ae5..af38441f1 100644
--- a/src/nautilus-window.h
+++ b/src/nautilus-window.h
@@ -57,7 +57,7 @@ typedef void (* NautilusWindowHandleExported) (NautilusWindow *window,
#define NAUTILUS_WINDOW_DEFAULT_WIDTH 890
#define NAUTILUS_WINDOW_DEFAULT_HEIGHT 550
-NautilusWindow * nautilus_window_new (GdkScreen *screen);
+NautilusWindow * nautilus_window_new (void);
void nautilus_window_close (NautilusWindow *window);
void nautilus_window_open_location_full (NautilusWindow *window,