/** * gimp_path_editor_set_path: * @editor: The path editor you want to set the search path from. * @path: The new path to set. * * The elements of the initial search path must be separated with the * #G_SEARCHPATH_SEPARATOR character. **/ void gimp_path_editor_set_path (GimpPathEditor *editor, const gchar *path) { gchar *old_path; GList *path_list; GList *list; g_return_if_fail (GIMP_IS_PATH_EDITOR (editor)); old_path = gimp_path_editor_get_path (editor); if (old_path && path && strcmp (old_path, path) == 0) { g_free (old_path); return; } g_free (old_path); path_list = gimp_path_parse (path, 16, TRUE, NULL); gtk_list_store_clear (editor->dir_list); for (list = path_list; list; list = g_list_next (list)) { gchar *directory = list->data; gchar *utf8; GtkTreeIter iter; utf8 = g_filename_to_utf8 (directory, -1, NULL, NULL, NULL); gtk_list_store_append (editor->dir_list, &iter); gtk_list_store_set (editor->dir_list, &iter, COLUMN_UTF8, utf8, COLUMN_DIRECTORY, directory, COLUMN_WRITABLE, FALSE, -1); g_free (utf8); editor->num_items++; } gimp_path_free (path_list); g_signal_emit (editor, gimp_path_editor_signals[PATH_CHANGED], 0); }
static gboolean fontsel_directories_dialog (GtkWidget *parent, const gchar *message, gchar **path) { GtkWidget *dialog; GtkWidget *path_editor; GtkWidget *label; gchar *new_path = NULL; dialog = gimp_dialog_new (_("Configure Font Search Path"), "font-path", parent, GTK_DIALOG_DESTROY_WITH_PARENT, gimp_standard_help_func, "plug-in-freetype", GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); if (message) { label = gtk_label_new (message); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_misc_set_padding (GTK_MISC (label), 12, 12); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, FALSE, FALSE, 0); } path_editor = gimp_path_editor_new (_("Choose a folder"), *path); gtk_container_set_border_width (GTK_CONTAINER (path_editor), 12); gtk_widget_set_usize (GTK_WIDGET (path_editor), -1, 240); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), path_editor, TRUE, TRUE, 0); label = gtk_label_new (_("You may specify multiple folders here.")); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_misc_set_padding (GTK_MISC (label), 12, 12); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, FALSE, FALSE, 0); gtk_widget_show_all (dialog); if (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK) new_path = gimp_path_editor_get_path (GIMP_PATH_EDITOR (path_editor)); gtk_widget_destroy (dialog); if (new_path && (!*path || strcmp (*path, new_path) != 0 || strcmp (*path, DEFAULT_FONTPATH) == 0)) { g_free (*path); *path = new_path; gimp_gimprc_set (FONTPATH_TOKEN, *path); return TRUE; } return FALSE; }