[gtk/columnview-rubberbanding: 62/63] Add rubberband api
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/columnview-rubberbanding: 62/63] Add rubberband api
- Date: Wed, 3 Jun 2020 17:44:41 +0000 (UTC)
commit 03c2202942f859fd7eca248f30c6edf49be2cb3c
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 | 58 ++++++++++++++++++++++++++++++++++++
gtk/gtkcolumnview.h | 5 ++++
gtk/gtkgridview.c | 58 ++++++++++++++++++++++++++++++++++++
gtk/gtkgridview.h | 5 ++++
gtk/gtklistview.c | 58 ++++++++++++++++++++++++++++++++++++
gtk/gtklistview.h | 6 ++++
7 files changed, 196 insertions(+)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 616d852bff..5e61658a0a 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -489,6 +489,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
@@ -519,6 +521,8 @@ gtk_column_view_set_single_click_activate
gtk_column_view_get_single_click_activate
gtk_column_view_set_reorderable
gtk_column_view_get_reorderable
+gtk_column_view_set_enable_rubberband
+gtk_column_view_get_enable_rubberband
<SUBSECTION Standard>
GTK_COLUMN_VIEW
GTK_COLUMN_VIEW_CLASS
@@ -578,6 +582,8 @@ 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>
GTK_GRID_VIEW
GTK_GRID_VIEW_CLASS
diff --git a/gtk/gtkcolumnview.c b/gtk/gtkcolumnview.c
index a3640fc64e..2a8080733b 100644
--- a/gtk/gtkcolumnview.c
+++ b/gtk/gtkcolumnview.c
@@ -106,6 +106,7 @@ enum
PROP_VSCROLL_POLICY,
PROP_SINGLE_CLICK_ACTIVATE,
PROP_REORDERABLE,
+ PROP_ENABLE_RUBBERBAND,
N_PROPS
};
@@ -401,6 +402,10 @@ gtk_column_view_get_property (GObject *object,
g_value_set_boolean (value, gtk_column_view_get_reorderable (self));
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;
@@ -476,6 +481,10 @@ gtk_column_view_set_property (GObject *object,
gtk_column_view_set_reorderable (self, g_value_get_boolean (value));
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;
@@ -584,6 +593,18 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
TRUE,
G_PARAM_READWRITE | 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);
/**
@@ -1404,3 +1425,40 @@ gtk_column_view_get_reorderable (GtkColumnView *self)
return self->reorderable;
}
+
+/**
+ * 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 5cff5d73dc..69bf8c7a19 100644
--- a/gtk/gtkcolumnview.h
+++ b/gtk/gtkcolumnview.h
@@ -93,11 +93,16 @@ GDK_AVAILABLE_IN_ALL
gboolean gtk_column_view_get_single_click_activate (GtkColumnView *self);
GDK_AVAILABLE_IN_ALL
+
void gtk_column_view_set_reorderable (GtkColumnView *self,
gboolean reorderable);
GDK_AVAILABLE_IN_ALL
gboolean gtk_column_view_get_reorderable (GtkColumnView *self);
+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
diff --git a/gtk/gtkgridview.c b/gtk/gtkgridview.c
index 7590446858..f6b93b3dec 100644
--- a/gtk/gtkgridview.c
+++ b/gtk/gtkgridview.c
@@ -91,6 +91,7 @@ enum
PROP_MIN_COLUMNS,
PROP_MODEL,
PROP_SINGLE_CLICK_ACTIVATE,
+ PROP_ENABLE_RUBBERBAND,
N_PROPS
};
@@ -916,6 +917,10 @@ gtk_grid_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;
@@ -952,6 +957,10 @@ gtk_grid_view_set_property (GObject *object,
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;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -1064,6 +1073,18 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * 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);
/**
@@ -1372,3 +1393,40 @@ gtk_grid_view_get_single_click_activate (GtkGridView *self)
return gtk_list_item_manager_get_single_click_activate (self->item_manager);
}
+
+/**
+ * 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 7b78fe15e8..6fb035ce12 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);
GDK_AVAILABLE_IN_ALL
void gtk_grid_view_set_single_click_activate (GtkGridView *self,
diff --git a/gtk/gtklistview.c b/gtk/gtklistview.c
index 811636e6e0..35a3df9339 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
};
@@ -645,6 +646,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;
@@ -677,6 +682,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;
@@ -773,6 +782,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);
/**
@@ -1035,3 +1056,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]