Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 9a491e585a | |||
| 21087a4009 | |||
| 89850b3602 | |||
| 6cf67e8b7c | |||
| da49e7bb79 | |||
| 32175fcd80 | |||
| e98b38f46e | |||
| 7453c733c7 | |||
| 76887647a1 | |||
| 0663c0f616 | |||
| 810008f25e | |||
| 2d8c88972d |
7 changed files with 2976 additions and 996 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -122,8 +122,7 @@ struct _GtkFileChooserWidgetPrivate
|
|||
|
||||
typedef enum {
|
||||
LOAD_EMPTY, /* There is no model */
|
||||
LOAD_PRELOAD, /* Model is loading and a timer is running; model isn't inserted into the tree yet */
|
||||
LOAD_LOADING, /* Timeout expired, model is inserted into the tree, but not fully loaded yet */
|
||||
LOAD_LOADING, /* Model is loading; the list view shows it, the icon view gets it when loading is done */
|
||||
LOAD_FINISHED /* Model is fully loaded and inserted into the tree */
|
||||
} LoadState;
|
||||
|
||||
|
|
@ -182,6 +181,7 @@ struct _GtkFileChooserDefault
|
|||
GtkWidget *browse_files_icon_view;
|
||||
GtkWidget *browse_files_popup_menu;
|
||||
GtkWidget *browse_files_popup_menu_add_shortcut_item;
|
||||
GtkWidget *browse_files_popup_menu_copy_location_item;
|
||||
GtkWidget *browse_files_popup_menu_hidden_files_item;
|
||||
GtkWidget *browse_files_popup_menu_size_column_item;
|
||||
GtkWidget *browse_files_popup_menu_sort_by_name_item;
|
||||
|
|
@ -228,14 +228,17 @@ struct _GtkFileChooserDefault
|
|||
GtkWidget *extra_widget;
|
||||
|
||||
GtkWidget *view_mode_combo_box;
|
||||
GtkWidget *icon_view_scale_hbox;
|
||||
GtkWidget *icon_view_scale_hbox; /* created when the icon view is first used */
|
||||
GtkWidget *icon_view_scale;
|
||||
GtkWidget *icon_view_scale_zoom_in_icon;
|
||||
GtkWidget *icon_view_scale_zoom_out_icon;
|
||||
guint icon_view_scale_timeout_id;
|
||||
guint icon_view_scale_visible_timeout_id;
|
||||
guint icon_view_scale_after_layout_id;
|
||||
gint pending_icon_view_icon_size;
|
||||
|
||||
/* Icon queries for the rows on screen (see icons_update_cb()) */
|
||||
GQueue icon_queries_waiting;
|
||||
GList *icon_queries_running;
|
||||
guint icons_update_id;
|
||||
gint icon_view_scale_visible_overscan;
|
||||
ViewMode view_mode;
|
||||
|
||||
|
|
@ -261,10 +264,11 @@ struct _GtkFileChooserDefault
|
|||
GCancellable *file_exists_get_info_cancellable;
|
||||
GCancellable *update_from_entry_cancellable;
|
||||
GCancellable *shortcuts_activate_iter_cancellable;
|
||||
GCancellable *shortcuts_current_folder_cancellable;
|
||||
GCancellable *create_folder_cancellable;
|
||||
|
||||
LoadState load_state;
|
||||
ReloadState reload_state;
|
||||
guint load_timeout_id;
|
||||
|
||||
OperationMode operation_mode;
|
||||
|
||||
|
|
|
|||
|
|
@ -840,33 +840,62 @@ _gtk_file_system_mount_volume (GtkFileSystem *file_system,
|
|||
return cancellable;
|
||||
}
|
||||
|
||||
static void
|
||||
enclosing_volume_found_cb (GObject *source_object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
AsyncFuncData *async_data = user_data;
|
||||
GtkFileSystemVolume *volume;
|
||||
GMount *mount;
|
||||
|
||||
mount = g_file_find_enclosing_mount_finish (G_FILE (source_object), result, NULL);
|
||||
volume = _gtk_file_system_volume_for_mount (G_FILE (source_object), mount);
|
||||
|
||||
gdk_threads_enter ();
|
||||
((GtkFileSystemVolumeMountCallback) async_data->callback) (async_data->cancellable, volume,
|
||||
NULL, async_data->data);
|
||||
gdk_threads_leave ();
|
||||
|
||||
_gtk_file_system_volume_unref (volume);
|
||||
free_async_data (async_data);
|
||||
}
|
||||
|
||||
static void
|
||||
enclosing_volume_mount_cb (GObject *source_object,
|
||||
GAsyncResult *result,
|
||||
gpointer user_data)
|
||||
{
|
||||
GtkFileSystemVolume *volume;
|
||||
AsyncFuncData *async_data;
|
||||
GError *error = NULL;
|
||||
|
||||
async_data = (AsyncFuncData *) user_data;
|
||||
g_file_mount_enclosing_volume_finish (G_FILE (source_object), result, &error);
|
||||
volume = _gtk_file_system_get_volume_for_file (async_data->file_system, G_FILE (source_object));
|
||||
|
||||
/* Silently drop G_IO_ERROR_ALREADY_MOUNTED error for gvfs backends without visible mounts. */
|
||||
/* Better than doing query_info with additional I/O every time. */
|
||||
if (error && g_error_matches (error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED))
|
||||
g_clear_error (&error);
|
||||
|
||||
gdk_threads_enter ();
|
||||
((GtkFileSystemVolumeMountCallback) async_data->callback) (async_data->cancellable, volume,
|
||||
error, async_data->data);
|
||||
gdk_threads_leave ();
|
||||
|
||||
if (error)
|
||||
g_error_free (error);
|
||||
{
|
||||
gdk_threads_enter ();
|
||||
((GtkFileSystemVolumeMountCallback) async_data->callback) (async_data->cancellable, NULL,
|
||||
error, async_data->data);
|
||||
gdk_threads_leave ();
|
||||
|
||||
_gtk_file_system_volume_unref (volume);
|
||||
g_error_free (error);
|
||||
free_async_data (async_data);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Finding the volume stats @file and its parents on the share that was
|
||||
* just mounted, which can take a while. */
|
||||
g_file_find_enclosing_mount_async (G_FILE (source_object),
|
||||
G_PRIORITY_DEFAULT,
|
||||
async_data->cancellable,
|
||||
enclosing_volume_found_cb,
|
||||
async_data);
|
||||
}
|
||||
|
||||
GCancellable *
|
||||
|
|
@ -1077,22 +1106,30 @@ _gtk_file_system_set_bookmark_label (GtkFileSystem *file_system,
|
|||
g_signal_emit_by_name (file_system, "bookmarks-changed", 0);
|
||||
}
|
||||
|
||||
/* The volume for the result of g_file_find_enclosing_mount() (or its
|
||||
* async variant) for @file; takes ownership of @mount. */
|
||||
GtkFileSystemVolume *
|
||||
_gtk_file_system_get_volume_for_file (GtkFileSystem *file_system,
|
||||
GFile *file)
|
||||
_gtk_file_system_volume_for_mount (GFile *file,
|
||||
GMount *mount)
|
||||
{
|
||||
GMount *mount;
|
||||
|
||||
DEBUG ("get_volume_for_file");
|
||||
|
||||
mount = g_file_find_enclosing_mount (file, NULL, NULL);
|
||||
|
||||
if (!mount && g_file_is_native (file))
|
||||
return (GtkFileSystemVolume *) root_volume_token;
|
||||
|
||||
return (GtkFileSystemVolume *) mount;
|
||||
}
|
||||
|
||||
/* Blocks while @file and its parents are examined; code on the main thread
|
||||
* should use g_file_find_enclosing_mount_async() and
|
||||
* _gtk_file_system_volume_for_mount() instead. */
|
||||
GtkFileSystemVolume *
|
||||
_gtk_file_system_get_volume_for_file (GtkFileSystem *file_system,
|
||||
GFile *file)
|
||||
{
|
||||
DEBUG ("get_volume_for_file");
|
||||
|
||||
return _gtk_file_system_volume_for_mount (file, g_file_find_enclosing_mount (file, NULL, NULL));
|
||||
}
|
||||
|
||||
/* GtkFolder methods */
|
||||
static void
|
||||
gtk_folder_set_property (GObject *object,
|
||||
|
|
@ -1626,18 +1663,105 @@ file_icon_cache_key_free (FileIconCacheKey *key)
|
|||
g_slice_free (FileIconCacheKey, key);
|
||||
}
|
||||
|
||||
static void
|
||||
file_icon_cache_theme_changed_cb (GtkIconTheme *icon_theme,
|
||||
GHashTable *cache)
|
||||
/* The cache is bounded (least recently used entries go first) so zooming
|
||||
* through many icon sizes does not keep every rendered size alive. */
|
||||
#define FILE_ICON_CACHE_MAX_ENTRIES 64
|
||||
#define FILE_ICON_CACHE_MAX_BYTES (4 * 1024 * 1024)
|
||||
|
||||
typedef struct
|
||||
{
|
||||
g_hash_table_remove_all (cache);
|
||||
GHashTable *table; /* FileIconCacheKey -> FileIconCacheEntry */
|
||||
GQueue lru; /* keys, most recently used first */
|
||||
gsize bytes;
|
||||
} FileIconCache;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GList *link; /* in FileIconCache.lru */
|
||||
gsize bytes;
|
||||
} FileIconCacheEntry;
|
||||
|
||||
static void
|
||||
file_icon_cache_entry_free (FileIconCacheEntry *entry)
|
||||
{
|
||||
g_object_unref (entry->pixbuf);
|
||||
g_slice_free (FileIconCacheEntry, entry);
|
||||
}
|
||||
|
||||
static GHashTable *
|
||||
static void
|
||||
file_icon_cache_free (FileIconCache *cache)
|
||||
{
|
||||
g_queue_clear (&cache->lru);
|
||||
g_hash_table_destroy (cache->table);
|
||||
g_slice_free (FileIconCache, cache);
|
||||
}
|
||||
|
||||
static void
|
||||
file_icon_cache_theme_changed_cb (GtkIconTheme *icon_theme,
|
||||
FileIconCache *cache)
|
||||
{
|
||||
g_queue_clear (&cache->lru);
|
||||
g_hash_table_remove_all (cache->table);
|
||||
cache->bytes = 0;
|
||||
}
|
||||
|
||||
static GdkPixbuf *
|
||||
file_icon_cache_lookup (FileIconCache *cache,
|
||||
const FileIconCacheKey *key)
|
||||
{
|
||||
FileIconCacheEntry *entry = g_hash_table_lookup (cache->table, key);
|
||||
|
||||
if (entry == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Mark as most recently used. */
|
||||
g_queue_unlink (&cache->lru, entry->link);
|
||||
g_queue_push_head_link (&cache->lru, entry->link);
|
||||
|
||||
return entry->pixbuf;
|
||||
}
|
||||
|
||||
static void
|
||||
file_icon_cache_insert (FileIconCache *cache,
|
||||
FileIconCacheKey *key,
|
||||
GdkPixbuf *pixbuf)
|
||||
{
|
||||
FileIconCacheEntry *entry;
|
||||
|
||||
/* g_hash_table_insert() would free @key and keep the old one, leaving a
|
||||
* dangling pointer in the LRU queue; keep the existing entry instead. */
|
||||
if (g_hash_table_lookup (cache->table, key) != NULL)
|
||||
{
|
||||
file_icon_cache_key_free (key);
|
||||
return;
|
||||
}
|
||||
|
||||
entry = g_slice_new (FileIconCacheEntry);
|
||||
entry->pixbuf = g_object_ref (pixbuf);
|
||||
entry->bytes = (gsize) gdk_pixbuf_get_rowstride (pixbuf) * gdk_pixbuf_get_height (pixbuf);
|
||||
g_queue_push_head (&cache->lru, key);
|
||||
entry->link = cache->lru.head;
|
||||
g_hash_table_insert (cache->table, key, entry);
|
||||
cache->bytes += entry->bytes;
|
||||
|
||||
while (cache->lru.length > 1 &&
|
||||
(cache->lru.length > FILE_ICON_CACHE_MAX_ENTRIES ||
|
||||
cache->bytes > FILE_ICON_CACHE_MAX_BYTES))
|
||||
{
|
||||
FileIconCacheKey *old_key = g_queue_pop_tail (&cache->lru);
|
||||
FileIconCacheEntry *old = g_hash_table_lookup (cache->table, old_key);
|
||||
|
||||
cache->bytes -= old->bytes;
|
||||
g_hash_table_remove (cache->table, old_key);
|
||||
}
|
||||
}
|
||||
|
||||
static FileIconCache *
|
||||
file_icon_cache_get_for_icon_theme (GtkIconTheme *icon_theme)
|
||||
{
|
||||
static GQuark quark_file_icon_cache = 0;
|
||||
GHashTable *cache;
|
||||
FileIconCache *cache;
|
||||
|
||||
if (G_UNLIKELY (quark_file_icon_cache == 0))
|
||||
quark_file_icon_cache = g_quark_from_static_string ("gtk-file-icon-cache");
|
||||
|
|
@ -1645,14 +1769,16 @@ file_icon_cache_get_for_icon_theme (GtkIconTheme *icon_theme)
|
|||
cache = g_object_get_qdata (G_OBJECT (icon_theme), quark_file_icon_cache);
|
||||
if (!cache)
|
||||
{
|
||||
cache = g_hash_table_new_full (file_icon_cache_key_hash,
|
||||
file_icon_cache_key_equal,
|
||||
(GDestroyNotify) file_icon_cache_key_free,
|
||||
g_object_unref);
|
||||
cache = g_slice_new0 (FileIconCache);
|
||||
cache->table = g_hash_table_new_full (file_icon_cache_key_hash,
|
||||
file_icon_cache_key_equal,
|
||||
(GDestroyNotify) file_icon_cache_key_free,
|
||||
(GDestroyNotify) file_icon_cache_entry_free);
|
||||
g_queue_init (&cache->lru);
|
||||
g_object_set_qdata_full (G_OBJECT (icon_theme),
|
||||
quark_file_icon_cache,
|
||||
cache,
|
||||
(GDestroyNotify) g_hash_table_destroy);
|
||||
(GDestroyNotify) file_icon_cache_free);
|
||||
|
||||
g_signal_connect (icon_theme, "changed",
|
||||
G_CALLBACK (file_icon_cache_theme_changed_cb),
|
||||
|
|
@ -1671,7 +1797,7 @@ get_pixbuf_from_gicon (GIcon *icon,
|
|||
GdkScreen *screen;
|
||||
GtkIconTheme *icon_theme;
|
||||
GtkIconInfo *icon_info;
|
||||
GHashTable *cache;
|
||||
FileIconCache *cache;
|
||||
FileIconCacheKey lookup_key;
|
||||
FileIconCacheKey *cache_key;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
|
@ -1695,7 +1821,7 @@ get_pixbuf_from_gicon (GIcon *icon,
|
|||
lookup_key.icon = icon;
|
||||
lookup_key.icon_size = icon_size;
|
||||
|
||||
pixbuf = g_hash_table_lookup (cache, &lookup_key);
|
||||
pixbuf = file_icon_cache_lookup (cache, &lookup_key);
|
||||
if (pixbuf)
|
||||
return g_object_ref (pixbuf);
|
||||
}
|
||||
|
|
@ -1721,7 +1847,7 @@ get_pixbuf_from_gicon (GIcon *icon,
|
|||
if (cache)
|
||||
{
|
||||
cache_key = file_icon_cache_key_new (screen, icon, icon_size);
|
||||
g_hash_table_insert (cache, cache_key, g_object_ref (pixbuf));
|
||||
file_icon_cache_insert (cache, cache_key, pixbuf);
|
||||
}
|
||||
|
||||
return pixbuf;
|
||||
|
|
|
|||
|
|
@ -130,6 +130,8 @@ void _gtk_file_system_set_bookmark_label (GtkFileSystem *file_system,
|
|||
GFile *file,
|
||||
const gchar *label);
|
||||
|
||||
GtkFileSystemVolume * _gtk_file_system_volume_for_mount (GFile *file,
|
||||
GMount *mount);
|
||||
GtkFileSystemVolume * _gtk_file_system_get_volume_for_file (GtkFileSystem *file_system,
|
||||
GFile *file);
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -52,7 +52,6 @@ GtkFileSystemModel *_gtk_file_system_model_new_for_directory(GFile *
|
|||
gpointer get_data,
|
||||
guint n_columns,
|
||||
...);
|
||||
GCancellable * _gtk_file_system_model_get_cancellable (GtkFileSystemModel *model);
|
||||
gboolean _gtk_file_system_model_iter_is_visible (GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter);
|
||||
gboolean _gtk_file_system_model_iter_is_filtered_out (GtkFileSystemModel *model,
|
||||
|
|
@ -94,6 +93,7 @@ void _gtk_file_system_model_set_filter (GtkFileSystemModel
|
|||
void _gtk_file_system_model_add_editable (GtkFileSystemModel *model,
|
||||
GtkTreeIter *iter);
|
||||
void _gtk_file_system_model_remove_editable (GtkFileSystemModel *model);
|
||||
void _gtk_file_system_model_flush (GtkFileSystemModel *model);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
|
|
@ -74,6 +74,15 @@ struct _GtkIconViewItem
|
|||
guint selected : 1;
|
||||
guint selected_before_rubberbanding : 1;
|
||||
|
||||
/* The result of the last gtk_icon_view_calculate_item_size2() and its
|
||||
* inputs: the item geometry before the call, the per-cell maximum
|
||||
* heights of the row and the text direction. Invalidated together with
|
||||
* the item size (see gtk_icon_view_item_invalidate_size()). */
|
||||
guint layout_valid : 1;
|
||||
guint layout_rtl : 1;
|
||||
gint layout_x, layout_y, layout_width;
|
||||
gint layout_out_width, layout_out_height;
|
||||
gint *layout_max_height;
|
||||
};
|
||||
|
||||
typedef struct _GtkIconViewCellInfo GtkIconViewCellInfo;
|
||||
|
|
@ -106,6 +115,14 @@ struct _GtkIconViewPrivate
|
|||
{
|
||||
gint width, height;
|
||||
|
||||
/* The item last looked up by index, so that row-changed for consecutive
|
||||
* rows is O(1) instead of O(n) each. Reset when items are removed or
|
||||
* reordered. */
|
||||
GList *nth_cache_link;
|
||||
|
||||
/* The text cell's wrap width at the last layout (see adjust_wrap_width()) */
|
||||
gint last_wrap_width;
|
||||
|
||||
GtkSelectionMode selection_mode;
|
||||
|
||||
GdkWindow *bin_window;
|
||||
|
|
@ -1425,6 +1442,9 @@ gtk_icon_view_style_set (GtkWidget *widget,
|
|||
gdk_window_set_background (icon_view->priv->bin_window, &widget->style->base[widget->state]);
|
||||
}
|
||||
|
||||
/* Fonts and spacing may have changed: measure the items again. */
|
||||
gtk_icon_view_invalidate_sizes (icon_view);
|
||||
|
||||
gtk_widget_queue_resize (widget);
|
||||
}
|
||||
|
||||
|
|
@ -1590,6 +1610,10 @@ gtk_icon_view_expose (GtkWidget *widget,
|
|||
GtkIconViewItem *item = icons->data;
|
||||
GdkRectangle area;
|
||||
|
||||
/* Rows are laid out top to bottom; nothing after this is exposed. */
|
||||
if (item->y > expose->area.y + expose->area.height)
|
||||
break;
|
||||
|
||||
area.x = item->x;
|
||||
area.y = item->y;
|
||||
area.width = item->width;
|
||||
|
|
@ -2687,6 +2711,69 @@ gtk_icon_view_adjustment_changed (GtkAdjustment *adjustment,
|
|||
}
|
||||
}
|
||||
|
||||
/* Makes the next layout measure the cells of all items again, as
|
||||
* gtk_icon_view_calculate_item_size2() always did before its results were
|
||||
* kept: for changes to the cells that do not invalidate the item sizes. */
|
||||
static void
|
||||
gtk_icon_view_invalidate_cell_layouts (GtkIconView *icon_view)
|
||||
{
|
||||
GList *l;
|
||||
|
||||
for (l = icon_view->priv->items; l; l = l->next)
|
||||
((GtkIconViewItem *) l->data)->layout_valid = FALSE;
|
||||
}
|
||||
|
||||
/* gtk_icon_view_calculate_item_size2(), but if nothing it depends on
|
||||
* changed except the item position, the cell boxes of the last call are
|
||||
* moved instead of measuring all cells again. Measuring text is by far
|
||||
* the most expensive part of a relayout, and every model change relayouts
|
||||
* all items, so this keeps large views responsive. */
|
||||
static void
|
||||
gtk_icon_view_calculate_item_size2_cached (GtkIconView *icon_view,
|
||||
GtkIconViewItem *item,
|
||||
gint *max_height,
|
||||
gboolean rtl)
|
||||
{
|
||||
gint n_cells = icon_view->priv->n_cells;
|
||||
gint i;
|
||||
|
||||
if (item->layout_valid &&
|
||||
item->n_cells == n_cells &&
|
||||
item->layout_rtl == (rtl != FALSE) &&
|
||||
item->layout_width == item->width &&
|
||||
memcmp (item->layout_max_height, max_height, n_cells * sizeof (gint)) == 0)
|
||||
{
|
||||
gint dx = item->x - item->layout_x;
|
||||
gint dy = item->y - item->layout_y;
|
||||
|
||||
for (i = 0; i < n_cells; i++)
|
||||
{
|
||||
item->box[i].x += dx;
|
||||
item->box[i].y += dy;
|
||||
}
|
||||
|
||||
item->layout_x = item->x;
|
||||
item->layout_y = item->y;
|
||||
item->width = item->layout_out_width;
|
||||
item->height = item->layout_out_height;
|
||||
return;
|
||||
}
|
||||
|
||||
item->layout_x = item->x;
|
||||
item->layout_y = item->y;
|
||||
item->layout_width = item->width;
|
||||
item->layout_rtl = rtl != FALSE;
|
||||
|
||||
gtk_icon_view_calculate_item_size2 (icon_view, item, max_height);
|
||||
|
||||
if (item->layout_max_height == NULL)
|
||||
item->layout_max_height = g_new (gint, n_cells);
|
||||
memcpy (item->layout_max_height, max_height, n_cells * sizeof (gint));
|
||||
item->layout_out_width = item->width;
|
||||
item->layout_out_height = item->height;
|
||||
item->layout_valid = item->n_cells == n_cells;
|
||||
}
|
||||
|
||||
static GList *
|
||||
gtk_icon_view_layout_single_row (GtkIconView *icon_view,
|
||||
GList *first_item,
|
||||
|
|
@ -2771,7 +2858,7 @@ gtk_icon_view_layout_single_row (GtkIconView *icon_view,
|
|||
item->col = col - 1 - item->col;
|
||||
}
|
||||
|
||||
gtk_icon_view_calculate_item_size2 (icon_view, item, max_height);
|
||||
gtk_icon_view_calculate_item_size2_cached (icon_view, item, max_height, rtl);
|
||||
|
||||
/* We may want to readjust the new y coordinate. */
|
||||
if (item->y + item->height + focus_width + icon_view->priv->row_spacing > *y)
|
||||
|
|
@ -2986,6 +3073,12 @@ adjust_wrap_width (GtkIconView *icon_view,
|
|||
|
||||
wrap_width -= icon_view->priv->item_padding * 2;
|
||||
|
||||
if (wrap_width != icon_view->priv->last_wrap_width)
|
||||
{
|
||||
icon_view->priv->last_wrap_width = wrap_width;
|
||||
gtk_icon_view_invalidate_cell_layouts (icon_view);
|
||||
}
|
||||
|
||||
g_object_set (text_info->cell, "wrap-width", wrap_width, NULL);
|
||||
g_object_set (text_info->cell, "width", wrap_width, NULL);
|
||||
}
|
||||
|
|
@ -3011,6 +3104,10 @@ gtk_icon_view_calculate_item_size (GtkIconView *icon_view,
|
|||
item->after = g_new0 (gint, icon_view->priv->n_cells);
|
||||
item->box = g_new0 (GdkRectangle, icon_view->priv->n_cells);
|
||||
|
||||
g_free (item->layout_max_height);
|
||||
item->layout_max_height = NULL;
|
||||
item->layout_valid = FALSE;
|
||||
|
||||
item->n_cells = icon_view->priv->n_cells;
|
||||
}
|
||||
|
||||
|
|
@ -3157,6 +3254,7 @@ gtk_icon_view_item_invalidate_size (GtkIconViewItem *item)
|
|||
{
|
||||
item->width = -1;
|
||||
item->height = -1;
|
||||
item->layout_valid = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3478,6 +3576,7 @@ gtk_icon_view_item_free (GtkIconViewItem *item)
|
|||
g_free (item->before);
|
||||
g_free (item->after);
|
||||
g_free (item->box);
|
||||
g_free (item->layout_max_height);
|
||||
|
||||
g_free (item);
|
||||
}
|
||||
|
|
@ -3586,6 +3685,8 @@ gtk_icon_view_unselect_item (GtkIconView *icon_view,
|
|||
static void
|
||||
verify_items (GtkIconView *icon_view)
|
||||
{
|
||||
/* O(n) for every inserted or deleted row: debug builds only */
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
GList *items;
|
||||
int i = 0;
|
||||
|
||||
|
|
@ -3599,6 +3700,28 @@ verify_items (GtkIconView *icon_view)
|
|||
|
||||
i++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* g_list_nth_data() on the items, O(1) when called for consecutive rows */
|
||||
static GtkIconViewItem *
|
||||
gtk_icon_view_nth_item (GtkIconView *icon_view,
|
||||
gint index)
|
||||
{
|
||||
GtkIconViewPrivate *priv = icon_view->priv;
|
||||
GList *link = priv->nth_cache_link;
|
||||
|
||||
/* Inserting rows keeps the cached link valid but shifts indices. */
|
||||
if (link && ((GtkIconViewItem *) link->data)->index == index)
|
||||
;
|
||||
else if (link && ((GtkIconViewItem *) link->data)->index == index - 1 && link->next)
|
||||
link = link->next;
|
||||
else
|
||||
link = g_list_nth (priv->items, index);
|
||||
|
||||
priv->nth_cache_link = link;
|
||||
|
||||
return link ? link->data : NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3616,7 +3739,7 @@ gtk_icon_view_row_changed (GtkTreeModel *model,
|
|||
gtk_icon_view_stop_editing (icon_view, TRUE);
|
||||
|
||||
index = gtk_tree_path_get_indices(path)[0];
|
||||
item = g_list_nth_data (icon_view->priv->items, index);
|
||||
item = gtk_icon_view_nth_item (icon_view, index);
|
||||
|
||||
gtk_icon_view_item_invalidate_size (item);
|
||||
gtk_icon_view_queue_layout (icon_view);
|
||||
|
|
@ -3689,6 +3812,8 @@ gtk_icon_view_row_deleted (GtkTreeModel *model,
|
|||
|
||||
gtk_icon_view_stop_editing (icon_view, TRUE);
|
||||
|
||||
icon_view->priv->nth_cache_link = NULL;
|
||||
|
||||
if (item == icon_view->priv->anchor_item)
|
||||
icon_view->priv->anchor_item = NULL;
|
||||
|
||||
|
|
@ -3735,6 +3860,8 @@ gtk_icon_view_rows_reordered (GtkTreeModel *model,
|
|||
|
||||
gtk_icon_view_stop_editing (icon_view, TRUE);
|
||||
|
||||
icon_view->priv->nth_cache_link = NULL;
|
||||
|
||||
length = gtk_tree_model_iter_n_children (model, NULL);
|
||||
|
||||
order = g_new (gint, length);
|
||||
|
|
@ -4603,6 +4730,8 @@ gtk_icon_view_cell_layout_pack_start (GtkCellLayout *layout,
|
|||
|
||||
icon_view->priv->cell_list = g_list_append (icon_view->priv->cell_list, info);
|
||||
icon_view->priv->n_cells++;
|
||||
|
||||
gtk_icon_view_invalidate_cell_layouts (icon_view);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -4626,6 +4755,8 @@ gtk_icon_view_cell_layout_pack_end (GtkCellLayout *layout,
|
|||
|
||||
icon_view->priv->cell_list = g_list_append (icon_view->priv->cell_list, info);
|
||||
icon_view->priv->n_cells++;
|
||||
|
||||
gtk_icon_view_invalidate_cell_layouts (icon_view);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -4644,6 +4775,8 @@ gtk_icon_view_cell_layout_add_attribute (GtkCellLayout *layout,
|
|||
GINT_TO_POINTER (column));
|
||||
info->attributes = g_slist_prepend (info->attributes,
|
||||
g_strdup (attribute));
|
||||
|
||||
gtk_icon_view_invalidate_cell_layouts (icon_view);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -4660,6 +4793,8 @@ gtk_icon_view_cell_layout_clear (GtkCellLayout *layout)
|
|||
}
|
||||
|
||||
icon_view->priv->n_cells = 0;
|
||||
|
||||
gtk_icon_view_invalidate_cell_layouts (icon_view);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -4686,6 +4821,8 @@ gtk_icon_view_cell_layout_set_cell_data_func (GtkCellLayout *layout,
|
|||
info->func = func;
|
||||
info->func_data = func_data;
|
||||
info->destroy = destroy;
|
||||
|
||||
gtk_icon_view_invalidate_cell_layouts (icon_view);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -4697,6 +4834,8 @@ gtk_icon_view_cell_layout_clear_attributes (GtkCellLayout *layout,
|
|||
info = gtk_icon_view_get_cell_info (GTK_ICON_VIEW (layout), renderer);
|
||||
if (info != NULL)
|
||||
free_cell_attributes (info);
|
||||
|
||||
gtk_icon_view_invalidate_cell_layouts (GTK_ICON_VIEW (layout));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -4734,6 +4873,8 @@ gtk_icon_view_cell_layout_reorder (GtkCellLayout *layout,
|
|||
info->position = i;
|
||||
}
|
||||
|
||||
gtk_icon_view_invalidate_cell_layouts (icon_view);
|
||||
|
||||
gtk_widget_queue_draw (GTK_WIDGET (icon_view));
|
||||
}
|
||||
|
||||
|
|
@ -5207,6 +5348,12 @@ gtk_icon_view_get_visible_range (GtkIconView *icon_view,
|
|||
{
|
||||
GtkIconViewItem *item = icons->data;
|
||||
|
||||
/* Items are laid out row by row: once one starts below the visible
|
||||
* area, all following ones do too. */
|
||||
if (start_index != -1 &&
|
||||
item->y > (int) (icon_view->priv->vadjustment->value + icon_view->priv->vadjustment->page_size))
|
||||
break;
|
||||
|
||||
if ((item->x + item->width >= (int)icon_view->priv->hadjustment->value) &&
|
||||
(item->y + item->height >= (int)icon_view->priv->vadjustment->value) &&
|
||||
(item->x <= (int) (icon_view->priv->hadjustment->value + icon_view->priv->hadjustment->page_size)) &&
|
||||
|
|
@ -5383,6 +5530,7 @@ gtk_icon_view_set_model (GtkIconView *icon_view,
|
|||
g_list_foreach (icon_view->priv->items, (GFunc)gtk_icon_view_item_free, NULL);
|
||||
g_list_free (icon_view->priv->items);
|
||||
icon_view->priv->items = NULL;
|
||||
icon_view->priv->nth_cache_link = NULL;
|
||||
icon_view->priv->anchor_item = NULL;
|
||||
icon_view->priv->cursor_item = NULL;
|
||||
icon_view->priv->last_single_clicked = NULL;
|
||||
|
|
|
|||
Loading…
Reference in a new issue