2018-09-21 03:05:34 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2018 Benjamin Otte
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: Benjamin Otte <otte@gnome.org>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "gtklistitemprivate.h"
|
|
|
|
|
|
|
|
#include "gtkintl.h"
|
|
|
|
|
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* GtkListItem:
|
2018-09-21 03:05:34 +00:00
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* `GtkListItem` is used by list widgets to represent items in a `GListModel`.
|
2018-09-21 03:05:34 +00:00
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* The `GtkListItem`s are managed by the list widget (with its factory)
|
|
|
|
* and cannot be created by applications, but they need to be populated
|
|
|
|
* by application code. This is done by calling [method@Gtk.ListItem.set_child].
|
2018-09-21 03:05:34 +00:00
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* `GtkListItem`s exist in 2 stages:
|
2018-09-21 03:05:34 +00:00
|
|
|
*
|
|
|
|
* 1. The unbound stage where the listitem is not currently connected to
|
2021-02-28 18:09:38 +00:00
|
|
|
* an item in the list. In that case, the [property@Gtk.ListItem:item]
|
|
|
|
* property is set to %NULL.
|
2018-09-21 03:05:34 +00:00
|
|
|
*
|
|
|
|
* 2. The bound stage where the listitem references an item from the list.
|
2021-02-28 18:09:38 +00:00
|
|
|
* The [property@Gtk.ListItem:item] property is not %NULL.
|
2018-09-21 03:05:34 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
struct _GtkListItemClass
|
|
|
|
{
|
2019-11-01 06:31:38 +00:00
|
|
|
GObjectClass parent_class;
|
2018-09-21 03:05:34 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2019-10-15 21:06:36 +00:00
|
|
|
PROP_ACTIVATABLE,
|
2018-09-21 03:05:34 +00:00
|
|
|
PROP_CHILD,
|
|
|
|
PROP_ITEM,
|
2018-09-24 02:01:37 +00:00
|
|
|
PROP_POSITION,
|
2018-09-29 20:34:43 +00:00
|
|
|
PROP_SELECTABLE,
|
|
|
|
PROP_SELECTED,
|
2018-09-21 03:05:34 +00:00
|
|
|
|
|
|
|
N_PROPS
|
|
|
|
};
|
|
|
|
|
2019-11-01 06:31:38 +00:00
|
|
|
G_DEFINE_TYPE (GtkListItem, gtk_list_item, G_TYPE_OBJECT)
|
2018-09-21 03:05:34 +00:00
|
|
|
|
|
|
|
static GParamSpec *properties[N_PROPS] = { NULL, };
|
2019-10-15 02:18:10 +00:00
|
|
|
|
2018-09-21 03:05:34 +00:00
|
|
|
static void
|
|
|
|
gtk_list_item_dispose (GObject *object)
|
|
|
|
{
|
|
|
|
GtkListItem *self = GTK_LIST_ITEM (object);
|
|
|
|
|
2019-11-01 06:31:38 +00:00
|
|
|
g_assert (self->owner == NULL); /* would hold a reference */
|
|
|
|
g_clear_object (&self->child);
|
2018-09-21 03:05:34 +00:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (gtk_list_item_parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_list_item_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkListItem *self = GTK_LIST_ITEM (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2019-10-15 21:06:36 +00:00
|
|
|
case PROP_ACTIVATABLE:
|
|
|
|
g_value_set_boolean (value, self->activatable);
|
|
|
|
break;
|
|
|
|
|
2018-09-21 03:05:34 +00:00
|
|
|
case PROP_CHILD:
|
|
|
|
g_value_set_object (value, self->child);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_ITEM:
|
2019-11-03 02:34:56 +00:00
|
|
|
if (self->owner)
|
|
|
|
g_value_set_object (value, gtk_list_item_widget_get_item (self->owner));
|
2018-09-21 03:05:34 +00:00
|
|
|
break;
|
|
|
|
|
2018-09-24 02:01:37 +00:00
|
|
|
case PROP_POSITION:
|
2019-11-03 02:34:56 +00:00
|
|
|
if (self->owner)
|
|
|
|
g_value_set_uint (value, gtk_list_item_widget_get_position (self->owner));
|
|
|
|
else
|
|
|
|
g_value_set_uint (value, GTK_INVALID_LIST_POSITION);
|
2018-09-24 02:01:37 +00:00
|
|
|
break;
|
|
|
|
|
2018-09-29 20:34:43 +00:00
|
|
|
case PROP_SELECTABLE:
|
|
|
|
g_value_set_boolean (value, self->selectable);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case PROP_SELECTED:
|
2019-11-03 02:34:56 +00:00
|
|
|
if (self->owner)
|
|
|
|
g_value_set_boolean (value, gtk_list_item_widget_get_selected (self->owner));
|
|
|
|
else
|
|
|
|
g_value_set_boolean (value, FALSE);
|
2018-09-29 20:34:43 +00:00
|
|
|
break;
|
|
|
|
|
2018-09-21 03:05:34 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_list_item_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GtkListItem *self = GTK_LIST_ITEM (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2019-10-15 21:06:36 +00:00
|
|
|
case PROP_ACTIVATABLE:
|
|
|
|
gtk_list_item_set_activatable (self, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
|
2018-09-21 03:05:34 +00:00
|
|
|
case PROP_CHILD:
|
|
|
|
gtk_list_item_set_child (self, g_value_get_object (value));
|
|
|
|
break;
|
|
|
|
|
2018-09-29 20:34:43 +00:00
|
|
|
case PROP_SELECTABLE:
|
|
|
|
gtk_list_item_set_selectable (self, g_value_get_boolean (value));
|
|
|
|
break;
|
|
|
|
|
2018-09-21 03:05:34 +00:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gtk_list_item_class_init (GtkListItemClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
|
|
|
gobject_class->dispose = gtk_list_item_dispose;
|
|
|
|
gobject_class->get_property = gtk_list_item_get_property;
|
|
|
|
gobject_class->set_property = gtk_list_item_set_property;
|
|
|
|
|
2019-10-15 21:06:36 +00:00
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* GtkListItem:activatable: (attributes org.gtk.Property.get=gtk_list_item_get_activatable org.gtk.Property.set=gtk_list_item_set_activatable)
|
2019-10-15 21:06:36 +00:00
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* If the item can be activated by the user.
|
2019-10-15 21:06:36 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_ACTIVATABLE] =
|
|
|
|
g_param_spec_boolean ("activatable",
|
|
|
|
P_("Activatable"),
|
|
|
|
P_("If the item can be activated by the user"),
|
|
|
|
TRUE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2018-09-21 03:05:34 +00:00
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* GtkListItem:child: (attributes org.gtk.Property.get=gtk_list_item_get_child org.gtk.Property.set=gtk_list_item_set_child)
|
2018-09-21 03:05:34 +00:00
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* Widget used for display.
|
2018-09-21 03:05:34 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_CHILD] =
|
|
|
|
g_param_spec_object ("child",
|
|
|
|
P_("Child"),
|
|
|
|
P_("Widget used for display"),
|
|
|
|
GTK_TYPE_WIDGET,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* GtkListItem:item: (attributes org.gtk.Property.get=gtk_list_item_get_item)
|
2018-09-21 03:05:34 +00:00
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* Displayed item.
|
2018-09-21 03:05:34 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_ITEM] =
|
|
|
|
g_param_spec_object ("item",
|
|
|
|
P_("Item"),
|
|
|
|
P_("Displayed item"),
|
|
|
|
G_TYPE_OBJECT,
|
|
|
|
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2018-09-24 02:01:37 +00:00
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* GtkListItem:position: (attributes org.gtk.Property.get=gtk_list_item_get_position)
|
2018-09-24 02:01:37 +00:00
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* Position of the item.
|
2018-09-24 02:01:37 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_POSITION] =
|
|
|
|
g_param_spec_uint ("position",
|
|
|
|
P_("Position"),
|
|
|
|
P_("Position of the item"),
|
|
|
|
0, G_MAXUINT, GTK_INVALID_LIST_POSITION,
|
|
|
|
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2018-09-29 20:34:43 +00:00
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* GtkListItem:selectable: (attributes org.gtk.Property.get=gtk_list_item_get_selectable org.gtk.Property.set=gtk_list_item_set_selectable)
|
2018-09-29 20:34:43 +00:00
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* If the item can be selected by the user.
|
2018-09-29 20:34:43 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_SELECTABLE] =
|
|
|
|
g_param_spec_boolean ("selectable",
|
|
|
|
P_("Selectable"),
|
|
|
|
P_("If the item can be selected by the user"),
|
|
|
|
TRUE,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* GtkListItem:selected: (attributes org.gtk.Property.get=gtk_list_item_get_selected)
|
2018-09-29 20:34:43 +00:00
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* If the item is currently selected.
|
2018-09-29 20:34:43 +00:00
|
|
|
*/
|
|
|
|
properties[PROP_SELECTED] =
|
|
|
|
g_param_spec_boolean ("selected",
|
|
|
|
P_("Selected"),
|
|
|
|
P_("If the item is currently selected"),
|
|
|
|
FALSE,
|
|
|
|
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY | G_PARAM_STATIC_STRINGS);
|
|
|
|
|
2018-09-21 03:05:34 +00:00
|
|
|
g_object_class_install_properties (gobject_class, N_PROPS, properties);
|
2018-10-05 21:24:18 +00:00
|
|
|
}
|
|
|
|
|
2018-09-21 03:05:34 +00:00
|
|
|
static void
|
|
|
|
gtk_list_item_init (GtkListItem *self)
|
|
|
|
{
|
2018-09-29 20:34:43 +00:00
|
|
|
self->selectable = TRUE;
|
2019-10-15 21:06:36 +00:00
|
|
|
self->activatable = TRUE;
|
2018-09-21 03:05:34 +00:00
|
|
|
}
|
|
|
|
|
2018-10-05 21:24:18 +00:00
|
|
|
GtkListItem *
|
2019-11-03 01:23:46 +00:00
|
|
|
gtk_list_item_new (void)
|
2018-09-21 03:05:34 +00:00
|
|
|
{
|
2021-02-28 18:09:38 +00:00
|
|
|
return g_object_new (GTK_TYPE_LIST_ITEM, NULL);
|
2018-09-21 03:05:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* gtk_list_item_get_item: (attributes org.gtk.Method.get_property=item)
|
|
|
|
* @self: a `GtkListItem`
|
2018-09-21 03:05:34 +00:00
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* Gets the model item that associated with @self.
|
|
|
|
*
|
|
|
|
* If @self is unbound, this function returns %NULL.
|
2018-09-21 03:05:34 +00:00
|
|
|
*
|
2018-09-24 02:01:37 +00:00
|
|
|
* Returns: (nullable) (transfer none) (type GObject): The item displayed
|
2018-09-21 03:05:34 +00:00
|
|
|
**/
|
|
|
|
gpointer
|
|
|
|
gtk_list_item_get_item (GtkListItem *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_LIST_ITEM (self), NULL);
|
|
|
|
|
2019-11-03 02:34:56 +00:00
|
|
|
if (self->owner == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return gtk_list_item_widget_get_item (self->owner);
|
2018-09-21 03:05:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* gtk_list_item_get_child: (attributes org.gtk.Method.get_property=child)
|
|
|
|
* @self: a `GtkListItem`
|
2018-09-21 03:05:34 +00:00
|
|
|
*
|
|
|
|
* Gets the child previously set via gtk_list_item_set_child() or
|
|
|
|
* %NULL if none was set.
|
|
|
|
*
|
|
|
|
* Returns: (transfer none) (nullable): The child
|
2021-02-28 18:09:38 +00:00
|
|
|
*/
|
2018-09-21 03:05:34 +00:00
|
|
|
GtkWidget *
|
|
|
|
gtk_list_item_get_child (GtkListItem *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_LIST_ITEM (self), NULL);
|
|
|
|
|
|
|
|
return self->child;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* gtk_list_item_set_child: (attributes org.gtk.Method.set_property=child)
|
|
|
|
* @self: a `GtkListItem`
|
2018-09-21 03:05:34 +00:00
|
|
|
* @child: (nullable): The list item's child or %NULL to unset
|
|
|
|
*
|
|
|
|
* Sets the child to be used for this listitem.
|
|
|
|
*
|
|
|
|
* This function is typically called by applications when
|
|
|
|
* setting up a listitem so that the widget can be reused when
|
|
|
|
* binding it multiple times.
|
2021-02-28 18:09:38 +00:00
|
|
|
*/
|
2018-09-21 03:05:34 +00:00
|
|
|
void
|
|
|
|
gtk_list_item_set_child (GtkListItem *self,
|
|
|
|
GtkWidget *child)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_LIST_ITEM (self));
|
|
|
|
g_return_if_fail (child == NULL || GTK_IS_WIDGET (child));
|
|
|
|
|
|
|
|
if (self->child == child)
|
|
|
|
return;
|
|
|
|
|
2019-11-01 06:31:38 +00:00
|
|
|
if (self->child && self->owner)
|
|
|
|
gtk_list_item_widget_remove_child (self->owner, self->child);
|
|
|
|
|
|
|
|
g_clear_object (&self->child);
|
2018-09-21 03:05:34 +00:00
|
|
|
|
|
|
|
if (child)
|
|
|
|
{
|
2019-11-01 06:31:38 +00:00
|
|
|
g_object_ref_sink (child);
|
2018-09-21 03:05:34 +00:00
|
|
|
self->child = child;
|
2019-10-30 17:03:23 +00:00
|
|
|
|
2019-11-01 06:31:38 +00:00
|
|
|
if (self->owner)
|
|
|
|
gtk_list_item_widget_add_child (self->owner, child);
|
2018-09-21 03:05:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ITEM]);
|
|
|
|
}
|
|
|
|
|
2018-09-24 02:01:37 +00:00
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* gtk_list_item_get_position: (attributes org.gtk.Method.get_property=position)
|
|
|
|
* @self: a `GtkListItem`
|
2018-09-24 02:01:37 +00:00
|
|
|
*
|
|
|
|
* Gets the position in the model that @self currently displays.
|
2021-02-28 18:09:38 +00:00
|
|
|
*
|
2020-06-27 03:07:28 +00:00
|
|
|
* If @self is unbound, %GTK_INVALID_LIST_POSITION is returned.
|
2018-09-24 02:01:37 +00:00
|
|
|
*
|
|
|
|
* Returns: The position of this item
|
2021-02-28 18:09:38 +00:00
|
|
|
*/
|
2018-09-24 02:01:37 +00:00
|
|
|
guint
|
|
|
|
gtk_list_item_get_position (GtkListItem *self)
|
|
|
|
{
|
2019-11-03 02:34:56 +00:00
|
|
|
g_return_val_if_fail (GTK_IS_LIST_ITEM (self), GTK_INVALID_LIST_POSITION);
|
2018-09-21 03:05:34 +00:00
|
|
|
|
2019-11-03 02:34:56 +00:00
|
|
|
if (self->owner == NULL)
|
|
|
|
return GTK_INVALID_LIST_POSITION;
|
2018-09-24 02:01:37 +00:00
|
|
|
|
2019-11-03 02:34:56 +00:00
|
|
|
return gtk_list_item_widget_get_position (self->owner);
|
2018-09-21 03:05:34 +00:00
|
|
|
}
|
|
|
|
|
2018-09-29 20:34:43 +00:00
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* gtk_list_item_get_selected: (attributes org.gtk.Method.get_property=selected)
|
|
|
|
* @self: a `GtkListItem`
|
2018-09-29 20:34:43 +00:00
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* Checks if the item is displayed as selected.
|
|
|
|
*
|
|
|
|
* The selected state is maintained by the liste widget and its model
|
|
|
|
* and cannot be set otherwise.
|
2018-09-29 20:34:43 +00:00
|
|
|
*
|
|
|
|
* Returns: %TRUE if the item is selected.
|
2021-02-28 18:09:38 +00:00
|
|
|
*/
|
2018-09-29 20:34:43 +00:00
|
|
|
gboolean
|
|
|
|
gtk_list_item_get_selected (GtkListItem *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_LIST_ITEM (self), FALSE);
|
|
|
|
|
2019-11-03 02:34:56 +00:00
|
|
|
if (self->owner == NULL)
|
|
|
|
return FALSE;
|
2018-09-29 20:34:43 +00:00
|
|
|
|
2019-11-03 02:34:56 +00:00
|
|
|
return gtk_list_item_widget_get_selected (self->owner);
|
2018-09-29 20:34:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* gtk_list_item_get_selectable: (attributes org.gtk.Method.get_property=selectable)
|
|
|
|
* @self: a `GtkListItem`
|
2018-09-29 20:34:43 +00:00
|
|
|
*
|
|
|
|
* Checks if a list item has been set to be selectable via
|
|
|
|
* gtk_list_item_set_selectable().
|
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* Do not confuse this function with [method@Gtk.ListItem.get_selected].
|
2018-09-29 20:34:43 +00:00
|
|
|
*
|
|
|
|
* Returns: %TRUE if the item is selectable
|
2021-02-28 18:09:38 +00:00
|
|
|
*/
|
2018-09-29 20:34:43 +00:00
|
|
|
gboolean
|
|
|
|
gtk_list_item_get_selectable (GtkListItem *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_LIST_ITEM (self), FALSE);
|
|
|
|
|
|
|
|
return self->selectable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* gtk_list_item_set_selectable: (attributes org.gtk.Method.set_property=selectable)
|
|
|
|
* @self: a `GtkListItem`
|
2018-09-29 20:34:43 +00:00
|
|
|
* @selectable: if the item should be selectable
|
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* Sets @self to be selectable.
|
|
|
|
*
|
|
|
|
* If an item is selectable, clicking on the item or using the keyboard
|
|
|
|
* will try to select or unselect the item. If this succeeds is up to
|
|
|
|
* the model to determine, as it is managing the selected state.
|
2018-09-29 20:34:43 +00:00
|
|
|
*
|
|
|
|
* Note that this means that making an item non-selectable has no
|
2021-02-28 18:09:38 +00:00
|
|
|
* influence on the selected state at all. A non-selectable item
|
2018-09-29 20:34:43 +00:00
|
|
|
* may still be selected.
|
|
|
|
*
|
|
|
|
* By default, list items are selectable. When rebinding them to
|
|
|
|
* a new item, they will also be reset to be selectable by GTK.
|
2021-02-28 18:09:38 +00:00
|
|
|
*/
|
2018-09-29 20:34:43 +00:00
|
|
|
void
|
|
|
|
gtk_list_item_set_selectable (GtkListItem *self,
|
|
|
|
gboolean selectable)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_LIST_ITEM (self));
|
|
|
|
|
|
|
|
if (self->selectable == selectable)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->selectable = selectable;
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SELECTABLE]);
|
|
|
|
}
|
2019-10-15 21:06:36 +00:00
|
|
|
|
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* gtk_list_item_get_activatable: (attributes org.gtk.Method.get_property=activatable)
|
|
|
|
* @self: a `GtkListItem`
|
2019-10-15 21:06:36 +00:00
|
|
|
*
|
|
|
|
* Checks if a list item has been set to be activatable via
|
|
|
|
* gtk_list_item_set_activatable().
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the item is activatable
|
2021-02-28 18:09:38 +00:00
|
|
|
*/
|
2019-10-15 21:06:36 +00:00
|
|
|
gboolean
|
|
|
|
gtk_list_item_get_activatable (GtkListItem *self)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GTK_IS_LIST_ITEM (self), FALSE);
|
|
|
|
|
|
|
|
return self->activatable;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-02-28 18:09:38 +00:00
|
|
|
* gtk_list_item_set_activatable: (attributes org.gtk.Method.set_property=activatable)
|
|
|
|
* @self: a `GtkListItem`
|
2019-10-15 21:06:36 +00:00
|
|
|
* @activatable: if the item should be activatable
|
|
|
|
*
|
|
|
|
* Sets @self to be activatable.
|
|
|
|
*
|
|
|
|
* If an item is activatable, double-clicking on the item, using
|
2020-06-27 03:07:28 +00:00
|
|
|
* the Return key or calling gtk_widget_activate() will activate
|
2019-10-15 21:06:36 +00:00
|
|
|
* the item. Activating instructs the containing view to handle
|
2021-02-28 18:09:38 +00:00
|
|
|
* activation. `GtkListView` for example will be emitting the
|
|
|
|
* [signal@Gtk.ListView::activate] signal.
|
2019-10-15 21:06:36 +00:00
|
|
|
*
|
2021-02-28 18:09:38 +00:00
|
|
|
* By default, list items are activatable.
|
|
|
|
*/
|
2019-10-15 21:06:36 +00:00
|
|
|
void
|
|
|
|
gtk_list_item_set_activatable (GtkListItem *self,
|
|
|
|
gboolean activatable)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GTK_IS_LIST_ITEM (self));
|
|
|
|
|
|
|
|
if (self->activatable == activatable)
|
|
|
|
return;
|
|
|
|
|
|
|
|
self->activatable = activatable;
|
|
|
|
|
|
|
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_ACTIVATABLE]);
|
|
|
|
}
|