Merge branch 'wip/otte/tab-behavior' into 'main'

listview: Add ::tab-behavior to list widgets

See merge request GNOME/gtk!5710
This commit is contained in:
Benjamin Otte 2023-03-26 19:10:29 +00:00
commit 8cf3a95d8c
10 changed files with 339 additions and 56 deletions

View File

@ -27,18 +27,17 @@
#include "gtkcolumnviewcolumnprivate.h"
#include "gtkcolumnviewsorterprivate.h"
#include "gtkcssnodeprivate.h"
#include "gtkdragsourceprivate.h"
#include "gtkdropcontrollermotion.h"
#include "gtkeventcontrollerkey.h"
#include "gtkeventcontrollermotion.h"
#include "gtkgestureclick.h"
#include "gtkgesturedrag.h"
#include "gtklistviewprivate.h"
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtkscrollable.h"
#include "gtksizerequest.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
#include "gtkgesturedrag.h"
#include "gtkeventcontrollermotion.h"
#include "gtkdragsourceprivate.h"
#include "gtkeventcontrollerkey.h"
#include "gtkgestureclick.h"
/**
* GtkColumnView:
@ -202,17 +201,18 @@ enum
{
PROP_0,
PROP_COLUMNS,
PROP_ENABLE_RUBBERBAND,
PROP_HADJUSTMENT,
PROP_HSCROLL_POLICY,
PROP_MODEL,
PROP_REORDERABLE,
PROP_SHOW_ROW_SEPARATORS,
PROP_SHOW_COLUMN_SEPARATORS,
PROP_SINGLE_CLICK_ACTIVATE,
PROP_SORTER,
PROP_TAB_BEHAVIOR,
PROP_VADJUSTMENT,
PROP_VSCROLL_POLICY,
PROP_SINGLE_CLICK_ACTIVATE,
PROP_REORDERABLE,
PROP_ENABLE_RUBBERBAND,
N_PROPS
};
@ -533,6 +533,10 @@ gtk_column_view_get_property (GObject *object,
g_value_set_object (value, self->columns);
break;
case PROP_ENABLE_RUBBERBAND:
g_value_set_boolean (value, gtk_column_view_get_enable_rubberband (self));
break;
case PROP_HADJUSTMENT:
g_value_set_object (value, self->hadjustment);
break;
@ -573,8 +577,8 @@ 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));
case PROP_TAB_BEHAVIOR:
g_value_set_enum (value, gtk_list_view_get_tab_behavior (self->listview));
break;
default:
@ -594,6 +598,10 @@ gtk_column_view_set_property (GObject *object,
switch (property_id)
{
case PROP_ENABLE_RUBBERBAND:
gtk_column_view_set_enable_rubberband (self, g_value_get_boolean (value));
break;
case PROP_HADJUSTMENT:
adjustment = g_value_get_object (value);
if (adjustment == NULL)
@ -656,8 +664,8 @@ 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));
case PROP_TAB_BEHAVIOR:
gtk_column_view_set_tab_behavior (self, g_value_get_enum (value));
break;
default:
@ -708,6 +716,16 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
G_TYPE_LIST_MODEL,
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GtkColumnView:enable-rubberband: (attributes org.gtk.Property.get=gtk_column_view_get_enable_rubberband org.gtk.Property.set=gtk_column_view_set_enable_rubberband)
*
* Allow rubberband selection.
*/
properties[PROP_ENABLE_RUBBERBAND] =
g_param_spec_boolean ("enable-rubberband", NULL, NULL,
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkColumnView:model: (attributes org.gtk.Property.get=gtk_column_view_get_model org.gtk.Property.set=gtk_column_view_set_model)
*
@ -769,14 +787,17 @@ gtk_column_view_class_init (GtkColumnViewClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
/**
* GtkColumnView:enable-rubberband: (attributes org.gtk.Property.get=gtk_column_view_get_enable_rubberband org.gtk.Property.set=gtk_column_view_set_enable_rubberband)
* GtkColumnView:tab-behavior: (attributes org.gtk.Property.get=gtk_column_view_get_tab_behavior org.gtk.Property.set=gtk_column_view_set_tab_behavior)
*
* Allow rubberband selection.
* Behavior of the <kbd>Tab</kbd> key
*
* Since: 4.12
*/
properties[PROP_ENABLE_RUBBERBAND] =
g_param_spec_boolean ("enable-rubberband", NULL, NULL,
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_TAB_BEHAVIOR] =
g_param_spec_enum ("tab-behavior", NULL, NULL,
GTK_TYPE_LIST_TAB_BEHAVIOR,
GTK_LIST_TAB_ALL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
@ -1885,3 +1906,45 @@ gtk_column_view_get_enable_rubberband (GtkColumnView *self)
return gtk_list_view_get_enable_rubberband (self->listview);
}
/**
* gtk_column_view_set_tab_behavior: (attributes org.gtk.Method.set_property=tab-behavior)
* @self: a `GtkColumnView`
* @tab_behavior: The desired tab behavior
*
* Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
*
* Since: 4.12
*/
void
gtk_column_view_set_tab_behavior (GtkColumnView *self,
GtkListTabBehavior tab_behavior)
{
g_return_if_fail (GTK_IS_COLUMN_VIEW (self));
if (tab_behavior == gtk_list_view_get_tab_behavior (self->listview))
return;
gtk_list_view_set_tab_behavior (self->listview, tab_behavior);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TAB_BEHAVIOR]);
}
/**
* gtk_column_view_get_tab_behavior: (attributes org.gtk.Method.get_property=tab-behavior)
* @self: a `GtkColumnView`
*
* Gets the behavior set for the <kbd>Tab</kbd> key.
*
* Returns: The behavior of the <kbd>Tab</kbd> key
*
* Since: 4.12
*/
gboolean
gtk_column_view_get_tab_behavior (GtkColumnView *self)
{
g_return_val_if_fail (GTK_IS_COLUMN_VIEW (self), FALSE);
return gtk_list_view_get_tab_behavior (self->listview);
}

View File

@ -109,6 +109,12 @@ void gtk_column_view_set_enable_rubberband (GtkColumnView
GDK_AVAILABLE_IN_ALL
gboolean gtk_column_view_get_enable_rubberband (GtkColumnView *self);
GDK_AVAILABLE_IN_4_12
void gtk_column_view_set_tab_behavior (GtkColumnView *self,
GtkListTabBehavior tab_behavior);
GDK_AVAILABLE_IN_4_12
gboolean gtk_column_view_get_tab_behavior (GtkColumnView *self);
G_END_DECLS
#endif /* __GTK_COLUMN_VIEW_H__ */

View File

@ -187,6 +187,13 @@ gtk_column_view_row_widget_focus (GtkWidget *widget,
return TRUE;
view = gtk_column_view_row_widget_get_column_view (self);
if (gtk_column_view_get_tab_behavior (view) == GTK_LIST_TAB_CELL &&
(direction == GTK_DIR_TAB_FORWARD || direction == GTK_DIR_TAB_BACKWARD))
{
if (focus_child || gtk_widget_is_focus (widget))
return FALSE;
}
if (focus_child == NULL)
{
GtkColumnViewColumn *focus_column = gtk_column_view_get_focus_column (view);

View File

@ -265,6 +265,31 @@ typedef enum
GTK_JUSTIFY_FILL
} GtkJustification;
/**
* GtkListTabBehavior:
* @GTK_LIST_TAB_ALL: Cycle through all focusable items of the list
* @GTK_LIST_TAB_ITEM: Cycle through a single list element, then move
* focus out of the list. Moving focus between items needs to be
* done with the arrow keys.
* @GTK_LIST_TAB_CELL: Cycle only through a single cell, then
* move focus out of the list. Moving focus between cells needs to
* be done with the arrow keys. This is only relevant for
* cell-based widgets like #GtkColumnView, otherwise it behaves
* like `GTK_LIST_TAB_ITEM`.
*
* Used to configure the focus behavior in the `GTK_DIR_TAB_FORWARD`
* and `GTK_DIR_TAB_BACKWARD` direction, like the <kbd>Tab</kbd> key
* in a [class@Gtk.ListView].
*
* Since: 4.12
*/
typedef enum
{
GTK_LIST_TAB_ALL,
GTK_LIST_TAB_ITEM,
GTK_LIST_TAB_CELL
} GtkListTabBehavior;
/**
* GtkMessageType:
* @GTK_MESSAGE_INFO: Informational message

View File

@ -26,11 +26,9 @@
#include "gtklistitemfactory.h"
#include "gtklistitemmanagerprivate.h"
#include "gtklistitemwidgetprivate.h"
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtksingleselection.h"
#include "gtkwidgetprivate.h"
#include "gtkmultiselection.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
/* Maximum number of list items created by the gridview.
* For debugging, you can set this to G_MAXUINT to ensure
@ -105,12 +103,13 @@ struct _GtkGridViewClass
enum
{
PROP_0,
PROP_ENABLE_RUBBERBAND,
PROP_FACTORY,
PROP_MAX_COLUMNS,
PROP_MIN_COLUMNS,
PROP_MODEL,
PROP_SINGLE_CLICK_ACTIVATE,
PROP_ENABLE_RUBBERBAND,
PROP_TAB_BEHAVIOR,
N_PROPS
};
@ -877,6 +876,10 @@ gtk_grid_view_get_property (GObject *object,
switch (property_id)
{
case PROP_ENABLE_RUBBERBAND:
g_value_set_boolean (value, gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (self)));
break;
case PROP_FACTORY:
g_value_set_object (value, self->factory);
break;
@ -897,8 +900,8 @@ gtk_grid_view_get_property (GObject *object,
g_value_set_boolean (value, self->single_click_activate);
break;
case PROP_ENABLE_RUBBERBAND:
g_value_set_boolean (value, gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (self)));
case PROP_TAB_BEHAVIOR:
g_value_set_enum (value, gtk_list_base_get_tab_behavior (GTK_LIST_BASE (self)));
break;
default:
@ -917,6 +920,10 @@ gtk_grid_view_set_property (GObject *object,
switch (property_id)
{
case PROP_ENABLE_RUBBERBAND:
gtk_grid_view_set_enable_rubberband (self, g_value_get_boolean (value));
break;
case PROP_FACTORY:
gtk_grid_view_set_factory (self, g_value_get_object (value));
break;
@ -937,8 +944,8 @@ 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));
case PROP_TAB_BEHAVIOR:
gtk_grid_view_set_tab_behavior (self, g_value_get_enum (value));
break;
default:
@ -987,6 +994,16 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
gobject_class->get_property = gtk_grid_view_get_property;
gobject_class->set_property = gtk_grid_view_set_property;
/**
* GtkGridView:enable-rubberband: (attributes org.gtk.Property.get=gtk_grid_view_get_enable_rubberband org.gtk.Property.set=gtk_grid_view_set_enable_rubberband)
*
* Allow rubberband selection.
*/
properties[PROP_ENABLE_RUBBERBAND] =
g_param_spec_boolean ("enable-rubberband", NULL, NULL,
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkGridView:factory: (attributes org.gtk.Property.get=gtk_grid_view_get_factory org.gtk.Property.set=gtk_grid_view_set_factory)
*
@ -1042,14 +1059,17 @@ gtk_grid_view_class_init (GtkGridViewClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkGridView:enable-rubberband: (attributes org.gtk.Property.get=gtk_grid_view_get_enable_rubberband org.gtk.Property.set=gtk_grid_view_set_enable_rubberband)
* GtkGridView:tab-behavior: (attributes org.gtk.Property.get=gtk_grid_view_get_tab_behavior org.gtk.Property.set=gtk_grid_view_set_tab_behavior)
*
* Allow rubberband selection.
* Behavior of the <kbd>Tab</kbd> key
*
* Since: 4.12
*/
properties[PROP_ENABLE_RUBBERBAND] =
g_param_spec_boolean ("enable-rubberband", NULL, NULL,
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_TAB_BEHAVIOR] =
g_param_spec_enum ("tab-behavior", NULL, NULL,
GTK_TYPE_LIST_TAB_BEHAVIOR,
GTK_LIST_TAB_ALL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
@ -1417,3 +1437,45 @@ gtk_grid_view_get_enable_rubberband (GtkGridView *self)
return gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (self));
}
/**
* gtk_grid_view_set_tab_behavior: (attributes org.gtk.Method.set_property=tab-behavior)
* @self: a `GtkGridView`
* @tab_behavior: The desired tab behavior
*
* Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
*
* Since: 4.12
*/
void
gtk_grid_view_set_tab_behavior (GtkGridView *self,
GtkListTabBehavior tab_behavior)
{
g_return_if_fail (GTK_IS_GRID_VIEW (self));
if (tab_behavior == gtk_list_base_get_tab_behavior (GTK_LIST_BASE (self)))
return;
gtk_list_base_set_tab_behavior (GTK_LIST_BASE (self), tab_behavior);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TAB_BEHAVIOR]);
}
/**
* gtk_grid_view_get_tab_behavior: (attributes org.gtk.Method.get_property=tab-behavior)
* @self: a `GtkGridView`
*
* Gets the behavior set for the <kbd>Tab</kbd> key.
*
* Returns: The behavior of the <kbd>Tab</kbd> key
*
* Since: 4.12
*/
gboolean
gtk_grid_view_get_tab_behavior (GtkGridView *self)
{
g_return_val_if_fail (GTK_IS_GRID_VIEW (self), FALSE);
return gtk_list_base_get_tab_behavior (GTK_LIST_BASE (self));
}

View File

@ -73,6 +73,12 @@ void gtk_grid_view_set_enable_rubberband (GtkGridView
GDK_AVAILABLE_IN_ALL
gboolean gtk_grid_view_get_enable_rubberband (GtkGridView *self);
GDK_AVAILABLE_IN_4_12
void gtk_grid_view_set_tab_behavior (GtkGridView *self,
GtkListTabBehavior tab_behavior);
GDK_AVAILABLE_IN_4_12
gboolean gtk_grid_view_get_tab_behavior (GtkGridView *self);
GDK_AVAILABLE_IN_ALL
void gtk_grid_view_set_single_click_activate (GtkGridView *self,
gboolean single_click_activate);

View File

@ -68,6 +68,7 @@ struct _GtkListBasePrivate
GtkOrientation orientation;
GtkAdjustment *adjustment[2];
GtkScrollablePolicy scroll_policy[2];
GtkListTabBehavior tab_behavior;
GtkListItemTracker *anchor;
double anchor_align_along;
@ -554,21 +555,42 @@ gtk_list_base_focus (GtkWidget *widget,
* while keeping the selection intact.
*/
old = GTK_INVALID_LIST_POSITION;
if (priv->tab_behavior == GTK_LIST_TAB_ALL)
{
if (direction == GTK_DIR_TAB_FORWARD)
pos = 0;
else if (direction == GTK_DIR_TAB_BACKWARD)
pos = n_items - 1;
}
}
else
{
switch (direction)
{
case GTK_DIR_TAB_FORWARD:
pos++;
if (pos >= n_items)
return FALSE;
if (priv->tab_behavior == GTK_LIST_TAB_ALL)
{
pos++;
if (pos >= n_items)
return FALSE;
}
else
{
return FALSE;
}
break;
case GTK_DIR_TAB_BACKWARD:
if (pos == 0)
return FALSE;
pos--;
if (priv->tab_behavior == GTK_LIST_TAB_ALL)
{
if (pos == 0)
return FALSE;
pos--;
}
else
{
return FALSE;
}
break;
case GTK_DIR_UP:
@ -1948,6 +1970,7 @@ gtk_list_base_init_real (GtkListBase *self,
priv->adjustment[GTK_ORIENTATION_VERTICAL] = gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
g_object_ref_sink (priv->adjustment[GTK_ORIENTATION_VERTICAL]);
priv->tab_behavior = GTK_LIST_TAB_ALL;
priv->orientation = GTK_ORIENTATION_VERTICAL;
gtk_widget_set_overflow (GTK_WIDGET (self), GTK_OVERFLOW_HIDDEN);
@ -2248,3 +2271,21 @@ gtk_list_base_set_model (GtkListBase *self,
return TRUE;
}
void
gtk_list_base_set_tab_behavior (GtkListBase *self,
GtkListTabBehavior behavior)
{
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
priv->tab_behavior = behavior;
}
GtkListTabBehavior
gtk_list_base_get_tab_behavior (GtkListBase *self)
{
GtkListBasePrivate *priv = gtk_list_base_get_instance_private (self);
return priv->tab_behavior;
}

View File

@ -85,6 +85,10 @@ void gtk_list_base_set_anchor_max_widgets (GtkListBase
void gtk_list_base_set_enable_rubberband (GtkListBase *self,
gboolean enable);
gboolean gtk_list_base_get_enable_rubberband (GtkListBase *self);
void gtk_list_base_set_tab_behavior (GtkListBase *self,
GtkListTabBehavior behavior);
GtkListTabBehavior gtk_list_base_get_tab_behavior (GtkListBase *self);
void gtk_list_base_allocate (GtkListBase *self);

View File

@ -25,11 +25,9 @@
#include "gtklistbaseprivate.h"
#include "gtklistitemmanagerprivate.h"
#include "gtklistitemwidgetprivate.h"
#include "gtkmain.h"
#include "gtkprivate.h"
#include "gtkrbtreeprivate.h"
#include "gtkwidgetprivate.h"
#include "gtkmultiselection.h"
#include "gtktypebuiltins.h"
#include "gtkwidgetprivate.h"
/* Maximum number of list items created by the listview.
* For debugging, you can set this to G_MAXUINT to ensure
@ -145,11 +143,12 @@
enum
{
PROP_0,
PROP_ENABLE_RUBBERBAND,
PROP_FACTORY,
PROP_MODEL,
PROP_SHOW_SEPARATORS,
PROP_SINGLE_CLICK_ACTIVATE,
PROP_ENABLE_RUBBERBAND,
PROP_TAB_BEHAVIOR,
N_PROPS
};
@ -627,6 +626,10 @@ gtk_list_view_get_property (GObject *object,
switch (property_id)
{
case PROP_ENABLE_RUBBERBAND:
g_value_set_boolean (value, gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (self)));
break;
case PROP_FACTORY:
g_value_set_object (value, self->factory);
break;
@ -643,8 +646,8 @@ gtk_list_view_get_property (GObject *object,
g_value_set_boolean (value, self->single_click_activate);
break;
case PROP_ENABLE_RUBBERBAND:
g_value_set_boolean (value, gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (self)));
case PROP_TAB_BEHAVIOR:
g_value_set_enum (value, gtk_list_base_get_tab_behavior (GTK_LIST_BASE (self)));
break;
default:
@ -663,6 +666,10 @@ gtk_list_view_set_property (GObject *object,
switch (property_id)
{
case PROP_ENABLE_RUBBERBAND:
gtk_list_view_set_enable_rubberband (self, g_value_get_boolean (value));
break;
case PROP_FACTORY:
gtk_list_view_set_factory (self, g_value_get_object (value));
break;
@ -679,8 +686,8 @@ 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));
case PROP_TAB_BEHAVIOR:
gtk_list_view_set_tab_behavior (self, g_value_get_enum (value));
break;
default:
@ -729,6 +736,16 @@ gtk_list_view_class_init (GtkListViewClass *klass)
gobject_class->get_property = gtk_list_view_get_property;
gobject_class->set_property = gtk_list_view_set_property;
/**
* GtkListView:enable-rubberband: (attributes org.gtk.Property.get=gtk_list_view_get_enable_rubberband org.gtk.Property.set=gtk_list_view_set_enable_rubberband)
*
* Allow rubberband selection.
*/
properties[PROP_ENABLE_RUBBERBAND] =
g_param_spec_boolean ("enable-rubberband", NULL, NULL,
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkListView:factory: (attributes org.gtk.Property.get=gtk_list_view_get_factory org.gtk.Property.set=gtk_list_view_set_factory)
*
@ -770,14 +787,17 @@ gtk_list_view_class_init (GtkListViewClass *klass)
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
/**
* GtkListView:enable-rubberband: (attributes org.gtk.Property.get=gtk_list_view_get_enable_rubberband org.gtk.Property.set=gtk_list_view_set_enable_rubberband)
* GtkListView:tab-behavior: (attributes org.gtk.Property.get=gtk_list_view_get_tab_behavior org.gtk.Property.set=gtk_list_view_set_tab_behavior)
*
* Allow rubberband selection.
* Behavior of the <kbd>Tab</kbd> key
*
* Since: 4.12
*/
properties[PROP_ENABLE_RUBBERBAND] =
g_param_spec_boolean ("enable-rubberband", NULL, NULL,
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
properties[PROP_TAB_BEHAVIOR] =
g_param_spec_enum ("tab-behavior", NULL, NULL,
GTK_TYPE_LIST_TAB_BEHAVIOR,
GTK_LIST_TAB_ALL,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
g_object_class_install_properties (gobject_class, N_PROPS, properties);
@ -1089,3 +1109,45 @@ gtk_list_view_get_enable_rubberband (GtkListView *self)
return gtk_list_base_get_enable_rubberband (GTK_LIST_BASE (self));
}
/**
* gtk_list_view_set_tab_behavior: (attributes org.gtk.Method.set_property=tab-behavior)
* @self: a `GtkListView`
* @tab_behavior: The desired tab behavior
*
* Sets the behavior of the <kbd>Tab</kbd> and <kbd>Shift</kbd>+<kbd>Tab</kbd> keys.
*
* Since: 4.12
*/
void
gtk_list_view_set_tab_behavior (GtkListView *self,
GtkListTabBehavior tab_behavior)
{
g_return_if_fail (GTK_IS_LIST_VIEW (self));
if (tab_behavior == gtk_list_base_get_tab_behavior (GTK_LIST_BASE (self)))
return;
gtk_list_base_set_tab_behavior (GTK_LIST_BASE (self), tab_behavior);
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_TAB_BEHAVIOR]);
}
/**
* gtk_list_view_get_tab_behavior: (attributes org.gtk.Method.get_property=tab-behavior)
* @self: a `GtkListView`
*
* Gets the behavior set for the <kbd>Tab</kbd> key.
*
* Returns: The behavior of the <kbd>Tab</kbd> key
*
* Since: 4.12
*/
gboolean
gtk_list_view_get_tab_behavior (GtkListView *self)
{
g_return_val_if_fail (GTK_IS_LIST_VIEW (self), FALSE);
return gtk_list_base_get_tab_behavior (GTK_LIST_BASE (self));
}

View File

@ -76,6 +76,13 @@ void gtk_list_view_set_enable_rubberband (GtkListView
GDK_AVAILABLE_IN_ALL
gboolean gtk_list_view_get_enable_rubberband (GtkListView *self);
GDK_AVAILABLE_IN_4_12
void gtk_list_view_set_tab_behavior (GtkListView *self,
GtkListTabBehavior tab_behavior);
GDK_AVAILABLE_IN_4_12
gboolean gtk_list_view_get_tab_behavior (GtkListView *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkListView, g_object_unref)
G_END_DECLS