forked from AuroraMiddleware/gtk
gtk: change GtkIconView to "support" actual trees
Remove the check for GTK_TREE_MODEL_LIST_ONLY and make the view display only the first level of the tree, ignoring all insert, remove etc. events on the model's branches. This enables generic application code which always produces GtkTreeStores (also for flat lists) to display grids of these flat trees.
This commit is contained in:
parent
331323e5c7
commit
e4654327df
@ -48,12 +48,17 @@
|
|||||||
* @title: GtkIconView
|
* @title: GtkIconView
|
||||||
* @short_description: A widget which displays a list of icons in a grid
|
* @short_description: A widget which displays a list of icons in a grid
|
||||||
*
|
*
|
||||||
* #GtkIconView provides an alternative view on a list model.
|
* #GtkIconView provides an alternative view on a #GtkTreeModel.
|
||||||
* It displays the model as a grid of icons with labels. Like
|
* It displays the model as a grid of icons with labels. Like
|
||||||
* #GtkTreeView, it allows to select one or multiple items
|
* #GtkTreeView, it allows to select one or multiple items
|
||||||
* (depending on the selection mode, see gtk_icon_view_set_selection_mode()).
|
* (depending on the selection mode, see gtk_icon_view_set_selection_mode()).
|
||||||
* In addition to selection with the arrow keys, #GtkIconView supports
|
* In addition to selection with the arrow keys, #GtkIconView supports
|
||||||
* rubberband selection, which is controlled by dragging the pointer.
|
* rubberband selection, which is controlled by dragging the pointer.
|
||||||
|
*
|
||||||
|
* Note that if the tree model is backed by an actual tree store (as
|
||||||
|
* opposed to a flat list where the mapping to icons is obvious),
|
||||||
|
* #GtkIconView will only display the first level of the tree and
|
||||||
|
* ignore the tree's branches.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define SCROLL_EDGE_SIZE 15
|
#define SCROLL_EDGE_SIZE 15
|
||||||
@ -3597,11 +3602,13 @@ gtk_icon_view_row_changed (GtkTreeModel *model,
|
|||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
GtkIconView *icon_view = GTK_ICON_VIEW (data);
|
||||||
GtkIconViewItem *item;
|
GtkIconViewItem *item;
|
||||||
gint index;
|
gint index;
|
||||||
GtkIconView *icon_view;
|
|
||||||
|
|
||||||
icon_view = GTK_ICON_VIEW (data);
|
/* ignore changes in branches */
|
||||||
|
if (gtk_tree_path_get_depth (path) > 1)
|
||||||
|
return;
|
||||||
|
|
||||||
gtk_icon_view_stop_editing (icon_view, TRUE);
|
gtk_icon_view_stop_editing (icon_view, TRUE);
|
||||||
|
|
||||||
@ -3620,13 +3627,15 @@ gtk_icon_view_row_inserted (GtkTreeModel *model,
|
|||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
GtkIconView *icon_view = GTK_ICON_VIEW (data);
|
||||||
gint index;
|
gint index;
|
||||||
GtkIconViewItem *item;
|
GtkIconViewItem *item;
|
||||||
gboolean iters_persist;
|
gboolean iters_persist;
|
||||||
GtkIconView *icon_view;
|
|
||||||
GList *list;
|
GList *list;
|
||||||
|
|
||||||
icon_view = GTK_ICON_VIEW (data);
|
/* ignore changes in branches */
|
||||||
|
if (gtk_tree_path_get_depth (path) > 1)
|
||||||
|
return;
|
||||||
|
|
||||||
iters_persist = gtk_tree_model_get_flags (icon_view->priv->model) & GTK_TREE_MODEL_ITERS_PERSIST;
|
iters_persist = gtk_tree_model_get_flags (icon_view->priv->model) & GTK_TREE_MODEL_ITERS_PERSIST;
|
||||||
|
|
||||||
@ -3664,13 +3673,15 @@ gtk_icon_view_row_deleted (GtkTreeModel *model,
|
|||||||
GtkTreePath *path,
|
GtkTreePath *path,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
GtkIconView *icon_view = GTK_ICON_VIEW (data);
|
||||||
gint index;
|
gint index;
|
||||||
GtkIconView *icon_view;
|
|
||||||
GtkIconViewItem *item;
|
GtkIconViewItem *item;
|
||||||
GList *list, *next;
|
GList *list, *next;
|
||||||
gboolean emit = FALSE;
|
gboolean emit = FALSE;
|
||||||
|
|
||||||
icon_view = GTK_ICON_VIEW (data);
|
/* ignore changes in branches */
|
||||||
|
if (gtk_tree_path_get_depth (path) > 1)
|
||||||
|
return;
|
||||||
|
|
||||||
index = gtk_tree_path_get_indices(path)[0];
|
index = gtk_tree_path_get_indices(path)[0];
|
||||||
|
|
||||||
@ -3714,14 +3725,16 @@ gtk_icon_view_rows_reordered (GtkTreeModel *model,
|
|||||||
gint *new_order,
|
gint *new_order,
|
||||||
gpointer data)
|
gpointer data)
|
||||||
{
|
{
|
||||||
|
GtkIconView *icon_view = GTK_ICON_VIEW (data);
|
||||||
int i;
|
int i;
|
||||||
int length;
|
int length;
|
||||||
GtkIconView *icon_view;
|
|
||||||
GList *items = NULL, *list;
|
GList *items = NULL, *list;
|
||||||
GtkIconViewItem **item_array;
|
GtkIconViewItem **item_array;
|
||||||
gint *order;
|
gint *order;
|
||||||
|
|
||||||
icon_view = GTK_ICON_VIEW (data);
|
/* ignore changes in branches */
|
||||||
|
if (iter != NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
gtk_icon_view_stop_editing (icon_view, TRUE);
|
gtk_icon_view_stop_editing (icon_view, TRUE);
|
||||||
|
|
||||||
@ -5334,8 +5347,6 @@ gtk_icon_view_set_model (GtkIconView *icon_view,
|
|||||||
if (model)
|
if (model)
|
||||||
{
|
{
|
||||||
GType column_type;
|
GType column_type;
|
||||||
|
|
||||||
g_return_if_fail (gtk_tree_model_get_flags (model) & GTK_TREE_MODEL_LIST_ONLY);
|
|
||||||
|
|
||||||
if (icon_view->priv->pixbuf_column != -1)
|
if (icon_view->priv->pixbuf_column != -1)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user