[gtk/prop-list: 75/75] Spread single-click-activate api
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/prop-list: 75/75] Spread single-click-activate api
- Date: Mon, 23 Dec 2019 20:33:16 +0000 (UTC)
commit 702d082d80cd7d65811c5252b600e56619de08cd
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 | 60 ++++++++++++++++++++++++++++++++++++
gtk/gtkcolumnview.h | 6 ++++
gtk/gtkgridview.c | 60 ++++++++++++++++++++++++++++++++++++
gtk/gtkgridview.h | 7 +++++
5 files changed, 137 insertions(+)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 17c37db1e0..78fb95aa0c 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -604,6 +604,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
gtk_column_view_set_enable_rubberband
gtk_column_view_get_enable_rubberband
gtk_column_view_sort_by_column
@@ -657,6 +659,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
gtk_grid_view_set_enable_rubberband
gtk_grid_view_get_enable_rubberband
<SUBSECTION Standard>
diff --git a/gtk/gtkcolumnview.c b/gtk/gtkcolumnview.c
index 2439d0f81c..1c54b4fd71 100644
--- a/gtk/gtkcolumnview.c
+++ b/gtk/gtkcolumnview.c
@@ -102,6 +102,7 @@ enum
PROP_SORTER,
PROP_VADJUSTMENT,
PROP_VSCROLL_POLICY,
+ PROP_SINGLE_CLICK_ACTIVATE,
PROP_ENABLE_RUBBERBAND,
N_PROPS
@@ -390,6 +391,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;
+
case PROP_ENABLE_RUBBERBAND:
g_value_set_boolean (value, gtk_column_view_get_enable_rubberband (self));
break;
@@ -461,6 +466,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;
+
case PROP_ENABLE_RUBBERBAND:
gtk_column_view_set_enable_rubberband (self, g_value_get_boolean (value));
break;
@@ -549,6 +558,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);
+
/**
* GtkColumnView:enable-rubberband:
*
@@ -1293,6 +1314,45 @@ gtk_column_view_sort_by_column (GtkColumnView *self,
direction == GTK_SORT_DESCENDING);
}
+/**
+ * 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);
+}
+
/**
* gtk_column_view_set_enable_rubberband:
* @self: a #GtkColumnView
diff --git a/gtk/gtkcolumnview.h b/gtk/gtkcolumnview.h
index 594b9c8fd4..8b38986417 100644
--- a/gtk/gtkcolumnview.h
+++ b/gtk/gtkcolumnview.h
@@ -86,6 +86,12 @@ void gtk_column_view_sort_by_column (GtkColumnView
GtkColumnViewColumn *column,
GtkSortType direction);
+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);
+
GDK_AVAILABLE_IN_ALL
void gtk_column_view_set_enable_rubberband (GtkColumnView *self,
gboolean enable_rubberband);
diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c
index e4da2ceafb..01feba2c16 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,
PROP_ENABLE_RUBBERBAND,
N_PROPS
@@ -910,6 +911,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;
+
case PROP_ENABLE_RUBBERBAND:
g_value_set_boolean (value, gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (self)));
break;
@@ -946,6 +951,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;
+
case PROP_ENABLE_RUBBERBAND:
gtk_grid_view_set_enable_rubberband (self, g_value_get_boolean (value));
break;
@@ -1050,6 +1059,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);
+
/**
* GtkGridView:enable-rubberband:
*
@@ -1332,6 +1353,45 @@ 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);
+}
+
/**
* gtk_grid_view_set_enable_rubberband:
* @self: a #GtkGridView
diff --git a/gtk/gtkgridview.h b/gtk/gtkgridview.h
index ca8c731d2c..ff4007f1dc 100644
--- a/gtk/gtkgridview.h
+++ b/gtk/gtkgridview.h
@@ -73,6 +73,13 @@ guint gtk_grid_view_get_max_columns (GtkGridView
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);
+
GDK_AVAILABLE_IN_ALL
void gtk_grid_view_set_enable_rubberband (GtkGridView *self,
gboolean enable_rubberband);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]