Commit 5764c092 authored by Cosimo Cecchi's avatar Cosimo Cecchi

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.
parent 9b7473b6
......@@ -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",
......@@ -1025,7 +1031,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
0,
G_MAXINT,
15,
GTK_PARAM_READABLE));
GTK_PARAM_READABLE|G_PARAM_DEPRECATED));
/**
* GtkComboBox:arrow-scaling:
......@@ -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",
......@@ -1042,7 +1049,7 @@ gtk_combo_box_class_init (GtkComboBoxClass *klass)
0,
2.0,
1.0,
GTK_PARAM_READABLE));
GTK_PARAM_READABLE|G_PARAM_DEPRECATED));
/**
* GtkComboBox:shadow-type:
......@@ -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);
......
......@@ -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
......
......@@ -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 {
......
......@@ -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 {
......
......@@ -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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment