[gtk+] widget: Remove gtk_widget_has_screen()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] widget: Remove gtk_widget_has_screen()
- Date: Tue, 31 Oct 2017 04:04:14 +0000 (UTC)
commit 1c36c6ed4de4df19d602f3699ae9f6652fc786e5
Author: Benjamin Otte <otte redhat com>
Date: Tue Oct 31 03:19:29 2017 +0100
widget: Remove gtk_widget_has_screen()
All widgets always have a screen (or display).
docs/reference/gtk/gtk4-sections.txt | 1 -
gtk/a11y/gtkentryaccessible.c | 9 -----
gtk/gtkfilechooserbutton.c | 16 ++++-----
gtk/gtkfilechooserwidget.c | 14 +++-----
gtk/gtklabel.c | 7 +---
gtk/gtkmenu.c | 3 +-
gtk/gtkmenushell.c | 5 +--
gtk/gtkprintunixdialog.c | 21 +++++-------
gtk/gtkwidget.c | 59 ++++++---------------------------
gtk/gtkwidget.h | 2 -
10 files changed, 37 insertions(+), 100 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 4a852a9..7065f9b 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -4556,7 +4556,6 @@ gtk_widget_get_settings
gtk_widget_get_clipboard
gtk_widget_get_display
gtk_widget_get_screen
-gtk_widget_has_screen
gtk_widget_get_size_request
gtk_widget_set_child_visible
gtk_widget_set_size_request
diff --git a/gtk/a11y/gtkentryaccessible.c b/gtk/a11y/gtkentryaccessible.c
index 1df260c..02c0fc6 100644
--- a/gtk/a11y/gtkentryaccessible.c
+++ b/gtk/a11y/gtkentryaccessible.c
@@ -1263,9 +1263,6 @@ gtk_entry_accessible_copy_text (AtkEditableText *text,
if (widget == NULL)
return;
- if (!gtk_widget_has_screen (widget))
- return;
-
editable = GTK_EDITABLE (widget);
str = gtk_editable_get_chars (editable, start_pos, end_pos);
clipboard = gtk_widget_get_clipboard (widget, GDK_SELECTION_CLIPBOARD);
@@ -1287,9 +1284,6 @@ gtk_entry_accessible_cut_text (AtkEditableText *text,
if (widget == NULL)
return;
- if (!gtk_widget_has_screen (widget))
- return;
-
editable = GTK_EDITABLE (widget);
if (!gtk_editable_get_editable (editable))
return;
@@ -1353,9 +1347,6 @@ gtk_entry_accessible_paste_text (AtkEditableText *text,
if (widget == NULL)
return;
- if (!gtk_widget_has_screen (widget))
- return;
-
editable = GTK_EDITABLE (widget);
if (!gtk_editable_get_editable (editable))
return;
diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index 856a703..806123a 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -1539,17 +1539,15 @@ change_icon_theme (GtkFileChooserButton *button)
static void
gtk_file_chooser_button_style_updated (GtkWidget *widget)
{
+ GtkStyleContext *context = gtk_widget_get_style_context (widget);
+ GtkCssStyleChange *change = gtk_style_context_get_change (context);
+
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->style_updated (widget);
- if (gtk_widget_has_screen (widget))
- {
- /* We need to update the icon surface, but only in case
- * the icon theme really changed. */
- GtkStyleContext *context = gtk_widget_get_style_context (widget);
- GtkCssStyleChange *change = gtk_style_context_get_change (context);
- if (!change || gtk_css_style_change_changes_property (change, GTK_CSS_PROPERTY_ICON_THEME))
- change_icon_theme (GTK_FILE_CHOOSER_BUTTON (widget));
- }
+ /* We need to update the icon surface, but only in case
+ * the icon theme really changed. */
+ if (!change || gtk_css_style_change_changes_property (change, GTK_CSS_PROPERTY_ICON_THEME))
+ change_icon_theme (GTK_FILE_CHOOSER_BUTTON (widget));
}
static void
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index a71ac37..4b880e0 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -3779,14 +3779,11 @@ check_icon_theme (GtkFileChooserWidget *impl)
return;
}
- if (gtk_widget_has_screen (GTK_WIDGET (impl)))
- {
- settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
- priv->settings_signal_id = g_signal_connect (settings, "notify",
- G_CALLBACK (settings_notify_cb), impl);
+ settings = gtk_settings_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (impl)));
+ priv->settings_signal_id = g_signal_connect (settings, "notify",
+ G_CALLBACK (settings_notify_cb), impl);
- change_icon_theme (impl);
- }
+ change_icon_theme (impl);
profile_end ("end", NULL);
}
@@ -3804,8 +3801,7 @@ gtk_file_chooser_widget_style_updated (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->style_updated (widget);
profile_msg (" parent class style_updated end", NULL);
- if (gtk_widget_has_screen (GTK_WIDGET (impl)))
- change_icon_theme (impl);
+ change_icon_theme (impl);
emit_default_size_changed (impl);
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 442a5a2..a950d97 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -5234,11 +5234,8 @@ gtk_label_select_region_index (GtkLabel *label,
priv->select_info->selection_anchor = anchor_index;
priv->select_info->selection_end = end_index;
- if (gtk_widget_has_screen (GTK_WIDGET (label)))
- clipboard = gtk_widget_get_clipboard (GTK_WIDGET (label),
- GDK_SELECTION_PRIMARY);
- else
- clipboard = NULL;
+ clipboard = gtk_widget_get_clipboard (GTK_WIDGET (label),
+ GDK_SELECTION_PRIMARY);
if (anchor_index != end_index)
{
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index ad61884..8c8828c 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -1305,8 +1305,7 @@ attach_widget_display_changed (GtkWidget *attach_widget,
GdkDisplay *previous_display,
GtkMenu *menu)
{
- if (gtk_widget_has_screen (attach_widget) &&
- !g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen"))
+ if (!g_object_get_data (G_OBJECT (menu), "gtk-menu-explicit-screen"))
menu_change_screen (menu, gtk_widget_get_screen (attach_widget));
}
diff --git a/gtk/gtkmenushell.c b/gtk/gtkmenushell.c
index 978fc8b..24548e3 100644
--- a/gtk/gtkmenushell.c
+++ b/gtk/gtkmenushell.c
@@ -1525,11 +1525,10 @@ gtk_menu_shell_get_key_hash (GtkMenuShell *menu_shell,
GtkMenuShellPrivate *priv = menu_shell->priv;
GtkWidget *widget = GTK_WIDGET (menu_shell);
- if (!priv->key_hash && create && gtk_widget_has_screen (widget))
+ if (!priv->key_hash && create)
{
GtkMnemonicHash *mnemonic_hash = gtk_menu_shell_get_mnemonic_hash (menu_shell, FALSE);
- GdkScreen *screen = gtk_widget_get_screen (widget);
- GdkKeymap *keymap = gdk_keymap_get_for_display (gdk_screen_get_display (screen));
+ GdkKeymap *keymap = gdk_keymap_get_for_display (gtk_widget_get_display (widget));
if (!mnemonic_hash)
return NULL;
diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c
index 7235ceb..ebe6ecf 100644
--- a/gtk/gtkprintunixdialog.c
+++ b/gtk/gtkprintunixdialog.c
@@ -2315,21 +2315,18 @@ draw_collate (GtkDrawingArea *da,
static void
gtk_print_unix_dialog_style_updated (GtkWidget *widget)
{
- GTK_WIDGET_CLASS (gtk_print_unix_dialog_parent_class)->style_updated (widget);
+ GtkPrintUnixDialog *dialog = (GtkPrintUnixDialog *)widget;
+ GtkPrintUnixDialogPrivate *priv = dialog->priv;
+ gint size;
+ gfloat scale;
- if (gtk_widget_has_screen (widget))
- {
- GtkPrintUnixDialog *dialog = (GtkPrintUnixDialog *)widget;
- GtkPrintUnixDialogPrivate *priv = dialog->priv;
- gint size;
- gfloat scale;
+ GTK_WIDGET_CLASS (gtk_print_unix_dialog_parent_class)->style_updated (widget);
- gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &size, NULL);
- scale = size / 48.0;
+ gtk_icon_size_lookup (GTK_ICON_SIZE_DIALOG, &size, NULL);
+ scale = size / 48.0;
- gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (priv->collate_image), (50 + 20) * scale);
- gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (priv->collate_image), (15 + 26) * scale);
- }
+ gtk_drawing_area_set_content_width (GTK_DRAWING_AREA (priv->collate_image), (50 + 20) * scale);
+ gtk_drawing_area_set_content_height (GTK_DRAWING_AREA (priv->collate_image), (15 + 26) * scale);
}
static void
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 5522b38..cf6e722 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -697,7 +697,6 @@ static void gtk_widget_real_state_flags_changed (GtkWidget
static AtkObject* gtk_widget_real_get_accessible (GtkWidget *widget);
static void gtk_widget_accessible_interface_init (AtkImplementorIface *iface);
static AtkObject* gtk_widget_ref_accessible (AtkImplementor *implementor);
-static GdkScreen * gtk_widget_get_screen_unchecked (GtkWidget *widget);
static gboolean gtk_widget_real_can_activate_accel (GtkWidget *widget,
guint signal_id);
@@ -9238,24 +9237,6 @@ gtk_widget_get_child_visible (GtkWidget *widget)
return widget->priv->child_visible;
}
-static GdkScreen *
-gtk_widget_get_screen_unchecked (GtkWidget *widget)
-{
- GtkWidget *toplevel;
-
- toplevel = _gtk_widget_get_toplevel (widget);
-
- if (_gtk_widget_is_toplevel (toplevel))
- {
- if (GTK_IS_WINDOW (toplevel))
- return _gtk_window_get_screen (GTK_WINDOW (toplevel));
- else if (GTK_IS_INVISIBLE (toplevel))
- return gtk_invisible_get_screen (GTK_INVISIBLE (widget));
- }
-
- return NULL;
-}
-
/**
* gtk_widget_get_screen:
* @widget: a #GtkWidget
@@ -9276,38 +9257,21 @@ gtk_widget_get_screen_unchecked (GtkWidget *widget)
GdkScreen*
gtk_widget_get_screen (GtkWidget *widget)
{
- GdkScreen *screen;
+ GtkWidget *toplevel;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- screen = gtk_widget_get_screen_unchecked (widget);
-
- if (screen)
- return screen;
- else
- return gdk_screen_get_default ();
-}
-
-/**
- * gtk_widget_has_screen:
- * @widget: a #GtkWidget
- *
- * Checks whether there is a #GdkScreen is associated with
- * this widget. All toplevel widgets have an associated
- * screen, and all widgets added into a hierarchy with a toplevel
- * window at the top.
- *
- * Returns: %TRUE if there is a #GdkScreen associated
- * with the widget.
- *
- * Since: 2.2
- **/
-gboolean
-gtk_widget_has_screen (GtkWidget *widget)
-{
- g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
+ toplevel = _gtk_widget_get_toplevel (widget);
- return (gtk_widget_get_screen_unchecked (widget) != NULL);
+ if (_gtk_widget_is_toplevel (toplevel))
+ {
+ if (GTK_IS_WINDOW (toplevel))
+ return _gtk_window_get_screen (GTK_WINDOW (toplevel));
+ else if (GTK_IS_INVISIBLE (toplevel))
+ return gtk_invisible_get_screen (GTK_INVISIBLE (widget));
+ }
+
+ return gdk_screen_get_default ();
}
void
@@ -12618,7 +12582,6 @@ GtkClipboard *
gtk_widget_get_clipboard (GtkWidget *widget, GdkAtom selection)
{
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
- g_return_val_if_fail (gtk_widget_has_screen (widget), NULL);
return gtk_clipboard_get_for_display (gtk_widget_get_display (widget),
selection);
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index 60302f6..a2cf955 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -784,8 +784,6 @@ GtkWidget* gtk_widget_get_ancestor (GtkWidget *widget,
GDK_AVAILABLE_IN_ALL
GdkScreen * gtk_widget_get_screen (GtkWidget *widget);
-GDK_AVAILABLE_IN_ALL
-gboolean gtk_widget_has_screen (GtkWidget *widget);
GDK_AVAILABLE_IN_3_10
gint gtk_widget_get_scale_factor (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]