[goobox] removed use of deprecated function gdk_screen_get_height
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goobox] removed use of deprecated function gdk_screen_get_height
- Date: Fri, 28 Dec 2018 17:15:08 +0000 (UTC)
commit b1dd6627e4ff4aff9ea5f6a3e8734bc99abaacc1
Author: Paolo Bacchilega <paobac src gnome org>
Date: Fri Dec 28 14:13:29 2018 +0100
removed use of deprecated function gdk_screen_get_height
src/goo-window.c | 10 +++--
src/gtk-utils.c | 125 ++++++++++++++++++++++++++++++++++++++++---------------
src/gtk-utils.h | 10 +++--
3 files changed, 104 insertions(+), 41 deletions(-)
---
diff --git a/src/goo-window.c b/src/goo-window.c
index 138cae6..c5a6f66 100644
--- a/src/goo-window.c
+++ b/src/goo-window.c
@@ -1887,13 +1887,17 @@ window_size_allocate_cb (GtkWidget *widget,
GdkRectangle *allocation,
gpointer user_data)
{
- GooWindow *window = user_data;
- int max_window_height;
+ GooWindow *window = user_data;
+ GdkRectangle geometry;
+ int max_window_height;
if (window->priv->resizable_playlist)
return;
- max_window_height = gdk_screen_get_height (gtk_widget_get_screen (GTK_WIDGET (window))) *
MAX_WINDOW_HEIGHT_PERCENTAGE;
+ if (!_gtk_widget_get_monitor_geometry (GTK_WIDGET (window), &geometry))
+ return;
+
+ max_window_height = (float) geometry.height * MAX_WINDOW_HEIGHT_PERCENTAGE;
if (allocation->height > max_window_height) {
GdkGeometry hints;
diff --git a/src/gtk-utils.c b/src/gtk-utils.c
index dab7fe9..c39dd59 100644
--- a/src/gtk-utils.c
+++ b/src/gtk-utils.c
@@ -685,40 +685,6 @@ _gtk_image_new_from_xpm_data (char * xpm_data[])
}
-GtkWidget *
-_gtk_image_new_from_inline (const guint8 *data)
-{
- GdkPixbuf *pixbuf;
- GtkWidget *image;
-
- pixbuf = gdk_pixbuf_new_from_inline (-1, data, FALSE, NULL);
- image = gtk_image_new_from_pixbuf (pixbuf);
- gtk_widget_show (image);
-
- g_object_unref (G_OBJECT (pixbuf));
-
- return image;
-}
-
-
-void
-_gtk_widget_get_screen_size (GtkWidget *widget,
- int *width,
- int *height)
-{
- GdkScreen *screen;
- GdkRectangle screen_geom;
-
- screen = gtk_widget_get_screen (widget);
- gdk_screen_get_monitor_geometry (screen,
- gdk_screen_get_monitor_at_window (screen, gtk_widget_get_window
(widget)),
- &screen_geom);
-
- *width = screen_geom.width;
- *height = screen_geom.height;
-}
-
-
void
_gtk_tree_path_list_free (GList *list)
{
@@ -1039,3 +1005,94 @@ _gtk_application_get_current_window (GtkApplication *application)
return GTK_WIDGET (windows->data);
}
+
+
+gboolean
+_gtk_window_get_monitor_info (GtkWindow *window,
+ GdkRectangle *geometry,
+ int *number,
+ char **name)
+{
+#if GTK_CHECK_VERSION(3, 22, 0)
+
+ GdkWindow *win;
+ GdkMonitor *monitor;
+
+ win = gtk_widget_get_window (GTK_WIDGET (window));
+ if (win == NULL)
+ return FALSE;
+
+ monitor = gdk_display_get_monitor_at_window (gdk_window_get_display (win), win);
+ if (monitor == NULL)
+ return FALSE;
+
+ if (geometry != NULL)
+ gdk_monitor_get_geometry (monitor, geometry);
+
+ if ((number != NULL) || (name != NULL)) {
+ GdkDisplay *display;
+ int monitor_num;
+ const char *monitor_name;
+ int i;
+
+ display = gdk_monitor_get_display (monitor);
+ monitor_num = 0;
+ for (i = 0; /* void */; i++) {
+ GdkMonitor *m = gdk_display_get_monitor (display, i);
+ if (m == monitor) {
+ monitor_num = i;
+ monitor_name = gdk_monitor_get_model (monitor);
+ break;
+ }
+ if (m == NULL)
+ break;
+ }
+
+ if (number != NULL) *number = monitor_num;
+ if (name != NULL) *name = g_strdup (monitor_name);
+ }
+
+#else
+
+ GdkWindow *win;
+ GdkScreen *screen;
+ int monitor_num;
+
+ win = gtk_widget_get_window (GTK_WIDGET (window));
+ if (win == NULL)
+ return FALSE;
+
+ screen = gdk_window_get_screen (win);
+ if (screen == NULL)
+ return FALSE;
+
+ monitor_num = gdk_screen_get_monitor_at_window (screen, win);
+ if (number != NULL)
+ *number = monitor_num;
+ if (geometry != NULL)
+ gdk_screen_get_monitor_geometry (screen, monitor_num, geometry);
+ if (name != NULL)
+ *name = gdk_screen_get_monitor_plug_name (screen, monitor_num);
+
+#endif
+
+ return TRUE;
+}
+
+
+gboolean
+_gtk_widget_get_monitor_geometry (GtkWidget *widget,
+ GdkRectangle *geometry)
+{
+ gboolean result = FALSE;
+ GtkWidget *window;
+
+ window = gtk_widget_get_toplevel (widget);
+ if (GTK_IS_WINDOW (window)) {
+ if (_gtk_window_get_monitor_info (GTK_WINDOW (window), geometry, NULL, NULL)) {
+ result = TRUE;
+ }
+ }
+
+ return result;
+}
diff --git a/src/gtk-utils.h b/src/gtk-utils.h
index 24b1d3f..f47c95b 100644
--- a/src/gtk-utils.h
+++ b/src/gtk-utils.h
@@ -123,10 +123,6 @@ void _gtk_combo_box_append_texts (GtkComboBox *combo_box,
const char *first_text,
...);
GtkWidget * _gtk_image_new_from_xpm_data (char *xpm_data[]);
-GtkWidget * _gtk_image_new_from_inline (const guint8 *data);
-void _gtk_widget_get_screen_size (GtkWidget *widget,
- int *width,
- int *height);
void _gtk_tree_path_list_free (GList *list);
int _gtk_paned_get_position2 (GtkPaned *paned);
void _gtk_paned_set_position2 (GtkPaned *paned,
@@ -153,6 +149,12 @@ void _g_action_map_change_action_state (GActionMap
*action_map,
const char *action_name,
gboolean value);
GtkWidget * _gtk_application_get_current_window (GtkApplication *application);
+gboolean _gtk_window_get_monitor_info (GtkWindow *window,
+ GdkRectangle *geometry,
+ int *number,
+ char **name);
+gboolean _gtk_widget_get_monitor_geometry (GtkWidget *widget,
+ GdkRectangle *geometry);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]