[gimp] Bug 599573 - Remember dialog defaults between Gimp sessions
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 599573 - Remember dialog defaults between Gimp sessions
- Date: Sun, 25 Sep 2016 22:18:06 +0000 (UTC)
commit f07b9e17cce78aa0b3c0d7c4e354b679440af616
Author: Michael Natterer <mitch gimp org>
Date: Mon Sep 26 00:16:47 2016 +0200
Bug 599573 - Remember dialog defaults between Gimp sessions
Remember the "Export Paths" and "Import Paths" dialog settings in
GimpDialogConfig, including their last used folders.
app/actions/vectors-commands.c | 153 ++++++++++++++++++++------------
app/config/gimpdialogconfig.c | 82 +++++++++++++++++
app/config/gimpdialogconfig.h | 7 ++
app/config/gimprc-blurbs.h | 15 +++
app/dialogs/preferences-dialog-utils.c | 21 +++++
app/dialogs/preferences-dialog-utils.h | 8 ++
app/dialogs/preferences-dialog.c | 31 +++++++
7 files changed, 261 insertions(+), 56 deletions(-)
---
diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c
index a700a5b..07a31aa 100644
--- a/app/actions/vectors-commands.c
+++ b/app/actions/vectors-commands.c
@@ -23,6 +23,7 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
+#include "libgimpconfig/gimpconfig.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "actions-types.h"
@@ -73,16 +74,16 @@
/* local function prototypes */
-static void vectors_new_callback (GtkWidget *dialog,
- GimpImage *image,
- GimpVectors *vectors,
- const gchar *vectors_name,
- gpointer user_data);
-static void vectors_edit_attributes_callback (GtkWidget *dialog,
- GimpImage *image,
- GimpVectors *vectors,
- const gchar *vectors_name,
- gpointer user_data);
+static void vectors_new_callback (GtkWidget *dialog,
+ GimpImage *image,
+ GimpVectors *vectors,
+ const gchar *vectors_name,
+ gpointer user_data);
+static void vectors_edit_attributes_callback (GtkWidget *dialog,
+ GimpImage *image,
+ GimpVectors *vectors,
+ const gchar *vectors_name,
+ gpointer user_data);
static void vectors_import_response (GtkWidget *widget,
gint response_id,
VectorsImportDialog *dialog);
@@ -91,13 +92,6 @@ static void vectors_export_response (GtkWidget *widget,
VectorsExportDialog *dialog);
-/* private variables */
-
-static gboolean vectors_import_merge = FALSE;
-static gboolean vectors_import_scale = FALSE;
-static gboolean vectors_export_active_only = TRUE;
-
-
/* public functions */
void
@@ -608,22 +602,31 @@ void
vectors_export_cmd_callback (GtkAction *action,
gpointer data)
{
- VectorsExportDialog *dialog;
GimpImage *image;
GimpVectors *vectors;
GtkWidget *widget;
- const gchar *folder;
+ GimpDialogConfig *config;
+ VectorsExportDialog *dialog;
return_if_no_vectors (image, vectors, data);
return_if_no_widget (widget, data);
+ config = GIMP_DIALOG_CONFIG (image->gimp->config);
+
dialog = vectors_export_dialog_new (image, widget,
- vectors_export_active_only);
+ config->vectors_export_active_only);
+
+ if (config->vectors_export_path)
+ {
+ gchar *folder = gimp_config_path_expand (config->vectors_export_path,
+ TRUE, NULL);
- folder = g_object_get_data (G_OBJECT (image->gimp),
- "gimp-vectors-export-folder");
- if (folder)
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog->dialog),
- folder);
+ if (folder)
+ {
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog->dialog),
+ folder);
+ g_free (folder);
+ }
+ }
g_signal_connect (dialog->dialog, "response",
G_CALLBACK (vectors_export_response),
@@ -636,22 +639,31 @@ void
vectors_import_cmd_callback (GtkAction *action,
gpointer data)
{
- VectorsImportDialog *dialog;
GimpImage *image;
GtkWidget *widget;
- const gchar *folder;
+ GimpDialogConfig *config;
+ VectorsImportDialog *dialog;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
+ config = GIMP_DIALOG_CONFIG (image->gimp->config);
+
dialog = vectors_import_dialog_new (image, widget,
- vectors_import_merge,
- vectors_import_scale);
+ config->vectors_import_merge,
+ config->vectors_import_scale);
- folder = g_object_get_data (G_OBJECT (image->gimp),
- "gimp-vectors-import-folder");
- if (folder)
- gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog->dialog),
- folder);
+ if (config->vectors_import_path)
+ {
+ gchar *folder = gimp_config_path_expand (config->vectors_import_path,
+ TRUE, NULL);
+
+ if (folder)
+ {
+ gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog->dialog),
+ folder);
+ g_free (folder);
+ }
+ }
g_signal_connect (dialog->dialog, "response",
G_CALLBACK (vectors_import_response),
@@ -820,17 +832,37 @@ vectors_import_response (GtkWidget *widget,
{
if (response_id == GTK_RESPONSE_OK)
{
- GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
- GFile *file;
- GError *error = NULL;
+ GimpDialogConfig *config;
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
+ GFile *file;
+ gchar *folder;
+ GError *error = NULL;
+
+ config = GIMP_DIALOG_CONFIG (dialog->image->gimp->config);
+
+ folder = gtk_file_chooser_get_current_folder (chooser);
+
+ if (folder)
+ {
+ gchar *tmp = gimp_config_path_unexpand (folder, TRUE, NULL);
+ g_free (folder);
+ folder = tmp;
+ }
+
+ g_object_set (config,
+ "path-import-path", folder,
+ "path-import-merge", dialog->merge_vectors,
+ "path-import-scale", dialog->scale_vectors,
+ NULL);
- vectors_import_merge = dialog->merge_vectors;
- vectors_import_scale = dialog->scale_vectors;
+ if (folder)
+ g_free (folder);
file = gtk_file_chooser_get_file (chooser);
if (gimp_vectors_import_file (dialog->image, file,
- vectors_import_merge, vectors_import_scale,
+ config->vectors_import_merge,
+ config->vectors_import_scale,
GIMP_IMAGE_ACTIVE_PARENT, -1,
NULL, &error))
{
@@ -846,11 +878,6 @@ vectors_import_response (GtkWidget *widget,
}
g_object_unref (file);
-
- g_object_set_data_full (G_OBJECT (dialog->image->gimp),
- "gimp-vectors-import-folder",
- gtk_file_chooser_get_current_folder (chooser),
- (GDestroyNotify) g_free);
}
gtk_widget_destroy (widget);
@@ -863,16 +890,35 @@ vectors_export_response (GtkWidget *widget,
{
if (response_id == GTK_RESPONSE_OK)
{
- GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
- GimpVectors *vectors = NULL;
- GFile *file;
- GError *error = NULL;
+ GimpDialogConfig *config;
+ GtkFileChooser *chooser = GTK_FILE_CHOOSER (widget);
+ GimpVectors *vectors = NULL;
+ GFile *file;
+ gchar *folder;
+ GError *error = NULL;
+
+ config = GIMP_DIALOG_CONFIG (dialog->image->gimp->config);
+
+ folder = gtk_file_chooser_get_current_folder (chooser);
+
+ if (folder)
+ {
+ gchar *tmp = gimp_config_path_unexpand (folder, TRUE, NULL);
+ g_free (folder);
+ folder = tmp;
+ }
- vectors_export_active_only = dialog->active_only;
+ g_object_set (config,
+ "path-export-path", folder,
+ "path-export-active-only", dialog->active_only,
+ NULL);
+
+ if (folder)
+ g_free (folder);
file = gtk_file_chooser_get_file (chooser);
- if (vectors_export_active_only)
+ if (config->vectors_export_active_only)
vectors = gimp_image_get_active_vectors (dialog->image);
if (! gimp_vectors_export_file (dialog->image, vectors, file, &error))
@@ -885,11 +931,6 @@ vectors_export_response (GtkWidget *widget,
}
g_object_unref (file);
-
- g_object_set_data_full (G_OBJECT (dialog->image->gimp),
- "gimp-vectors-export-folder",
- gtk_file_chooser_get_current_folder (chooser),
- (GDestroyNotify) g_free);
}
gtk_widget_destroy (widget);
diff --git a/app/config/gimpdialogconfig.c b/app/config/gimpdialogconfig.c
index fd2700c..ae6ab82 100644
--- a/app/config/gimpdialogconfig.c
+++ b/app/config/gimpdialogconfig.c
@@ -66,6 +66,13 @@ enum
PROP_VECTORS_NEW_NAME,
+ PROP_VECTORS_EXPORT_PATH,
+ PROP_VECTORS_EXPORT_ACTIVE_ONLY,
+
+ PROP_VECTORS_IMPORT_PATH,
+ PROP_VECTORS_IMPORT_MERGE,
+ PROP_VECTORS_IMPORT_SCALE,
+
PROP_SELECTION_FEATHER_RADIUS,
PROP_SELECTION_GROW_RADIUS,
@@ -235,6 +242,43 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
_("Path"),
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_PROP_PATH (object_class, PROP_VECTORS_EXPORT_PATH,
+ "path-export-path",
+ "Default path export folder path",
+ VECTORS_EXPORT_PATH_BLURB,
+ GIMP_CONFIG_PATH_FILE,
+ NULL,
+ GIMP_PARAM_STATIC_STRINGS);
+
+ GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_VECTORS_EXPORT_ACTIVE_ONLY,
+ "path-export-active-only",
+ "Default export only the active path",
+ VECTORS_EXPORT_ACTIVE_ONLY_BLURB,
+ TRUE,
+ GIMP_PARAM_STATIC_STRINGS);
+
+ GIMP_CONFIG_PROP_PATH (object_class, PROP_VECTORS_IMPORT_PATH,
+ "path-import-path",
+ "Default path import folder path",
+ VECTORS_IMPORT_PATH_BLURB,
+ GIMP_CONFIG_PATH_FILE,
+ NULL,
+ GIMP_PARAM_STATIC_STRINGS);
+
+ GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_VECTORS_IMPORT_MERGE,
+ "path-import-merge",
+ "Default merge imported vectors",
+ VECTORS_IMPORT_MERGE_BLURB,
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
+
+ GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_VECTORS_IMPORT_SCALE,
+ "path-import-scale",
+ "Default scale imported vectors",
+ VECTORS_IMPORT_SCALE_BLURB,
+ FALSE,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_SELECTION_FEATHER_RADIUS,
"selection-feather-radius",
"Selection feather radius",
@@ -444,6 +488,27 @@ gimp_dialog_config_set_property (GObject *object,
config->vectors_new_name = g_value_dup_string (value);
break;
+ case PROP_VECTORS_EXPORT_PATH:
+ if (config->vectors_export_path)
+ g_free (config->vectors_export_path);
+ config->vectors_export_path = g_value_dup_string (value);
+ break;
+ case PROP_VECTORS_EXPORT_ACTIVE_ONLY:
+ config->vectors_export_active_only = g_value_get_boolean (value);
+ break;
+
+ case PROP_VECTORS_IMPORT_PATH:
+ if (config->vectors_import_path)
+ g_free (config->vectors_import_path);
+ config->vectors_import_path = g_value_dup_string (value);
+ break;
+ case PROP_VECTORS_IMPORT_MERGE:
+ config->vectors_import_merge = g_value_get_boolean (value);
+ break;
+ case PROP_VECTORS_IMPORT_SCALE:
+ config->vectors_import_scale = g_value_get_boolean (value);
+ break;
+
case PROP_SELECTION_FEATHER_RADIUS:
config->selection_feather_radius = g_value_get_double (value);
break;
@@ -547,6 +612,23 @@ gimp_dialog_config_get_property (GObject *object,
g_value_set_string (value, config->vectors_new_name);
break;
+ case PROP_VECTORS_EXPORT_PATH:
+ g_value_set_string (value, config->vectors_export_path);
+ break;
+ case PROP_VECTORS_EXPORT_ACTIVE_ONLY:
+ g_value_set_boolean (value, config->vectors_export_active_only);
+ break;
+
+ case PROP_VECTORS_IMPORT_PATH:
+ g_value_set_string (value, config->vectors_import_path);
+ break;
+ case PROP_VECTORS_IMPORT_MERGE:
+ g_value_set_boolean (value, config->vectors_import_merge);
+ break;
+ case PROP_VECTORS_IMPORT_SCALE:
+ g_value_set_boolean (value, config->vectors_import_scale);
+ break;
+
case PROP_SELECTION_FEATHER_RADIUS:
g_value_set_double (value, config->selection_feather_radius);
break;
diff --git a/app/config/gimpdialogconfig.h b/app/config/gimpdialogconfig.h
index adc59ec..99e2d7f 100644
--- a/app/config/gimpdialogconfig.h
+++ b/app/config/gimpdialogconfig.h
@@ -64,6 +64,13 @@ struct _GimpDialogConfig
gchar *vectors_new_name;
+ gchar *vectors_export_path;
+ gboolean vectors_export_active_only;
+
+ gchar *vectors_import_path;
+ gboolean vectors_import_merge;
+ gboolean vectors_import_scale;
+
gdouble selection_feather_radius;
gdouble selection_grow_radius;
diff --git a/app/config/gimprc-blurbs.h b/app/config/gimprc-blurbs.h
index ef64dff..2feb2da 100644
--- a/app/config/gimprc-blurbs.h
+++ b/app/config/gimprc-blurbs.h
@@ -457,6 +457,21 @@ _("Sets the default color and opacity for the 'New Channel' dialog.")
#define VECTORS_NEW_NAME_BLURB \
_("Sets the default path name for the 'New Path' dialog.")
+#define VECTORS_EXPORT_PATH_BLURB \
+_("Sets the default folder path for the 'Export Path' dialog.")
+
+#define VECTORS_EXPORT_ACTIVE_ONLY_BLURB \
+_("Sets the default 'Export the active path' state for the 'Export Path' dialog.")
+
+#define VECTORS_IMPORT_PATH_BLURB \
+_("Sets the default folder path for the 'Import Path' dialog.")
+
+#define VECTORS_IMPORT_MERGE_BLURB \
+_("Sets the default 'Merge imported paths' state for the 'Import Path' dialog.")
+
+#define VECTORS_IMPORT_SCALE_BLURB \
+_("Sets the default 'Scale imported paths to fit size' state for the 'Import Path' dialog.")
+
#define SELECTION_FEATHER_RADIUS_BLURB \
_("Sets the default feather radius for the 'Feather Selection' dialog.")
diff --git a/app/dialogs/preferences-dialog-utils.c b/app/dialogs/preferences-dialog-utils.c
index 3e38fb9..9da01b9 100644
--- a/app/dialogs/preferences-dialog-utils.c
+++ b/app/dialogs/preferences-dialog-utils.c
@@ -283,6 +283,27 @@ prefs_memsize_entry_add (GObject *config,
}
GtkWidget *
+prefs_file_chooser_button_add (GObject *config,
+ const gchar *property_name,
+ const gchar *label,
+ const gchar *dialog_title,
+ GtkTable *table,
+ gint table_row,
+ GtkSizeGroup *group)
+{
+ GtkWidget *button;
+
+ button = gimp_prop_file_chooser_button_new (config, property_name,
+ dialog_title,
+ GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+
+ if (button)
+ prefs_widget_add_aligned (button, label, table, table_row, FALSE, group);
+
+ return button;
+}
+
+GtkWidget *
prefs_enum_combo_box_add (GObject *config,
const gchar *property_name,
gint minimum,
diff --git a/app/dialogs/preferences-dialog-utils.h b/app/dialogs/preferences-dialog-utils.h
index 38b4f38..8185039 100644
--- a/app/dialogs/preferences-dialog-utils.h
+++ b/app/dialogs/preferences-dialog-utils.h
@@ -84,6 +84,14 @@ GtkWidget * prefs_memsize_entry_add (GObject *config,
gint table_row,
GtkSizeGroup *group);
+GtkWidget * prefs_file_chooser_button_add (GObject *config,
+ const gchar *property_name,
+ const gchar *label,
+ const gchar *dialog_title,
+ GtkTable *table,
+ gint table_row,
+ GtkSizeGroup *group);
+
GtkWidget * prefs_enum_combo_box_add (GObject *config,
const gchar *property_name,
gint minimum,
diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c
index 6f91da2..332512e 100644
--- a/app/dialogs/preferences-dialog.c
+++ b/app/dialogs/preferences-dialog.c
@@ -1903,6 +1903,37 @@ prefs_dialog_new (Gimp *gimp,
_("Path name:"),
GTK_TABLE (table), 0, size_group);
+ /* Export Path Dialog */
+ vbox2 = prefs_frame_new (_("Export Paths Dialog"),
+ GTK_CONTAINER (vbox), FALSE);
+ table = prefs_table_new (1, GTK_CONTAINER (vbox2));
+
+ prefs_file_chooser_button_add (object, "path-export-path",
+ _("Export folder:"),
+ _("Select Default Folder for Exporting Paths"),
+ GTK_TABLE (table), 0, size_group);
+
+ prefs_check_button_add (object, "path-export-active-only",
+ _("Export the active path only"),
+ GTK_BOX (vbox2));
+
+ /* Import Path Dialog */
+ vbox2 = prefs_frame_new (_("Import Paths Dialog"),
+ GTK_CONTAINER (vbox), FALSE);
+ table = prefs_table_new (1, GTK_CONTAINER (vbox2));
+
+ prefs_file_chooser_button_add (object, "path-import-path",
+ _("Import folder:"),
+ _("Select Default Folder for Importing Paths"),
+ GTK_TABLE (table), 0, size_group);
+
+ prefs_check_button_add (object, "path-import-merge",
+ _("Merge imported paths"),
+ GTK_BOX (vbox2));
+ prefs_check_button_add (object, "path-import-scale",
+ _("Scale imported paths"),
+ GTK_BOX (vbox2));
+
/* Feather Selection Dialog */
vbox2 = prefs_frame_new (_("Feather Selection Dialog"),
GTK_CONTAINER (vbox), FALSE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]