From 285aa226e56897de593f04195b7327dcea6efdd7 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Thu, 16 Apr 2020 23:25:06 -0400 Subject: [PATCH] scrolledwindow: Drop shadow-type We were only using this as a boolean, so change it to a boolean property named has-frame. --- demos/gtk-demo/application.ui | 2 +- demos/gtk-demo/blendmodes.ui | 2 +- demos/gtk-demo/demo.ui | 2 +- demos/gtk-demo/editable_cells.c | 3 +- demos/gtk-demo/expander.c | 2 +- demos/gtk-demo/fontrendering.ui | 2 +- demos/gtk-demo/iconview.c | 3 +- demos/gtk-demo/list_store.c | 3 +- demos/gtk-demo/main.c | 2 - demos/gtk-demo/tree_store.c | 3 +- demos/widget-factory/widget-factory.ui | 14 ++-- docs/reference/gtk/gtk4-sections.txt | 4 +- gtk/gtkcustompaperunixdialog.c | 3 +- gtk/gtkentrycompletion.c | 2 - gtk/gtkmountoperation.c | 2 +- gtk/gtkplacessidebar.c | 2 +- gtk/gtkscrolledwindow.c | 74 +++++++++----------- gtk/gtkscrolledwindow.h | 6 +- gtk/inspector/resource-list.ui | 4 +- gtk/inspector/type-info.ui | 4 +- gtk/ui/gtkaboutdialog.ui | 6 +- gtk/ui/gtkappchooserwidget.ui | 2 +- gtk/ui/gtkfontchooserwidget.ui | 4 +- gtk/ui/gtkplacesview.ui | 2 +- gtk/ui/gtkprintunixdialog.ui | 2 +- tests/print-editor.c | 3 +- tests/testcellrenderertext.c | 2 +- tests/testexpander.c | 2 +- tests/testtreeedit.c | 2 +- tests/testtreefocus.c | 4 +- tests/testtreesort.c | 8 +-- tests/testverticalcells.c | 2 +- testsuite/gtk/focus-chain/widget-factory.ui | 14 ++-- testsuite/gtk/focus-chain/widget-factory2.ui | 14 ++-- testsuite/gtk/focus-chain/widget-factory3.ui | 14 ++-- 35 files changed, 102 insertions(+), 118 deletions(-) diff --git a/demos/gtk-demo/application.ui b/demos/gtk-demo/application.ui index 12468c11ef..14f2b22566 100644 --- a/demos/gtk-demo/application.ui +++ b/demos/gtk-demo/application.ui @@ -61,7 +61,7 @@ - in + 1 1 diff --git a/demos/gtk-demo/blendmodes.ui b/demos/gtk-demo/blendmodes.ui index 9dadc63b20..1c43ef4482 100644 --- a/demos/gtk-demo/blendmodes.ui +++ b/demos/gtk-demo/blendmodes.ui @@ -26,7 +26,7 @@ 1 - in + 1 150 0 diff --git a/demos/gtk-demo/demo.ui b/demos/gtk-demo/demo.ui index f4cda56077..a25c12d6a1 100644 --- a/demos/gtk-demo/demo.ui +++ b/demos/gtk-demo/demo.ui @@ -166,7 +166,7 @@ - in + 1 1 1 diff --git a/demos/gtk-demo/editable_cells.c b/demos/gtk-demo/editable_cells.c index 8491ccf419..52a432b344 100644 --- a/demos/gtk-demo/editable_cells.c +++ b/demos/gtk-demo/editable_cells.c @@ -366,8 +366,7 @@ do_editable_cells (GtkWidget *do_widget) gtk_label_new ("Shopping list (you can edit the cells!)")); sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), - GTK_SHADOW_ETCHED_IN); + gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); diff --git a/demos/gtk-demo/expander.c b/demos/gtk-demo/expander.c index fc3e7c60f9..cc9691ab7d 100644 --- a/demos/gtk-demo/expander.c +++ b/demos/gtk-demo/expander.c @@ -59,7 +59,7 @@ do_expander (GtkWidget *do_widget) gtk_widget_set_vexpand (expander, TRUE); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (sw), 100); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); + gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); diff --git a/demos/gtk-demo/fontrendering.ui b/demos/gtk-demo/fontrendering.ui index 8803dbd7dc..b106c1f9d4 100644 --- a/demos/gtk-demo/fontrendering.ui +++ b/demos/gtk-demo/fontrendering.ui @@ -193,7 +193,7 @@ 1 - in + 1 1 1 diff --git a/demos/gtk-demo/iconview.c b/demos/gtk-demo/iconview.c index 2e6c145a3d..98ee9e03e6 100644 --- a/demos/gtk-demo/iconview.c +++ b/demos/gtk-demo/iconview.c @@ -277,8 +277,7 @@ do_iconview (GtkWidget *do_widget) sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), - GTK_SHADOW_ETCHED_IN); + gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); diff --git a/demos/gtk-demo/list_store.c b/demos/gtk-demo/list_store.c index ffd964925b..a75cca1854 100644 --- a/demos/gtk-demo/list_store.c +++ b/demos/gtk-demo/list_store.c @@ -272,8 +272,7 @@ do_list_store (GtkWidget *do_widget) gtk_container_add (GTK_CONTAINER (vbox), label); sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), - GTK_SHADOW_ETCHED_IN); + gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); diff --git a/demos/gtk-demo/main.c b/demos/gtk-demo/main.c index aef7b1922a..f61f4bac62 100644 --- a/demos/gtk-demo/main.c +++ b/demos/gtk-demo/main.c @@ -612,8 +612,6 @@ display_text (const char *resource) gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), - GTK_SHADOW_NONE); gtk_container_add (GTK_CONTAINER (sw), textview); return sw; diff --git a/demos/gtk-demo/tree_store.c b/demos/gtk-demo/tree_store.c index a2b8b19b44..7b01ab2a5e 100644 --- a/demos/gtk-demo/tree_store.c +++ b/demos/gtk-demo/tree_store.c @@ -408,8 +408,7 @@ do_tree_store (GtkWidget *do_widget) gtk_label_new ("Jonathan's Holiday Card Planning Sheet")); sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), - GTK_SHADOW_ETCHED_IN); + gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sw), TRUE); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui index 31ce03bfd8..e7c30454e3 100644 --- a/demos/widget-factory/widget-factory.ui +++ b/demos/widget-factory/widget-factory.ui @@ -1113,7 +1113,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus. 150 always - in + 1 1 @@ -1187,7 +1187,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus. - in + 1 1 @@ -1597,7 +1597,7 @@ microphone-sensitivity-medium-symbolic - in + 1 never 200 0 @@ -1999,7 +1999,7 @@ microphone-sensitivity-medium-symbolic vertical - in + 1 6 226 @@ -2105,7 +2105,7 @@ microphone-sensitivity-medium-symbolic never always 300 - in + 1 vertical @@ -2171,7 +2171,7 @@ microphone-sensitivity-medium-symbolic never 1 - in + 1 multiple @@ -3141,7 +3141,7 @@ bad things might happen. start - in + 1 70 120 100 diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt index d438d4bc3d..594692736b 100644 --- a/docs/reference/gtk/gtk4-sections.txt +++ b/docs/reference/gtk/gtk4-sections.txt @@ -2205,8 +2205,8 @@ GtkCornerType gtk_scrolled_window_get_placement gtk_scrolled_window_set_placement gtk_scrolled_window_unset_placement -gtk_scrolled_window_get_shadow_type -gtk_scrolled_window_set_shadow_type +gtk_scrolled_window_get_has_frame +gtk_scrolled_window_set_has_frame gtk_scrolled_window_get_kinetic_scrolling gtk_scrolled_window_set_kinetic_scrolling gtk_scrolled_window_get_capture_button_press diff --git a/gtk/gtkcustompaperunixdialog.c b/gtk/gtkcustompaperunixdialog.c index 5a44f31631..92c15b14df 100644 --- a/gtk/gtkcustompaperunixdialog.c +++ b/gtk/gtkcustompaperunixdialog.c @@ -1022,8 +1022,7 @@ populate_dialog (GtkCustomPaperUnixDialog *dialog) scrolled = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), - GTK_SHADOW_IN); + gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (scrolled), TRUE); gtk_container_add (GTK_CONTAINER (vbox), scrolled); gtk_widget_show (scrolled); diff --git a/gtk/gtkentrycompletion.c b/gtk/gtkentrycompletion.c index 1d5f32fae9..a7fc1f649d 100644 --- a/gtk/gtkentrycompletion.c +++ b/gtk/gtkentrycompletion.c @@ -548,8 +548,6 @@ gtk_entry_completion_constructed (GObject *object) gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scrolled_window), - GTK_SHADOW_NONE); /* a nasty hack to get the completions treeview to size nicely */ gtk_widget_set_size_request (gtk_scrolled_window_get_vscrollbar (GTK_SCROLLED_WINDOW (priv->scrolled_window)), diff --git a/gtk/gtkmountoperation.c b/gtk/gtkmountoperation.c index ee84e060d9..8830ba3e6d 100644 --- a/gtk/gtkmountoperation.c +++ b/gtk/gtkmountoperation.c @@ -1592,7 +1592,7 @@ create_show_processes_dialog (GtkMountOperation *op, gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_IN); + gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (scrolled_window), TRUE); gtk_container_add (GTK_CONTAINER (scrolled_window), tree_view); gtk_container_add (GTK_CONTAINER (vbox), scrolled_window); diff --git a/gtk/gtkplacessidebar.c b/gtk/gtkplacessidebar.c index 110bfa7acb..dabe9470ef 100644 --- a/gtk/gtkplacessidebar.c +++ b/gtk/gtkplacessidebar.c @@ -3768,7 +3768,7 @@ gtk_places_sidebar_init (GtkPlacesSidebar *sidebar) gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sidebar->swin), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sidebar->swin), GTK_SHADOW_IN); + gtk_scrolled_window_set_has_frame (GTK_SCROLLED_WINDOW (sidebar->swin), TRUE); gtk_widget_add_css_class (GTK_WIDGET (sidebar), "sidebar"); diff --git a/gtk/gtkscrolledwindow.c b/gtk/gtkscrolledwindow.c index 5e3f9ea949..3900b624fe 100644 --- a/gtk/gtkscrolledwindow.c +++ b/gtk/gtkscrolledwindow.c @@ -248,8 +248,7 @@ typedef struct Indicator vindicator; GtkCornerType window_placement; - guint16 shadow_type; - + guint has_frame : 1; guint hscrollbar_policy : 2; guint vscrollbar_policy : 2; guint hscrollbar_visible : 1; @@ -309,7 +308,7 @@ enum { PROP_HSCROLLBAR_POLICY, PROP_VSCROLLBAR_POLICY, PROP_WINDOW_PLACEMENT, - PROP_SHADOW_TYPE, + PROP_HAS_FRAME, PROP_MIN_CONTENT_WIDTH, PROP_MIN_CONTENT_HEIGHT, PROP_KINETIC_SCROLLING, @@ -580,13 +579,12 @@ gtk_scrolled_window_class_init (GtkScrolledWindowClass *class) GTK_CORNER_TOP_LEFT, GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY); - properties[PROP_SHADOW_TYPE] = - g_param_spec_enum ("shadow-type", - P_("Shadow Type"), - P_("Style of bevel around the contents"), - GTK_TYPE_SHADOW_TYPE, - GTK_SHADOW_NONE, - GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY); + properties[PROP_HAS_FRAME] = + g_param_spec_boolean ("has-frame", + P_("Has Frame"), + P_("Whether to draw a frame around the contents"), + FALSE, + GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY); /** * GtkScrolledWindow:min-content-width: @@ -2410,52 +2408,50 @@ gtk_scrolled_window_unset_placement (GtkScrolledWindow *scrolled_window) } /** - * gtk_scrolled_window_set_shadow_type: + * gtk_scrolled_window_set_has_frame: * @scrolled_window: a #GtkScrolledWindow - * @type: kind of shadow to draw around scrolled window contents + * @type: whether to draw a frame around scrolled window contents * - * Changes the type of shadow drawn around the contents of - * @scrolled_window. + * Changes the frame drawn around the contents of @scrolled_window. **/ void -gtk_scrolled_window_set_shadow_type (GtkScrolledWindow *scrolled_window, - GtkShadowType type) +gtk_scrolled_window_set_has_frame (GtkScrolledWindow *scrolled_window, + gboolean has_frame) { GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window); g_return_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window)); - g_return_if_fail (type >= GTK_SHADOW_NONE && type <= GTK_SHADOW_ETCHED_OUT); - if (priv->shadow_type != type) - { - priv->shadow_type = type; + if (priv->has_frame == has_frame) + return; - if (type != GTK_SHADOW_NONE) - gtk_widget_add_css_class (GTK_WIDGET (scrolled_window), GTK_STYLE_CLASS_FRAME); - else - gtk_widget_remove_css_class (GTK_WIDGET (scrolled_window), GTK_STYLE_CLASS_FRAME); + priv->has_frame = has_frame; - g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_SHADOW_TYPE]); - } + if (has_frame) + gtk_widget_add_css_class (GTK_WIDGET (scrolled_window), GTK_STYLE_CLASS_FRAME); + else + gtk_widget_remove_css_class (GTK_WIDGET (scrolled_window), GTK_STYLE_CLASS_FRAME); + + g_object_notify_by_pspec (G_OBJECT (scrolled_window), properties[PROP_HAS_FRAME]); } /** - * gtk_scrolled_window_get_shadow_type: + * gtk_scrolled_window_get_has_frame: * @scrolled_window: a #GtkScrolledWindow * - * Gets the shadow type of the scrolled window. See - * gtk_scrolled_window_set_shadow_type(). + * Gets whether the scrolled window draws a frame. + * See gtk_scrolled_window_set_has_frame(). * - * Returns: the current shadow type + * Returns: %TRUE if the @scrolled_window has a frame **/ -GtkShadowType -gtk_scrolled_window_get_shadow_type (GtkScrolledWindow *scrolled_window) +gboolean +gtk_scrolled_window_get_has_frame (GtkScrolledWindow *scrolled_window) { GtkScrolledWindowPrivate *priv = gtk_scrolled_window_get_instance_private (scrolled_window); - g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), GTK_SHADOW_NONE); + g_return_val_if_fail (GTK_IS_SCROLLED_WINDOW (scrolled_window), FALSE); - return priv->shadow_type; + return priv->has_frame; } /** @@ -2647,9 +2643,9 @@ gtk_scrolled_window_set_property (GObject *object, gtk_scrolled_window_set_placement (scrolled_window, g_value_get_enum (value)); break; - case PROP_SHADOW_TYPE: - gtk_scrolled_window_set_shadow_type (scrolled_window, - g_value_get_enum (value)); + case PROP_HAS_FRAME: + gtk_scrolled_window_set_has_frame (scrolled_window, + g_value_get_boolean (value)); break; case PROP_MIN_CONTENT_WIDTH: gtk_scrolled_window_set_min_content_width (scrolled_window, @@ -2711,8 +2707,8 @@ gtk_scrolled_window_get_property (GObject *object, case PROP_WINDOW_PLACEMENT: g_value_set_enum (value, priv->window_placement); break; - case PROP_SHADOW_TYPE: - g_value_set_enum (value, priv->shadow_type); + case PROP_HAS_FRAME: + g_value_set_boolean (value, priv->has_frame); break; case PROP_HSCROLLBAR_POLICY: g_value_set_enum (value, priv->hscrollbar_policy); diff --git a/gtk/gtkscrolledwindow.h b/gtk/gtkscrolledwindow.h index fdbdb67631..7dd59623c1 100644 --- a/gtk/gtkscrolledwindow.h +++ b/gtk/gtkscrolledwindow.h @@ -125,10 +125,10 @@ void gtk_scrolled_window_unset_placement (GtkScrolledWindow *scrolle GDK_AVAILABLE_IN_ALL GtkCornerType gtk_scrolled_window_get_placement (GtkScrolledWindow *scrolled_window); GDK_AVAILABLE_IN_ALL -void gtk_scrolled_window_set_shadow_type (GtkScrolledWindow *scrolled_window, - GtkShadowType type); +void gtk_scrolled_window_set_has_frame (GtkScrolledWindow *scrolled_window, + gboolean has_frame); GDK_AVAILABLE_IN_ALL -GtkShadowType gtk_scrolled_window_get_shadow_type (GtkScrolledWindow *scrolled_window); +gboolean gtk_scrolled_window_get_has_frame (GtkScrolledWindow *scrolled_window); GDK_AVAILABLE_IN_ALL gint gtk_scrolled_window_get_min_content_width (GtkScrolledWindow *scrolled_window); diff --git a/gtk/inspector/resource-list.ui b/gtk/inspector/resource-list.ui index f18fac1c6d..3dd57024da 100644 --- a/gtk/inspector/resource-list.ui +++ b/gtk/inspector/resource-list.ui @@ -204,7 +204,7 @@ 1 1 - in + 1 @@ -225,7 +225,7 @@ 1 1 - in + 1 diff --git a/gtk/inspector/type-info.ui b/gtk/inspector/type-info.ui index 9705468ed8..32a4bdaf8c 100644 --- a/gtk/inspector/type-info.ui +++ b/gtk/inspector/type-info.ui @@ -17,7 +17,7 @@ - etched-in + 1 200 200 1 @@ -38,7 +38,7 @@ - etched-in + 1 200 150 1 diff --git a/gtk/ui/gtkaboutdialog.ui b/gtk/ui/gtkaboutdialog.ui index 77f1ce2f75..fcb4f47400 100644 --- a/gtk/ui/gtkaboutdialog.ui +++ b/gtk/ui/gtkaboutdialog.ui @@ -125,7 +125,7 @@ never - in + 1 1 @@ -165,7 +165,7 @@ never - in + 1 1 @@ -208,7 +208,7 @@ never - in + 1 1 diff --git a/gtk/ui/gtkappchooserwidget.ui b/gtk/ui/gtkappchooserwidget.ui index efca0e6b0b..cfce252c1a 100644 --- a/gtk/ui/gtkappchooserwidget.ui +++ b/gtk/ui/gtkappchooserwidget.ui @@ -25,7 +25,7 @@ 400 300 never - in + 1 program_list_sort diff --git a/gtk/ui/gtkfontchooserwidget.ui b/gtk/ui/gtkfontchooserwidget.ui index 3a94b91d11..ac50802f91 100644 --- a/gtk/ui/gtkfontchooserwidget.ui +++ b/gtk/ui/gtkfontchooserwidget.ui @@ -64,7 +64,7 @@ 1 1 never - etched-in + 1 filter_model @@ -236,7 +236,7 @@ never - in + 1 1