GtkWidget *popup;
GtkWidget *button;
+ GtkWidget *arrow;
GtkWidget *popup_list;
GtkWidget *button_stack;
GtkWidget *search_box;
GtkWidget *search_entry;
- gboolean enable_search;
GtkExpression *expression;
+
+ guint enable_search : 1;
+ guint show_arrow : 1;
};
struct _GtkDropDownClass
PROP_SELECTED_ITEM,
PROP_ENABLE_SEARCH,
PROP_EXPRESSION,
+ PROP_SHOW_ARROW,
N_PROPS
};
gtk_value_set_expression (value, self->expression);
break;
+ case PROP_SHOW_ARROW:
+ g_value_set_boolean (value, gtk_drop_down_get_show_arrow (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
gtk_drop_down_set_expression (self, gtk_value_get_expression (value));
break;
+ case PROP_SHOW_ARROW:
+ gtk_drop_down_set_show_arrow (self, g_value_get_boolean (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
P_("Expression to determine strings to search for"),
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+ /**
+ * GtkDropDown:show-arrow: (attributes org.gtk.Property.get=gtk_drop_down_get_show_arrow org.gtk.Property.set=gtk_drop_down_set_show_arrow)
+ *
+ * Whether to show an arrow within the GtkDropDown widget.
+ *
+ * Since: 4.6
+ */
+ properties[PROP_SHOW_ARROW] =
+ g_param_spec_boolean ("show-arrow",
+ P_("Show arrow"),
+ P_("Whether to show an arrow within the widget"),
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties (gobject_class, N_PROPS, properties);
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/libgtk/ui/gtkdropdown.ui");
+ gtk_widget_class_bind_template_child (widget_class, GtkDropDown, arrow);
gtk_widget_class_bind_template_child (widget_class, GtkDropDown, button);
gtk_widget_class_bind_template_child (widget_class, GtkDropDown, button_stack);
gtk_widget_class_bind_template_child (widget_class, GtkDropDown, button_item);
gtk_widget_init_template (GTK_WIDGET (self));
+ self->show_arrow = gtk_widget_get_visible (self->arrow);
+
set_default_factory (self);
}
if (!g_set_object (&self->list_factory, factory))
return;
-
+
if (self->list_factory != NULL)
gtk_list_view_set_factory (GTK_LIST_VIEW (self->popup_list), self->list_factory);
else
{
g_return_if_fail (GTK_IS_DROP_DOWN (self));
+ enable_search = !!enable_search;
+
if (self->enable_search == enable_search)
return;
gtk_editable_set_text (GTK_EDITABLE (self->search_entry), "");
gtk_widget_set_visible (self->search_box, enable_search);
-
+
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ENABLE_SEARCH]);
}
* Returns whether search is enabled.
*
* Returns: %TRUE if the popup includes a search entry
- **/
+ */
gboolean
gtk_drop_down_get_enable_search (GtkDropDown *self)
{
return self->expression;
}
+
+/**
+ * gtk_drop_down_set_show_arrow: (attributes org.gtk.Method.set_property=show-arrow)
+ * @self: a `GtkDropDown`
+ * @show_arrow: whether to show an arrow within the widget
+ *
+ * Sets whether an arrow will be displayed within the widget.
+ *
+ * Since: 4.6
+ */
+void
+gtk_drop_down_set_show_arrow (GtkDropDown *self,
+ gboolean show_arrow)
+{
+ g_return_if_fail (GTK_IS_DROP_DOWN (self));
+
+ show_arrow = !!show_arrow;
+
+ if (self->show_arrow == show_arrow)
+ return;
+
+ self->show_arrow = show_arrow;
+
+ gtk_widget_set_visible (self->arrow, show_arrow);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_ARROW]);
+}
+
+/**
+ * gtk_drop_down_get_show_arrow: (attributes org.gtk.Method.set_property=show-arrow)
+ * @self: a `GtkDropDown`
+ *
+ * Returns whether to show an arrow within the widget.
+ *
+ * Returns: %TRUE if an arrow will be shown.
+ *
+ * Since: 4.6
+ */
+gboolean
+gtk_drop_down_get_show_arrow (GtkDropDown *self)
+{
+ g_return_val_if_fail (GTK_IS_DROP_DOWN (self), FALSE);
+
+ return self->show_arrow;
+}