[gtk/columnview-separators: 30/30] columnview: Add a property for column separators
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/columnview-separators: 30/30] columnview: Add a property for column separators
- Date: Wed, 3 Jun 2020 21:58:25 +0000 (UTC)
commit 4b683629816ea3a1809d7e8d99a44cc10d33bbbe
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Jun 3 17:34:35 2020 -0400
columnview: Add a property for column separators
Rename the show-separators property to show-row-separators,
and add a matching show-column-separators property. It is
implemented by setting the .column-separators style class
on the column view.
docs/reference/gtk/gtk4-sections.txt | 6 +-
gtk/gtkcolumnview.c | 106 ++++++++++++++++++++++++++++-------
gtk/gtkcolumnview.h | 12 +++-
3 files changed, 99 insertions(+), 25 deletions(-)
---
diff --git a/docs/reference/gtk/gtk4-sections.txt b/docs/reference/gtk/gtk4-sections.txt
index 5e61658a0a..8e88c6d1db 100644
--- a/docs/reference/gtk/gtk4-sections.txt
+++ b/docs/reference/gtk/gtk4-sections.txt
@@ -514,8 +514,10 @@ gtk_column_view_get_columns
gtk_column_view_get_model
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_get_show_row_separators
+gtk_column_view_set_show_row_separators
+gtk_column_view_get_show_column_separators
+gtk_column_view_set_show_column_separators
gtk_column_view_sort_by_column
gtk_column_view_set_single_click_activate
gtk_column_view_get_single_click_activate
diff --git a/gtk/gtkcolumnview.c b/gtk/gtkcolumnview.c
index 2a8080733b..e7ef11d797 100644
--- a/gtk/gtkcolumnview.c
+++ b/gtk/gtkcolumnview.c
@@ -73,6 +73,7 @@ struct _GtkColumnView
GtkAdjustment *hadjustment;
gboolean reorderable;
+ gboolean show_column_separators;
gboolean in_column_resize;
gboolean in_column_reorder;
@@ -100,7 +101,8 @@ enum
PROP_HADJUSTMENT,
PROP_HSCROLL_POLICY,
PROP_MODEL,
- PROP_SHOW_SEPARATORS,
+ PROP_SHOW_ROW_SEPARATORS,
+ PROP_SHOW_COLUMN_SEPARATORS,
PROP_SORTER,
PROP_VADJUSTMENT,
PROP_VSCROLL_POLICY,
@@ -378,10 +380,14 @@ gtk_column_view_get_property (GObject *object,
g_value_set_object (value, gtk_list_view_get_model (self->listview));
break;
- case PROP_SHOW_SEPARATORS:
+ case PROP_SHOW_ROW_SEPARATORS:
g_value_set_boolean (value, gtk_list_view_get_show_separators (self->listview));
break;
+ case PROP_SHOW_COLUMN_SEPARATORS:
+ g_value_set_boolean (value, self->show_column_separators);
+ break;
+
case PROP_VADJUSTMENT:
g_value_set_object (value, gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (self->listview)));
break;
@@ -453,8 +459,12 @@ gtk_column_view_set_property (GObject *object,
gtk_column_view_set_model (self, g_value_get_object (value));
break;
- case PROP_SHOW_SEPARATORS:
- gtk_column_view_set_show_separators (self, g_value_get_boolean (value));
+ case PROP_SHOW_ROW_SEPARATORS:
+ gtk_column_view_set_show_row_separators (self, g_value_get_boolean (value));
+ break;
+
+ case PROP_SHOW_COLUMN_SEPARATORS:
+ gtk_column_view_set_show_column_separators (self, g_value_get_boolean (value));
break;
case PROP_VADJUSTMENT:
@@ -546,17 +556,29 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
- * GtkColumnView:show-separators:
+ * GtkColumnView:show-row-separators:
*
* Show separators between rows
*/
- properties[PROP_SHOW_SEPARATORS] =
- g_param_spec_boolean ("show-separators",
- P_("Show separators"),
+ properties[PROP_SHOW_ROW_SEPARATORS] =
+ g_param_spec_boolean ("show-row-separators",
+ P_("Show row separators"),
P_("Show separators between rows"),
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+ /**
+ * GtkColumnView:show-column-separators:
+ *
+ * Show separators between columns
+ */
+ properties[PROP_SHOW_COLUMN_SEPARATORS] =
+ g_param_spec_boolean ("show-column-separators",
+ P_("Show column separators"),
+ P_("Show separators between columns"),
+ FALSE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
+
/**
* GtkColumnView:sorter:
*
@@ -712,7 +734,7 @@ gtk_column_view_in_header (GtkColumnView *self,
GtkWidget *header;
graphene_rect_t rect;
- header = gtk_column_view_column_get_header (column);
+header = gtk_column_view_column_get_header (column);
if (!gtk_widget_compute_bounds (header, self->header, &rect))
return FALSE;
@@ -1112,44 +1134,88 @@ gtk_column_view_get_columns (GtkColumnView *self)
}
/**
- * gtk_column_view_set_show_separators:
+ * gtk_column_view_set_show_row_separators:
* @self: a #GtkColumnView
- * @show_separators: %TRUE to show separators
+ * @show_separators: %TRUE to show row separators
*
* Sets whether the list should show separators
* between rows.
*/
void
-gtk_column_view_set_show_separators (GtkColumnView *self,
- gboolean show_separators)
+gtk_column_view_set_show_row_separators (GtkColumnView *self,
+ gboolean show_row_separators)
{
g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
- if (gtk_list_view_get_show_separators (self->listview) == show_separators)
+ if (gtk_list_view_get_show_separators (self->listview) == show_row_separators)
return;
- gtk_list_view_set_show_separators (self->listview, show_separators);
+ gtk_list_view_set_show_separators (self->listview, show_row_separators);
- g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_SEPARATORS]);
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_ROW_SEPARATORS]);
}
/**
- * gtk_column_view_get_show_separators:
+ * gtk_column_view_get_show_row_separators:
* @self: a #GtkColumnView
*
- * Returns whether the list box should show separators
+ * Returns whether the list should show separators
* between rows.
*
- * Returns: %TRUE if the list box shows separators
+ * Returns: %TRUE if the list shows separators
*/
gboolean
-gtk_column_view_get_show_separators (GtkColumnView *self)
+gtk_column_view_get_show_row_separators (GtkColumnView *self)
{
g_return_val_if_fail (GTK_IS_COLUMN_VIEW (self), FALSE);
return gtk_list_view_get_show_separators (self->listview);
}
+/**
+ * gtk_column_view_set_show_column_separators:
+ * @self: a #GtkColumnView
+ * @show_column_separators: %TRUE to show column separators
+ *
+ * Sets whether the list should show separators
+ * between columns.
+ */
+void
+gtk_column_view_set_show_column_separators (GtkColumnView *self,
+ gboolean show_column_separators)
+{
+ g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
+
+ if (self->show_column_separators == show_column_separators)
+ return;
+
+ self->show_column_separators = show_column_separators;
+
+ if (show_column_separators)
+ gtk_widget_add_css_class (GTK_WIDGET (self), "column-separators");
+ else
+ gtk_widget_remove_css_class (GTK_WIDGET (self), "column-separators");
+
+ g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_COLUMN_SEPARATORS]);
+}
+
+/**
+ * gtk_column_view_get_show_column_separators:
+ * @self: a #GtkColumnView
+ *
+ * Returns whether the list should show separators
+ * between columns.
+ *
+ * Returns: %TRUE if the list shows column separators
+ */
+gboolean
+gtk_column_view_get_show_column_separators (GtkColumnView *self)
+{
+ g_return_val_if_fail (GTK_IS_COLUMN_VIEW (self), FALSE);
+
+ return self->show_column_separators;
+}
+
/**
* gtk_column_view_append_column:
* @self: a #GtkColumnView
diff --git a/gtk/gtkcolumnview.h b/gtk/gtkcolumnview.h
index 69bf8c7a19..fb393e4ac6 100644
--- a/gtk/gtkcolumnview.h
+++ b/gtk/gtkcolumnview.h
@@ -73,10 +73,16 @@ void gtk_column_view_set_model (GtkColumnView
GListModel *model);
GDK_AVAILABLE_IN_ALL
-gboolean gtk_column_view_get_show_separators (GtkColumnView *self);
+gboolean gtk_column_view_get_show_row_separators (GtkColumnView *self);
GDK_AVAILABLE_IN_ALL
-void gtk_column_view_set_show_separators (GtkColumnView *self,
- gboolean show_separators);
+void gtk_column_view_set_show_row_separators (GtkColumnView *self,
+ gboolean
show_row_separators);
+
+GDK_AVAILABLE_IN_ALL
+gboolean gtk_column_view_get_show_column_separators (GtkColumnView *self);
+GDK_AVAILABLE_IN_ALL
+void gtk_column_view_set_show_column_separators (GtkColumnView *self,
+ gboolean
show_column_separators);
GDK_AVAILABLE_IN_ALL
GtkSorter * gtk_column_view_get_sorter (GtkColumnView *self);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]