mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 06:00:22 +00:00
listview: Add gtk_list_view_set_show_separators()
Do the same thing that GtkListBox does in commit
0249bd4f8a
This commit is contained in:
parent
1acfae8df2
commit
0174bf4345
@ -436,6 +436,8 @@ GtkListView
|
||||
gtk_list_view_new
|
||||
gtk_list_view_set_model
|
||||
gtk_list_view_get_model
|
||||
gtk_list_view_set_show_separators
|
||||
gtk_list_view_get_show_separators
|
||||
<SUBSECTION Standard>
|
||||
GTK_LIST_VIEW
|
||||
GTK_LIST_VIEW_CLASS
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "gtkscrollable.h"
|
||||
#include "gtkselectionmodel.h"
|
||||
#include "gtksingleselection.h"
|
||||
#include "gtkstylecontext.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
|
||||
/* Maximum number of list items created by the listview.
|
||||
@ -60,6 +61,7 @@ struct _GtkListView
|
||||
GtkListItemManager *item_manager;
|
||||
GtkAdjustment *adjustment[2];
|
||||
GtkScrollablePolicy scroll_policy[2];
|
||||
gboolean show_separators;
|
||||
|
||||
int list_width;
|
||||
|
||||
@ -85,6 +87,7 @@ enum
|
||||
PROP_HADJUSTMENT,
|
||||
PROP_HSCROLL_POLICY,
|
||||
PROP_MODEL,
|
||||
PROP_SHOW_SEPARATORS,
|
||||
PROP_VADJUSTMENT,
|
||||
PROP_VSCROLL_POLICY,
|
||||
|
||||
@ -600,6 +603,10 @@ gtk_list_view_get_property (GObject *object,
|
||||
g_value_set_object (value, self->model);
|
||||
break;
|
||||
|
||||
case PROP_SHOW_SEPARATORS:
|
||||
g_value_set_boolean (value, self->show_separators);
|
||||
break;
|
||||
|
||||
case PROP_VADJUSTMENT:
|
||||
g_value_set_object (value, self->adjustment[GTK_ORIENTATION_VERTICAL]);
|
||||
break;
|
||||
@ -677,6 +684,10 @@ gtk_list_view_set_property (GObject *object,
|
||||
gtk_list_view_set_model (self, g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_SHOW_SEPARATORS:
|
||||
gtk_list_view_set_show_separators (self, g_value_get_boolean (value));
|
||||
break;
|
||||
|
||||
case PROP_VADJUSTMENT:
|
||||
gtk_list_view_set_adjustment (self, GTK_ORIENTATION_VERTICAL, g_value_get_object (value));
|
||||
break;
|
||||
@ -761,6 +772,18 @@ gtk_list_view_class_init (GtkListViewClass *klass)
|
||||
G_TYPE_LIST_MODEL,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
||||
|
||||
/**
|
||||
* GtkListView:show-separators:
|
||||
*
|
||||
* Show separators between rows
|
||||
*/
|
||||
properties[PROP_SHOW_SEPARATORS] =
|
||||
g_param_spec_boolean ("show-separators",
|
||||
P_("Show separators"),
|
||||
P_("Show separators between rows"),
|
||||
FALSE,
|
||||
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
||||
|
||||
/**
|
||||
@ -897,3 +920,46 @@ gtk_list_view_set_functions (GtkListView *self,
|
||||
g_object_unref (factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_list_view_set_show_separators:
|
||||
* @self: a #GtkListView
|
||||
* @show_separators: %TRUE to show separators
|
||||
*
|
||||
* Sets whether the list box should show separators
|
||||
* between rows.
|
||||
*/
|
||||
void
|
||||
gtk_list_view_set_show_separators (GtkListView *self,
|
||||
gboolean show_separators)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_LIST_VIEW (self));
|
||||
|
||||
if (self->show_separators == show_separators)
|
||||
return;
|
||||
|
||||
self->show_separators = show_separators;
|
||||
|
||||
if (show_separators)
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)), "separators");
|
||||
else
|
||||
gtk_style_context_remove_class (gtk_widget_get_style_context (GTK_WIDGET (self)), "separators");
|
||||
|
||||
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SHOW_SEPARATORS]);
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_list_view_get_show_separators:
|
||||
* @self: a #GtkListView
|
||||
*
|
||||
* Returns whether the list box should show separators
|
||||
* between rows.
|
||||
*
|
||||
* Returns: %TRUE if the list box shows separators
|
||||
*/
|
||||
gboolean
|
||||
gtk_list_view_get_show_separators (GtkListView *self)
|
||||
{
|
||||
g_return_val_if_fail (GTK_IS_LIST_VIEW (self), FALSE);
|
||||
|
||||
return self->show_separators;
|
||||
}
|
||||
|
@ -49,6 +49,12 @@ void gtk_list_view_set_functions (GtkListView
|
||||
gpointer user_data,
|
||||
GDestroyNotify user_destroy);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_list_view_set_show_separators (GtkListView *self,
|
||||
gboolean show_separators);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_list_view_get_show_separators (GtkListView *self);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_LIST_VIEW_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user