static void on_recent_file_query_result (GObject *source, GAsyncResult *result, gpointer user_data) { ShellDocSystemRecentQueryData *data = user_data; ShellDocSystem *self = data->self; GError *error = NULL; GFileInfo *fileinfo; fileinfo = g_file_query_info_finish (G_FILE (source), result, &error); if (fileinfo) g_object_unref (fileinfo); /* This is a strict error check; we don't want to cause recent files to * vanish for anything potentially transient. */ if (error != NULL && error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_FOUND) { self->priv->infos_by_timestamp = g_slist_remove (self->priv->infos_by_timestamp, data->info); g_hash_table_remove (self->priv->infos_by_uri, gtk_recent_info_get_uri (data->info)); g_hash_table_insert (self->priv->deleted_infos, gtk_recent_info_ref (data->info), NULL); if (self->priv->idle_emit_deleted_id == 0) self->priv->idle_emit_deleted_id = g_timeout_add (0, shell_doc_system_idle_emit_deleted, self); } g_clear_error (&error); gtk_recent_info_unref (data->info); g_free (data); }
/** * shell_doc_system_queue_existence_check: * @system: A #ShellDocSystem * @n_items: Count of items to check for existence, starting from most recent * * Asynchronously start a check of a number of recent file for existence; * any deleted files will be emitted from the #ShellDocSystem::deleted * signal. Note that this function ignores non-local files; they * will simply always appear to exist (until they are removed from * the recent file list manually). * * The intent of this function is to be called after a #ShellDocSystem::changed * signal has been emitted, and a display has shown a subset of those files. */ void shell_doc_system_queue_existence_check (ShellDocSystem *self, guint n_items) { GSList *iter; guint i; for (i = 0, iter = self->priv->infos_by_timestamp; i < n_items && iter; i++, iter = iter->next) { GtkRecentInfo *info = iter->data; const char *uri; GFile *file; ShellDocSystemRecentQueryData *data; if (!gtk_recent_info_is_local (info)) continue; data = g_new0 (ShellDocSystemRecentQueryData, 1); data->self = self; data->info = gtk_recent_info_ref (info); uri = gtk_recent_info_get_uri (info); file = g_file_new_for_uri (uri); g_file_query_info_async (file, "standard::type", G_FILE_QUERY_INFO_NONE, G_PRIORITY_DEFAULT, NULL, on_recent_file_query_result, data); g_object_unref (file); } }
static void load_recent_thumbnail_async (StTextureCache *cache, GtkRecentInfo *info, guint size, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *result; AsyncIconLookupData *data; data = g_new0 (AsyncIconLookupData, 1); data->cache = cache; data->thumbnail = TRUE; data->recent_info = gtk_recent_info_ref (info); data->width = size; data->height = size; data->user_data = user_data; result = g_simple_async_result_new (G_OBJECT (cache), callback, user_data, load_recent_thumbnail_async); g_object_set_data_full (G_OBJECT (result), "load_pixbuf_async", data, icon_lookup_data_destroy); g_simple_async_result_run_in_thread (result, load_pixbuf_thread, G_PRIORITY_DEFAULT, cancellable); g_object_unref (result); }
/** * st_texture_cache_load_recent_thumbnail: * @cache: * @size: Size in pixels to use for thumbnail * @info: Recent item info * * Asynchronously load a thumbnail image of a #GtkRecentInfo into a texture. The * returned texture object will be a new instance; however, its texture data * may be shared with other objects. This implies the texture data is cached. * * The current caching policy is permanent; to uncache, you must explicitly * call st_texture_cache_unref_recent_thumbnail(). * * Returns: (transfer none): A new #ClutterActor */ ClutterActor * st_texture_cache_load_recent_thumbnail (StTextureCache *cache, int size, GtkRecentInfo *info) { ClutterTexture *texture; AsyncTextureLoadData *data; char *key; CoglHandle texdata; const char *uri; uri = gtk_recent_info_get_uri (info); /* Don't attempt to load thumbnails for non-local URIs */ if (!g_str_has_prefix (uri, "file://")) { GIcon *icon = icon_for_recent (info); return st_texture_cache_load_gicon (cache, icon, size); } texture = CLUTTER_TEXTURE (clutter_texture_new ()); clutter_actor_set_size (CLUTTER_ACTOR (texture), size, size); key = g_strdup_printf (CACHE_PREFIX_THUMBNAIL_URI "uri=%s,size=%d", uri, size); texdata = g_hash_table_lookup (cache->priv->keyed_cache, key); if (!texdata) { data = g_new0 (AsyncTextureLoadData, 1); data->key = g_strdup (key); data->policy = ST_TEXTURE_CACHE_POLICY_FOREVER; data->thumbnail = TRUE; data->recent_info = gtk_recent_info_ref (info); data->width = size; data->height = size; data->textures = g_slist_prepend (data->textures, g_object_ref (texture)); load_recent_thumbnail_async (cache, info, size, NULL, on_pixbuf_loaded, data); } else { set_texture_cogl_texture (texture, texdata); } g_free (key); return CLUTTER_ACTOR (texture); }
void RecentManager::addRecentMenu(GtkRecentInfo *info, int i) { XOJ_CHECK_TYPE(RecentManager); gchar * label = NULL; const char * display_name = gtk_recent_info_get_display_name(info); char * escaped = gedit_utils_escape_underscores(display_name, -1); if (i >= 10) { label = g_strdup_printf("%d. %s", i, escaped); } else { label = g_strdup_printf("_%d. %s", i, escaped); } g_free(escaped); /* gtk_recent_info_get_uri_display (info) is buggy and * works only for local files */ char * uri = gedit_utils_uri_for_display(gtk_recent_info_get_uri(info)); char * ruri = gedit_utils_replace_home_dir_with_tilde(uri); g_free(uri); // Translators: %s is a URI char * tip = g_strdup_printf(_("Open '%s'"), ruri); g_free(ruri); GtkWidget * item = gtk_menu_item_new_with_mnemonic(label); gtk_widget_set_tooltip_text(item, tip); g_object_set_data_full(G_OBJECT (item), "gtk-recent-info", gtk_recent_info_ref(info), (GDestroyNotify) gtk_recent_info_unref); g_signal_connect (item, "activate", G_CALLBACK (recentsMenuActivateCallback), this); gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); gtk_widget_set_visible(GTK_WIDGET(item), true); this->menuItemList = g_list_append(this->menuItemList, item); g_free(label); g_free(tip); }