[gtk/prop-list: 66/75] Add rubberband api
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/prop-list: 66/75] Add rubberband api
- Date: Mon, 23 Dec 2019 20:32:31 +0000 (UTC)
commit 94ef94458d9537b6b526c0ec94b59ef987adc049
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Dec 23 14:47:19 2019 -0500
Add rubberband api
Add an enable-rubberband property to GtkListView,
GtkGridView and GtkColumnView.
docs/reference/gtk/gtk4-sections.txt | 6 ++++
gtk/gtkcolumnview.c | 59 ++++++++++++++++++++++++++++++++++++
gtk/gtkcolumnview.h | 7 +++++
gtk/gtkgridview.c | 57 ++++++++++++++++++++++++++++++++++
gtk/gtkgridview.h | 5 +++
gtk/gtklistview.c | 58 +++++++++++++++++++++++++++++++++++
gtk/gtklistview.h | 6 ++++
7 files changed, 198 insertions(+)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 63bfd531d9..17c37db1e0 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -577,6 +577,8 @@ gtk_list_view_set_show_separators
gtk_list_view_get_show_separators
gtk_list_view_set_single_click_activate
gtk_list_view_get_single_click_activate
+gtk_list_view_set_enable_rubberband
+gtk_list_view_get_enable_rubberband
<SUBSECTION Standard>
GTK_LIST_VIEW
GTK_LIST_VIEW_CLASS
@@ -602,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_enable_rubberband
+gtk_column_view_get_enable_rubberband
gtk_column_view_sort_by_column
<SUBSECTION Standard>
GTK_COLUMN_VIEW
@@ -653,6 +657,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_enable_rubberband
+gtk_grid_view_get_enable_rubberband
<SUBSECTION Standard>
GTK_GRID_VIEW
GTK_GRID_VIEW_CLASS
diff --git a/gtk/gtkcolumnview.c b/gtk/gtkcolumnview.c
index 064c49a683..db17e3100e 100644
--- a/gtk/gtkcolumnview.c
+++ b/gtk/gtkcolumnview.c
@@ -102,6 +102,7 @@ enum
PROP_SORTER,
PROP_VADJUSTMENT,
PROP_VSCROLL_POLICY,
+ PROP_ENABLE_RUBBERBAND,
N_PROPS
};
@@ -370,6 +371,10 @@ gtk_column_view_get_property (GObject *object,
g_value_set_object (value, self->sorter);
break;
+ case PROP_ENABLE_RUBBERBAND:
+ g_value_set_boolean (value, gtk_column_view_get_enable_rubberband (self));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -437,6 +442,10 @@ gtk_column_view_set_property (GObject *object,
}
break;
+ case PROP_ENABLE_RUBBERBAND:
+ gtk_column_view_set_enable_rubberband (self, g_value_get_boolean (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -521,6 +530,18 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
GTK_TYPE_SORTER,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
+ /**
+ * GtkColumnView:enable-rubberband:
+ *
+ * Allow rubberband selection
+ */
+ properties[PROP_ENABLE_RUBBERBAND] =
+ g_param_spec_boolean ("enable-rubberband",
+ P_("Enable rubberband selection"),
+ P_("Allow selecting items by dragging with the mouse"),
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (gobject_class, N_PROPS, properties);
/**
@@ -1252,3 +1273,41 @@ gtk_column_view_sort_by_column (GtkColumnView *self,
column,
direction == GTK_SORT_DESCENDING);
}
+
+/**
+ * gtk_column_view_set_enable_rubberband:
+ * @self: a #GtkColumnView
+ * @enable_rubberband: %TRUE to enable rubberband selection
+ *
+ * Sets whether selections can be changed by dragging with the mouse.
+ */
+void
+gtk_column_view_set_enable_rubberband (GtkColumnView *self,
+ gboolean enable_rubberband)
+{
+ g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
+
+ if (enable_rubberband == gtk_list_view_get_enable_rubberband (self->listview))
+ return;
+
+ gtk_list_view_set_enable_rubberband (self->listview, enable_rubberband);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ENABLE_RUBBERBAND]);
+}
+
+/**
+ * gtk_column_view_get_enable_rubberband:
+ * @self: a #GtkColumnView
+ *
+ * Returns whether rows can be selected by dragging with the mouse.
+ *
+ * Returns: %TRUE if rubberband selection is enabled
+ */
+gboolean
+gtk_column_view_get_enable_rubberband (GtkColumnView *self)
+{
+ g_return_val_if_fail (GTK_IS_COLUMN_VIEW (self), FALSE);
+
+ return gtk_list_view_get_enable_rubberband (self->listview);
+}
+
diff --git a/gtk/gtkcolumnview.h b/gtk/gtkcolumnview.h
index a8f73933c4..594b9c8fd4 100644
--- a/gtk/gtkcolumnview.h
+++ b/gtk/gtkcolumnview.h
@@ -86,6 +86,13 @@ void gtk_column_view_sort_by_column (GtkColumnView
GtkColumnViewColumn *column,
GtkSortType direction);
+GDK_AVAILABLE_IN_ALL
+void gtk_column_view_set_enable_rubberband (GtkColumnView *self,
+ gboolean enable_rubberband);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_column_view_get_enable_rubberband (GtkColumnView *self);
+
+
G_END_DECLS
#endif /* __GTK_COLUMN_VIEW_H__ */
diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c
index 4184552d5e..e4da2ceafb 100644
--- a/gtk/gtkgridview.c
+++ b/gtk/gtkgridview.c
@@ -90,6 +90,7 @@ enum
PROP_MAX_COLUMNS,
PROP_MIN_COLUMNS,
PROP_MODEL,
+ PROP_ENABLE_RUBBERBAND,
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_ENABLE_RUBBERBAND:
+ g_value_set_boolean (value, gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (self)));
+ 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_ENABLE_RUBBERBAND:
+ gtk_grid_view_set_enable_rubberband (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:enable-rubberband:
+ *
+ * Allow rubberband selection
+ */
+ properties[PROP_ENABLE_RUBBERBAND] =
+ g_param_spec_boolean ("enable-rubberband",
+ P_("Enable rubberband selection"),
+ P_("Allow selecting items by dragging with the mouse"),
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (gobject_class, N_PROPS, properties);
/**
@@ -1311,3 +1332,39 @@ gtk_grid_view_set_min_columns (GtkGridView *self,
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_MIN_COLUMNS]);
}
+/**
+ * gtk_grid_view_set_enable_rubberband:
+ * @self: a #GtkGridView
+ * @enable_rubberband: %TRUE to enable rubberband selection
+ *
+ * Sets whether selections can be changed by dragging with the mouse.
+ */
+void
+gtk_grid_view_set_enable_rubberband (GtkGridView *self,
+ gboolean enable_rubberband)
+{
+ g_return_if_fail (GTK_IS_GRID_VIEW (self));
+
+ if (enable_rubberband == gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (self)))
+ return;
+
+ gtk_list_base_set_enable_rubberband (GTK_LIST_BASE (self), enable_rubberband);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ENABLE_RUBBERBAND]);
+}
+
+/**
+ * gtk_grid_view_get_enable_rubberband:
+ * @self: a #GtkGridView
+ *
+ * Returns whether rows can be selected by dragging with the mouse.
+ *
+ * Returns: %TRUE if rubberband selection is enabled
+ */
+gboolean
+gtk_grid_view_get_enable_rubberband (GtkGridView *self)
+{
+ g_return_val_if_fail (GTK_IS_GRID_VIEW (self), FALSE);
+
+ return gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (self));
+}
diff --git a/gtk/gtkgridview.h b/gtk/gtkgridview.h
index cba7769401..ca8c731d2c 100644
--- a/gtk/gtkgridview.h
+++ b/gtk/gtkgridview.h
@@ -73,6 +73,11 @@ 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_enable_rubberband (GtkGridView *self,
+ gboolean enable_rubberband);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_grid_view_get_enable_rubberband (GtkGridView *self);
G_END_DECLS
diff --git a/gtk/gtklistview.c b/gtk/gtklistview.c
index 272be9d46f..de5249e6b1 100644
--- a/gtk/gtklistview.c
+++ b/gtk/gtklistview.c
@@ -85,6 +85,7 @@ enum
PROP_MODEL,
PROP_SHOW_SEPARATORS,
PROP_SINGLE_CLICK_ACTIVATE,
+ PROP_ENABLE_RUBBERBAND,
N_PROPS
};
@@ -643,6 +644,10 @@ gtk_list_view_get_property (GObject *object,
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;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -675,6 +680,10 @@ gtk_list_view_set_property (GObject *object,
gtk_list_view_set_single_click_activate (self, g_value_get_boolean (value));
break;
+ case PROP_ENABLE_RUBBERBAND:
+ gtk_list_view_set_enable_rubberband (self, g_value_get_boolean (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -771,6 +780,18 @@ gtk_list_view_class_init (GtkListViewClass *klass)
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * GtkListView:enable-rubberband:
+ *
+ * Allow rubberband selection
+ */
+ properties[PROP_ENABLE_RUBBERBAND] =
+ g_param_spec_boolean ("enable-rubberband",
+ P_("Enable rubberband selection"),
+ P_("Allow selecting items by dragging with the mouse"),
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
g_object_class_install_properties (gobject_class, N_PROPS, properties);
/**
@@ -1033,3 +1054,40 @@ gtk_list_view_get_single_click_activate (GtkListView *self)
return gtk_list_item_manager_get_single_click_activate (self->item_manager);
}
+
+/**
+ * gtk_list_view_set_enable_rubberband:
+ * @self: a #GtkListView
+ * @enable_rubberband: %TRUE to enable rubberband selection
+ *
+ * Sets whether selections can be changed by dragging with the mouse.
+ */
+void
+gtk_list_view_set_enable_rubberband (GtkListView *self,
+ gboolean enable_rubberband)
+{
+ g_return_if_fail (GTK_IS_LIST_VIEW (self));
+
+ if (enable_rubberband == gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (self)))
+ return;
+
+ gtk_list_base_set_enable_rubberband (GTK_LIST_BASE (self), enable_rubberband);
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ENABLE_RUBBERBAND]);
+}
+
+/**
+ * gtk_list_view_get_enable_rubberband:
+ * @self: a #GtkListView
+ *
+ * Returns whether rows can be selected by dragging with the mouse.
+ *
+ * Returns: %TRUE if rubberband selection is enabled
+ */
+gboolean
+gtk_list_view_get_enable_rubberband (GtkListView *self)
+{
+ g_return_val_if_fail (GTK_IS_LIST_VIEW (self), FALSE);
+
+ return gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (self));
+}
diff --git a/gtk/gtklistview.h b/gtk/gtklistview.h
index f00bcf7e3f..afcfb6225f 100644
--- a/gtk/gtklistview.h
+++ b/gtk/gtklistview.h
@@ -75,6 +75,12 @@ void gtk_list_view_set_single_click_activate (GtkListView
GDK_AVAILABLE_IN_ALL
gboolean gtk_list_view_get_single_click_activate (GtkListView *self);
+GDK_AVAILABLE_IN_ALL
+void gtk_list_view_set_enable_rubberband (GtkListView *self,
+ gboolean enable_rubberband);
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_list_view_get_enable_rubberband (GtkListView *self);
+
G_END_DECLS
#endif /* __GTK_LIST_VIEW_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]