Пример #1
0
static gboolean
update_file_list (gpointer user_data)
{
	DialogData *data = user_data;
	LoaderData *loader_data;
	GList      *items;
	GList      *file_data_list;

	if (data->update_selectection_event != 0) {
		g_source_remove (data->update_selectection_event);
		data->update_selectection_event = 0;
	}

	cancel_file_list_loading (data);

	loader_data = g_new0 (LoaderData, 1);
	loader_data->data = dialog_data_ref (data);

	items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (data->browser)));
	file_data_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (data->browser)), items);
	loader_data->files = gth_file_data_list_to_file_list (file_data_list);

	data->loader = gth_load_file_data_task_new (loader_data->files, "*");
	g_signal_connect (data->loader,
			  "completed",
			  G_CALLBACK (loader_completed_cb),
			  loader_data);
	gth_browser_exec_task (data->browser, data->loader, FALSE);

	_g_object_list_unref (file_data_list);
	_gtk_tree_path_list_free (items);

	return FALSE;
}
Пример #2
0
static void
edit_metadata_dialog__response_cb (GtkDialog *dialog,
				   int        response,
				   gpointer   user_data)
{
	DialogData *data = user_data;
	GthMonitor *monitor;
	GHashTable *parents;
	GList      *scan;
	GthTask    *task;

	if ((response != GTK_RESPONSE_OK) && (response != GTK_RESPONSE_APPLY)) {
		cancel_file_list_loading (data);
		close_dialog (data);
		return;
	}

	if (data->file_list == NULL)
		return;

	data->close_dialog = (response == GTK_RESPONSE_OK);

	/* get the parents list */

	parents = g_hash_table_new_full (g_file_hash, (GEqualFunc) g_file_equal, g_object_unref, NULL);
	for (scan = data->file_list; scan; scan = scan->next) {
		GthFileData *file_data = scan->data;
		GFile       *parent;

		parent = g_file_get_parent (file_data->file);
		if (G_LIKELY (parent != NULL)) {
			if (g_hash_table_lookup (parents, parent) == NULL)
				g_hash_table_insert (parents, g_object_ref (parent), GINT_TO_POINTER (1));
			g_object_unref (parent);
		}
	}
	_g_object_list_unref (data->parents);
	data->parents = g_hash_table_get_keys (parents);
	g_list_foreach (data->parents, (GFunc) g_object_ref, NULL);
	g_hash_table_unref (parents);

	/* ignore changes to all the parents */

	monitor = gth_main_get_default_monitor ();
	for (scan = data->parents; scan; scan = scan->next)
		gth_monitor_pause (monitor, (GFile *) scan->data);

	gth_edit_metadata_dialog_update_info (GTH_EDIT_METADATA_DIALOG (data->dialog), data->file_list);

	dialog_data_ref (data);
	task = gth_save_file_data_task_new (data->file_list, "*");
	g_signal_connect (task,
			  "completed",
			  G_CALLBACK (saver_completed_cb),
			  data);
	gth_browser_exec_task (data->browser, task, FALSE);

	g_object_unref (task);

}