Commit e6063f61 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

Let the user decide whether tool options are persistant or not as

2005-04-11  Michael Natterer  <mitch@gimp.org>

	Let the user decide whether tool options are persistant or not as
	suggested in bug #165078:

	* app/config/gimprc-blurbs.h
	* app/config/gimpguiconfig.[ch]: added "gboolean save_tool_options".

	* app/tools/gimp-tools.[ch]: implement the same logic as for
	devicerc and essionrc: added gimp_tools_clear() which deletes the
	stored tool options and added "save_tool_options" and
	"always_save" parameters to gimp_tools_save(). Everything affects
	just the primary tool options, *not* the separately saved presets
	for each tool.

	* app/gui/gui.c (gui_exit_callback): changed accordingly.

	* app/dialogs/preferences-dialog.c: added GUI for the stuff above
	in the style of the devicerc and seccionrc prefs GUIs.
parent fc18afbf
2005-04-11 Michael Natterer <mitch@gimp.org>
Let the user decide whether tool options are persistant or not as
suggested in bug #165078:
* app/config/gimprc-blurbs.h
* app/config/gimpguiconfig.[ch]: added "gboolean save_tool_options".
* app/tools/gimp-tools.[ch]: implement the same logic as for
devicerc and essionrc: added gimp_tools_clear() which deletes the
stored tool options and added "save_tool_options" and
"always_save" parameters to gimp_tools_save(). Everything affects
just the primary tool options, *not* the separately saved presets
for each tool.
* app/gui/gui.c (gui_exit_callback): changed accordingly.
* app/dialogs/preferences-dialog.c: added GUI for the stuff above
in the style of the devicerc and seccionrc prefs GUIs.
2005-04-11 Raphaël Quinet <raphael@gimp.org>
* plug-ins/metadata/base64.h
......
......@@ -66,6 +66,7 @@ enum
PROP_SAVE_DEVICE_STATUS,
PROP_SAVE_SESSION_INFO,
PROP_RESTORE_SESSION,
PROP_SAVE_TOOL_OPTIONS,
PROP_SHOW_TIPS,
PROP_SHOW_TOOL_TIPS,
PROP_TEAROFF_MENUS,
......@@ -168,6 +169,11 @@ gimp_gui_config_class_init (GimpGuiConfigClass *klass)
"restore-session", RESTORE_SESSION_BLURB,
TRUE,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SAVE_TOOL_OPTIONS,
"save-tool-options",
SAVE_TOOL_OPTIONS_BLURB,
TRUE,
0);
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_SHOW_TIPS,
"show-tips", SHOW_TIPS_BLURB,
TRUE,
......@@ -315,6 +321,9 @@ gimp_gui_config_set_property (GObject *object,
case PROP_RESTORE_SESSION:
gui_config->restore_session = g_value_get_boolean (value);
break;
case PROP_SAVE_TOOL_OPTIONS:
gui_config->save_tool_options = g_value_get_boolean (value);
break;
case PROP_SHOW_TIPS:
gui_config->show_tips = g_value_get_boolean (value);
break;
......@@ -423,6 +432,9 @@ gimp_gui_config_get_property (GObject *object,
case PROP_RESTORE_SESSION:
g_value_set_boolean (value, gui_config->restore_session);
break;
case PROP_SAVE_TOOL_OPTIONS:
g_value_set_boolean (value, gui_config->save_tool_options);
break;
case PROP_SHOW_TIPS:
g_value_set_boolean (value, gui_config->show_tips);
break;
......
......@@ -47,6 +47,7 @@ struct _GimpGuiConfig
gboolean save_device_status;
gboolean save_session_info;
gboolean restore_session;
gboolean save_tool_options;
gboolean show_tips;
gboolean show_tool_tips;
gboolean tearoff_menus;
......
......@@ -274,6 +274,9 @@ N_("Remember the current tool, pattern, color, and brush across GIMP " \
#define SAVE_SESSION_INFO_BLURB \
N_("Save the positions and sizes of the main dialogs when the GIMP exits.")
#define SAVE_TOOL_OPTIONS_BLURB \
N_("Save the tool options when the GIMP exits.")
#define SCRIPT_FU_PATH_BLURB \
"This path will be searched for scripts when the Script-Fu plug-in is run."
......
......@@ -53,6 +53,8 @@
#include "menus/menus.h"
#include "tools/gimp-tools.h"
#include "gui/session.h"
#include "gui/themes.h"
......@@ -98,6 +100,10 @@ static void prefs_devices_save_callback (GtkWidget *widget,
Gimp *gimp);
static void prefs_devices_clear_callback (GtkWidget *widget,
Gimp *gimp);
static void prefs_tool_options_save_callback (GtkWidget *widget,
Gimp *gimp);
static void prefs_tool_options_clear_callback (GtkWidget *widget,
Gimp *gimp);
/* private variables */
......@@ -658,6 +664,40 @@ prefs_devices_clear_callback (GtkWidget *widget,
}
}
static void
prefs_tool_options_save_callback (GtkWidget *widget,
Gimp *gimp)
{
GtkWidget *clear_button;
gimp_tools_save (gimp, TRUE, TRUE);
clear_button = g_object_get_data (G_OBJECT (widget), "clear-button");
if (clear_button)
gtk_widget_set_sensitive (clear_button, TRUE);
}
static void
prefs_tool_options_clear_callback (GtkWidget *widget,
Gimp *gimp)
{
GError *error = NULL;
if (! gimp_tools_clear (gimp, &error))
{
g_message (error->message);
g_clear_error (&error);
}
else
{
gtk_widget_set_sensitive (widget, FALSE);
g_message (_("Your tool options will be reset to "
"default values the next time you start GIMP."));
}
}
static GtkWidget *
prefs_notebook_append_page (Gimp *gimp,
GtkNotebook *notebook,
......@@ -1597,6 +1637,31 @@ prefs_dialog_new (Gimp *gimp,
size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
/* General */
vbox2 = prefs_frame_new (_("General"), GTK_CONTAINER (vbox), FALSE);
prefs_check_button_add (object, "save-tool-options",
_("_Save tool options on exit"),
GTK_BOX (vbox2));
button = prefs_button_add (GTK_STOCK_SAVE,
_("Save Tool Options _Now"),
GTK_BOX (vbox2));
g_signal_connect (button, "clicked",
G_CALLBACK (prefs_tool_options_save_callback),
gimp);
button2 = prefs_button_add (GIMP_STOCK_RESET,
_("_Reset Saved Tool Options to "
"Default Values"),
GTK_BOX (vbox2));
g_signal_connect (button2, "clicked",
G_CALLBACK (prefs_tool_options_clear_callback),
gimp);
g_object_set_data (G_OBJECT (button), "clear-button", button2);
/* Snapping Distance */
vbox2 = prefs_frame_new (_("Guide and Grid Snapping"),
GTK_CONTAINER (vbox), FALSE);
......
......@@ -478,7 +478,7 @@ gui_exit_callback (Gimp *gimp,
gimp_displays_delete (gimp);
gimp_tools_save (gimp);
gimp_tools_save (gimp, gui_config->save_tool_options, FALSE);
gimp_tools_exit (gimp);
return FALSE; /* continue exiting */
......
......@@ -18,6 +18,13 @@
#include "config.h"
#include <errno.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <glib/gstdio.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
......@@ -93,6 +100,11 @@ static void gimp_tools_register (GType tool_type,
gpointer data);
/* private variables */
static gboolean tool_options_deleted = FALSE;
/* public functions */
void
......@@ -291,7 +303,6 @@ gimp_tools_restore (Gimp *gimp)
if (tool_info->options_presets)
{
gchar *filename;
GList *list;
filename = gimp_tool_options_build_filename (tool_info->tool_options,
......@@ -314,7 +325,9 @@ gimp_tools_restore (Gimp *gimp)
}
void
gimp_tools_save (Gimp *gimp)
gimp_tools_save (Gimp *gimp,
gboolean save_tool_options,
gboolean always_save)
{
GList *list;
gchar *filename;
......@@ -327,11 +340,11 @@ gimp_tools_save (Gimp *gimp)
{
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
gimp_tool_options_serialize (tool_info->tool_options, NULL, NULL);
if (save_tool_options && (! tool_options_deleted || always_save))
gimp_tool_options_serialize (tool_info->tool_options, NULL, NULL);
if (tool_info->options_presets)
{
gchar *filename;
gchar *header;
gchar *footer;
......@@ -362,6 +375,42 @@ gimp_tools_save (Gimp *gimp)
g_free (filename);
}
gboolean
gimp_tools_clear (Gimp *gimp,
GError **error)
{
GList *list;
gboolean success = TRUE;
g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
for (list = GIMP_LIST (gimp->tool_info_list)->list;
list;
list = g_list_next (list))
{
GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data);
gchar *filename;
filename = gimp_tool_options_build_filename (tool_info->tool_options,
NULL);
if (g_unlink (filename) != 0 && errno != ENOENT)
{
g_set_error (error, 0, 0, _("Deleting \"%s\" failed: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
success = FALSE;
break;
}
g_free (filename);
}
if (success)
tool_options_deleted = TRUE;
return success;
}
GList *
gimp_tools_get_default_order (Gimp *gimp)
{
......
......@@ -20,13 +20,18 @@
#define __GIMP_TOOLS_H__
void gimp_tools_init (Gimp *gimp);
void gimp_tools_exit (Gimp *gimp);
void gimp_tools_init (Gimp *gimp);
void gimp_tools_exit (Gimp *gimp);
void gimp_tools_restore (Gimp *gimp);
void gimp_tools_save (Gimp *gimp);
void gimp_tools_restore (Gimp *gimp);
void gimp_tools_save (Gimp *gimp,
gboolean save_tool_options,
gboolean always_save);
GList *gimp_tools_get_default_order (Gimp *gimp);
gboolean gimp_tools_clear (Gimp *gimp,
GError **error);
GList * gimp_tools_get_default_order (Gimp *gimp);
#endif /* __GIMP_TOOLS_H__ */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment