static void remove_catalog (GtkWindow *window, GthFileData *file_data) { GFile *gio_file; GError *error = NULL; gio_file = gth_main_get_gio_file (file_data->file); if (g_file_delete (gio_file, NULL, &error)) { GFile *parent; GList *files; parent = g_file_get_parent (file_data->file); files = g_list_prepend (NULL, g_object_ref (file_data->file)); gth_monitor_folder_changed (gth_main_get_default_monitor (), parent, files, GTH_MONITOR_EVENT_DELETED); _g_object_list_unref (files); _g_object_unref (parent); } else { _gtk_error_dialog_from_gerror_show (window, _("Could not remove the catalog"), error); g_clear_error (&error); } g_object_unref (gio_file); }
static void catalog_save_done_cb (void **buffer, gsize count, GError *error, gpointer user_data) { AddData *add_data = user_data; if (error != NULL) { _gtk_error_dialog_from_gerror_show (GTK_WINDOW (add_data->parent_window), _("Could not add the files to the catalog"), &error); return; } gth_monitor_folder_changed (gth_main_get_default_monitor (), add_data->catalog_file, add_data->files, GTH_MONITOR_EVENT_CREATED); if (add_data->view_destination) gth_browser_go_to (add_data->browser, add_data->catalog_file, NULL); if (add_data->dialog != NULL) gtk_widget_destroy (add_data->dialog); add_data_free (add_data); }
static void pixbuf_saved_cb (GthFileData *file_data, GError *error, gpointer user_data) { GthPixbufListTask *self = user_data; GFile *parent; GList *file_list; if (error != NULL) { if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) { if (self->priv->overwrite_mode == GTH_OVERWRITE_SKIP) { process_next_file (self); } else { GthFileData *file_data; GtkWidget *dialog; gth_task_dialog (GTH_TASK (self), TRUE); file_data = self->priv->current->data; dialog = gth_overwrite_dialog_new (NULL, self->priv->new_pixbuf, file_data->file, GTH_OVERWRITE_RESPONSE_YES, (self->priv->n_files == 1)); g_signal_connect (dialog, "response", G_CALLBACK (overwrite_dialog_response_cb), self); gtk_widget_show (dialog); } } else gth_task_completed (GTH_TASK (self), error); return; } parent = g_file_get_parent (file_data->file); file_list = g_list_append (NULL, file_data->file); gth_monitor_folder_changed (gth_main_get_default_monitor (), parent, file_list, GTH_MONITOR_EVENT_CHANGED); g_list_free (file_list); g_object_unref (parent); process_next_file (self); }
static void catalog_new_dialog_response_cb (GtkWidget *dialog, int response_id, gpointer user_data) { GthBrowser *browser = user_data; char *name; GthFileData *selected_parent; GFile *parent; GthFileSource *file_source; GFile *gio_parent; char *display_name; GError *error = NULL; GFile *gio_file; if (response_id != GTK_RESPONSE_OK) { gtk_widget_destroy (dialog); return; } name = gth_request_dialog_get_normalized_text (GTH_REQUEST_DIALOG (dialog)); if (_g_utf8_all_spaces (name)) { g_free (name); gth_request_dialog_set_info_text (GTH_REQUEST_DIALOG (dialog), GTK_MESSAGE_ERROR, _("No name specified")); return; } if (g_regex_match_simple ("/", name, 0, 0)) { char *message; message = g_strdup_printf (_("Invalid name. The following characters are not allowed: %s"), "/"); gth_request_dialog_set_info_text (GTH_REQUEST_DIALOG (dialog), GTK_MESSAGE_ERROR, message); g_free (message); g_free (name); return; } selected_parent = gth_browser_get_folder_popup_file_data (browser); if (selected_parent != NULL) { GthFileSource *file_source; GFileInfo *info; file_source = gth_main_get_file_source (selected_parent->file); info = gth_file_source_get_file_info (file_source, selected_parent->file, GFILE_BASIC_ATTRIBUTES); if (g_file_info_get_attribute_boolean (info, "gthumb::no-child")) parent = g_file_get_parent (selected_parent->file); else parent = g_file_dup (selected_parent->file); g_object_unref (info); g_object_unref (file_source); } else parent = g_file_new_for_uri ("catalog:///"); file_source = gth_main_get_file_source (parent); gio_parent = gth_file_source_to_gio_file (file_source, parent); display_name = g_strconcat (name, ".catalog", NULL); gio_file = g_file_get_child_for_display_name (gio_parent, display_name, &error); if (gio_file != NULL) { GFileOutputStream *stream; stream = g_file_create (gio_file, G_FILE_CREATE_NONE, NULL, &error); if (stream != NULL) { GFile *file; GList *list; file = gth_catalog_file_from_gio_file (gio_file, NULL); list = g_list_prepend (NULL, file); gth_monitor_folder_changed (gth_main_get_default_monitor (), parent, list, GTH_MONITOR_EVENT_CREATED); g_list_free (list); g_object_unref (file); g_object_unref (stream); } g_object_unref (gio_file); } if (error != NULL) { if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) gth_request_dialog_set_info_text (GTH_REQUEST_DIALOG (dialog), GTK_MESSAGE_ERROR, _("Name already used")); else gth_request_dialog_set_info_text (GTH_REQUEST_DIALOG (dialog), GTK_MESSAGE_ERROR, error->message); g_clear_error (&error); } else gtk_widget_destroy (dialog); g_free (display_name); g_object_unref (gio_parent); g_object_unref (file_source); g_free (name); }
static void new_library_button_clicked_cb (GtkWidget *widget, DialogData *data) { char *name; GthFileData *selected_parent; GFile *parent; GthFileSource *file_source; GFile *gio_parent; GError *error = NULL; GFile *gio_file; name = _gtk_request_dialog_run (GTK_WINDOW (data->dialog), GTK_DIALOG_MODAL, _("Enter the library name: "), "", 1024, GTK_STOCK_CANCEL, _("C_reate")); if (name == NULL) return; selected_parent = gth_folder_tree_get_selected_or_parent (GTH_FOLDER_TREE (data->source_tree)); if (selected_parent != NULL) { GthFileSource *file_source; GFileInfo *info; file_source = gth_main_get_file_source (selected_parent->file); info = gth_file_source_get_file_info (file_source, selected_parent->file, GFILE_BASIC_ATTRIBUTES); if (g_file_info_get_attribute_boolean (info, "gthumb::no-child")) parent = g_file_get_parent (selected_parent->file); else parent = g_file_dup (selected_parent->file); g_object_unref (info); g_object_unref (file_source); } else parent = g_file_new_for_uri ("catalog:///"); file_source = gth_main_get_file_source (parent); gio_parent = gth_file_source_to_gio_file (file_source, parent); gio_file = _g_directory_create_unique (gio_parent, name, "", &error); if (gio_file != NULL) { GFile *file; GList *list; file = gth_catalog_file_from_gio_file (gio_file, NULL); list = g_list_prepend (NULL, file); gth_monitor_folder_changed (gth_main_get_default_monitor (), parent, list, GTH_MONITOR_EVENT_CREATED); g_list_free (list); g_object_unref (file); } else _gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->dialog), _("Could not create the library"), &error); g_object_unref (gio_file); g_object_unref (gio_parent); g_object_unref (file_source); /* selected_catalog = gth_folder_tree_get_selected (GTH_FOLDER_TREE (data->source_tree)); parent = get_catalog_parent (selected_catalog->file); new_library = g_file_get_child_for_display_name (parent, name, &error); if ((new_library != NULL) && (strchr (display_name, '/') != NULL)) { error = g_error_new (G_IO_ERROR, G_IO_ERROR_INVALID_FILENAME, _("The name \"%s\" is not valid because it contains the character \"/\". " "Please use a different name."), display_name); g_object_unref (new_library); new_library = NULL; } if (error == NULL) { GFile *gio_file; gio_file = gth_file_source_to_gio_file (data->file_source, new_library); g_file_make_directory (new_library, NULL, &error); g_object_unref (gio_file); } if (error != NULL) _gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->dialog), _("Could not create a new library"), &error); if (new_library != NULL) g_object_unref (new_library); g_object_unref (parent); g_object_unref (selected_catalog); g_free (name); */ }
static void new_catalog_button_clicked_cb (GtkWidget *widget, DialogData *data) { char *name; GthFileData *selected_parent; GFile *parent; GthFileSource *file_source; GFile *gio_parent; GError *error; GFile *gio_file; name = _gtk_request_dialog_run (GTK_WINDOW (data->dialog), GTK_DIALOG_MODAL, _("Enter the catalog name: "), "", 1024, GTK_STOCK_CANCEL, _("C_reate")); if (name == NULL) return; selected_parent = gth_folder_tree_get_selected_or_parent (GTH_FOLDER_TREE (data->source_tree)); if (selected_parent != NULL) { GthFileSource *file_source; GFileInfo *info; file_source = gth_main_get_file_source (selected_parent->file); info = gth_file_source_get_file_info (file_source, selected_parent->file, GFILE_BASIC_ATTRIBUTES); if (g_file_info_get_attribute_boolean (info, "gthumb::no-child")) parent = g_file_get_parent (selected_parent->file); else parent = g_file_dup (selected_parent->file); g_object_unref (info); g_object_unref (file_source); } else parent = g_file_new_for_uri ("catalog:///"); file_source = gth_main_get_file_source (parent); gio_parent = gth_file_source_to_gio_file (file_source, parent); gio_file = _g_file_create_unique (gio_parent, name, ".catalog", &error); if (gio_file != NULL) { GFile *file; GList *list; file = gth_catalog_file_from_gio_file (gio_file, NULL); list = g_list_prepend (NULL, file); gth_monitor_folder_changed (gth_main_get_default_monitor (), parent, list, GTH_MONITOR_EVENT_CREATED); g_list_free (list); g_object_unref (file); } else _gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->dialog), _("Could not create the catalog"), &error); g_object_unref (gio_file); g_object_unref (gio_parent); g_object_unref (file_source); }
static void new_folder_dialog_response_cb (GtkWidget *dialog, int response_id, gpointer user_data) { NewFolderData *data = user_data; char *name; GFile *folder; GError *error = NULL; if (response_id != GTK_RESPONSE_OK) { new_folder_data_free (data); gtk_widget_destroy (dialog); return; } name = gth_request_dialog_get_normalized_text (GTH_REQUEST_DIALOG (dialog)); if (_g_utf8_all_spaces (name)) { g_free (name); gth_request_dialog_set_info_text (GTH_REQUEST_DIALOG (dialog), GTK_MESSAGE_ERROR, _("No name specified")); return; } if (g_regex_match_simple ("/", name, 0, 0)) { char *message; message = g_strdup_printf (_("Invalid name. The following characters are not allowed: %s"), "/"); gth_request_dialog_set_info_text (GTH_REQUEST_DIALOG (dialog), GTK_MESSAGE_ERROR, message); g_free (message); g_free (name); return; } folder = g_file_get_child_for_display_name (data->parent, name, &error); if ((folder != NULL) && g_file_make_directory (folder, NULL, &error)) { GList *list; GtkWidget *folder_tree; GtkTreePath *path; list = g_list_prepend (NULL, folder); gth_monitor_folder_changed (gth_main_get_default_monitor (), data->parent, list, GTH_MONITOR_EVENT_CREATED); folder_tree = gth_browser_get_folder_tree (data->browser); path = gth_folder_tree_get_path (GTH_FOLDER_TREE (folder_tree), data->parent); gth_folder_tree_expand_row (GTH_FOLDER_TREE (folder_tree), path, FALSE); gtk_tree_path_free (path); g_list_free (list); } if (error != NULL) { if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_EXISTS)) gth_request_dialog_set_info_text (GTH_REQUEST_DIALOG (dialog), GTK_MESSAGE_ERROR, _("Name already used")); else gth_request_dialog_set_info_text (GTH_REQUEST_DIALOG (dialog), GTK_MESSAGE_ERROR, error->message); g_clear_error (&error); } else { gth_browser_load_location (data->browser, folder); new_folder_data_free (data); gtk_widget_destroy (dialog); } g_object_unref (folder); }