mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-27 14:10:30 +00:00
Merge branch 'wip/otte/for-master' into 'master'
Wip/otte/for master See merge request GNOME/gtk!2064
This commit is contained in:
commit
bd2f2a6f65
@ -1389,10 +1389,9 @@ gtk_list_base_stop_rubberband (GtkListBase *self)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!priv->rubberband->extend)
|
gtk_selection_model_select_callback (model,
|
||||||
gtk_selection_model_unselect_all (model);
|
!priv->rubberband->extend,
|
||||||
|
range_cb, priv->rubberband->active);
|
||||||
gtk_selection_model_select_callback (model, range_cb, priv->rubberband->active);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_clear_pointer (&priv->rubberband, rubberband_data_free);
|
g_clear_pointer (&priv->rubberband, rubberband_data_free);
|
||||||
|
@ -395,7 +395,6 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
|
|||||||
|
|
||||||
if (item == NULL || item->widget)
|
if (item == NULL || item->widget)
|
||||||
item = gtk_rb_tree_insert_before (self->items, item);
|
item = gtk_rb_tree_insert_before (self->items, item);
|
||||||
|
|
||||||
item->n_items += n_items;
|
item->n_items += n_items;
|
||||||
gtk_rb_tree_node_mark_dirty (item);
|
gtk_rb_tree_node_mark_dirty (item);
|
||||||
|
|
||||||
@ -570,12 +569,6 @@ gtk_list_item_manager_ensure_items (GtkListItemManager *self,
|
|||||||
gtk_list_item_manager_release_list_item (self, NULL, widget);
|
gtk_list_item_manager_release_list_item (self, NULL, widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gtk_list_item_manager_model_selection_changed_cb (GListModel *model,
|
|
||||||
guint position,
|
|
||||||
guint n_items,
|
|
||||||
GtkListItemManager *self);
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_list_item_manager_model_items_changed_cb (GListModel *model,
|
gtk_list_item_manager_model_items_changed_cb (GListModel *model,
|
||||||
guint position,
|
guint position,
|
||||||
@ -742,8 +735,6 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
|
|||||||
|
|
||||||
g_hash_table_unref (change);
|
g_hash_table_unref (change);
|
||||||
|
|
||||||
gtk_list_item_manager_model_selection_changed_cb (model, position, added, self);
|
|
||||||
|
|
||||||
gtk_widget_queue_resize (self->widget);
|
gtk_widget_queue_resize (self->widget);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -988,7 +979,7 @@ gtk_list_item_manager_try_reacquire_list_item (GtkListItemManager *self,
|
|||||||
gtk_list_item_widget_update (list_item,
|
gtk_list_item_widget_update (list_item,
|
||||||
position,
|
position,
|
||||||
gtk_list_item_widget_get_item (list_item),
|
gtk_list_item_widget_get_item (list_item),
|
||||||
gtk_list_item_widget_get_selected (list_item));
|
gtk_selection_model_is_selected (self->model, position));
|
||||||
gtk_widget_insert_after (result, self->widget, prev_sibling);
|
gtk_widget_insert_after (result, self->widget, prev_sibling);
|
||||||
/* XXX: Should we let the listview do this? */
|
/* XXX: Should we let the listview do this? */
|
||||||
gtk_widget_queue_resize (result);
|
gtk_widget_queue_resize (result);
|
||||||
|
@ -175,6 +175,7 @@ gtk_multi_selection_unselect_all (GtkSelectionModel *model)
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_multi_selection_add_or_remove (GtkSelectionModel *model,
|
gtk_multi_selection_add_or_remove (GtkSelectionModel *model,
|
||||||
|
gboolean unselect_rest,
|
||||||
gboolean add,
|
gboolean add,
|
||||||
GtkSelectionCallback callback,
|
GtkSelectionCallback callback,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
@ -190,6 +191,13 @@ gtk_multi_selection_add_or_remove (GtkSelectionModel *model,
|
|||||||
min = G_MAXUINT;
|
min = G_MAXUINT;
|
||||||
max = 0;
|
max = 0;
|
||||||
|
|
||||||
|
if (unselect_rest)
|
||||||
|
{
|
||||||
|
min = gtk_set_get_min (self->selected);
|
||||||
|
max = gtk_set_get_max (self->selected);
|
||||||
|
gtk_set_remove_all (self->selected);
|
||||||
|
}
|
||||||
|
|
||||||
for (pos = 0; pos < n; pos = start + n_items)
|
for (pos = 0; pos < n; pos = start + n_items)
|
||||||
{
|
{
|
||||||
callback (pos, &start, &n_items, &in, data);
|
callback (pos, &start, &n_items, &in, data);
|
||||||
@ -223,10 +231,11 @@ gtk_multi_selection_add_or_remove (GtkSelectionModel *model,
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_multi_selection_select_callback (GtkSelectionModel *model,
|
gtk_multi_selection_select_callback (GtkSelectionModel *model,
|
||||||
|
gboolean unselect_rest,
|
||||||
GtkSelectionCallback callback,
|
GtkSelectionCallback callback,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
return gtk_multi_selection_add_or_remove (model, TRUE, callback, data);
|
return gtk_multi_selection_add_or_remove (model, unselect_rest, TRUE, callback, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -234,7 +243,7 @@ gtk_multi_selection_unselect_callback (GtkSelectionModel *model,
|
|||||||
GtkSelectionCallback callback,
|
GtkSelectionCallback callback,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
return gtk_multi_selection_add_or_remove (model, FALSE, callback, data);
|
return gtk_multi_selection_add_or_remove (model, FALSE, FALSE, callback, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -210,16 +210,24 @@ gtk_property_selection_unselect_all (GtkSelectionModel *model)
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_property_selection_add_or_remove (GtkSelectionModel *model,
|
gtk_property_selection_add_or_remove (GtkSelectionModel *model,
|
||||||
|
gboolean unselect_rest,
|
||||||
gboolean add,
|
gboolean add,
|
||||||
GtkSelectionCallback callback,
|
GtkSelectionCallback callback,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkPropertySelection *self = GTK_PROPERTY_SELECTION (model);
|
GtkPropertySelection *self = GTK_PROPERTY_SELECTION (model);
|
||||||
guint pos, start, n;
|
guint pos, start, n, n_items;
|
||||||
gboolean in;
|
gboolean in;
|
||||||
guint min, max;
|
guint min, max;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
n_items = g_list_model_get_n_items (G_LIST_MODEL (self));
|
||||||
|
if (unselect_rest)
|
||||||
|
{
|
||||||
|
for (i = 0; i < n_items; i++)
|
||||||
|
set_selected (self, i, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
min = G_MAXUINT;
|
min = G_MAXUINT;
|
||||||
max = 0;
|
max = 0;
|
||||||
|
|
||||||
@ -241,7 +249,10 @@ gtk_property_selection_add_or_remove (GtkSelectionModel *model,
|
|||||||
}
|
}
|
||||||
while (n > 0);
|
while (n > 0);
|
||||||
|
|
||||||
if (min <= max)
|
/* FIXME: do better here */
|
||||||
|
if (unselect_rest)
|
||||||
|
gtk_selection_model_selection_changed (model, 0, n_items);
|
||||||
|
else if (min <= max)
|
||||||
gtk_selection_model_selection_changed (model, min, max - min + 1);
|
gtk_selection_model_selection_changed (model, min, max - min + 1);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -249,10 +260,11 @@ gtk_property_selection_add_or_remove (GtkSelectionModel *model,
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_property_selection_select_callback (GtkSelectionModel *model,
|
gtk_property_selection_select_callback (GtkSelectionModel *model,
|
||||||
|
gboolean unselect_rest,
|
||||||
GtkSelectionCallback callback,
|
GtkSelectionCallback callback,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
return gtk_property_selection_add_or_remove (model, TRUE, callback, data);
|
return gtk_property_selection_add_or_remove (model, unselect_rest, TRUE, callback, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -260,7 +272,7 @@ gtk_property_selection_unselect_callback (GtkSelectionModel *model,
|
|||||||
GtkSelectionCallback callback,
|
GtkSelectionCallback callback,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
return gtk_property_selection_add_or_remove (model, FALSE, callback, data);
|
return gtk_property_selection_add_or_remove (model, FALSE, FALSE, callback, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -85,7 +85,7 @@ gtk_selection_model_default_is_selected (GtkSelectionModel *model,
|
|||||||
static gboolean
|
static gboolean
|
||||||
gtk_selection_model_default_select_item (GtkSelectionModel *model,
|
gtk_selection_model_default_select_item (GtkSelectionModel *model,
|
||||||
guint position,
|
guint position,
|
||||||
gboolean exclusive)
|
gboolean unselect_rest)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ static gboolean
|
|||||||
gtk_selection_model_default_select_range (GtkSelectionModel *model,
|
gtk_selection_model_default_select_range (GtkSelectionModel *model,
|
||||||
guint position,
|
guint position,
|
||||||
guint n_items,
|
guint n_items,
|
||||||
gboolean exclusive)
|
gboolean unselect_rest)
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -115,6 +115,7 @@ gtk_selection_model_default_unselect_range (GtkSelectionModel *model,
|
|||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gtk_selection_model_default_select_callback (GtkSelectionModel *model,
|
gtk_selection_model_default_select_callback (GtkSelectionModel *model,
|
||||||
|
gboolean unselect_rest,
|
||||||
GtkSelectionCallback callback,
|
GtkSelectionCallback callback,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
@ -228,21 +229,21 @@ gtk_selection_model_is_selected (GtkSelectionModel *model,
|
|||||||
* gtk_selection_model_select_item:
|
* gtk_selection_model_select_item:
|
||||||
* @model: a #GtkSelectionModel
|
* @model: a #GtkSelectionModel
|
||||||
* @position: the position of the item to select
|
* @position: the position of the item to select
|
||||||
* @exclusive: whether previously selected items should be unselected
|
* @unselect_rest: whether previously selected items should be unselected
|
||||||
*
|
*
|
||||||
* Requests to select an item in the model.
|
* Requests to select an item in the model.
|
||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gtk_selection_model_select_item (GtkSelectionModel *model,
|
gtk_selection_model_select_item (GtkSelectionModel *model,
|
||||||
guint position,
|
guint position,
|
||||||
gboolean exclusive)
|
gboolean unselect_rest)
|
||||||
{
|
{
|
||||||
GtkSelectionModelInterface *iface;
|
GtkSelectionModelInterface *iface;
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_SELECTION_MODEL (model), 0);
|
g_return_val_if_fail (GTK_IS_SELECTION_MODEL (model), 0);
|
||||||
|
|
||||||
iface = GTK_SELECTION_MODEL_GET_IFACE (model);
|
iface = GTK_SELECTION_MODEL_GET_IFACE (model);
|
||||||
return iface->select_item (model, position, exclusive);
|
return iface->select_item (model, position, unselect_rest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -269,7 +270,7 @@ gtk_selection_model_unselect_item (GtkSelectionModel *model,
|
|||||||
* @model: a #GtkSelectionModel
|
* @model: a #GtkSelectionModel
|
||||||
* @position: the first item to select
|
* @position: the first item to select
|
||||||
* @n_items: the number of items to select
|
* @n_items: the number of items to select
|
||||||
* @exclusive: whether previously selected items should be unselected
|
* @unselect_rest: whether previously selected items should be unselected
|
||||||
*
|
*
|
||||||
* Requests to select a range of items in the model.
|
* Requests to select a range of items in the model.
|
||||||
*/
|
*/
|
||||||
@ -277,14 +278,14 @@ gboolean
|
|||||||
gtk_selection_model_select_range (GtkSelectionModel *model,
|
gtk_selection_model_select_range (GtkSelectionModel *model,
|
||||||
guint position,
|
guint position,
|
||||||
guint n_items,
|
guint n_items,
|
||||||
gboolean exclusive)
|
gboolean unselect_rest)
|
||||||
{
|
{
|
||||||
GtkSelectionModelInterface *iface;
|
GtkSelectionModelInterface *iface;
|
||||||
|
|
||||||
g_return_val_if_fail (GTK_IS_SELECTION_MODEL (model), 0);
|
g_return_val_if_fail (GTK_IS_SELECTION_MODEL (model), 0);
|
||||||
|
|
||||||
iface = GTK_SELECTION_MODEL_GET_IFACE (model);
|
iface = GTK_SELECTION_MODEL_GET_IFACE (model);
|
||||||
return iface->select_range (model, position, n_items, exclusive);
|
return iface->select_range (model, position, n_items, unselect_rest);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -345,6 +346,7 @@ gtk_selection_model_unselect_all (GtkSelectionModel *model)
|
|||||||
/**
|
/**
|
||||||
* gtk_selection_model_select_callback:
|
* gtk_selection_model_select_callback:
|
||||||
* @model: a #GtkSelectionModel
|
* @model: a #GtkSelectionModel
|
||||||
|
* @unselect_rest: whether previously selected items should be unselected
|
||||||
* @callback: (scope call): a #GtkSelectionCallback to determine items to select
|
* @callback: (scope call): a #GtkSelectionCallback to determine items to select
|
||||||
* @data: data to pass to @callback
|
* @data: data to pass to @callback
|
||||||
*
|
*
|
||||||
@ -353,12 +355,13 @@ gtk_selection_model_unselect_all (GtkSelectionModel *model)
|
|||||||
*/
|
*/
|
||||||
gboolean
|
gboolean
|
||||||
gtk_selection_model_select_callback (GtkSelectionModel *model,
|
gtk_selection_model_select_callback (GtkSelectionModel *model,
|
||||||
|
gboolean unselect_rest,
|
||||||
GtkSelectionCallback callback,
|
GtkSelectionCallback callback,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GTK_IS_SELECTION_MODEL (model), FALSE);
|
g_return_val_if_fail (GTK_IS_SELECTION_MODEL (model), FALSE);
|
||||||
|
|
||||||
return GTK_SELECTION_MODEL_GET_IFACE (model)->select_callback (model, callback, data);
|
return GTK_SELECTION_MODEL_GET_IFACE (model)->select_callback (model, unselect_rest, callback, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,19 +97,20 @@ struct _GtkSelectionModelInterface
|
|||||||
|
|
||||||
gboolean (* select_item) (GtkSelectionModel *model,
|
gboolean (* select_item) (GtkSelectionModel *model,
|
||||||
guint position,
|
guint position,
|
||||||
gboolean exclusive);
|
gboolean unselect_rest);
|
||||||
gboolean (* unselect_item) (GtkSelectionModel *model,
|
gboolean (* unselect_item) (GtkSelectionModel *model,
|
||||||
guint position);
|
guint position);
|
||||||
gboolean (* select_range) (GtkSelectionModel *model,
|
gboolean (* select_range) (GtkSelectionModel *model,
|
||||||
guint position,
|
guint position,
|
||||||
guint n_items,
|
guint n_items,
|
||||||
gboolean exclusive);
|
gboolean unselect_rest);
|
||||||
gboolean (* unselect_range) (GtkSelectionModel *model,
|
gboolean (* unselect_range) (GtkSelectionModel *model,
|
||||||
guint position,
|
guint position,
|
||||||
guint n_items);
|
guint n_items);
|
||||||
gboolean (* select_all) (GtkSelectionModel *model);
|
gboolean (* select_all) (GtkSelectionModel *model);
|
||||||
gboolean (* unselect_all) (GtkSelectionModel *model);
|
gboolean (* unselect_all) (GtkSelectionModel *model);
|
||||||
gboolean (* select_callback) (GtkSelectionModel *model,
|
gboolean (* select_callback) (GtkSelectionModel *model,
|
||||||
|
gboolean unselect_rest,
|
||||||
GtkSelectionCallback callback,
|
GtkSelectionCallback callback,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
gboolean (* unselect_callback) (GtkSelectionModel *model,
|
gboolean (* unselect_callback) (GtkSelectionModel *model,
|
||||||
@ -129,7 +130,7 @@ gboolean gtk_selection_model_is_selected (GtkSelectionMod
|
|||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
gboolean gtk_selection_model_select_item (GtkSelectionModel *model,
|
gboolean gtk_selection_model_select_item (GtkSelectionModel *model,
|
||||||
guint position,
|
guint position,
|
||||||
gboolean exclusive);
|
gboolean unselect_rest);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
gboolean gtk_selection_model_unselect_item (GtkSelectionModel *model,
|
gboolean gtk_selection_model_unselect_item (GtkSelectionModel *model,
|
||||||
guint position);
|
guint position);
|
||||||
@ -137,7 +138,7 @@ GDK_AVAILABLE_IN_ALL
|
|||||||
gboolean gtk_selection_model_select_range (GtkSelectionModel *model,
|
gboolean gtk_selection_model_select_range (GtkSelectionModel *model,
|
||||||
guint position,
|
guint position,
|
||||||
guint n_items,
|
guint n_items,
|
||||||
gboolean exclusive);
|
gboolean unselect_rest);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
gboolean gtk_selection_model_unselect_range (GtkSelectionModel *model,
|
gboolean gtk_selection_model_unselect_range (GtkSelectionModel *model,
|
||||||
guint position,
|
guint position,
|
||||||
@ -149,6 +150,7 @@ gboolean gtk_selection_model_unselect_all (GtkSelectionMod
|
|||||||
|
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
gboolean gtk_selection_model_select_callback (GtkSelectionModel *model,
|
gboolean gtk_selection_model_select_callback (GtkSelectionModel *model,
|
||||||
|
gboolean unselect_rest,
|
||||||
GtkSelectionCallback callback,
|
GtkSelectionCallback callback,
|
||||||
gpointer data);
|
gpointer data);
|
||||||
GDK_AVAILABLE_IN_ALL
|
GDK_AVAILABLE_IN_ALL
|
||||||
|
@ -496,7 +496,7 @@ test_callback (void)
|
|||||||
assert_selection (selection, "");
|
assert_selection (selection, "");
|
||||||
assert_selection_changes (selection, "");
|
assert_selection_changes (selection, "");
|
||||||
|
|
||||||
ret = gtk_selection_model_select_callback (selection, select_some, data);
|
ret = gtk_selection_model_select_callback (selection, FALSE, select_some, data);
|
||||||
g_assert_true (ret);
|
g_assert_true (ret);
|
||||||
assert_selection (selection, "3 4 5 7 8 9");
|
assert_selection (selection, "3 4 5 7 8 9");
|
||||||
assert_selection_changes (selection, "2:7");
|
assert_selection_changes (selection, "2:7");
|
||||||
|
Loading…
Reference in New Issue
Block a user