added gimp->edit_config which is a copy of gimp->config except for

2002-11-30  Michael Natterer  <mitch@gimp.org>

	* app/core/gimp.[ch]: added gimp->edit_config which is a copy of
	gimp->config except for GIMP_PARAM_RESTRT options. Create it in
	gimp_set_config() which must be called before anything else after
	gimp_new(). Install "notify" handlers between the both to keep
	them up-to-date. Enable auto saving for the edit_config.

	* app/app_procs.c: call gimp_set_config().

	* tools/pdbgen/pdb/gimprc.pdb: use gimp->edit_config here so we
	don't accidentially change GIMP_PARAM_RESTART values from the PDB.

	* app/pdb/gimprc_cmds.c: regenerated.

	* app/gui/preferences-dialog.c: use gimp->edit_config as the base
	for all prefs operations. Disable auto saving while the prefs
	dialog is open. No need any more to parse the saved gimprc to get
	GIMP_PARAM_RESTART values. Removed GIMP_PARAM_RESTART special
	hacks because edit_config handles them transparently for us.

	Unrelated:

	* app/core/gimpimage.c (gimp_image_init): initialize active_vectors.

	* app/gui/gui.c (gui_image_disconect): when the last image
	disappears, show the toolbox only if the image had a display.
This commit is contained in:
Michael Natterer 2002-11-30 13:08:44 +00:00 committed by Michael Natterer
parent b1706da93d
commit 64eb7d748a
10 changed files with 253 additions and 141 deletions

View File

@ -1,3 +1,31 @@
2002-11-30 Michael Natterer <mitch@gimp.org>
* app/core/gimp.[ch]: added gimp->edit_config which is a copy of
gimp->config except for GIMP_PARAM_RESTRT options. Create it in
gimp_set_config() which must be called before anything else after
gimp_new(). Install "notify" handlers between the both to keep
them up-to-date. Enable auto saving for the edit_config.
* app/app_procs.c: call gimp_set_config().
* tools/pdbgen/pdb/gimprc.pdb: use gimp->edit_config here so we
don't accidentially change GIMP_PARAM_RESTART values from the PDB.
* app/pdb/gimprc_cmds.c: regenerated.
* app/gui/preferences-dialog.c: use gimp->edit_config as the base
for all prefs operations. Disable auto saving while the prefs
dialog is open. No need any more to parse the saved gimprc to get
GIMP_PARAM_RESTART values. Removed GIMP_PARAM_RESTART special
hacks because edit_config handles them transparently for us.
Unrelated:
* app/core/gimpimage.c (gimp_image_init): initialize active_vectors.
* app/gui/gui.c (gui_image_disconect): when the last image
disappears, show the toolbox only if the image had a display.
2002-11-29 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpdnd.c: more useful debugging output.
@ -5,7 +33,7 @@
2002-11-29 Michael Natterer <mitch@gimp.org>
* libgimpwidgets/gimpwidgets.c (gimp_pixmap_button_new):
use gtk_label_new_with_mnemonic():
use gtk_label_new_with_mnemonic().
* plug-ins/common/uniteditor.c: Treeviewized and undeprecated.
Removed all static variables. Cleanup.

View File

@ -89,6 +89,7 @@ app_init (gint gimp_argc,
gchar **gimp_argv)
{
const gchar *gimp_dir;
GimpRc *gimprc;
/* Create an instance of the "Gimp" object which is the root of the
* core object system
@ -129,17 +130,22 @@ app_init (gint gimp_argc,
*/
gimp_unitrc_load (the_gimp);
the_gimp->config = GIMP_CORE_CONFIG (gimp_rc_new (alternate_system_gimprc,
alternate_gimprc,
be_verbose));
gimprc = gimp_rc_new (alternate_system_gimprc,
alternate_gimprc,
be_verbose);
/* solely for debugging */
g_signal_connect (G_OBJECT (the_gimp->config), "notify",
g_signal_connect (G_OBJECT (gimprc), "notify",
G_CALLBACK (gimprc_notify_callback),
NULL);
/* initialize lowlevel stuff */
base_init (GIMP_BASE_CONFIG (the_gimp->config));
base_init (GIMP_BASE_CONFIG (gimprc));
gimp_set_config (the_gimp, GIMP_CORE_CONFIG (gimprc));
g_object_unref (gimprc);
gimprc = NULL;
if (! no_interface)
{

View File

@ -26,6 +26,8 @@
#include "core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpconfig-params.h"
#include "config/gimprc.h"
#include "pdb/procedural_db.h"
@ -62,13 +64,20 @@
#include "libgimp/gimpintl.h"
static void gimp_class_init (GimpClass *klass);
static void gimp_init (Gimp *gimp);
static void gimp_class_init (GimpClass *klass);
static void gimp_init (Gimp *gimp);
static void gimp_dispose (GObject *object);
static void gimp_finalize (GObject *object);
static void gimp_dispose (GObject *object);
static void gimp_finalize (GObject *object);
static gsize gimp_get_memsize (GimpObject *object);
static gsize gimp_get_memsize (GimpObject *object);
static void gimp_global_config_notify (GObject *global_config,
GParamSpec *param_spec,
GObject *edit_config);
static void gimp_edit_config_notify (GObject *edit_config,
GParamSpec *param_spec,
GObject *global_config);
static GimpObjectClass *parent_class = NULL;
@ -345,10 +354,16 @@ gimp_finalize (GObject *object)
if (gimp->parasites)
{
g_object_unref (G_OBJECT (gimp->parasites));
g_object_unref (gimp->parasites);
gimp->parasites = NULL;
}
if (gimp->edit_config)
{
g_object_unref (gimp->edit_config);
gimp->edit_config = NULL;
}
if (gimp->user_units)
gimp_units_exit (gimp);
@ -425,6 +440,104 @@ gimp_new (gboolean be_verbose,
return gimp;
}
static void
gimp_global_config_notify (GObject *global_config,
GParamSpec *param_spec,
GObject *edit_config)
{
GValue global_value = { 0, };
GValue edit_value = { 0, };
g_value_init (&global_value, param_spec->value_type);
g_value_init (&edit_value, param_spec->value_type);
g_object_get_property (global_config, param_spec->name, &global_value);
g_object_get_property (edit_config, param_spec->name, &edit_value);
if (g_param_values_cmp (param_spec, &global_value, &edit_value))
{
g_signal_handlers_block_by_func (edit_config,
gimp_edit_config_notify,
global_config);
g_object_set_property (edit_config, param_spec->name, &global_value);
g_signal_handlers_unblock_by_func (edit_config,
gimp_edit_config_notify,
global_config);
}
g_value_unset (&global_value);
g_value_unset (&edit_value);
}
static void
gimp_edit_config_notify (GObject *edit_config,
GParamSpec *param_spec,
GObject *global_config)
{
GValue edit_value = { 0, };
GValue global_value = { 0, };
g_value_init (&edit_value, param_spec->value_type);
g_value_init (&global_value, param_spec->value_type);
g_object_get_property (edit_config, param_spec->name, &edit_value);
g_object_get_property (global_config, param_spec->name, &global_value);
if (g_param_values_cmp (param_spec, &edit_value, &global_value))
{
if (param_spec->flags & GIMP_PARAM_RESTART)
{
g_print ("NOT Applying edit_config change of '%s' to global_config "
"because it needs restart\n",
param_spec->name);
}
else
{
g_print ("Applying edit_config change of '%s' to global_config\n",
param_spec->name);
g_signal_handlers_block_by_func (global_config,
gimp_global_config_notify,
edit_config);
g_object_set_property (global_config, param_spec->name, &edit_value);
g_signal_handlers_unblock_by_func (global_config,
gimp_global_config_notify,
edit_config);
}
}
g_value_unset (&edit_value);
g_value_unset (&global_value);
}
void
gimp_set_config (Gimp *gimp,
GimpCoreConfig *core_config)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (GIMP_IS_CORE_CONFIG (core_config));
g_return_if_fail (gimp->config == NULL);
g_return_if_fail (gimp->edit_config == NULL);
gimp->config = g_object_ref (core_config);
gimp->edit_config =
GIMP_CORE_CONFIG (gimp_config_duplicate (G_OBJECT (gimp->config)));
gimp_rc_set_autosave (GIMP_RC (gimp->edit_config), TRUE);
g_signal_connect_object (gimp->config, "notify",
G_CALLBACK (gimp_global_config_notify),
gimp->edit_config, 0);
g_signal_connect_object (gimp->edit_config, "notify",
G_CALLBACK (gimp_edit_config_notify),
gimp->config, 0);
}
void
gimp_initialize (Gimp *gimp,
GimpInitStatusFunc status_callback)
@ -458,6 +571,7 @@ gimp_initialize (Gimp *gimp,
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (status_callback != NULL);
g_return_if_fail (GIMP_IS_CORE_CONFIG (gimp->config));
gimp->brush_factory =
gimp_data_factory_new (GIMP_TYPE_BRUSH,

View File

@ -47,6 +47,9 @@ struct _Gimp
GimpObject parent_instance;
GimpCoreConfig *config;
GimpCoreConfig *edit_config; /* don't use this one, it's just
* for the preferences dialog
*/
gboolean be_verbose;
gboolean no_data;
@ -142,6 +145,9 @@ Gimp * gimp_new (gboolean be_verbose,
gboolean no_interface,
GimpStackTraceMode stack_trace_mode);
void gimp_set_config (Gimp *gimp,
GimpCoreConfig *core_config);
void gimp_initialize (Gimp *gimp,
GimpInitStatusFunc status_callback);

View File

@ -451,6 +451,8 @@ gimp_image_init (GimpImage *gimage)
gimage->active_layer = NULL;
gimage->active_channel = NULL;
gimage->active_vectors = NULL;
gimage->floating_sel = NULL;
gimage->selection_mask = NULL;

View File

@ -95,43 +95,13 @@ preferences_dialog_create (Gimp *gimp)
if (prefs_dialog)
return prefs_dialog;
config = G_OBJECT (gimp->config);
/* turn of autosaving while the prefs dialog is open */
gimp_rc_set_autosave (GIMP_RC (gimp->edit_config), FALSE);
config = G_OBJECT (gimp->edit_config);
config_copy = gimp_config_duplicate (config);
config_orig = gimp_config_duplicate (config);
/* read the saved gimprc to get GIMP_PARAM_RESTART values */
{
GimpRc *gimprc;
GObject *config_saved;
GList *diff;
GList *list;
gimprc = gimp_rc_new (GIMP_RC (config)->system_gimprc,
GIMP_RC (config)->user_gimprc,
GIMP_RC (config)->verbose);
config_saved = G_OBJECT (gimprc);
diff = gimp_config_diff (config_saved, config_copy, GIMP_PARAM_RESTART);
for (list = diff; list; list = g_list_next (list))
{
GParamSpec *param_spec;
GValue value = { 0, };
param_spec = (GParamSpec *) list->data;
g_value_init (&value, param_spec->value_type);
g_object_get_property (config_saved, param_spec->name, &value);
g_object_set_property (config_copy, param_spec->name, &value);
g_value_unset (&value);
}
g_list_free (diff);
g_object_unref (gimprc);
}
g_signal_connect_object (config, "notify",
G_CALLBACK (prefs_config_notify),
config_copy, 0);
@ -208,13 +178,7 @@ prefs_config_copy_notify (GObject *config_copy,
if (g_param_values_cmp (param_spec, &copy_value, &global_value))
{
if (param_spec->flags & GIMP_PARAM_RESTART)
{
g_print ("NOT Applying prefs change of '%s' to global config "
"because it needs restart\n",
param_spec->name);
}
else if (param_spec->flags & GIMP_PARAM_CONFIRM)
if (param_spec->flags & GIMP_PARAM_CONFIRM)
{
g_print ("NOT Applying prefs change of '%s' to global config "
"because it needs confirmation\n",
@ -257,10 +221,10 @@ prefs_cancel_callback (GtkWidget *widget,
gtk_widget_destroy (dialog); /* destroys config_copy */
diff = gimp_config_diff (G_OBJECT (gimp->config), config_orig,
diff = gimp_config_diff (G_OBJECT (gimp->edit_config), config_orig,
GIMP_PARAM_SERIALIZE);
g_object_freeze_notify (G_OBJECT (gimp->config));
g_object_freeze_notify (G_OBJECT (gimp->edit_config));
for (list = diff; list; list = g_list_next (list))
{
@ -274,18 +238,20 @@ prefs_cancel_callback (GtkWidget *widget,
g_object_get_property (config_orig,
param_spec->name,
&value);
g_object_set_property (G_OBJECT (gimp->config),
g_object_set_property (G_OBJECT (gimp->edit_config),
param_spec->name,
&value);
g_value_unset (&value);
}
g_object_thaw_notify (G_OBJECT (gimp->config));
g_object_thaw_notify (G_OBJECT (gimp->edit_config));
g_list_free (diff);
g_object_unref (config_orig);
/* enable autosaving again */
gimp_rc_set_autosave (GIMP_RC (gimp->edit_config), TRUE);
}
static void
@ -303,14 +269,12 @@ prefs_ok_callback (GtkWidget *widget,
g_object_ref (config_copy);
gtk_widget_destroy (dialog);
gtk_widget_destroy (dialog); /* destroys config_orig */
restart_diff = gimp_config_diff (G_OBJECT (gimp->config), config_copy,
GIMP_PARAM_RESTART);
confirm_diff = gimp_config_diff (G_OBJECT (gimp->config), config_copy,
confirm_diff = gimp_config_diff (G_OBJECT (gimp->edit_config), config_copy,
GIMP_PARAM_CONFIRM);
g_object_freeze_notify (G_OBJECT (gimp->config));
g_object_freeze_notify (G_OBJECT (gimp->edit_config));
for (list = confirm_diff; list; list = g_list_next (list))
{
@ -324,14 +288,29 @@ prefs_ok_callback (GtkWidget *widget,
g_object_get_property (config_copy,
param_spec->name,
&value);
g_object_set_property (G_OBJECT (gimp->config),
g_object_set_property (G_OBJECT (gimp->edit_config),
param_spec->name,
&value);
g_value_unset (&value);
}
g_object_thaw_notify (G_OBJECT (gimp->config));
g_object_thaw_notify (G_OBJECT (gimp->edit_config));
g_list_free (confirm_diff);
g_object_unref (config_copy);
gimp_rc_save (GIMP_RC (gimp->edit_config));
/* enable autosaving again */
gimp_rc_set_autosave (GIMP_RC (gimp->edit_config), TRUE);
/* spit out a solely informational warning about changed values
* which need restart
*/
restart_diff = gimp_config_diff (G_OBJECT (gimp->edit_config),
G_OBJECT (gimp->config),
GIMP_PARAM_RESTART);
if (restart_diff)
{
@ -355,12 +334,7 @@ prefs_ok_callback (GtkWidget *widget,
g_string_free (string, TRUE);
}
g_list_free (confirm_diff);
g_list_free (restart_diff);
gimp_rc_save (GIMP_RC (config_copy));
g_object_unref (config_copy);
}
static void

View File

@ -87,7 +87,7 @@ static void gui_display_changed (GimpContext *context,
GimpDisplay *display,
Gimp *gimp);
static void gui_image_disconnect (GimpImage *gimage,
gpointer data);
Gimp *gimp);
/* private variables */
@ -330,7 +330,6 @@ gui_exit (Gimp *gimp)
gimp);
gimp_container_remove_handler (gimp->images, image_disconnect_handler_id);
image_disconnect_handler_id = 0;
if (themes_hash)
@ -625,14 +624,11 @@ gui_display_changed (GimpContext *context,
static void
gui_image_disconnect (GimpImage *gimage,
gpointer data)
Gimp *gimp)
{
Gimp *gimp;
gimp = (Gimp *) data;
/* check if this is the last image */
if (gimp_container_num_children (gimp->images) == 1)
/* check if this is the last image and if it had a display */
if (gimp_container_num_children (gimp->images) == 1 &&
gimage->instance_count > 0)
{
dialogs_show_toolbox ();
}

View File

@ -95,43 +95,13 @@ preferences_dialog_create (Gimp *gimp)
if (prefs_dialog)
return prefs_dialog;
config = G_OBJECT (gimp->config);
/* turn of autosaving while the prefs dialog is open */
gimp_rc_set_autosave (GIMP_RC (gimp->edit_config), FALSE);
config = G_OBJECT (gimp->edit_config);
config_copy = gimp_config_duplicate (config);
config_orig = gimp_config_duplicate (config);
/* read the saved gimprc to get GIMP_PARAM_RESTART values */
{
GimpRc *gimprc;
GObject *config_saved;
GList *diff;
GList *list;
gimprc = gimp_rc_new (GIMP_RC (config)->system_gimprc,
GIMP_RC (config)->user_gimprc,
GIMP_RC (config)->verbose);
config_saved = G_OBJECT (gimprc);
diff = gimp_config_diff (config_saved, config_copy, GIMP_PARAM_RESTART);
for (list = diff; list; list = g_list_next (list))
{
GParamSpec *param_spec;
GValue value = { 0, };
param_spec = (GParamSpec *) list->data;
g_value_init (&value, param_spec->value_type);
g_object_get_property (config_saved, param_spec->name, &value);
g_object_set_property (config_copy, param_spec->name, &value);
g_value_unset (&value);
}
g_list_free (diff);
g_object_unref (gimprc);
}
g_signal_connect_object (config, "notify",
G_CALLBACK (prefs_config_notify),
config_copy, 0);
@ -208,13 +178,7 @@ prefs_config_copy_notify (GObject *config_copy,
if (g_param_values_cmp (param_spec, &copy_value, &global_value))
{
if (param_spec->flags & GIMP_PARAM_RESTART)
{
g_print ("NOT Applying prefs change of '%s' to global config "
"because it needs restart\n",
param_spec->name);
}
else if (param_spec->flags & GIMP_PARAM_CONFIRM)
if (param_spec->flags & GIMP_PARAM_CONFIRM)
{
g_print ("NOT Applying prefs change of '%s' to global config "
"because it needs confirmation\n",
@ -257,10 +221,10 @@ prefs_cancel_callback (GtkWidget *widget,
gtk_widget_destroy (dialog); /* destroys config_copy */
diff = gimp_config_diff (G_OBJECT (gimp->config), config_orig,
diff = gimp_config_diff (G_OBJECT (gimp->edit_config), config_orig,
GIMP_PARAM_SERIALIZE);
g_object_freeze_notify (G_OBJECT (gimp->config));
g_object_freeze_notify (G_OBJECT (gimp->edit_config));
for (list = diff; list; list = g_list_next (list))
{
@ -274,18 +238,20 @@ prefs_cancel_callback (GtkWidget *widget,
g_object_get_property (config_orig,
param_spec->name,
&value);
g_object_set_property (G_OBJECT (gimp->config),
g_object_set_property (G_OBJECT (gimp->edit_config),
param_spec->name,
&value);
g_value_unset (&value);
}
g_object_thaw_notify (G_OBJECT (gimp->config));
g_object_thaw_notify (G_OBJECT (gimp->edit_config));
g_list_free (diff);
g_object_unref (config_orig);
/* enable autosaving again */
gimp_rc_set_autosave (GIMP_RC (gimp->edit_config), TRUE);
}
static void
@ -303,14 +269,12 @@ prefs_ok_callback (GtkWidget *widget,
g_object_ref (config_copy);
gtk_widget_destroy (dialog);
gtk_widget_destroy (dialog); /* destroys config_orig */
restart_diff = gimp_config_diff (G_OBJECT (gimp->config), config_copy,
GIMP_PARAM_RESTART);
confirm_diff = gimp_config_diff (G_OBJECT (gimp->config), config_copy,
confirm_diff = gimp_config_diff (G_OBJECT (gimp->edit_config), config_copy,
GIMP_PARAM_CONFIRM);
g_object_freeze_notify (G_OBJECT (gimp->config));
g_object_freeze_notify (G_OBJECT (gimp->edit_config));
for (list = confirm_diff; list; list = g_list_next (list))
{
@ -324,14 +288,29 @@ prefs_ok_callback (GtkWidget *widget,
g_object_get_property (config_copy,
param_spec->name,
&value);
g_object_set_property (G_OBJECT (gimp->config),
g_object_set_property (G_OBJECT (gimp->edit_config),
param_spec->name,
&value);
g_value_unset (&value);
}
g_object_thaw_notify (G_OBJECT (gimp->config));
g_object_thaw_notify (G_OBJECT (gimp->edit_config));
g_list_free (confirm_diff);
g_object_unref (config_copy);
gimp_rc_save (GIMP_RC (gimp->edit_config));
/* enable autosaving again */
gimp_rc_set_autosave (GIMP_RC (gimp->edit_config), TRUE);
/* spit out a solely informational warning about changed values
* which need restart
*/
restart_diff = gimp_config_diff (G_OBJECT (gimp->edit_config),
G_OBJECT (gimp->config),
GIMP_PARAM_RESTART);
if (restart_diff)
{
@ -355,12 +334,7 @@ prefs_ok_callback (GtkWidget *widget,
g_string_free (string, TRUE);
}
g_list_free (confirm_diff);
g_list_free (restart_diff);
gimp_rc_save (GIMP_RC (config_copy));
g_object_unref (config_copy);
}
static void

View File

@ -63,7 +63,10 @@ gimprc_query_invoker (Gimp *gimp,
if (success)
{
success = (value = gimp_rc_query (GIMP_RC (gimp->config), token)) != NULL;
/* use edit_config so we get the values back we have set using
* gimprc_set() before
*/
success = (value = gimp_rc_query (GIMP_RC (gimp->edit_config), token)) != NULL;
}
return_args = procedural_db_return_args (&gimprc_query_proc, success);
@ -126,7 +129,10 @@ gimprc_set_invoker (Gimp *gimp,
if (success)
{
gimp_config_add_unknown_token (G_OBJECT (gimp->config), token, value);
/* set the value in edit_config so we don't accidentially set
* GIMP_PARAM_RESTART values via the PDB
*/
gimp_config_add_unknown_token (G_OBJECT (gimp->edit_config), token, value);
success = TRUE;
}

View File

@ -56,7 +56,10 @@ HELP
vars => [ 'gchar *value = NULL' ],
code => <<'CODE'
{
success = (value = gimp_rc_query (GIMP_RC (gimp->config), token)) != NULL;
/* use edit_config so we get the values back we have set using
* gimprc_set() before
*/
success = (value = gimp_rc_query (GIMP_RC (gimp->edit_config), token)) != NULL;
}
CODE
);
@ -88,7 +91,10 @@ HELP
headers => [ qw("config/gimpconfig.h") ],
code => <<'CODE'
{
gimp_config_add_unknown_token (G_OBJECT (gimp->config), token, value);
/* set the value in edit_config so we don't accidentially set
* GIMP_PARAM_RESTART values via the PDB
*/
gimp_config_add_unknown_token (G_OBJECT (gimp->edit_config), token, value);
success = TRUE;
}
CODE