Bug 599573 - Remember dialog defaults between Gimp sessions

Remember the "New Path" dialog settings in GimpDialogConfig.
This commit is contained in:
Michael Natterer 2016-08-24 19:49:59 +02:00
parent 8132d51b29
commit 2ae3393c3b
5 changed files with 80 additions and 32 deletions

View File

@ -27,6 +27,8 @@
#include "actions-types.h"
#include "config/gimpdialogconfig.h"
#include "core/gimp.h"
#include "core/gimp-utils.h"
#include "core/gimpchannel.h"
@ -86,7 +88,6 @@ static void vectors_export_response (GtkWidget *widget,
/* private variables */
static gchar *vectors_name = NULL;
static gboolean vectors_import_merge = FALSE;
static gboolean vectors_import_scale = FALSE;
static gboolean vectors_export_active_only = TRUE;
@ -156,14 +157,16 @@ vectors_new_cmd_callback (GtkAction *action,
VectorsOptionsDialog *options;
GimpImage *image;
GtkWidget *widget;
GimpDialogConfig *config;
return_if_no_image (image, data);
return_if_no_widget (widget, data);
config = GIMP_DIALOG_CONFIG (image->gimp->config);
options = vectors_options_dialog_new (image, NULL,
action_data_get_context (data),
widget,
vectors_name ? vectors_name :
_("Path"),
config->vectors_new_name,
_("New Path"),
"gimp-vectors-new",
GIMP_STOCK_PATH,
@ -181,13 +184,16 @@ void
vectors_new_last_vals_cmd_callback (GtkAction *action,
gpointer data)
{
GimpImage *image;
GimpVectors *new_vectors;
GimpImage *image;
GimpVectors *vectors;
GimpDialogConfig *config;
return_if_no_image (image, data);
new_vectors = gimp_vectors_new (image, vectors_name);
config = GIMP_DIALOG_CONFIG (image->gimp->config);
gimp_image_add_vectors (image, new_vectors,
vectors = gimp_vectors_new (image, config->vectors_new_name);
gimp_image_add_vectors (image, vectors,
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
gimp_image_flush (image);
@ -752,27 +758,29 @@ vectors_lock_position_cmd_callback (GtkAction *action,
static void
vectors_new_vectors_response (GtkWidget *widget,
gint response_id,
VectorsOptionsDialog *options)
VectorsOptionsDialog *dialog)
{
if (response_id == GTK_RESPONSE_OK)
{
GimpVectors *new_vectors;
GimpDialogConfig *config;
GimpVectors *vectors;
if (vectors_name)
g_free (vectors_name);
config = GIMP_DIALOG_CONFIG (dialog->image->gimp->config);
vectors_name =
g_strdup (gtk_entry_get_text (GTK_ENTRY (options->name_entry)));
g_object_set (config,
"path-new-name",
gtk_entry_get_text (GTK_ENTRY (dialog->name_entry)),
NULL);
new_vectors = gimp_vectors_new (options->image, vectors_name);
vectors = gimp_vectors_new (dialog->image, config->vectors_new_name);
gimp_image_add_vectors (options->image, new_vectors,
gimp_image_add_vectors (dialog->image, vectors,
GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE);
gimp_image_flush (options->image);
gimp_image_flush (dialog->image);
}
gtk_widget_destroy (options->dialog);
gtk_widget_destroy (dialog->dialog);
}
static void

View File

@ -48,7 +48,9 @@ enum
PROP_LAYER_ADD_MASK_INVERT,
PROP_CHANNEL_NEW_NAME,
PROP_CHANNEL_NEW_COLOR
PROP_CHANNEL_NEW_COLOR,
PROP_VECTORS_NEW_NAME
};
@ -130,6 +132,13 @@ gimp_dialog_config_class_init (GimpDialogConfigClass *klass)
TRUE,
&half_transparent,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_STRING (object_class, PROP_VECTORS_NEW_NAME,
"path-new-name",
"Default new path name",
VECTORS_NEW_NAME_BLURB,
_("Path"),
GIMP_PARAM_STATIC_STRINGS);
}
static void
@ -154,6 +163,12 @@ gimp_dialog_config_finalize (GObject *object)
config->channel_new_name = NULL;
}
if (config->vectors_new_name)
{
g_free (config->vectors_new_name);
config->vectors_new_name = NULL;
}
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@ -196,6 +211,12 @@ gimp_dialog_config_set_property (GObject *object,
gimp_value_get_rgb (value, &config->channel_new_color);
break;
case PROP_VECTORS_NEW_NAME:
if (config->vectors_new_name)
g_free (config->vectors_new_name);
config->vectors_new_name = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -237,6 +258,10 @@ gimp_dialog_config_get_property (GObject *object,
gimp_value_set_rgb (value, &config->channel_new_color);
break;
case PROP_VECTORS_NEW_NAME:
g_value_set_string (value, config->vectors_new_name);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;

View File

@ -47,6 +47,8 @@ struct _GimpDialogConfig
gchar *channel_new_name;
GimpRGB channel_new_color;
gchar *vectors_new_name;
};
struct _GimpDialogConfigClass

View File

@ -438,6 +438,9 @@ _("Sets the default channel name for the 'New Channel' dialog.")
#define CHANNEL_NEW_COLOR_BLURB \
_("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 THUMBNAIL_SIZE_BLURB \
_("Sets the size of the thumbnail shown in the Open dialog.")

View File

@ -1650,16 +1650,13 @@ prefs_dialog_new (Gimp *gimp,
/* Quick Mask Color */
vbox2 = prefs_frame_new (_("Quick Mask"), GTK_CONTAINER (vbox), FALSE);
table = prefs_table_new (1, GTK_CONTAINER (vbox2));
button = gimp_prop_color_button_new (object, "quick-mask-color",
_("Set the default Quick Mask color"),
COLOR_BUTTON_WIDTH,
COLOR_BUTTON_HEIGHT,
GIMP_COLOR_AREA_SMALL_CHECKS);
button = prefs_color_button_add (object, "quick-mask-color",
_("Quick Mask color:"),
_("Set the default Quick Mask color"),
GTK_TABLE (table), 0, NULL);
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button),
gimp_get_user_context (gimp));
prefs_widget_add_aligned (button, _("Quick Mask color:"),
GTK_TABLE (table), 0, TRUE, NULL);
/**********************************/
@ -2052,9 +2049,10 @@ prefs_dialog_new (Gimp *gimp,
table = prefs_table_new (2, GTK_CONTAINER (vbox2));
entry = gimp_prop_entry_new (object, "layer-new-name", -1);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Layer name:"), 0.0, 0.5,
entry, 1, FALSE);
prefs_widget_add_aligned (entry,
_("Layer name:"),
GTK_WIDGET (table), 0, FALSE,
size_group);
prefs_enum_combo_box_add (object, "layer-new-fill-type", 0, 0,
_("Fill type:"),
@ -2079,9 +2077,10 @@ prefs_dialog_new (Gimp *gimp,
table = prefs_table_new (2, GTK_CONTAINER (vbox2));
entry = gimp_prop_entry_new (object, "channel-new-name", -1);
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
_("Channel name:"), 0.0, 0.5,
entry, 1, FALSE);
prefs_widget_add_aligned (entry,
_("Channel name:"),
GTK_WIDGET (table), 0, FALSE,
size_group);
button = prefs_color_button_add (object, "channel-new-color",
_("Color and opacity:"),
@ -2090,6 +2089,17 @@ prefs_dialog_new (Gimp *gimp,
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button),
gimp_get_user_context (gimp));
/* New Path Dialog */
vbox2 = prefs_frame_new (_("New Path Dialog"),
GTK_CONTAINER (vbox), FALSE);
table = prefs_table_new (1, GTK_CONTAINER (vbox2));
entry = gimp_prop_entry_new (object, "path-new-name", -1);
prefs_widget_add_aligned (entry,
_("Path name:"),
GTK_WIDGET (table), 0, FALSE,
size_group);
g_object_unref (size_group);