diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-12-13 20:56:32 -0500 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-05-30 19:26:46 -0400 |
commit | 69c86ae3855485bd9f68343233b7cdb6ef7f3712 (patch) | |
tree | d8954e56dfb649f92c86e83fd8356e20fe02c9c9 /gtk/gtklistitemmanager.c | |
parent | 21eac434c37c057f416aad4b1ec45152a281cd89 (diff) | |
download | gtk+-69c86ae3855485bd9f68343233b7cdb6ef7f3712.tar.gz |
listitemwidget: Add single-click-activate
Add a mode to GtkListItemWidget that activates on
single click and selects on hover. Make
GtkListItemManager set this on its items
when its own 'property' of the same name is set.
Diffstat (limited to 'gtk/gtklistitemmanager.c')
-rw-r--r-- | gtk/gtklistitemmanager.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/gtk/gtklistitemmanager.c b/gtk/gtklistitemmanager.c index 92221235b6..ef0570d45a 100644 --- a/gtk/gtklistitemmanager.c +++ b/gtk/gtklistitemmanager.c @@ -33,6 +33,7 @@ struct _GtkListItemManager GtkWidget *widget; GtkSelectionModel *model; GtkListItemFactory *factory; + gboolean single_click_activate; const char *item_css_name; GtkRbTree *items; @@ -932,6 +933,8 @@ gtk_list_item_manager_acquire_list_item (GtkListItemManager *self, result = gtk_list_item_widget_new (self->factory, self->item_css_name); + gtk_list_item_widget_set_single_click_activate (GTK_LIST_ITEM_WIDGET (result), self->single_click_activate); + item = g_list_model_get_item (G_LIST_MODEL (self->model), position); selected = gtk_selection_model_is_selected (self->model, position); gtk_list_item_widget_update (GTK_LIST_ITEM_WIDGET (result), position, item, selected); @@ -1079,6 +1082,33 @@ gtk_list_item_manager_release_list_item (GtkListItemManager *self, gtk_widget_unparent (item); } +void +gtk_list_item_manager_set_single_click_activate (GtkListItemManager *self, + gboolean single_click_activate) +{ + GtkListItemManagerItem *item; + + g_return_if_fail (GTK_IS_LIST_ITEM_MANAGER (self)); + + self->single_click_activate = single_click_activate; + + for (item = gtk_rb_tree_get_first (self->items); + item != NULL; + item = gtk_rb_tree_node_get_next (item)) + { + if (item->widget) + gtk_list_item_widget_set_single_click_activate (GTK_LIST_ITEM_WIDGET (item->widget), single_click_activate); + } +} + +gboolean +gtk_list_item_manager_get_single_click_activate (GtkListItemManager *self) +{ + g_return_val_if_fail (GTK_IS_LIST_ITEM_MANAGER (self), FALSE); + + return self->single_click_activate; +} + GtkListItemTracker * gtk_list_item_tracker_new (GtkListItemManager *self) { |