summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-04-17 00:20:09 -0400
committerMatthias Clasen <mclasen@redhat.com>2020-04-17 10:57:36 -0400
commitdf1816a29cb5e7b37494aaf7f92fcd6bba98e7ef (patch)
tree964c89f35e269b545b0b5d531cc66659a591f6f6 /gtk
parentfdbbef863dd34211311016eaaf58ae4767e9f409 (diff)
downloadgtk+-df1816a29cb5e7b37494aaf7f92fcd6bba98e7ef.tar.gz
button: Drop relief
We are only using this as a boolean, so change it to a boolean property named has-frame.
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtkbutton.c75
-rw-r--r--gtk/gtkbutton.h6
-rw-r--r--gtk/gtklinkbutton.c2
-rw-r--r--gtk/gtkmenubutton.c10
-rw-r--r--gtk/gtknotebook.c2
-rw-r--r--gtk/gtkplacesview.c2
-rw-r--r--gtk/inspector/css-editor.ui4
-rw-r--r--gtk/inspector/data-list.ui2
-rw-r--r--gtk/inspector/object-tree.c2
-rw-r--r--gtk/inspector/recorder.c4
-rw-r--r--gtk/inspector/recorder.ui8
-rw-r--r--gtk/inspector/window.ui4
-rw-r--r--gtk/ui/gtkemojichooser.ui20
-rw-r--r--gtk/ui/gtkscalebutton.ui6
14 files changed, 72 insertions, 75 deletions
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 6ad1fb6304..b1be03fa9f 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -102,7 +102,7 @@ enum {
enum {
PROP_0,
PROP_LABEL,
- PROP_RELIEF,
+ PROP_HAS_FRAME,
PROP_USE_UNDERLINE,
PROP_ICON_NAME,
@@ -228,13 +228,12 @@ gtk_button_class_init (GtkButtonClass *klass)
FALSE,
GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
- props[PROP_RELIEF] =
- g_param_spec_enum ("relief",
- P_("Border relief"),
- P_("The border relief style"),
- GTK_TYPE_RELIEF_STYLE,
- GTK_RELIEF_NORMAL,
- GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
+ props[PROP_HAS_FRAME] =
+ g_param_spec_boolean ("has-frame",
+ P_("Has Frame"),
+ P_("Whether the button has a frame"),
+ TRUE,
+ GTK_PARAM_READWRITE|G_PARAM_EXPLICIT_NOTIFY);
props[PROP_ICON_NAME] =
g_param_spec_string ("icon-name",
@@ -484,8 +483,8 @@ gtk_button_set_property (GObject *object,
case PROP_LABEL:
gtk_button_set_label (button, g_value_get_string (value));
break;
- case PROP_RELIEF:
- gtk_button_set_relief (button, g_value_get_enum (value));
+ case PROP_HAS_FRAME:
+ gtk_button_set_has_frame (button, g_value_get_boolean (value));
break;
case PROP_USE_UNDERLINE:
gtk_button_set_use_underline (button, g_value_get_boolean (value));
@@ -519,8 +518,8 @@ gtk_button_get_property (GObject *object,
case PROP_LABEL:
g_value_set_string (value, gtk_button_get_label (button));
break;
- case PROP_RELIEF:
- g_value_set_enum (value, gtk_button_get_relief (button));
+ case PROP_HAS_FRAME:
+ g_value_set_boolean (value, gtk_button_get_has_frame (button));
break;
case PROP_USE_UNDERLINE:
g_value_set_boolean (value, priv->use_underline);
@@ -641,51 +640,45 @@ gtk_button_new_with_mnemonic (const gchar *label)
}
/**
- * gtk_button_set_relief:
- * @button: The #GtkButton you want to set relief styles of
- * @relief: The GtkReliefStyle as described above
+ * gtk_Button_set_has_frame:
+ * @button: a #GtkButton
+ * @has_frame: whether the button should have a visible frame
*
- * Sets the relief style of the edges of the given #GtkButton widget.
- * Two styles exist, %GTK_RELIEF_NORMAL and %GTK_RELIEF_NONE.
- * The default style is, as one can guess, %GTK_RELIEF_NORMAL.
+ * Sets the style of the button. Buttons can has a flat appearance
+ * or have a frame drawn around them.
*/
void
-gtk_button_set_relief (GtkButton *button,
- GtkReliefStyle relief)
+gtk_button_set_has_frame (GtkButton *button,
+ gboolean has_frame)
{
- GtkReliefStyle old_relief;
g_return_if_fail (GTK_IS_BUTTON (button));
- old_relief = gtk_button_get_relief (button);
- if (old_relief != relief)
- {
- if (relief == GTK_RELIEF_NONE)
- gtk_widget_add_css_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT);
- else
- gtk_widget_remove_css_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT);
+ if (gtk_button_get_has_frame (button) == has_frame)
+ return;
- g_object_notify_by_pspec (G_OBJECT (button), props[PROP_RELIEF]);
- }
+ if (has_frame)
+ gtk_widget_remove_css_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT);
+ else
+ gtk_widget_add_css_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT);
+
+ g_object_notify_by_pspec (G_OBJECT (button), props[PROP_HAS_FRAME]);
}
/**
- * gtk_button_get_relief:
- * @button: The #GtkButton you want the #GtkReliefStyle from.
+ * gtk_button_get_has_frame:
+ * @button: a #GtkButton
*
- * Returns the current relief style of the given #GtkButton.
+ * Returns whether the button has a frame.
*
- * Returns: The current #GtkReliefStyle
+ * Returns: %TRUE if the button has a frame
*/
-GtkReliefStyle
-gtk_button_get_relief (GtkButton *button)
+gboolean
+gtk_button_get_has_frame (GtkButton *button)
{
- g_return_val_if_fail (GTK_IS_BUTTON (button), GTK_RELIEF_NORMAL);
+ g_return_val_if_fail (GTK_IS_BUTTON (button), TRUE);
- if (gtk_widget_has_css_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT))
- return GTK_RELIEF_NONE;
- else
- return GTK_RELIEF_NORMAL;
+ return !gtk_widget_has_css_class (GTK_WIDGET (button), GTK_STYLE_CLASS_FLAT);
}
static void
diff --git a/gtk/gtkbutton.h b/gtk/gtkbutton.h
index f3738f9166..9a4b15c992 100644
--- a/gtk/gtkbutton.h
+++ b/gtk/gtkbutton.h
@@ -86,10 +86,10 @@ GDK_AVAILABLE_IN_ALL
GtkWidget* gtk_button_new_with_mnemonic (const gchar *label);
GDK_AVAILABLE_IN_ALL
-void gtk_button_set_relief (GtkButton *button,
- GtkReliefStyle relief);
+void gtk_button_set_has_frame (GtkButton *button,
+ gboolean has_frame);
GDK_AVAILABLE_IN_ALL
-GtkReliefStyle gtk_button_get_relief (GtkButton *button);
+gboolean gtk_button_get_has_frame (GtkButton *button);
GDK_AVAILABLE_IN_ALL
void gtk_button_set_label (GtkButton *button,
const gchar *label);
diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c
index ee82086798..a260f146cf 100644
--- a/gtk/gtklinkbutton.c
+++ b/gtk/gtklinkbutton.c
@@ -345,7 +345,7 @@ gtk_link_button_init (GtkLinkButton *link_button)
GdkContentProvider *content;
GtkDragSource *source;
- gtk_button_set_relief (GTK_BUTTON (link_button), GTK_RELIEF_NONE);
+ gtk_button_set_has_frame (GTK_BUTTON (link_button), FALSE);
gtk_widget_set_state_flags (GTK_WIDGET (link_button), GTK_STATE_FLAG_LINK, FALSE);
gtk_widget_set_has_tooltip (GTK_WIDGET (link_button), TRUE);
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index c210d096d0..3e9f78ca4a 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -946,12 +946,15 @@ void
gtk_menu_button_set_relief (GtkMenuButton *menu_button,
GtkReliefStyle relief)
{
+ gboolean has_frame;
+
g_return_if_fail (GTK_IS_MENU_BUTTON (menu_button));
- if (relief == gtk_button_get_relief (GTK_BUTTON (menu_button->button)))
+ has_frame = relief == GTK_RELIEF_NORMAL;
+ if (gtk_button_get_has_frame (GTK_BUTTON (menu_button->button)) == has_frame)
return;
- gtk_button_set_relief (GTK_BUTTON (menu_button->button), relief);
+ gtk_button_set_has_frame (GTK_BUTTON (menu_button->button), has_frame);
g_object_notify_by_pspec (G_OBJECT (menu_button), menu_button_props[PROP_RELIEF]);
}
@@ -968,7 +971,8 @@ gtk_menu_button_get_relief (GtkMenuButton *menu_button)
{
g_return_val_if_fail (GTK_IS_MENU_BUTTON (menu_button), GTK_RELIEF_NORMAL);
- return gtk_button_get_relief (GTK_BUTTON (menu_button->button));
+ return gtk_button_get_has_frame (GTK_BUTTON (menu_button->button))
+ ? GTK_RELIEF_NORMAL : GTK_RELIEF_NONE;
}
/**
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index 277138fe32..1faaf5f8ea 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -5545,7 +5545,7 @@ gtk_notebook_menu_item_create (GtkNotebook *notebook,
}
menu_item = gtk_button_new ();
- gtk_button_set_relief (GTK_BUTTON (menu_item), GTK_RELIEF_NONE);
+ gtk_button_set_has_frame (GTK_BUTTON (menu_item), FALSE);
gtk_container_add (GTK_CONTAINER (menu_item), page->menu_label);
gtk_container_add (GTK_CONTAINER (notebook->menu_box), menu_item);
g_signal_connect (menu_item, "clicked",
diff --git a/gtk/gtkplacesview.c b/gtk/gtkplacesview.c
index 415358486f..4a66513b03 100644
--- a/gtk/gtkplacesview.c
+++ b/gtk/gtkplacesview.c
@@ -610,7 +610,7 @@ populate_servers (GtkPlacesView *view)
button = gtk_button_new_from_icon_name ("window-close-symbolic");
gtk_widget_set_halign (button, GTK_ALIGN_END);
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
gtk_widget_add_css_class (button, "sidebar-button");
gtk_grid_attach (GTK_GRID (grid), button, 1, 0, 1, 2);
diff --git a/gtk/inspector/css-editor.ui b/gtk/inspector/css-editor.ui
index 50b9bee503..dc4649904c 100644
--- a/gtk/inspector/css-editor.ui
+++ b/gtk/inspector/css-editor.ui
@@ -29,7 +29,7 @@
<property name="margin-bottom">6</property>
<child>
<object class="GtkToggleButton" id="disable_button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes">Disable this custom CSS</property>
<property name="icon-name">media-playback-pause-symbolic</property>
<signal name="toggled" handler="disable_toggled"/>
@@ -37,7 +37,7 @@
</child>
<child>
<object class="GtkButton" id="save_button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes">Save the current CSS</property>
<property name="icon-name">document-save-symbolic</property>
<signal name="clicked" handler="save_clicked"/>
diff --git a/gtk/inspector/data-list.ui b/gtk/inspector/data-list.ui
index 19549a9834..78e2369777 100644
--- a/gtk/inspector/data-list.ui
+++ b/gtk/inspector/data-list.ui
@@ -10,7 +10,7 @@
<property name="margin-bottom">6</property>
<child>
<object class="GtkToggleButton" id="show_button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes">Show data</property>
<property name="icon-name">view-refresh-symbolic</property>
<signal name="toggled" handler="toggle_show"/>
diff --git a/gtk/inspector/object-tree.c b/gtk/inspector/object-tree.c
index a1a8760f4d..bc720a4b19 100644
--- a/gtk/inspector/object-tree.c
+++ b/gtk/inspector/object-tree.c
@@ -1020,7 +1020,7 @@ gtk_inspector_object_tree_create_list_widget (gpointer row_item,
child = g_object_new (GTK_TYPE_BOX, "css-name", "expander", NULL);
title = g_object_new (GTK_TYPE_TOGGLE_BUTTON, "css-name", "title", NULL);
- gtk_button_set_relief (GTK_BUTTON (title), GTK_RELIEF_NONE);
+ gtk_button_set_has_frame (GTK_BUTTON (title), FALSE);
g_object_bind_property (row_item, "expanded", title, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
gtk_container_add (GTK_CONTAINER (child), title);
diff --git a/gtk/inspector/recorder.c b/gtk/inspector/recorder.c
index b4ed3d965e..ac7f728f7f 100644
--- a/gtk/inspector/recorder.c
+++ b/gtk/inspector/recorder.c
@@ -324,7 +324,7 @@ create_widget_for_render_node (gpointer row_item,
child = g_object_new (GTK_TYPE_BOX, "css-name", "expander", NULL);
title = g_object_new (GTK_TYPE_TOGGLE_BUTTON, "css-name", "title", NULL);
- gtk_button_set_relief (GTK_BUTTON (title), GTK_RELIEF_NONE);
+ gtk_button_set_has_frame (GTK_BUTTON (title), FALSE);
g_object_bind_property (row_item, "expanded", title, "active", G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
gtk_container_add (GTK_CONTAINER (child), title);
g_object_set_data_full (G_OBJECT (row), "make-sure-its-not-unreffed", g_object_ref (row_item), g_object_unref);
@@ -1117,7 +1117,7 @@ gtk_inspector_recorder_recordings_list_create_widget (gpointer item,
gtk_container_add (GTK_CONTAINER (hbox), label);
button = gtk_toggle_button_new ();
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ gtk_button_set_has_frame (GTK_BUTTON (button), FALSE);
gtk_button_set_icon_name (GTK_BUTTON (button), "view-more-symbolic");
gtk_container_add (GTK_CONTAINER (hbox), button);
diff --git a/gtk/inspector/recorder.ui b/gtk/inspector/recorder.ui
index 54fed8871e..c3e6d2071e 100644
--- a/gtk/inspector/recorder.ui
+++ b/gtk/inspector/recorder.ui
@@ -13,7 +13,7 @@
<property name="margin-bottom">6</property>
<child>
<object class="GtkToggleButton">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="icon-name">media-record-symbolic</property>
<property name="tooltip-text" translatable="yes">Record frames</property>
<property name="active" bind-source="GtkInspectorRecorder" bind-property="recording" bind-flags="bidirectional|sync-create"/>
@@ -21,7 +21,7 @@
</child>
<child>
<object class="GtkButton">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="icon-name">edit-clear-all-symbolic</property>
<property name="tooltip-text" translatable="yes">Clear recorded frames</property>
<signal name="clicked" handler="recordings_clear_all"/>
@@ -29,7 +29,7 @@
</child>
<child>
<object class="GtkToggleButton">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="icon-name">insert-object-symbolic</property>
<property name="tooltip-text" translatable="yes">Add debug nodes</property>
<property name="active" bind-source="GtkInspectorRecorder" bind-property="debug-nodes" bind-flags="bidirectional|sync-create"/>
@@ -39,7 +39,7 @@
</child>
<child>
<object class="GtkButton" id="render_node_save_button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="sensitive">0</property>
<property name="icon-name">document-save-as-symbolic</property>
<property name="tooltip-text" translatable="yes">Save selected node</property>
diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui
index 4623a72229..4fc07bcfc8 100644
--- a/gtk/inspector/window.ui
+++ b/gtk/inspector/window.ui
@@ -230,7 +230,7 @@
<object class="GtkButton">
<property name="icon-name">go-previous-symbolic</property>
<property name="tooltip-text" translatable="yes">Toggle Sidebar</property>
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="margin-start">6</property>
<property name="margin-end">6</property>
<property name="margin-top">6</property>
@@ -262,7 +262,7 @@
<property name="margin-bottom">6</property>
<property name="icon-name">view-refresh-symbolic</property>
<property name="tooltip-text" translatable="yes">Refresh action state</property>
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
</object>
</property>
</object>
diff --git a/gtk/ui/gtkemojichooser.ui b/gtk/ui/gtkemojichooser.ui
index ad7ad0191b..388761ca0d 100644
--- a/gtk/ui/gtkemojichooser.ui
+++ b/gtk/ui/gtkemojichooser.ui
@@ -215,7 +215,7 @@
</style>
<child>
<object class="GtkButton" id="recent.button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes" context="emoji category">Recent</property>
<style>
<class name="emoji-section"/>
@@ -224,7 +224,7 @@
</child>
<child>
<object class="GtkButton" id="people.button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes" context="emoji category">Smileys &amp; People</property>
<style>
<class name="emoji-section"/>
@@ -233,7 +233,7 @@
</child>
<child>
<object class="GtkButton" id="body.button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes" context="emoji category">Body &amp; Clothing</property>
<style>
<class name="emoji-section"/>
@@ -242,7 +242,7 @@
</child>
<child>
<object class="GtkButton" id="nature.button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes" context="emoji category">Animals &amp; Nature</property>
<style>
<class name="emoji-section"/>
@@ -251,7 +251,7 @@
</child>
<child>
<object class="GtkButton" id="food.button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes" context="emoji category">Food &amp; Drink</property>
<style>
<class name="emoji-section"/>
@@ -260,7 +260,7 @@
</child>
<child>
<object class="GtkButton" id="travel.button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes" context="emoji category">Travel &amp; Places</property>
<style>
<class name="emoji-section"/>
@@ -269,7 +269,7 @@
</child>
<child>
<object class="GtkButton" id="activities.button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes" context="emoji category">Activities</property>
<style>
<class name="emoji-section"/>
@@ -278,7 +278,7 @@
</child>
<child>
<object class="GtkButton" id="objects.button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes" context="emoji category">Objects</property>
<style>
<class name="emoji-section"/>
@@ -287,7 +287,7 @@
</child>
<child>
<object class="GtkButton" id="symbols.button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes" context="emoji category">Symbols</property>
<style>
<class name="emoji-section"/>
@@ -296,7 +296,7 @@
</child>
<child>
<object class="GtkButton" id="flags.button">
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="tooltip-text" translatable="yes" context="emoji category">Flags</property>
<style>
<class name="emoji-section"/>
diff --git a/gtk/ui/gtkscalebutton.ui b/gtk/ui/gtkscalebutton.ui
index f7611fa481..f95045e62d 100644
--- a/gtk/ui/gtkscalebutton.ui
+++ b/gtk/ui/gtkscalebutton.ui
@@ -6,7 +6,7 @@
<property name="receives-default">1</property>
<property name="focus-on-click">0</property>
<property name="icon-name">image-missing</property>
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
</object>
</child>
</template>
@@ -26,7 +26,7 @@
<child>
<object class="GtkButton" id="plus_button">
<property name="receives-default">1</property>
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">list-add-symbolic</property>
@@ -46,7 +46,7 @@
<child>
<object class="GtkButton" id="minus_button">
<property name="receives-default">1</property>
- <property name="relief">none</property>
+ <property name="has-frame">0</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="icon-name">list-remove-symbolic</property>