[gtk+] widget: Remove gtk_widget_get_screen()



commit 648d0403952cd4f50cf43c56d91ec281c8d3a75c
Author: Benjamin Otte <otte redhat com>
Date:   Tue Oct 31 08:17:37 2017 +0100

    widget: Remove gtk_widget_get_screen()
    
    Replace the remaining users with "correct" code that does not need that
    function anymore.

 docs/reference/gtk/gtk4-sections.txt |    1 -
 gtk/gtkdnd.c                         |   20 ++++++------
 gtk/gtkfilechooserwidget.c           |    2 +-
 gtk/gtkpathbar.c                     |    2 +-
 gtk/gtkwidget.c                      |   53 +++++++++-------------------------
 gtk/gtkwidget.h                      |    2 -
 gtk/inspector/object-tree.c          |    6 ++--
 7 files changed, 29 insertions(+), 57 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 2ddc7bb..3aab14d 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -4555,7 +4555,6 @@ gtk_widget_get_parent
 gtk_widget_get_settings
 gtk_widget_get_clipboard
 gtk_widget_get_display
-gtk_widget_get_screen
 gtk_widget_get_size_request
 gtk_widget_set_child_visible
 gtk_widget_set_size_request
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 2518aeb..0992347 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -153,7 +153,7 @@ static GdkCursor *   gtk_drag_get_cursor         (GtkWidget      *widget,
                                                   GtkDragSourceInfo *info);
 static void          gtk_drag_update_cursor      (GtkDragSourceInfo *info);
 static GtkWidget    *gtk_drag_get_ipc_widget            (GtkWidget *widget);
-static GtkWidget    *gtk_drag_get_ipc_widget_for_screen (GdkScreen *screen);
+static GtkWidget    *gtk_drag_get_ipc_widget_for_display(GdkDisplay*display);
 static void          gtk_drag_release_ipc_widget (GtkWidget      *widget);
 
 static void     gtk_drag_selection_received     (GtkWidget        *widget,
@@ -268,10 +268,10 @@ static struct {
  *********************/
 
 static GtkWidget *
-gtk_drag_get_ipc_widget_for_screen (GdkScreen *screen)
+gtk_drag_get_ipc_widget_for_display (GdkDisplay *display)
 {
   GtkWidget *result;
-  GSList *drag_widgets = g_object_get_data (G_OBJECT (screen), 
+  GSList *drag_widgets = g_object_get_data (G_OBJECT (display), 
                                             "gtk-dnd-ipc-widgets");
   
   if (drag_widgets)
@@ -279,7 +279,7 @@ gtk_drag_get_ipc_widget_for_screen (GdkScreen *screen)
       GSList *tmp = drag_widgets;
       result = drag_widgets->data;
       drag_widgets = drag_widgets->next;
-      g_object_set_data (G_OBJECT (screen),
+      g_object_set_data (G_OBJECT (display),
                          I_("gtk-dnd-ipc-widgets"),
                          drag_widgets);
       g_slist_free_1 (tmp);
@@ -287,7 +287,7 @@ gtk_drag_get_ipc_widget_for_screen (GdkScreen *screen)
   else
     {
       result = gtk_window_new (GTK_WINDOW_POPUP);
-      gtk_window_set_display (GTK_WINDOW (result), gdk_screen_get_display (screen));
+      gtk_window_set_display (GTK_WINDOW (result), display);
       gtk_window_resize (GTK_WINDOW (result), 1, 1);
       gtk_window_move (GTK_WINDOW (result), -99, -99);
       gtk_widget_show (result);
@@ -302,7 +302,7 @@ gtk_drag_get_ipc_widget (GtkWidget *widget)
   GtkWidget *result;
   GtkWidget *toplevel;
 
-  result = gtk_drag_get_ipc_widget_for_screen (gtk_widget_get_screen (widget));
+  result = gtk_drag_get_ipc_widget_for_display (gtk_widget_get_display (widget));
   
   toplevel = gtk_widget_get_toplevel (widget);
   
@@ -350,9 +350,9 @@ static void
 gtk_drag_release_ipc_widget (GtkWidget *widget)
 {
   GtkWindow *window = GTK_WINDOW (widget);
-  GdkScreen *screen = gtk_widget_get_screen (widget);
+  GdkDisplay *display = gtk_widget_get_display (widget);
   GdkDragContext *context = g_object_get_data (G_OBJECT (widget), "drag-context");
-  GSList *drag_widgets = g_object_get_data (G_OBJECT (screen),
+  GSList *drag_widgets = g_object_get_data (G_OBJECT (display),
                                             "gtk-dnd-ipc-widgets");
   GdkDevice *pointer, *keyboard;
 
@@ -369,7 +369,7 @@ gtk_drag_release_ipc_widget (GtkWidget *widget)
     gtk_window_group_remove_window (gtk_window_get_group (window),
                                     window);
   drag_widgets = g_slist_prepend (drag_widgets, widget);
-  g_object_set_data (G_OBJECT (screen),
+  g_object_set_data (G_OBJECT (display),
                      I_("gtk-dnd-ipc-widgets"),
                      drag_widgets);
 }
@@ -654,7 +654,7 @@ gtk_drag_finish (GdkDragContext *context,
 
   if (target != GDK_NONE)
     {
-      GtkWidget *selection_widget = gtk_drag_get_ipc_widget_for_screen (gdk_window_get_screen 
(gdk_drag_context_get_source_window (context)));
+      GtkWidget *selection_widget = gtk_drag_get_ipc_widget_for_display (gdk_window_get_display 
(gdk_drag_context_get_source_window (context)));
 
       g_object_ref (context);
       
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 4b880e0..e826c4a 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -3779,7 +3779,7 @@ check_icon_theme (GtkFileChooserWidget *impl)
       return;
     }
 
-  settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
+  settings = gtk_widget_get_settings (GTK_WIDGET (impl));
   priv->settings_signal_id = g_signal_connect (settings, "notify",
                                                G_CALLBACK (settings_notify_cb), impl);
 
diff --git a/gtk/gtkpathbar.c b/gtk/gtkpathbar.c
index 2a49a98..7895a90 100644
--- a/gtk/gtkpathbar.c
+++ b/gtk/gtkpathbar.c
@@ -1195,7 +1195,7 @@ gtk_path_bar_check_icon_theme (GtkPathBar *path_bar)
     {
       GtkSettings *settings;
 
-      settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (path_bar)));
+      settings = gtk_widget_get_settings (GTK_WIDGET (path_bar));
       path_bar->priv->settings_signal_id = g_signal_connect (settings, "notify",
                                                              G_CALLBACK (settings_notify_cb), path_bar);
     }
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 161f869..8e6619f 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -9237,43 +9237,6 @@ gtk_widget_get_child_visible (GtkWidget *widget)
   return widget->priv->child_visible;
 }
 
-/**
- * gtk_widget_get_screen:
- * @widget: a #GtkWidget
- *
- * Get the #GdkScreen from the toplevel window associated with
- * this widget. This function can only be called after the widget
- * has been added to a widget hierarchy with a #GtkWindow
- * at the top.
- *
- * In general, you should only create screen specific
- * resources when a widget has been realized, and you should
- * free those resources when the widget is unrealized.
- *
- * Returns: (transfer none): the #GdkScreen for the toplevel for this widget.
- *
- * Since: 2.2
- **/
-GdkScreen*
-gtk_widget_get_screen (GtkWidget *widget)
-{
-  GtkWidget *toplevel;
-
-  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
-  toplevel = _gtk_widget_get_toplevel (widget);
-
-  if (_gtk_widget_is_toplevel (toplevel))
-    {
-      if (GTK_IS_WINDOW (toplevel))
-       return gdk_display_get_default_screen (gtk_window_get_display (GTK_WINDOW (toplevel)));
-      else if (GTK_IS_INVISIBLE (toplevel))
-       return gdk_display_get_default_screen (gtk_invisible_get_display (GTK_INVISIBLE (widget)));
-    }
-  
-  return gdk_screen_get_default ();
-}
-
 void
 _gtk_widget_scale_changed (GtkWidget *widget)
 {
@@ -9351,9 +9314,21 @@ gtk_widget_get_scale_factor (GtkWidget *widget)
 GdkDisplay*
 gtk_widget_get_display (GtkWidget *widget)
 {
+  GtkWidget *toplevel;
+
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
 
-  return gdk_screen_get_display (gtk_widget_get_screen (widget));
+  toplevel = _gtk_widget_get_toplevel (widget);
+
+  if (_gtk_widget_is_toplevel (toplevel))
+    {
+      if (GTK_IS_WINDOW (toplevel))
+       return gtk_window_get_display (GTK_WINDOW (toplevel));
+      else if (GTK_IS_INVISIBLE (toplevel))
+       return gtk_invisible_get_display (GTK_INVISIBLE (widget));
+    }
+  
+  return gdk_display_get_default ();
 }
 
 /**
@@ -9771,7 +9746,7 @@ gtk_widget_get_settings (GtkWidget *widget)
 {
   g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
 
-  return gtk_settings_get_for_screen (gtk_widget_get_screen (widget));
+  return gtk_settings_get_for_display (gtk_widget_get_display (widget));
 }
 
 /**
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index a2cf955..46317ac 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -782,8 +782,6 @@ GDK_AVAILABLE_IN_ALL
 GtkWidget*   gtk_widget_get_ancestor   (GtkWidget      *widget,
                                         GType           widget_type);
 
-GDK_AVAILABLE_IN_ALL
-GdkScreen *   gtk_widget_get_screen      (GtkWidget *widget);
 GDK_AVAILABLE_IN_3_10
 gint          gtk_widget_get_scale_factor (GtkWidget *widget);
 GDK_AVAILABLE_IN_ALL
diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c
index 74d5815..d4a491d 100644
--- a/gtk/inspector/object-tree.c
+++ b/gtk/inspector/object-tree.c
@@ -1182,7 +1182,7 @@ gtk_inspector_object_tree_scan (GtkInspectorObjectTree *wt,
 {
   GtkWidget *inspector_win;
   GList *toplevels, *l;
-  GdkScreen *screen;
+  GdkDisplay *display;
   GObject *selected;
 
   block_selection_changed (wt);
@@ -1197,7 +1197,7 @@ gtk_inspector_object_tree_scan (GtkInspectorObjectTree *wt,
   if (window)
     gtk_inspector_object_tree_append_object (wt, G_OBJECT (window), NULL, NULL);
 
-  screen = gdk_screen_get_default ();
+  display = gdk_display_get_default ();
 
   inspector_win = gtk_widget_get_toplevel (GTK_WIDGET (wt));
   toplevels = gtk_window_list_toplevels ();
@@ -1205,7 +1205,7 @@ gtk_inspector_object_tree_scan (GtkInspectorObjectTree *wt,
     {
       if (GTK_IS_WINDOW (l->data) &&
           gtk_window_get_window_type (l->data) == GTK_WINDOW_TOPLEVEL &&
-          gtk_widget_get_screen (l->data) == screen &&
+          gtk_widget_get_display (l->data) == display &&
           l->data != window &&
           l->data != inspector_win)
         gtk_inspector_object_tree_append_object (wt, G_OBJECT (l->data), NULL, NULL);


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