static void update_location_list (gpointer user_data) { GthLocationChooser *self = user_data; GtkTreeIter iter; self->priv->update_location_list_id = 0; if (self->priv->location == NULL) return; if (get_iter_from_current_file_entries (self, self->priv->location, &iter)) { g_signal_handlers_block_by_func (self->priv->combo, combo_changed_cb, self); gtk_combo_box_set_active_iter (GTK_COMBO_BOX (self->priv->combo), &iter); g_signal_handlers_unblock_by_func (self->priv->combo, combo_changed_cb, self); } else { GList *list; GList *scan; int position = 0; delete_current_file_entries (self); list = gth_file_source_get_current_list (self->priv->file_source, self->priv->location); for (scan = list; scan; scan = scan->next) { GFile *file = scan->data; GFileInfo *info; info = gth_file_source_get_file_info (self->priv->file_source, file, GFILE_DISPLAY_ATTRIBUTES); if (info == NULL) continue; add_file_source_entries (self, file, g_file_info_get_display_name (info), g_file_info_get_symbolic_icon (info), position++, TRUE, ITEM_TYPE_LOCATION); g_object_unref (info); } _g_object_list_unref (list); } }
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); }