[gtk/listview-for-merge: 155/157] Spread single-click-activate api
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/listview-for-merge: 155/157] Spread single-click-activate api
- Date: Sat, 30 May 2020 19:32:32 +0000 (UTC)
commit 1b4b10db7c66778942630f4648d85db6f2d141ba
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Dec 23 15:22:35 2019 -0500
Spread single-click-activate api
This makes sense to have in all the views,
not just GtkListView.
docs/reference/gtk/gtk4-sections.txt | 4 +++
gtk/gtkcolumnview.c | 59 ++++++++++++++++++++++++++++++++++++
gtk/gtkcolumnview.h | 6 ++++
gtk/gtkgridview.c | 59 ++++++++++++++++++++++++++++++++++++
gtk/gtkgridview.h | 6 ++++
5 files changed, 134 insertions(+)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index c9730752de..9b7d828a5b 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -503,6 +503,8 @@ gtk_column_view_set_model
gtk_column_view_get_sorter
gtk_column_view_get_show_separators
gtk_column_view_set_show_separators
+gtk_column_view_set_single_click_activate
+gtk_column_view_get_single_click_activate
<SUBSECTION Standard>
GTK_COLUMN_VIEW
GTK_COLUMN_VIEW_CLASS
@@ -549,6 +551,8 @@ gtk_grid_view_set_max_columns
gtk_grid_view_get_max_columns
gtk_grid_view_set_min_columns
gtk_grid_view_get_min_columns
+gtk_grid_view_set_single_click_activate
+gtk_grid_view_get_single_click_activate
<SUBSECTION Standard>
GTK_GRID_VIEW
GTK_GRID_VIEW_CLASS
diff --git a/gtk/gtkcolumnview.c b/gtk/gtkcolumnview.c
index 9d3bf91299..737c07e2cf 100644
--- a/gtk/gtkcolumnview.c
+++ b/gtk/gtkcolumnview.c
@@ -81,6 +81,7 @@ enum
PROP_SORTER,
PROP_VADJUSTMENT,
PROP_VSCROLL_POLICY,
+ PROP_SINGLE_CLICK_ACTIVATE,
N_PROPS
};
@@ -317,6 +318,10 @@ gtk_column_view_get_property (GObject *object,
g_value_set_object (value, self->sorter);
break;
+ case PROP_SINGLE_CLICK_ACTIVATE:
+ g_value_set_boolean (value, gtk_column_view_get_single_click_activate (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -373,6 +378,10 @@ gtk_column_view_set_property (GObject *object,
}
break;
+ case PROP_SINGLE_CLICK_ACTIVATE:
+ gtk_column_view_set_single_click_activate (self, g_value_get_boolean (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -457,6 +466,18 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
GTK_TYPE_SORTER,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+ /**
+ * GtkColumnView:single-click-activate:
+ *
+ * Activate rows on single click and select them on hover
+ */
+ properties[PROP_SINGLE_CLICK_ACTIVATE] =
+ g_param_spec_boolean ("single-click-activate",
+ P_("Single click activate"),
+ P_("Activate rows on single click"),
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (gobject_class, N_PROPS, properties);
/**
@@ -736,3 +757,41 @@ gtk_column_view_get_sorter (GtkColumnView *self)
return self->sorter;
}
+/**
+ * gtk_column_view_set_single_click_activate:
+ * @self: a #GtkColumnView
+ * @single_click_activate: %TRUE to activate items on single click
+ *
+ * Sets whether rows should be activated on single click and
+ * selected on hover.
+ */
+void
+gtk_column_view_set_single_click_activate (GtkColumnView *self,
+ gboolean single_click_activate)
+{
+ g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
+
+ if (single_click_activate == gtk_list_view_get_single_click_activate (self->listview))
+ return;
+
+ gtk_list_view_set_single_click_activate (self->listview, single_click_activate);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SINGLE_CLICK_ACTIVATE]);
+}
+
+/**
+ * gtk_column_view_get_single_click_activate:
+ * @self: a #GtkColumnView
+ *
+ * Returns whether rows will be activated on single click and
+ * selected on hover.
+ *
+ * Returns: %TRUE if rows are activated on single click
+ */
+gboolean
+gtk_column_view_get_single_click_activate (GtkColumnView *self)
+{
+ g_return_val_if_fail (GTK_IS_COLUMN_VIEW (self), FALSE);
+
+ return gtk_list_view_get_single_click_activate (self->listview);
+}
diff --git a/gtk/gtkcolumnview.h b/gtk/gtkcolumnview.h
index 6ec91319e8..953ac55b6e 100644
--- a/gtk/gtkcolumnview.h
+++ b/gtk/gtkcolumnview.h
@@ -77,6 +77,12 @@ void gtk_column_view_set_show_separators (GtkColumnView
GDK_AVAILABLE_IN_ALL
GtkSorter * gtk_column_view_get_sorter (GtkColumnView *self);
+GDK_AVAILABLE_IN_ALL
+void gtk_column_view_set_single_click_activate (GtkColumnView *self,
+ gboolean
single_click_activate);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_column_view_get_single_click_activate (GtkColumnView *self);
+
G_END_DECLS
#endif /* __GTK_COLUMN_VIEW_H__ */
diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c
index 4184552d5e..debfcf0946 100644
--- a/gtk/gtkgridview.c
+++ b/gtk/gtkgridview.c
@@ -90,6 +90,7 @@ enum
PROP_MAX_COLUMNS,
PROP_MIN_COLUMNS,
PROP_MODEL,
+ PROP_SINGLE_CLICK_ACTIVATE,
N_PROPS
};
@@ -909,6 +910,10 @@ gtk_grid_view_get_property (GObject *object,
g_value_set_object (value, gtk_list_base_get_model (GTK_LIST_BASE (self)));
break;
+ case PROP_SINGLE_CLICK_ACTIVATE:
+ g_value_set_boolean (value, gtk_list_item_manager_get_single_click_activate (self->item_manager));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -941,6 +946,10 @@ gtk_grid_view_set_property (GObject *object,
gtk_grid_view_set_model (self, g_value_get_object (value));
break;
+ case PROP_SINGLE_CLICK_ACTIVATE:
+ gtk_grid_view_set_single_click_activate (self, g_value_get_boolean (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -1041,6 +1050,18 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
G_TYPE_LIST_MODEL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+ /**
+ * GtkGridView:single-click-activate:
+ *
+ * Activate rows on single click and select them on hover
+ */
+ properties[PROP_SINGLE_CLICK_ACTIVATE] =
+ g_param_spec_boolean ("single-click-activate",
+ P_("Single click activate"),
+ P_("Activate rows on single click"),
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (gobject_class, N_PROPS, properties);
/**
@@ -1311,3 +1332,41 @@ gtk_grid_view_set_min_columns (GtkGridView *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MIN_COLUMNS]);
}
+/**
+ * gtk_grid_view_set_single_click_activate:
+ * @self: a #GtkGridView
+ * @single_click_activate: %TRUE to activate items on single click
+ *
+ * Sets whether items should be activated on single click and
+ * selected on hover.
+ */
+void
+gtk_grid_view_set_single_click_activate (GtkGridView *self,
+ gboolean single_click_activate)
+{
+ g_return_if_fail (GTK_IS_GRID_VIEW (self));
+
+ if (single_click_activate == gtk_list_item_manager_get_single_click_activate (self->item_manager))
+ return;
+
+ gtk_list_item_manager_set_single_click_activate (self->item_manager, single_click_activate);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SINGLE_CLICK_ACTIVATE]);
+}
+
+/**
+ * gtk_grid_view_get_single_click_activate:
+ * @self: a #GtkListView
+ *
+ * Returns whether items will be activated on single click and
+ * selected on hover.
+ *
+ * Returns: %TRUE if items are activated on single click
+ */
+gboolean
+gtk_grid_view_get_single_click_activate (GtkGridView *self)
+{
+ g_return_val_if_fail (GTK_IS_GRID_VIEW (self), FALSE);
+
+ return gtk_list_item_manager_get_single_click_activate (self->item_manager);
+}
diff --git a/gtk/gtkgridview.h b/gtk/gtkgridview.h
index cba7769401..7b78fe15e8 100644
--- a/gtk/gtkgridview.h
+++ b/gtk/gtkgridview.h
@@ -74,6 +74,12 @@ GDK_AVAILABLE_IN_ALL
void gtk_grid_view_set_max_columns (GtkGridView *self,
guint max_columns);
+GDK_AVAILABLE_IN_ALL
+void gtk_grid_view_set_single_click_activate (GtkGridView *self,
+ gboolean
single_click_activate);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_grid_view_get_single_click_activate (GtkGridView *self);
+
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]