minor cleanup.

2003-10-15  Sven Neumann  <sven@gimp.org>

	* app/config/gimpconfig-utils.c (gimp_config_diff_internal): minor
	cleanup.

	* app/core/gimptemplate.[ch]: added a comment property.

	* app/config/gimpcoreconfig.[ch]
	* app/config/gimprc-blurbs.h: removed "default_comment" property
	and set the default comment on the default image template.

	* app/widgets/gimptemplateeditor.c: added a comment editor widget.

	* app/core/gimp.c
	* app/gui/file-new-dialog.c
	* app/gui/preferences-dialog.c
	* app/pdb/gimprc_cmds.c
	* tools/pdbgen/pdb/gimprc.pdb: changed accordingly.

	* libgimpwidgets/gimpmemsizeentry.c (gimp_memsize_entry_init):
	increased spacing between the spinbutton and the menu.
This commit is contained in:
Sven Neumann 2003-10-15 15:30:11 +00:00 committed by Sven Neumann
parent e78c87b228
commit 1e0816fa93
17 changed files with 170 additions and 139 deletions

View File

@ -1,3 +1,25 @@
2003-10-15 Sven Neumann <sven@gimp.org>
* app/config/gimpconfig-utils.c (gimp_config_diff_internal): minor
cleanup.
* app/core/gimptemplate.[ch]: added a comment property.
* app/config/gimpcoreconfig.[ch]
* app/config/gimprc-blurbs.h: removed "default_comment" property
and set the default comment on the default image template.
* app/widgets/gimptemplateeditor.c: added a comment editor widget.
* app/core/gimp.c
* app/gui/file-new-dialog.c
* app/gui/preferences-dialog.c
* app/pdb/gimprc_cmds.c
* tools/pdbgen/pdb/gimprc.pdb: changed accordingly.
* libgimpwidgets/gimpmemsizeentry.c (gimp_memsize_entry_init):
increased spacing between the spinbutton and the menu.
2003-10-15 Michael Natterer <mitch@gimp.org>
* app/widgets/widgets-enums.[ch]: new enum GimpColorFrameMode.

View File

@ -135,12 +135,12 @@ gimp_config_diff_internal (GimpConfig *a,
if (! gimp_config_is_equal_to (g_value_get_object (&a_value),
g_value_get_object (&b_value)))
{
list = g_list_prepend (list, param_specs[i]);
list = g_list_prepend (list, prop_spec);
}
}
else
{
list = g_list_prepend (list, param_specs[i]);
list = g_list_prepend (list, prop_spec);
}
}

View File

@ -86,7 +86,6 @@ enum
PROP_DEFAULT_GRADIENT,
PROP_DEFAULT_FONT,
PROP_DEFAULT_IMAGE,
PROP_DEFAULT_COMMENT,
PROP_DEFAULT_GRID,
PROP_UNDO_LEVELS,
PROP_UNDO_SIZE,
@ -213,10 +212,6 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
"default-image", DEFAULT_IMAGE_BLURB,
GIMP_TYPE_TEMPLATE,
GIMP_PARAM_AGGREGATE);
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_DEFAULT_COMMENT,
"default-comment", DEFAULT_COMMENT_BLURB,
DEFAULT_COMMENT,
0);
GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_DEFAULT_GRID,
"default-grid", DEFAULT_GRID_BLURB,
GIMP_TYPE_GRID,
@ -267,7 +262,9 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
static void
gimp_core_config_init (GimpCoreConfig *config)
{
config->default_image = g_object_new (GIMP_TYPE_TEMPLATE, NULL);
config->default_image = g_object_new (GIMP_TYPE_TEMPLATE,
"comment", DEFAULT_COMMENT,
NULL);
g_signal_connect (config->default_image, "notify",
G_CALLBACK (gimp_core_config_default_image_changed),
config);
@ -298,7 +295,6 @@ gimp_core_config_finalize (GObject *object)
g_free (core_config->default_palette);
g_free (core_config->default_gradient);
g_free (core_config->default_font);
g_free (core_config->default_comment);
g_free (core_config->plug_in_rc_path);
if (core_config->default_image)
@ -382,10 +378,6 @@ gimp_core_config_set_property (GObject *object,
gimp_config_sync (GIMP_CONFIG (g_value_get_object (value)),
GIMP_CONFIG (core_config->default_image), 0);
break;
case PROP_DEFAULT_COMMENT:
g_free (core_config->default_comment);
core_config->default_comment = g_value_dup_string (value);
break;
case PROP_DEFAULT_GRID:
if (g_value_get_object (value))
gimp_config_sync (GIMP_CONFIG (g_value_get_object (value)),
@ -483,9 +475,6 @@ gimp_core_config_get_property (GObject *object,
case PROP_DEFAULT_IMAGE:
g_value_set_object (value, core_config->default_image);
break;
case PROP_DEFAULT_COMMENT:
g_value_set_string (value, core_config->default_comment);
break;
case PROP_DEFAULT_GRID:
g_value_set_object (value, core_config->default_grid);
break;

View File

@ -55,7 +55,6 @@ struct _GimpCoreConfig
gchar *default_gradient;
gchar *default_font;
GimpTemplate *default_image;
gchar *default_comment;
GimpGrid *default_grid;
gint levels_of_undo;
gulong undo_size;

View File

@ -46,9 +46,6 @@ N_("Context-dependent cursors are cool. They are enabled by default. " \
"Specify a default brush. The brush is searched for in the " \
"specified brush path."
#define DEFAULT_COMMENT_BLURB \
"Sets the default comment."
#define DEFAULT_DOT_FOR_DOT_BLURB \
N_("When enabled, this will ensure that each pixel of an image gets " \
"mapped to a pixel on the screen.")

View File

@ -1148,16 +1148,19 @@ gimp_create_image (Gimp *gimp,
gimp_container_add (gimp->images, GIMP_OBJECT (gimage));
if (attach_comment && gimp->config->default_comment)
if (attach_comment)
{
GimpParasite *parasite;
const gchar *comment = gimp->config->default_image->comment;
parasite = gimp_parasite_new ("gimp-comment",
GIMP_PARASITE_PERSISTENT,
strlen (gimp->config->default_comment) + 1,
gimp->config->default_comment);
gimp_image_parasite_attach (gimage, parasite);
gimp_parasite_free (parasite);
if (comment)
{
GimpParasite *parasite = gimp_parasite_new ("gimp-comment",
GIMP_PARASITE_PERSISTENT,
strlen (comment) + 1,
comment);
gimp_image_parasite_attach (gimage, parasite);
gimp_parasite_free (parasite);
}
}
return gimage;

View File

@ -54,6 +54,7 @@ enum
PROP_RESOLUTION_UNIT,
PROP_IMAGE_TYPE,
PROP_FILL_TYPE,
PROP_COMMENT,
PROP_FILENAME
};
@ -184,6 +185,12 @@ gimp_template_class_init (GimpTemplateClass *klass)
GIMP_TYPE_FILL_TYPE, GIMP_BACKGROUND_FILL,
0);
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_COMMENT,
"comment",
NULL,
NULL,
0);
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_FILENAME,
"filename",
NULL,
@ -203,6 +210,12 @@ gimp_template_finalize (GObject *object)
{
GimpTemplate *template = GIMP_TEMPLATE (object);
if (template->comment)
{
g_free (template->comment);
template->comment = NULL;
}
if (template->filename)
{
g_free (template->filename);
@ -246,6 +259,11 @@ gimp_template_set_property (GObject *object,
case PROP_FILL_TYPE:
template->fill_type = g_value_get_enum (value);
break;
case PROP_COMMENT:
if (template->comment)
g_free (template->comment);
template->comment = g_value_dup_string (value);
break;
case PROP_FILENAME:
if (template->filename)
g_free (template->filename);
@ -291,6 +309,9 @@ gimp_template_get_property (GObject *object,
case PROP_FILL_TYPE:
g_value_set_enum (value, template->fill_type);
break;
case PROP_COMMENT:
g_value_set_string (value, template->comment);
break;
case PROP_FILENAME:
g_value_set_string (value, template->filename);
break;
@ -372,9 +393,11 @@ void
gimp_template_set_from_image (GimpTemplate *template,
GimpImage *gimage)
{
gdouble xresolution;
gdouble yresolution;
GimpImageBaseType image_type;
gdouble xresolution;
gdouble yresolution;
GimpImageBaseType image_type;
GimpParasite *parasite;
gchar *comment = NULL;
g_return_if_fail (GIMP_IS_TEMPLATE (template));
g_return_if_fail (GIMP_IS_IMAGE (gimage));
@ -386,6 +409,11 @@ gimp_template_set_from_image (GimpTemplate *template,
if (image_type == GIMP_INDEXED)
image_type = GIMP_RGB;
parasite = gimp_image_parasite_find (gimage, "gimp-comment");
if (parasite)
comment = g_strndup (gimp_parasite_data (parasite),
gimp_parasite_data_size (parasite));
g_object_set (template,
"width", gimp_image_get_width (gimage),
"height", gimp_image_get_height (gimage),
@ -394,7 +422,11 @@ gimp_template_set_from_image (GimpTemplate *template,
"yresolution", yresolution,
"resolution-unit", gimage->gimp->config->default_image->resolution_unit,
"image-type", image_type,
"comment", comment,
NULL);
if (comment)
g_free (comment);
}
GimpImage *
@ -412,10 +444,22 @@ gimp_template_create_image (Gimp *gimp,
gimage = gimp_create_image (gimp,
template->width, template->height,
template->image_type,
TRUE);
FALSE);
gimp_image_undo_disable (gimage);
if (template->comment)
{
GimpParasite *parasite;
parasite = gimp_parasite_new ("gimp-comment",
GIMP_PARASITE_PERSISTENT,
strlen (template->comment) + 1,
template->comment);
gimp_image_parasite_attach (gimage, parasite);
gimp_parasite_free (parasite);
}
gimp_image_set_resolution (gimage,
template->xresolution, template->yresolution);
gimp_image_set_unit (gimage, template->unit);

View File

@ -51,6 +51,7 @@ struct _GimpTemplate
GimpImageBaseType image_type;
GimpFillType fill_type;
gchar *comment;
gchar *filename;
gulong initial_size;

View File

@ -18,6 +18,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
@ -242,9 +244,24 @@ file_new_template_select (GimpContainerMenu *menu,
gpointer insert_data,
FileNewDialog *dialog)
{
if (template)
gimp_config_sync (GIMP_CONFIG (template),
GIMP_CONFIG (dialog->template), 0);
gchar *comment = NULL;
if (!template)
return;
if (!template->comment || !strlen (template->comment))
comment = g_strdup (dialog->template->comment);
gimp_config_sync (GIMP_CONFIG (template), GIMP_CONFIG (dialog->template), 0);
if (comment)
{
g_object_set (dialog->template,
"comment", comment,
NULL);
g_free (comment);
}
}

View File

@ -57,9 +57,6 @@
#include "gimp-intl.h"
#define MAX_COMMENT_LENGTH 512 /* arbitrary */
/* preferences local functions */
static GtkWidget * prefs_dialog_new (Gimp *gimp,
@ -864,9 +861,6 @@ prefs_dialog_new (Gimp *gimp,
GtkWidget *sizeentry;
GtkWidget *separator;
GtkWidget *calibrate_button;
GtkWidget *scrolled_window;
GtkWidget *text_view;
GtkTextBuffer *text_buffer;
PangoAttrList *attrs;
PangoAttribute *attr;
GSList *group;
@ -1047,44 +1041,6 @@ prefs_dialog_new (Gimp *gimp,
_("Maximum Image Size:"),
GTK_TABLE (table), 1);
/*********************************/
/* New Image / Default Comment */
/*********************************/
vbox = prefs_notebook_append_page (gimp,
GTK_NOTEBOOK (notebook),
_("Default Image Comment"),
"default-comment.png",
GTK_TREE_STORE (tree),
_("Default Comment"),
GIMP_HELP_PREFS_NEW_IMAGE_COMMENT,
&top_iter,
&child_iter,
page_index++);
/* Comment */
vbox2 = prefs_frame_new (_("Comment Used for New Images"),
GTK_CONTAINER (vbox), TRUE);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_SHADOW_ETCHED_IN);
gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 4);
gtk_container_add (GTK_CONTAINER (vbox2), scrolled_window);
gtk_widget_show (scrolled_window);
text_buffer = gimp_prop_text_buffer_new (object, "default-comment",
MAX_COMMENT_LENGTH);
text_view = gtk_text_view_new_with_buffer (text_buffer);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
gtk_widget_show (text_view);
g_object_unref (text_buffer);
/*********************************/
/* New Image / Default Grid */

View File

@ -18,6 +18,8 @@
#include "config.h"
#include <string.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
@ -242,9 +244,24 @@ file_new_template_select (GimpContainerMenu *menu,
gpointer insert_data,
FileNewDialog *dialog)
{
if (template)
gimp_config_sync (GIMP_CONFIG (template),
GIMP_CONFIG (dialog->template), 0);
gchar *comment = NULL;
if (!template)
return;
if (!template->comment || !strlen (template->comment))
comment = g_strdup (dialog->template->comment);
gimp_config_sync (GIMP_CONFIG (template), GIMP_CONFIG (dialog->template), 0);
if (comment)
{
g_object_set (dialog->template,
"comment", comment,
NULL);
g_free (comment);
}
}

View File

@ -57,9 +57,6 @@
#include "gimp-intl.h"
#define MAX_COMMENT_LENGTH 512 /* arbitrary */
/* preferences local functions */
static GtkWidget * prefs_dialog_new (Gimp *gimp,
@ -864,9 +861,6 @@ prefs_dialog_new (Gimp *gimp,
GtkWidget *sizeentry;
GtkWidget *separator;
GtkWidget *calibrate_button;
GtkWidget *scrolled_window;
GtkWidget *text_view;
GtkTextBuffer *text_buffer;
PangoAttrList *attrs;
PangoAttribute *attr;
GSList *group;
@ -1047,44 +1041,6 @@ prefs_dialog_new (Gimp *gimp,
_("Maximum Image Size:"),
GTK_TABLE (table), 1);
/*********************************/
/* New Image / Default Comment */
/*********************************/
vbox = prefs_notebook_append_page (gimp,
GTK_NOTEBOOK (notebook),
_("Default Image Comment"),
"default-comment.png",
GTK_TREE_STORE (tree),
_("Default Comment"),
GIMP_HELP_PREFS_NEW_IMAGE_COMMENT,
&top_iter,
&child_iter,
page_index++);
/* Comment */
vbox2 = prefs_frame_new (_("Comment Used for New Images"),
GTK_CONTAINER (vbox), TRUE);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_SHADOW_ETCHED_IN);
gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 4);
gtk_container_add (GTK_CONTAINER (vbox2), scrolled_window);
gtk_widget_show (scrolled_window);
text_buffer = gimp_prop_text_buffer_new (object, "default-comment",
MAX_COMMENT_LENGTH);
text_view = gtk_text_view_new_with_buffer (text_buffer);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
gtk_widget_show (text_view);
g_object_unref (text_buffer);
/*********************************/
/* New Image / Default Grid */

View File

@ -33,6 +33,7 @@
#include "config/gimpdisplayconfig.h"
#include "config/gimprc.h"
#include "core/gimp.h"
#include "core/gimptemplate.h"
static ProcRecord gimprc_query_proc;
static ProcRecord gimprc_set_proc;
@ -178,7 +179,7 @@ get_default_comment_invoker (Gimp *gimp,
Argument *return_args;
gchar *comment;
comment = g_strdup (gimp->config->default_comment);
comment = g_strdup (gimp->config->default_image->comment);
success = TRUE;
return_args = procedural_db_return_args (&get_default_comment_proc, success);

View File

@ -44,7 +44,8 @@
#include "gimp-intl.h"
#define SB_WIDTH 10
#define SB_WIDTH 10
#define MAX_COMMENT_LENGTH 512 /* arbitrary */
enum
{
@ -199,6 +200,9 @@ gimp_template_editor_constructor (GType type,
GtkWidget *xres;
GtkWidget *yres;
GtkWidget *chainbutton;
GtkWidget *scrolled_window;
GtkWidget *text_view;
GtkTextBuffer *text_buffer;
GList *focus_chain = NULL;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
@ -417,6 +421,11 @@ gimp_template_editor_constructor (GType type,
0, 1, 0, 1);
gtk_widget_show (xres);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (editor->size_se), 0,
editor->template->xresolution, FALSE);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (editor->size_se), 1,
editor->template->yresolution, FALSE);
/* the resolution chainbutton */
chainbutton = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
gtk_table_attach_defaults (GTK_TABLE (editor->resolution_se), chainbutton,
@ -461,10 +470,30 @@ gimp_template_editor_constructor (GType type,
gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (editor->size_se), 0,
editor->template->xresolution, FALSE);
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (editor->size_se), 1,
editor->template->yresolution, FALSE);
/* frame for Comment */
frame = gtk_frame_new (_("Image Comment"));
gtk_box_pack_start (GTK_BOX (editor), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_AUTOMATIC,
GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_SHADOW_ETCHED_IN);
gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 4);
gtk_container_add (GTK_CONTAINER (frame), scrolled_window);
gtk_widget_show (scrolled_window);
text_buffer = gimp_prop_text_buffer_new (G_OBJECT (editor->template),
"comment", MAX_COMMENT_LENGTH);
text_view = gtk_text_view_new_with_buffer (text_buffer);
g_object_unref (text_buffer);
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD);
gtk_container_add (GTK_CONTAINER (scrolled_window), text_view);
gtk_widget_show (text_view);
g_signal_connect (editor->template, "notify",
G_CALLBACK (gimp_template_editor_template_notify),

View File

@ -135,12 +135,12 @@ gimp_config_diff_internal (GimpConfig *a,
if (! gimp_config_is_equal_to (g_value_get_object (&a_value),
g_value_get_object (&b_value)))
{
list = g_list_prepend (list, param_specs[i]);
list = g_list_prepend (list, prop_spec);
}
}
else
{
list = g_list_prepend (list, param_specs[i]);
list = g_list_prepend (list, prop_spec);
}
}

View File

@ -90,7 +90,7 @@ gimp_memsize_entry_class_init (GimpMemsizeEntryClass *klass)
object_class->finalize = gimp_memsize_entry_finalize;
gimp_memsize_entry_signals[VALUE_CHANGED] =
gimp_memsize_entry_signals[VALUE_CHANGED] =
g_signal_new ("value_changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_FIRST,
@ -105,7 +105,7 @@ gimp_memsize_entry_class_init (GimpMemsizeEntryClass *klass)
static void
gimp_memsize_entry_init (GimpMemsizeEntry *entry)
{
gtk_box_set_spacing (GTK_BOX (entry), 2);
gtk_box_set_spacing (GTK_BOX (entry), 4);
entry->value = 0;
entry->lower = 0;
@ -240,7 +240,7 @@ gulong
gimp_memsize_entry_get_value (GimpMemsizeEntry *entry)
{
g_return_val_if_fail (GIMP_IS_MEMSIZE_ENTRY (entry), 0);
return entry->value;
}

View File

@ -148,10 +148,10 @@ sub get_default_comment {
);
%invoke = (
headers => [ qw("config/gimpcoreconfig.h") ],
headers => [ qw("config/gimpcoreconfig.h" "core/gimptemplate.h") ],
code => <<'CODE'
{
comment = g_strdup (gimp->config->default_comment);
comment = g_strdup (gimp->config->default_image->comment);
success = TRUE;
}
CODE