[nautilus/gtk4-preparation-trunk: 17/60] window: Drop GdkScreen parameter from ::new()
- From: António Fernandes <antoniof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus/gtk4-preparation-trunk: 17/60] window: Drop GdkScreen parameter from ::new()
- Date: Fri, 24 Dec 2021 03:11:24 +0000 (UTC)
commit 331b476885ef6df69b39ea16cb83a42dc4225dc0
Author: António Fernandes <antoniof gnome org>
Date: Thu Dec 16 00:05:47 2021 +0000
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.
src/nautilus-application.c | 21 +++++++++++----------
src/nautilus-application.h | 3 +--
src/nautilus-gtk4-helpers.c | 17 +++++++++++++++++
src/nautilus-gtk4-helpers.h | 6 ++++++
src/nautilus-window.c | 8 ++++----
src/nautilus-window.h | 2 +-
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 e5fa24c7a..6ed00bab6 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1973,8 +1973,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",
@@ -2818,11 +2819,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 6341d865f..ad721a8bc 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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]