コード例 #1
0
static void
file_buffer_ready_cb (void     **buffer,
		      gsize      count,
		      GError    *error,
		      gpointer   user_data)
{
	GthPixbufListTask *self = user_data;
	GInputStream      *istream;
	GdkPixbuf         *pixbuf;

	if (error != NULL) {
		gth_task_completed (GTH_TASK (self), error);
		return;
	}

	istream = g_memory_input_stream_new_from_data (*buffer, count, NULL);
	pixbuf = gdk_pixbuf_new_from_stream (istream, gth_task_get_cancellable (GTH_TASK (self)), &error);
	if (pixbuf != NULL) {
		self->priv->original_pixbuf = gdk_pixbuf_apply_embedded_orientation (pixbuf);
		g_object_unref (pixbuf);
	}
	else
		self->priv->original_pixbuf = NULL;

	g_object_unref (istream);

	if (self->priv->original_pixbuf == NULL) {
		gth_task_completed (GTH_TASK (self), error);
		return;
	}

	gth_pixbuf_task_set_source (GTH_PIXBUF_TASK (self->priv->task), self->priv->original_pixbuf);
	gth_task_exec (self->priv->task, gth_task_get_cancellable (GTH_TASK (self)));
}
コード例 #2
0
ファイル: picasa-web-service.c プロジェクト: KapTmaN/gthumb
static void
ask_authorization_dialog_loaded_cb (OAuthAskAuthorizationDialog *dialog,
				    gpointer                     user_data)
{
	PicasaWebService *self = user_data;
	const char       *title;

	title = oauth_ask_authorization_dialog_get_title (dialog);
	if (title == NULL)
		return;

	if (g_str_has_prefix (title, PICASA_WEB_REDIRECT_TITLE)) {
		const char *authorization_code;

		gtk_widget_hide (GTK_WIDGET (dialog));
		gth_task_dialog (GTH_TASK (self), FALSE, NULL);

		authorization_code = title + strlen (PICASA_WEB_REDIRECT_TITLE);
		_picasa_web_service_get_refresh_token (self,
						       authorization_code,
						       gth_task_get_cancellable (GTH_TASK (self)),
						       refresh_token_ready_cb,
						       self);
	}
}
コード例 #3
0
static void
process_current_file (GthPixbufListTask *self)
{
	GthFileData *file_data;
	GList       *singleton;

	if (self->priv->current == NULL) {
		gth_task_completed (GTH_TASK (self), NULL);
		return;
	}

	_g_object_unref (self->priv->original_pixbuf);
	self->priv->original_pixbuf = NULL;
	_g_object_unref (self->priv->new_pixbuf);
	self->priv->new_pixbuf = NULL;

	gth_task_progress (GTH_TASK (self),
			   NULL,
			   NULL,
			   FALSE,
			   ((double) self->priv->n_current + 1) / (self->priv->n_files + 1));

	file_data = self->priv->current->data;
	singleton = g_list_append (NULL, g_object_ref (file_data->file));
	_g_query_all_metadata_async (singleton,
				     FALSE,
				     TRUE,
				     "*",
				     gth_task_get_cancellable (GTH_TASK (self)),
				     file_info_ready_cb,
				     self);

	_g_object_list_unref (singleton);
}
コード例 #4
0
ファイル: oauth-service.c プロジェクト: KapTmaN/gthumb
static void
oauth_service_ask_authorization (WebService *base)
{
	OAuthService *self = OAUTH_SERVICE (base);

	oauth_service_set_token (self, NULL);
	oauth_service_set_token_secret (self, NULL);
	_oauth_service_get_request_token (self,
					  gth_task_get_cancellable (GTH_TASK (self)),
					  get_request_token_ready_cb,
					  self);
}
コード例 #5
0
ファイル: gth-organize-task.c プロジェクト: Peliadia/gthumb
static void
gth_organize_task_exec (GthTask *base)
{
	GthOrganizeTask *self;
	const char      *attributes;

	self = GTH_ORGANIZE_TASK (base);

	self->priv->organized = FALSE;
	self->priv->n_catalogs = 0;
	self->priv->n_files = 0;
	gtk_list_store_clear (self->priv->results_liststore);
	switch (self->priv->group_policy) {
	case GTH_GROUP_POLICY_DIGITALIZED_DATE:
		attributes = "standard::name,standard::type,time::modified,time::modified-usec,Embedded::Photo::DateTimeOriginal";
		break;
	case GTH_GROUP_POLICY_MODIFIED_DATE:
	default:
		attributes = "standard::name,standard::type,time::modified,time::modified-usec";
		break;
	}
	g_directory_foreach_child (self->priv->folder,
				   self->priv->recursive,
				   TRUE,
				   attributes,
				   gth_task_get_cancellable (GTH_TASK (self)),
				   start_dir_func,
				   for_each_file_func,
				   done_func,
				   self);

	gtk_widget_show (GET_WIDGET ("cancel_button"));
	gtk_widget_hide (GET_WIDGET ("close_button"));
	gtk_widget_hide (GET_WIDGET ("ok_button"));
	gtk_window_set_transient_for (GTK_WINDOW (GET_WIDGET ("organize_files_dialog")), GTK_WINDOW (self->priv->browser));
	gtk_window_set_modal (GTK_WINDOW (GET_WIDGET ("organize_files_dialog")), TRUE);
	gtk_widget_show (GET_WIDGET ("organize_files_dialog"));

	gth_task_dialog (base, TRUE);
}
コード例 #6
0
ファイル: oauth-service.c プロジェクト: KapTmaN/gthumb
static void
ask_authorization_dialog_load_request_cb (OAuthAskAuthorizationDialog *dialog,
					  gpointer                     user_data)
{
	OAuthService *self = user_data;
	const char   *uri;

	uri = oauth_ask_authorization_dialog_get_uri (dialog);
	if (uri == NULL)
		return;

	if (g_str_has_prefix (uri, OAUTH_CALLBACK)) {
		const char *uri_data;
		GHashTable *data;
		gboolean    success = FALSE;

		uri_data = uri + strlen (OAUTH_CALLBACK "?");

		data = soup_form_decode (uri_data);
		_g_strset (&self->priv->token, g_hash_table_lookup (data, "oauth_token"));

		if (self->priv->token != NULL) {
			gtk_widget_hide (GTK_WIDGET (dialog));
			gth_task_dialog (GTH_TASK (self), FALSE, NULL);

			success = TRUE;
			_oauth_service_get_access_token (self,
							 g_hash_table_lookup (data, "oauth_verifier"),
							 gth_task_get_cancellable (GTH_TASK (self)),
							 get_access_token_ready_cb,
							 self);
		}

		if (! success)
			gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);

		g_hash_table_destroy (data);
	}
}
コード例 #7
0
static void
file_info_ready_cb (GList    *files,
		    GError   *error,
		    gpointer  user_data)
{
	GthPixbufListTask *self = user_data;
	GthFileData       *updated_file_data;
	GthFileData       *file_data;

	if (error != NULL) {
		gth_task_completed (GTH_TASK (self), error);
		return;
	}

	file_data = self->priv->current->data;
	updated_file_data = (GthFileData*) files->data;
	g_file_info_copy_into (updated_file_data->info, file_data->info);

	g_load_file_async (file_data->file,
			   G_PRIORITY_DEFAULT,
			   gth_task_get_cancellable (GTH_TASK (self)),
			   file_buffer_ready_cb,
			   self);
}