[gtk+/wip/cosimoc/combobox-gadget: 2/2] combobox: use GtkIcon to render button arrow
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cosimoc/combobox-gadget: 2/2] combobox: use GtkIcon to render button arrow
- Date: Mon, 21 Dec 2015 22:49:10 +0000 (UTC)
commit 0af5ec1a984bab06595a17bdb4abe8fbcfb1d473
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Dec 21 14:45:58 2015 -0800
combobox: use GtkIcon to render button arrow
We can now use the newly introduced GtkIcon widget to properly render
the arrow in the combobox with CSS.
gtk/gtkcombobox.c | 31 ++++++++---------------------
gtk/theme/Adwaita/_common.scss | 6 ++++-
gtk/theme/Adwaita/gtk-contained-dark.css | 5 +++-
gtk/theme/Adwaita/gtk-contained.css | 5 +++-
gtk/ui/gtkcombobox.ui | 4 +-
5 files changed, 24 insertions(+), 27 deletions(-)
---
diff --git a/gtk/gtkcombobox.c b/gtk/gtkcombobox.c
index d89e89c..03c5836 100644
--- a/gtk/gtkcombobox.c
+++ b/gtk/gtkcombobox.c
@@ -29,6 +29,7 @@
#include "gtkcssnodeprivate.h"
#include "gtkeventbox.h"
#include "gtkframe.h"
+#include "gtkiconprivate.h"
#include "gtkbox.h"
#include "gtkliststore.h"
#include "gtkmain.h"
@@ -93,10 +94,12 @@
* |[<!-- language="plain" -->
* combobox
* ╰── button.combo
+ * ╰── arrow
* ]|
*
* GtkComboBox has a single CSS node with name combobox. It adds the
* .combo style class to the button that it contains.
+ * The button also contains another node with name arrow.
*/
@@ -1017,6 +1020,9 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
* by arrow size.
*
* Since: 2.12
+ *
+ * Deprecated: 3.20: use the standard min-width/min-height CSS properties on
+ * the arrow node; the value of this style property is ignored.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("arrow-size",
@@ -1033,7 +1039,8 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
* Sets the amount of space used up by the combobox arrow,
* proportional to the font size.
*
- * Since: 3.2
+ * Deprecated: 3.20: use the standard min-width/min-height CSS properties on
+ * the arrow node; the value of this style property is ignored.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_float ("arrow-scaling",
@@ -1120,6 +1127,7 @@ gtk_combo_box_init (GtkComboBox *combo_box)
priv->text_renderer = NULL;
priv->id_column = -1;
+ g_type_ensure (GTK_TYPE_ICON);
gtk_widget_init_template (GTK_WIDGET (combo_box));
gtk_widget_add_events (priv->button, GDK_SCROLL_MASK);
@@ -5030,14 +5038,10 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
{
GtkComboBox *combo_box = GTK_COMBO_BOX (widget);
GtkComboBoxPrivate *priv = combo_box->priv;
- gint font_size, arrow_size;
- PangoContext *context;
- PangoFontMetrics *metrics;
GtkWidget *child;
gint child_min, child_nat;
gint but_min, but_nat;
GtkBorder padding;
- gfloat arrow_scaling;
gint dummy;
/* https://bugzilla.gnome.org/show_bug.cgi?id=729496 */
@@ -5051,25 +5055,8 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
else
gtk_widget_get_preferred_width (child, &child_min, &child_nat);
- gtk_widget_style_get (GTK_WIDGET (widget),
- "arrow-size", &arrow_size,
- "arrow-scaling", &arrow_scaling,
- NULL);
-
get_widget_padding_and_border (widget, &padding);
- context = gtk_widget_get_pango_context (GTK_WIDGET (widget));
- metrics = pango_context_get_metrics (context,
- pango_context_get_font_description (context),
- pango_context_get_language (context));
- font_size = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
- pango_font_metrics_get_descent (metrics));
- pango_font_metrics_unref (metrics);
-
- arrow_size = MAX (arrow_size, font_size) * arrow_scaling;
-
- gtk_widget_set_size_request (priv->arrow, arrow_size, arrow_size);
-
gtk_widget_get_preferred_width (priv->button,
&but_min, &but_nat);
diff --git a/gtk/theme/Adwaita/_common.scss b/gtk/theme/Adwaita/_common.scss
index fd40259..394df05 100644
--- a/gtk/theme/Adwaita/_common.scss
+++ b/gtk/theme/Adwaita/_common.scss
@@ -945,7 +945,6 @@ combobox {
> button.combo { padding-top: 3px; padding-bottom: 4px; } // Otherwise combos
// are bigger then
// buttons
- -GtkComboBox-arrow-scaling: 0.5;
-GtkComboBox-shadow-type: none;
@include _button_text_shadow;
@@ -963,6 +962,11 @@ combobox {
&:backdrop:insensitive {
color: $backdrop_insensitive_color;
}
+ & arrow {
+ -gtk-icon-source: -gtk-icontheme('pan-down-symbolic');
+ min-height: 16px;
+ min-width: 16px;
+ }
& menuitem { text-shadow: none; }
&.separator.vertical {
// always disable separators
diff --git a/gtk/theme/Adwaita/gtk-contained-dark.css b/gtk/theme/Adwaita/gtk-contained-dark.css
index 0df8a74..83016d1 100644
--- a/gtk/theme/Adwaita/gtk-contained-dark.css
+++ b/gtk/theme/Adwaita/gtk-contained-dark.css
@@ -1511,7 +1511,6 @@ treeview spinbutton entry, treeview spinbutton spinbutton, treeview spinbutton e
* ComboBoxes *
**************/
combobox {
- -GtkComboBox-arrow-scaling: 0.5;
-GtkComboBox-shadow-type: none;
text-shadow: 0 -1px rgba(0, 0, 0, 0.81176);
-gtk-icon-shadow: 0 -1px rgba(0, 0, 0, 0.81176); }
@@ -1529,6 +1528,10 @@ combobox {
-gtk-icon-shadow: none; }
combobox:backdrop:insensitive {
color: #5d6767; }
+ combobox arrow {
+ -gtk-icon-source: -gtk-icontheme("pan-down-symbolic");
+ min-height: 16px;
+ min-width: 16px; }
combobox menuitem {
text-shadow: none; }
combobox.separator.vertical {
diff --git a/gtk/theme/Adwaita/gtk-contained.css b/gtk/theme/Adwaita/gtk-contained.css
index 660e410..50e4bee 100644
--- a/gtk/theme/Adwaita/gtk-contained.css
+++ b/gtk/theme/Adwaita/gtk-contained.css
@@ -1511,7 +1511,6 @@ treeview spinbutton entry, treeview spinbutton spinbutton, treeview spinbutton e
* ComboBoxes *
**************/
combobox {
- -GtkComboBox-arrow-scaling: 0.5;
-GtkComboBox-shadow-type: none;
text-shadow: 0 1px rgba(255, 255, 255, 0.76923);
-gtk-icon-shadow: 0 1px rgba(255, 255, 255, 0.76923); }
@@ -1529,6 +1528,10 @@ combobox {
-gtk-icon-shadow: none; }
combobox:backdrop:insensitive {
color: #c3c3c0; }
+ combobox arrow {
+ -gtk-icon-source: -gtk-icontheme("pan-down-symbolic");
+ min-height: 16px;
+ min-width: 16px; }
combobox menuitem {
text-shadow: none; }
combobox.separator.vertical {
diff --git a/gtk/ui/gtkcombobox.ui b/gtk/ui/gtkcombobox.ui
index ad4d5bd..b6f3515 100644
--- a/gtk/ui/gtkcombobox.ui
+++ b/gtk/ui/gtkcombobox.ui
@@ -10,9 +10,9 @@
<object class="GtkBox">
<property name="visible">1</property>
<child>
- <object class="GtkImage" id="arrow">
+ <object class="GtkIcon" id="arrow">
<property name="visible">1</property>
- <property name="icon-name">pan-down-symbolic</property>
+ <property name="css_name">arrow</property>
</object>
<packing>
<property name="pack_type">end</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]