[nautilus/gtk4-preparation-trunk: 39/49] 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: 39/49] window: Drop GdkScreen parameter from ::new()
- Date: Fri, 31 Dec 2021 23:57:05 +0000 (UTC)
commit f52e0c9e8f09dd581d57a55ffb0c6a65b669263d
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 00bfb6900..ac605fa04 100644
--- a/src/nautilus-application.c
+++ b/src/nautilus-application.c
@@ -65,6 +65,7 @@
#include "nautilus-view.h"
#include "nautilus-window-slot.h"
#include "nautilus-window.h"
+#include "nautilus-gtk4-helpers.h"
typedef struct
{
@@ -239,8 +240,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;
@@ -251,7 +251,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);
@@ -368,7 +368,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
@@ -440,12 +440,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;
}
@@ -464,7 +465,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)
{
@@ -505,7 +506,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 8812db618..c8f35fc3f 100644
--- a/src/nautilus-gtk4-helpers.c
+++ b/src/nautilus-gtk4-helpers.c
@@ -132,3 +132,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 edeaa3762..6bc991ac9 100644
--- a/src/nautilus-gtk4-helpers.h
+++ b/src/nautilus-gtk4-helpers.h
@@ -38,5 +38,11 @@ void gtk_check_button_set_active (GtkCheckButton *button,
gboolean gtk_check_button_get_active (GtkCheckButton *button);
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 bb4de5a70..317c5eeee 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -1936,8 +1936,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",
@@ -2772,11 +2773,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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]