mirror of https://github.com/GNOME/gimp.git
app/actions/tool-options-commands.c app/core/gimptoolpresets.[ch] code
2006-12-11 Sven Neumann <sven@gimp.org> * app/actions/tool-options-commands.c * app/core/gimptoolpresets.[ch] * app/tools/gimp-tools.c: code cleanup.
This commit is contained in:
parent
dea94bb4a7
commit
6dc91417e1
|
@ -1,3 +1,9 @@
|
|||
2006-12-11 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/actions/tool-options-commands.c
|
||||
* app/core/gimptoolpresets.[ch]
|
||||
* app/tools/gimp-tools.c: code cleanup.
|
||||
|
||||
2006-12-10 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/actions/tool-options-commands.c
|
||||
|
|
|
@ -90,8 +90,7 @@ tool_options_save_to_cmd_callback (GtkAction *action,
|
|||
GimpToolInfo *tool_info = gimp_context_get_tool (context);
|
||||
GimpToolOptions *options;
|
||||
|
||||
options = (GimpToolOptions *)
|
||||
gimp_container_get_child_by_index (tool_info->presets, value);
|
||||
options = gimp_tool_presets_get_options (tool_info->presets, value);
|
||||
|
||||
if (options)
|
||||
{
|
||||
|
@ -158,11 +157,11 @@ tool_options_delete_saved_cmd_callback (GtkAction *action,
|
|||
GimpToolInfo *tool_info = gimp_context_get_tool (context);
|
||||
GimpToolOptions *options;
|
||||
|
||||
options = (GimpToolOptions *)
|
||||
gimp_container_get_child_by_index (tool_info->presets, value);
|
||||
options = gimp_tool_presets_get_options (tool_info->presets, value);
|
||||
|
||||
if (options)
|
||||
gimp_container_remove (tool_info->presets, GIMP_OBJECT (options));
|
||||
gimp_container_remove (GIMP_CONTAINER (tool_info->presets),
|
||||
GIMP_OBJECT (options));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -245,7 +244,8 @@ tool_options_save_callback (GtkWidget *widget,
|
|||
else
|
||||
gimp_object_set_static_name (GIMP_OBJECT (copy), _("Saved Options"));
|
||||
|
||||
gimp_container_insert (tool_info->presets, GIMP_OBJECT (copy), -1);
|
||||
gimp_container_insert (GIMP_CONTAINER (tool_info->presets),
|
||||
GIMP_OBJECT (copy), -1);
|
||||
g_object_unref (copy);
|
||||
}
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimptoolinfo.h"
|
||||
#include "gimptooloptions.h"
|
||||
#include "gimptoolpresets.h"
|
||||
|
@ -172,9 +173,9 @@ gimp_tool_presets_get_options (GimpToolPresets *presets,
|
|||
|
||||
gboolean
|
||||
gimp_tool_presets_save (GimpToolPresets *presets,
|
||||
gboolean be_verbose,
|
||||
GError **error)
|
||||
{
|
||||
Gimp *gimp;
|
||||
const gchar *name;
|
||||
gchar *filename;
|
||||
gboolean retval = TRUE;
|
||||
|
@ -182,6 +183,8 @@ gimp_tool_presets_save (GimpToolPresets *presets,
|
|||
g_return_val_if_fail (GIMP_IS_TOOL_PRESETS (presets), FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
gimp = presets->tool_info->gimp;
|
||||
|
||||
name = gimp_object_get_name (GIMP_OBJECT (presets->tool_info));
|
||||
|
||||
filename = gimp_tool_options_build_filename (name, "presets");
|
||||
|
@ -190,7 +193,7 @@ gimp_tool_presets_save (GimpToolPresets *presets,
|
|||
{
|
||||
gchar *footer;
|
||||
|
||||
if (be_verbose)
|
||||
if (gimp->be_verbose)
|
||||
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
|
||||
|
||||
footer = g_strdup_printf ("end of %s", GIMP_OBJECT (presets)->name);
|
||||
|
@ -204,7 +207,7 @@ gimp_tool_presets_save (GimpToolPresets *presets,
|
|||
}
|
||||
else if (g_file_test (filename, G_FILE_TEST_EXISTS))
|
||||
{
|
||||
if (be_verbose)
|
||||
if (gimp->be_verbose)
|
||||
g_print ("Deleting '%s'\n", gimp_filename_to_utf8 (filename));
|
||||
|
||||
if (g_unlink (filename) != 0)
|
||||
|
@ -224,9 +227,9 @@ gimp_tool_presets_save (GimpToolPresets *presets,
|
|||
|
||||
gboolean
|
||||
gimp_tool_presets_load (GimpToolPresets *presets,
|
||||
gboolean be_verbose,
|
||||
GError **error)
|
||||
{
|
||||
Gimp *gimp;
|
||||
GList *list;
|
||||
const gchar *name;
|
||||
gchar *filename;
|
||||
|
@ -235,26 +238,26 @@ gimp_tool_presets_load (GimpToolPresets *presets,
|
|||
g_return_val_if_fail (GIMP_IS_TOOL_PRESETS (presets), FALSE);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
|
||||
|
||||
gimp = presets->tool_info->gimp;
|
||||
|
||||
gimp_container_clear (GIMP_CONTAINER (presets));
|
||||
|
||||
name = gimp_object_get_name (GIMP_OBJECT (presets->tool_info));
|
||||
|
||||
filename = gimp_tool_options_build_filename (name, "presets");
|
||||
|
||||
if (be_verbose)
|
||||
if (gimp->be_verbose)
|
||||
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
|
||||
|
||||
retval = gimp_config_deserialize_file (GIMP_CONFIG (presets), filename,
|
||||
presets->tool_info->gimp,
|
||||
retval = gimp_config_deserialize_file (GIMP_CONFIG (presets), filename, gimp,
|
||||
error);
|
||||
|
||||
g_free (filename);
|
||||
|
||||
if (retval)
|
||||
{
|
||||
gimp_list_reverse (GIMP_LIST (presets));
|
||||
gimp_list_reverse (GIMP_LIST (presets));
|
||||
|
||||
for (list = GIMP_LIST (presets)->list; list; list = g_list_next (list))
|
||||
g_object_set (list->data, "tool-info", presets->tool_info, NULL);
|
||||
}
|
||||
for (list = GIMP_LIST (presets)->list; list; list = g_list_next (list))
|
||||
g_object_set (list->data, "tool-info", presets->tool_info, NULL);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
|
@ -57,10 +57,9 @@ GimpToolOptions * gimp_tool_presets_get_options (GimpToolPresets *presets,
|
|||
gint index);
|
||||
|
||||
gboolean gimp_tool_presets_save (GimpToolPresets *presets,
|
||||
gboolean be_verbose,
|
||||
GError **error);
|
||||
gboolean gimp_tool_presets_load (GimpToolPresets *presets,
|
||||
gboolean be_verbose,
|
||||
GError **error);
|
||||
|
||||
|
||||
#endif /* __GIMP_TOOL_PRESETS_H__ */
|
||||
|
|
|
@ -330,7 +330,7 @@ gimp_tools_restore (Gimp *gimp)
|
|||
"gimp-tool-options-gui", options_gui);
|
||||
|
||||
if (tool_info->presets)
|
||||
gimp_tool_presets_load (tool_info->presets, gimp->be_verbose, NULL);
|
||||
gimp_tool_presets_load (tool_info->presets, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ gimp_tools_save (Gimp *gimp,
|
|||
gimp_tool_options_serialize (tool_info->tool_options, NULL, NULL);
|
||||
|
||||
if (tool_info->presets)
|
||||
gimp_tool_presets_save (tool_info->presets, gimp->be_verbose, NULL);
|
||||
gimp_tool_presets_save (tool_info->presets, NULL);
|
||||
}
|
||||
|
||||
filename = gimp_personal_rc_file ("toolrc");
|
||||
|
|
Loading…
Reference in New Issue