static void ok_clicked_cb (GtkWidget *widget, DialogData *data) { GList *file_list; GFile *destination; GError *error = NULL; gboolean import; file_list = get_selected_file_list (data); destination = gth_import_preferences_get_destination (); if (! gth_import_task_check_free_space (destination, file_list, &error)) { _gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->dialog), _("Could not import the files"), error); g_clear_error (&error); import = FALSE; } else import = TRUE; _g_object_unref (destination); _g_object_list_unref (file_list); if (! import) return; data->import = TRUE; close_dialog (NULL, data); }
static void import_dialog_response_cb (GtkDialog *dialog, int response_id, gpointer user_data) { DialogData *data = user_data; switch (response_id) { case GTK_RESPONSE_DELETE_EVENT: case GTK_RESPONSE_CANCEL: gth_file_list_cancel (GTH_FILE_LIST (data->file_list), (DataFunc) gtk_widget_destroy, data->dialog); break; case GTK_RESPONSE_OK: { GtkTreeIter iter; PicasaWebAlbum *album; GList *file_list; if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (GET_WIDGET ("album_combobox")), &iter)) { gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK, FALSE); return; } gtk_tree_model_get (GTK_TREE_MODEL (GET_WIDGET ("album_liststore")), &iter, ALBUM_DATA_COLUMN, &album, -1); file_list = get_files_to_download (data); if (file_list != NULL) { GFile *destination; GError *error = NULL; GSettings *settings; gboolean single_subfolder; GthSubfolderType subfolder_type; GthSubfolderFormat subfolder_format; char *custom_format; char **tags; int i; GthTask *task; destination = gth_import_preferences_get_destination (); if (! gth_import_task_check_free_space (destination, file_list, &error)) { _gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->dialog), _("Could not import the files"), error); g_clear_error (&error); _g_object_unref (destination); _g_object_list_unref (file_list); g_object_unref (album); return; } settings = g_settings_new (GTHUMB_IMPORTER_SCHEMA); subfolder_type = g_settings_get_enum (settings, PREF_IMPORTER_SUBFOLDER_TYPE); subfolder_format = g_settings_get_enum (settings, PREF_IMPORTER_SUBFOLDER_FORMAT); single_subfolder = g_settings_get_boolean (settings, PREF_IMPORTER_SUBFOLDER_SINGLE); custom_format = g_settings_get_string (settings, PREF_IMPORTER_SUBFOLDER_CUSTOM_FORMAT); tags = g_strsplit ((album->keywords != NULL ? album->keywords : ""), ",", -1); for (i = 0; tags[i] != NULL; i++) tags[i] = g_strstrip (tags[i]); task = gth_import_task_new (data->browser, file_list, destination, subfolder_type, subfolder_format, single_subfolder, custom_format, (album->title != NULL ? album->title : ""), tags, FALSE, FALSE, FALSE); gth_browser_exec_task (data->browser, task, GTH_TASK_FLAGS_DEFAULT); gtk_widget_destroy (data->dialog); g_object_unref (task); g_strfreev (tags); g_object_unref (settings); _g_object_unref (destination); } _g_object_list_unref (file_list); g_object_unref (album); } break; default: break; } }