static void try_read_from_file (NemoPreviewCoverArtFetcher *self, GFile *file) { g_file_read_async (file, G_PRIORITY_DEFAULT, NULL, read_async_ready_cb, self); }
void gitg_platform_support_http_get (GFile *file, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data) { g_file_read_async (file, G_PRIORITY_DEFAULT, cancellable, callback, user_data); }
static void rygel_seekable_response_real_run (RygelHTTPResponse* base, GCancellable* cancellable) { RygelSeekableResponse * self; GCancellable* _tmp1_; GCancellable* _tmp0_; self = (RygelSeekableResponse*) base; _tmp1_ = NULL; _tmp0_ = NULL; ((RygelHTTPResponse*) self)->cancellable = (_tmp1_ = (_tmp0_ = cancellable, (_tmp0_ == NULL) ? NULL : g_object_ref (_tmp0_)), (((RygelHTTPResponse*) self)->cancellable == NULL) ? NULL : (((RygelHTTPResponse*) self)->cancellable = (g_object_unref (((RygelHTTPResponse*) self)->cancellable), NULL)), _tmp1_); g_file_read_async (self->priv->file, self->priv->priority, cancellable, _rygel_seekable_response_on_file_read_gasync_ready_callback, self); }
static void gtkhash_hash_file_open(struct hash_file_s *data) { if (G_UNLIKELY(g_cancellable_is_cancelled(data->cancellable))) { gtkhash_hash_file_set_state(data, HASH_FILE_STATE_FINISH); return; } gtkhash_hash_file_remove_source(data); g_file_read_async(data->file, G_PRIORITY_DEFAULT, data->cancellable, (GAsyncReadyCallback)gtkhash_hash_file_open_finish, data); }
static void after_mount_enclosing_volume (GDownloadable * download) { //g_message ("get size and read after mounting ...\n"); if (download->priv->size == 0) g_file_query_info_async (download->priv->remote_file, G_FILE_ATTRIBUTE_STANDARD_SIZE, 0, G_PRIORITY_DEFAULT, NULL, on_size_query_ready, download); g_file_read_async (download->priv->remote_file, G_PRIORITY_DEFAULT, NULL, on_file_read_ready, download); }
static void photos_base_item_refresh_thumb_path (PhotosBaseItem *self) { PhotosBaseItemPrivate *priv = self->priv; GFile *thumb_file; thumb_file = g_file_new_for_path (priv->thumb_path); g_file_read_async (thumb_file, G_PRIORITY_DEFAULT, NULL, photos_base_item_refresh_thumb_path_read, g_object_ref (self)); g_object_unref (thumb_file); }
void www_download (struct rom_romItem* item) { www_downloadingItm++; gchar *fileNameWeb = g_strdup_printf (www_webProvider, item->name); g_print ("fetching(%i) [%s] %s\n", www_downloadingItm, item->name, fileNameWeb); GFile *tileFile = g_file_new_for_uri (fileNameWeb); g_file_read_async (tileFile, G_PRIORITY_HIGH, FALSE, (GAsyncReadyCallback) www_fileRead_cb, item); g_free (fileNameWeb); }
static void load_location (NemoImagePropertiesPage *page, NemoFileInfo *info) { GFile *file; char *uri; FileOpenData *data; g_assert (NEMO_IS_IMAGE_PROPERTIES_PAGE (page)); g_assert (info != NULL); page->details->cancellable = g_cancellable_new (); uri = nemo_file_info_get_uri (info); file = g_file_new_for_uri (uri); #ifdef HAVE_EXEMPI { /* Current Exempi does not support setting custom IO to be able to use Gnome-vfs */ /* So it will only work with local files. Future version might remove this limitation */ XmpFilePtr xf; char *localname; localname = g_filename_from_uri (uri, NULL, NULL); if (localname) { xf = xmp_files_open_new (localname, 0); page->details->xmp = xmp_files_get_new_xmp (xf); /* only load when loading */ xmp_files_close (xf, 0); g_free (localname); } else { page->details->xmp = NULL; } } #endif /*HAVE_EXEMPI*/ data = g_new0 (FileOpenData, 1); data->page = page; data->info = info; g_file_read_async (file, 0, page->details->cancellable, file_open_callback, data); g_object_unref (file); g_free (uri); }
/* Open the given handle */ static void vfs_data_open_helper (VfsAsyncHandle *ah) { g_assert (ah->file != NULL); g_assert (ah->state == VFS_ASYNC_READY); ah->state = VFS_ASYNC_PROCESSING; ah->operation = VFS_OP_OPENING; /* Note that we always overwrite the file */ if (ah->writer) g_file_replace_async (ah->file, NULL, FALSE, G_FILE_CREATE_NONE, G_PRIORITY_DEFAULT, ah->cancellable, vfs_data_open_done, ah); else g_file_read_async (ah->file, G_PRIORITY_DEFAULT, ah->cancellable, vfs_data_open_done, ah); }
static void ft_handler_complete_request (EmpathyFTHandler *handler) { EmpathyFTHandlerPriv *priv = GET_PRIV (handler); /* populate the request table with all the known properties */ ft_handler_populate_outgoing_request (handler); if (priv->use_hash) /* start hashing the file */ g_file_read_async (priv->gfile, G_PRIORITY_DEFAULT, priv->cancellable, ft_handler_read_async_cb, handler); else /* push directly the handler to the dispatcher */ ft_handler_push_to_dispatcher (handler); }
static GtkWidget* make_popover_for_image_url (VteTerminal *vtterm, const gchar *uri) { g_assert (vtterm); g_assert (uri); GtkWidget *popover = gtk_popover_new (GTK_WIDGET (vtterm)); dg_lobj GVfs* gvfs = g_vfs_get_default (); dg_lobj GFile* file = g_vfs_get_file_for_uri (gvfs, uri); g_file_read_async (file, G_PRIORITY_DEFAULT, NULL, (GAsyncReadyCallback) image_file_opened, popover); return popover; }
static void insert_search_result (RBPodcastAddDialog *dialog, RBPodcastChannel *channel, gboolean select) { GtkTreeIter iter; GFile *image_file; int episodes; if (channel->posts) { episodes = g_list_length (channel->posts); } else { episodes = channel->num_posts; } /* if there's an image to load, fetch it */ if (channel->img) { rb_debug ("fetching image %s", channel->img); image_file = g_file_new_for_uri (channel->img); } else { image_file = NULL; } gtk_list_store_insert_with_values (dialog->priv->feed_model, &iter, G_MAXINT, FEED_COLUMN_TITLE, channel->title, FEED_COLUMN_AUTHOR, channel->author, FEED_COLUMN_EPISODE_COUNT, episodes, FEED_COLUMN_IMAGE, NULL, FEED_COLUMN_IMAGE_FILE, image_file, FEED_COLUMN_PARSED_FEED, channel, -1); if (image_file != NULL) { g_file_read_async (image_file, G_PRIORITY_DEFAULT, NULL, (GAsyncReadyCallback) image_file_read_cb, g_object_ref (dialog)); } if (select) { GtkTreeSelection *selection; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (dialog->priv->feed_view)); gtk_tree_selection_select_iter (selection, &iter); } }
static void ido_media_player_menu_item_set_album_art (IdoMediaPlayerMenuItem *self, const gchar *url) { GFile *file; g_return_if_fail (IDO_IS_MEDIA_PLAYER_MENU_ITEM (self)); gtk_image_clear (GTK_IMAGE (self->album_art)); if (url == NULL) return; file = g_file_new_for_uri (url); g_file_read_async (file, G_PRIORITY_DEFAULT, self->cancellable, album_art_file_opened, self); g_object_unref (file); }
static gboolean add_single_file (BgPicturesSource *bg_source, GFile *file, GFileInfo *info, const char *source_uri) { const gchar *content_type; CcBackgroundItem *item; char *uri; guint64 mtime; /* find png and jpeg files */ content_type = g_file_info_get_content_type (info); if (!content_type) return FALSE; if (!in_content_types (content_type)) return FALSE; /* create a new CcBackgroundItem */ uri = g_file_get_uri (file); mtime = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED); item = cc_background_item_new (uri); g_free (uri); g_object_set (G_OBJECT (item), "flags", CC_BACKGROUND_ITEM_HAS_URI | CC_BACKGROUND_ITEM_HAS_SHADING, "shading", G_DESKTOP_BACKGROUND_SHADING_SOLID, "placement", G_DESKTOP_BACKGROUND_STYLE_ZOOM, "modified", mtime, NULL); if (source_uri != NULL) g_object_set (G_OBJECT (item), "source-url", source_uri, NULL); g_object_set_data (G_OBJECT (file), "item", item); g_file_read_async (file, G_PRIORITY_DEFAULT, bg_source->priv->cancellable, picture_opened_for_read, bg_source); g_object_unref (file); return TRUE; }
static void load_location (CajaImagePropertiesPage *page, const char *location) { GFile *file; g_assert (CAJA_IS_IMAGE_PROPERTIES_PAGE (page)); g_assert (location != NULL); page->details->cancellable = g_cancellable_new (); file = g_file_new_for_uri (location); #ifdef HAVE_EXEMPI { /* Current Exempi does not support setting custom IO to be able to use Mate-vfs */ /* So it will only work with local files. Future version might remove this limitation */ XmpFilePtr xf; char *localname; localname = g_filename_from_uri (location, NULL, NULL); if (localname) { xf = xmp_files_open_new (localname, 0); page->details->xmp = xmp_files_get_new_xmp (xf); /* only load when loading */ xmp_files_close (xf, 0); g_free (localname); } else { page->details->xmp = NULL; } } #endif /*HAVE_EXEMPI*/ g_file_read_async (file, 0, page->details->cancellable, file_open_callback, page); g_object_unref (file); }
static gboolean add_single_file (BgPicturesSource *bg_source, GFile *file, GFileInfo *info, const char *source_uri) { const gchar *content_type; /* find png and jpeg files */ content_type = g_file_info_get_content_type (info); if (!content_type) return FALSE; if (g_str_equal ("image/png", content_type) || g_str_equal ("image/jpeg", content_type) || g_str_equal ("image/svg+xml", content_type)) { CcBackgroundItem *item; char *uri; /* create a new CcBackgroundItem */ uri = g_file_get_uri (file); item = cc_background_item_new (uri); g_free (uri); g_object_set (G_OBJECT (item), "flags", CC_BACKGROUND_ITEM_HAS_URI | CC_BACKGROUND_ITEM_HAS_SHADING, "shading", G_DESKTOP_BACKGROUND_SHADING_SOLID, "placement", G_DESKTOP_BACKGROUND_STYLE_ZOOM, NULL); if (source_uri != NULL && !g_file_is_native (file)) g_object_set (G_OBJECT (item), "source-url", source_uri, NULL); g_object_set_data (G_OBJECT (file), "item", item); g_file_read_async (file, 0, NULL, picture_opened_for_read, bg_source); g_object_unref (file); return TRUE; } return FALSE; }
EelPixbufLoadHandle * eel_gdk_pixbuf_load_async (const char *uri, int priority, EelPixbufLoadCallback callback, gpointer callback_data) { EelPixbufLoadHandle *handle; GFile *file; handle = g_new0 (EelPixbufLoadHandle, 1); handle->cancellable = g_cancellable_new (); handle->callback = callback; handle->callback_data = callback_data; file = g_file_new_for_uri (uri); g_file_read_async (file, priority, handle->cancellable, file_opened_callback, handle); return handle; }
static void picture_copied_for_read (GObject *source_object, GAsyncResult *res, gpointer user_data) { BgPicturesSource *bg_source; CcBackgroundItem *item; GError *error = NULL; GFile *thumbnail_file = G_FILE (source_object); GFile *native_file; if (!g_file_copy_finish (thumbnail_file, res, &error)) { if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED)) goto out; else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) { gchar *uri; uri = g_file_get_uri (thumbnail_file); g_warning ("Failed to download '%s': %s", uri, error->message); g_free (uri); goto out; } } bg_source = BG_PICTURES_SOURCE (user_data); native_file = g_object_get_data (G_OBJECT (thumbnail_file), "native-file"); item = g_object_get_data (G_OBJECT (thumbnail_file), "item"); g_object_set_data_full (G_OBJECT (native_file), "item", g_object_ref (item), g_object_unref); g_file_read_async (native_file, G_PRIORITY_DEFAULT, bg_source->priv->cancellable, picture_opened_for_read, bg_source); out: g_clear_error (&error); }
/** * empathy_tp_file_offer: * @self: an outgoing #EmpathyTpFile * @gfile: the source #GFile for the transfer * @cancellable: a #GCancellable * @progress_callback: function to callback with progress information * @progress_user_data: user_data to pass to @progress_callback * @op_callback: function to callback when the transfer ends * @op_user_data: user_data to pass to @op_callback * * Offers an outgoing file transfer, reading data from @gfile. * The callback @op_callback will be called both when the transfer is * successful and in case of an error. Note that cancelling @cancellable, * closes the socket of the file operation in progress, but doesn't * guarantee that the transfer channel will be closed as well. Thus, * empathy_tp_file_cancel() or empathy_tp_file_close() should be used to * actually cancel an ongoing #EmpathyTpFile. */ void empathy_tp_file_offer (EmpathyTpFile *self, GFile *gfile, GCancellable *cancellable, EmpathyTpFileProgressCallback progress_callback, gpointer progress_user_data, EmpathyTpFileOperationCallback op_callback, gpointer op_user_data) { g_return_if_fail (EMPATHY_IS_TP_FILE (self)); g_return_if_fail (G_IS_FILE (gfile)); g_return_if_fail (G_IS_CANCELLABLE (cancellable)); self->priv->cancellable = g_object_ref (cancellable); self->priv->progress_callback = progress_callback; self->priv->progress_user_data = progress_user_data; self->priv->op_callback = op_callback; self->priv->op_user_data = op_user_data; g_file_read_async (gfile, G_PRIORITY_DEFAULT, cancellable, file_read_async_cb, self); }
/** * rb_chunk_loader_start: * @loader: a #RBChunkLoader * @uri: the uri to load * @chunk_size: maximum chunk size * * Starts loading data from the specified URI, passing it in chunks * of at most @chunk_size to the callback. */ void rb_chunk_loader_start (RBChunkLoader *loader, const char *uri, gssize chunk_size) { g_assert (loader->priv->uri == NULL); g_assert (loader->priv->callback != NULL); loader->priv->uri = g_strdup (uri); loader->priv->chunk_size = chunk_size; loader->priv->chunk = g_malloc0 (chunk_size+1); loader->priv->chunk_string.str = (gchar *)loader->priv->chunk; loader->priv->chunk_string.len = 0; loader->priv->chunk_string.allocated_len = chunk_size; loader->priv->cancel = g_cancellable_new (); loader->priv->file = g_file_new_for_commandline_arg (loader->priv->uri); g_file_read_async (loader->priv->file, G_PRIORITY_DEFAULT, loader->priv->cancel, file_read_async_cb, loader); }
static void photos_glib_file_copy_create (GObject *source_object, GAsyncResult *res, gpointer user_data) { GCancellable *cancellable; g_autoptr (GFile) unique_file = NULL; GFile *destination = G_FILE (source_object); GFile *source; g_autoptr (GFileOutputStream) ostream = NULL; g_autoptr (GTask) task = G_TASK (user_data); PhotosGLibFileCopyData *data; cancellable = g_task_get_cancellable (task); data = (PhotosGLibFileCopyData *) g_task_get_task_data (task); source = G_FILE (g_task_get_source_object (task)); { g_autoptr (GError) error = NULL; ostream = photos_glib_file_create_finish (destination, res, &unique_file, &error); if (error != NULL) { g_task_return_error (task, g_steal_pointer (&error)); goto out; } } g_assert_null (data->ostream); g_assert_true (G_IS_FILE_OUTPUT_STREAM (ostream)); data->ostream = g_object_ref (ostream); g_assert_null (data->unique_file); g_assert_true (G_IS_FILE (unique_file)); data->unique_file = g_object_ref (unique_file); g_file_read_async (source, data->io_priority, cancellable, photos_glib_file_copy_read, g_object_ref (task)); out: return; }
GnomeGdkPixbufAsyncHandle * gnome_gdk_pixbuf_new_from_uri_async (const char *uri, GnomeGdkPixbufLoadCallback load_callback, GnomeGdkPixbufDoneCallback done_callback, gpointer callback_data) { GnomeGdkPixbufAsyncHandle *handle; handle = g_new0 (GnomeGdkPixbufAsyncHandle, 1); handle->load_callback = load_callback; handle->done_callback = done_callback; handle->callback_data = callback_data; handle->file = g_file_new_for_uri (uri); handle->cancellable = g_cancellable_new (); g_file_read_async (handle->file, G_PRIORITY_DEFAULT, handle->cancellable, input_stream_ready_callback, handle); return handle; }
static void webkit_pref_callback_user_stylesheet (GSettings *settings, const char *key, gpointer data) { gboolean value; value = g_settings_get_boolean (settings, key); if (!value) webkit_user_content_manager_remove_all_style_sheets (WEBKIT_USER_CONTENT_MANAGER (ephy_embed_shell_get_user_content_manager (ephy_embed_shell_get_default ()))); else { GFile *file; char *filename; filename = g_build_filename (ephy_dot_dir (), USER_STYLESHEET_FILENAME, NULL); file = g_file_new_for_path (filename); g_free (filename); g_file_read_async (file, G_PRIORITY_DEFAULT, NULL, (GAsyncReadyCallback)user_style_seet_read_cb, NULL); g_object_unref (file); } }
static void query_progress_cb (GDataEntry *entry, guint entry_key, guint entry_count, QueryData *data) { GList *thumbnails; GDataMediaThumbnail *thumbnail = NULL; gint delta = G_MININT; GtkTreeIter iter; const gchar *title, *id; GtkProgressBar *progress_bar; TotemYouTubePlugin *self = data->plugin; /* Add the entry to the tree view */ title = gdata_entry_get_title (entry); id = gdata_youtube_video_get_video_id (GDATA_YOUTUBE_VIDEO (entry)); gtk_list_store_append (self->list_store[data->tree_view], &iter); gtk_list_store_set (self->list_store[data->tree_view], &iter, 0, NULL, /* the thumbnail will be downloaded asynchronously and added to the tree view later */ 1, title, 2, NULL, /* the video URI will be resolved asynchronously and added to the tree view later */ 3, entry, -1); g_debug ("Added entry %s to tree view (title: \"%s\")", id, title); /* Update the progress bar; we have three steps for each entry in the results: the entry, its thumbnail, and its t parameter */ g_assert (entry_count > 0); progress_bar = self->progress_bar[data->tree_view]; self->progress_bar_increment[data->tree_view] = 1.0 / (entry_count * 3.0); g_debug ("Setting progress_bar_increment to 1.0 / (%u * 3.0) = %f", entry_count, self->progress_bar_increment[data->tree_view]); gtk_progress_bar_set_fraction (progress_bar, gtk_progress_bar_get_fraction (progress_bar) + self->progress_bar_increment[data->tree_view]); /* Resolve the t parameter for the video, which is required before it can be played */ /* This will be cancelled if the main query is cancelled, in query_finished_cb() */ data->t_param_cancellable = g_cancellable_new (); resolve_t_param (self, entry, &iter, data->tree_view, data->t_param_cancellable); /* Download the entry's thumbnail, ready for adding it to the tree view. * Find the thumbnail size which is closest to the wanted size (THUMBNAIL_WIDTH), so that we: * a) avoid fuzzy images due to scaling up, and * b) avoid downloading too much just to scale down by a factor of 10. */ thumbnails = gdata_youtube_video_get_thumbnails (GDATA_YOUTUBE_VIDEO (entry)); for (; thumbnails != NULL; thumbnails = thumbnails->next) { gint new_delta; GDataMediaThumbnail *current_thumb = (GDataMediaThumbnail*) thumbnails->data; g_debug ("%u pixel wide thumbnail available for entry %s", gdata_media_thumbnail_get_width (current_thumb), id); new_delta = gdata_media_thumbnail_get_width (current_thumb) - THUMBNAIL_WIDTH; if (delta == 0) { break; } else if ((delta == G_MININT) || (delta < 0 && new_delta > delta) || (delta > 0 && new_delta > 0 && new_delta < delta)) { delta = new_delta; thumbnail = current_thumb; g_debug ("Choosing a %u pixel wide thumbnail (delta: %i) for entry %s", gdata_media_thumbnail_get_width (current_thumb), new_delta, id); } } if (thumbnail != NULL) { GFile *thumbnail_file; ThumbnailData *t_data; t_data = g_slice_new (ThumbnailData); t_data->plugin = g_object_ref (self); t_data->path = gtk_tree_model_get_path (GTK_TREE_MODEL (self->list_store[data->tree_view]), &iter); t_data->tree_view = data->tree_view; /* We can use the same cancellable for reading the file and making a pixbuf out of it, as they're consecutive operations */ /* This will be cancelled if the main query is cancelled, in query_finished_cb() */ data->thumbnail_cancellable = g_cancellable_new (); t_data->cancellable = g_object_ref (data->thumbnail_cancellable); g_debug ("Starting thumbnail download for entry %s", id); thumbnail_file = g_file_new_for_uri (gdata_media_thumbnail_get_uri (thumbnail)); g_file_read_async (thumbnail_file, G_PRIORITY_DEFAULT, data->thumbnail_cancellable, (GAsyncReadyCallback) thumbnail_opened_cb, t_data); g_object_unref (thumbnail_file); } }
static void queryInfoCallback(GObject* source, GAsyncResult* res, gpointer data) { ResourceHandle* handle = static_cast<ResourceHandle*>(data); ResourceHandleInternal* d = handle->getInternal(); ResourceHandleClient* client = handle->client(); if (d->m_cancelled) { cleanupGioOperation(handle); return; } ResourceResponse response; char* uri = g_file_get_uri(d->m_gfile); response.setUrl(KURL(uri)); g_free(uri); GError *error = NULL; GFileInfo* info = g_file_query_info_finish(d->m_gfile, res, &error); if (error) { // FIXME: to be able to handle ftp URIs properly, we must // check if the error is G_IO_ERROR_NOT_MOUNTED, and if so, // call g_file_mount_enclosing_volume() to mount the ftp // server (and then keep track of the fact that we mounted it, // and set a timeout to unmount it later after it's been idle // for a while). cleanupGioOperation(handle); if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_NOT_FOUND) response.setHTTPStatusCode(SOUP_STATUS_NOT_FOUND); else if (error->domain == G_IO_ERROR && error->code == G_IO_ERROR_PERMISSION_DENIED) response.setHTTPStatusCode(SOUP_STATUS_FORBIDDEN); else response.setHTTPStatusCode(SOUP_STATUS_BAD_REQUEST); // ? g_error_free(error); // FIXME: do we need to fake up a response body containing the // error message? client->didReceiveResponse(handle, response); client->didFinishLoading(handle); return; } if (g_file_info_get_file_type(info) != G_FILE_TYPE_REGULAR) { // FIXME: what if the URI points to a directory? Should we // generate a listing? How? What do other backends do here? cleanupGioOperation(handle); response.setHTTPStatusCode(SOUP_STATUS_FORBIDDEN); // ? client->didReceiveResponse(handle, response); client->didFinishLoading(handle); return; } response.setMimeType(g_file_info_get_content_type(info)); response.setExpectedContentLength(g_file_info_get_size(info)); response.setHTTPStatusCode(SOUP_STATUS_OK); GTimeVal tv; g_file_info_get_modification_time(info, &tv); response.setLastModifiedDate(tv.tv_sec); client->didReceiveResponse(handle, response); g_file_read_async(d->m_gfile, G_PRIORITY_DEFAULT, d->m_cancellable, openCallback, handle); }
static gboolean add_single_file (BgPicturesSource *bg_source, GFile *file, const gchar *content_type, guint64 mtime, GtkTreeRowReference **ret_row_ref) { CcBackgroundItem *item = NULL; CcBackgroundItemFlags flags = 0; GtkListStore *store; GtkTreeIter iter; GtkTreePath *path = NULL; GtkTreeRowReference *row_ref = NULL; cairo_surface_t *surface = NULL; char *source_uri = NULL; char *uri = NULL; gboolean needs_download; gboolean retval = FALSE; GFile *pictures_dir, *cache_dir; GrlMedia *media; /* find png and jpeg files */ if (!content_type) goto out; if (!in_content_types (content_type)) goto out; /* create a new CcBackgroundItem */ uri = g_file_get_uri (file); pictures_dir = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES)); cache_dir = bg_pictures_source_get_cache_file (); needs_download = !g_file_has_parent (file, pictures_dir) && !g_file_has_parent (file, cache_dir); g_object_unref (pictures_dir); g_object_unref (cache_dir); if (!needs_download) { source_uri = g_strdup (uri); flags |= CC_BACKGROUND_ITEM_HAS_URI; } else { source_uri = uri; uri = NULL; } item = cc_background_item_new (uri); flags |= CC_BACKGROUND_ITEM_HAS_SHADING | CC_BACKGROUND_ITEM_HAS_PLACEMENT; g_object_set (G_OBJECT (item), "flags", flags, "shading", G_DESKTOP_BACKGROUND_SHADING_SOLID, "placement", G_DESKTOP_BACKGROUND_STYLE_ZOOM, "modified", mtime, "needs-download", needs_download, "source-url", source_uri, NULL); if (!ret_row_ref && in_screenshot_types (content_type)) goto read_file; surface = get_content_loading_icon (BG_SOURCE (bg_source)); store = bg_source_get_liststore (BG_SOURCE (bg_source)); /* insert the item into the liststore */ gtk_list_store_insert_with_values (store, &iter, -1, 0, surface, 1, item, -1); path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter); row_ref = gtk_tree_row_reference_new (GTK_TREE_MODEL (store), path); g_object_set_data_full (G_OBJECT (item), "row-ref", row_ref, (GDestroyNotify) gtk_tree_row_reference_free); read_file: media = g_object_get_data (G_OBJECT (file), "grl-media"); if (media == NULL) { g_object_set_data_full (G_OBJECT (file), "item", g_object_ref (item), g_object_unref); g_file_read_async (file, G_PRIORITY_DEFAULT, bg_source->priv->cancellable, picture_opened_for_read, bg_source); } else { GFile *native_file; GFile *thumbnail_file = NULL; gchar *native_dir; gchar *native_path; const gchar *title; const gchar *thumbnail_uri; title = grl_media_get_title (media); g_object_set (G_OBJECT (item), "name", title, NULL); thumbnail_uri = grl_media_get_thumbnail (media); thumbnail_file = g_file_new_for_uri (thumbnail_uri); native_path = gnome_desktop_thumbnail_path_for_uri (source_uri, GNOME_DESKTOP_THUMBNAIL_SIZE_LARGE); native_file = g_file_new_for_path (native_path); native_dir = g_path_get_dirname (native_path); g_mkdir_with_parents (native_dir, USER_DIR_MODE); g_object_set_data_full (G_OBJECT (thumbnail_file), "item", g_object_ref (item), g_object_unref); g_object_set_data_full (G_OBJECT (thumbnail_file), "native-file", g_object_ref (native_file), g_object_unref); g_file_copy_async (thumbnail_file, native_file, G_FILE_COPY_ALL_METADATA, G_PRIORITY_DEFAULT, bg_source->priv->cancellable, NULL, NULL, picture_copied_for_read, bg_source); g_clear_object (&thumbnail_file); g_object_unref (native_file); g_free (native_dir); g_free (native_path); } retval = TRUE; out: if (ret_row_ref) { if (row_ref && retval != FALSE) *ret_row_ref = gtk_tree_row_reference_copy (row_ref); else *ret_row_ref = NULL; } gtk_tree_path_free (path); g_clear_pointer (&surface, (GDestroyNotify) cairo_surface_destroy); g_clear_object (&item); g_object_unref (file); g_free (source_uri); g_free (uri); return retval; }
static gboolean rygel_seekable_response_real_run_co (RygelSeekableResponseRunData* data) { switch (data->_state_) { case 0: goto _state_0; case 13: goto _state_13; case 14: goto _state_14; default: g_assert_not_reached (); } _state_0: { { data->_state_ = 13; g_file_read_async (data->self->priv->file, data->self->priv->priority, rygel_state_machine_get_cancellable ((RygelStateMachine*) data->self), rygel_seekable_response_run_ready, data); return FALSE; _state_13: data->_tmp0_ = g_file_read_finish (data->self->priv->file, data->_res_, &data->_inner_error_); if (data->_inner_error_ != NULL) { goto __catch35_g_error; } #line 59 "rygel-seekable-response.vala" data->self->priv->input_stream = (data->_tmp1_ = data->_tmp0_, _g_object_unref0 (data->self->priv->input_stream), data->_tmp1_); #line 350 "rygel-seekable-response.c" } goto __finally35; __catch35_g_error: { data->err = data->_inner_error_; data->_inner_error_ = NULL; { #line 62 "rygel-seekable-response.vala" g_warning (_ ("Failed to read from URI: %s: %s"), data->_tmp2_ = g_file_get_uri (data->self->priv->file), data->err->message); #line 360 "rygel-seekable-response.c" _g_free0 (data->_tmp2_); #line 65 "rygel-seekable-response.vala" rygel_http_response_end ((RygelHTTPResponse*) data->self, FALSE, (guint) SOUP_STATUS_NOT_FOUND); #line 364 "rygel-seekable-response.c" _g_error_free0 (data->err); { if (data->_state_ == 0) { g_simple_async_result_complete_in_idle (data->_async_result); } else { g_simple_async_result_complete (data->_async_result); } g_object_unref (data->_async_result); return FALSE; } _g_error_free0 (data->err); } } __finally35: if (data->_inner_error_ != NULL) { g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, data->_inner_error_->message, g_quark_to_string (data->_inner_error_->domain), data->_inner_error_->code); g_clear_error (&data->_inner_error_); return FALSE; } data->_state_ = 14; rygel_seekable_response_perform_seek (data->self, rygel_seekable_response_run_ready, data); return FALSE; _state_14: #line 70 "rygel-seekable-response.vala" rygel_seekable_response_perform_seek_finish (data->self, data->_res_); #line 390 "rygel-seekable-response.c" } { if (data->_state_ == 0) { g_simple_async_result_complete_in_idle (data->_async_result); } else { g_simple_async_result_complete (data->_async_result); } g_object_unref (data->_async_result); return FALSE; } }