mirror of https://github.com/GNOME/gimp.git
made gimp_config_sync() and gimp_config_connect() also work on objects of
2004-03-11 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.c: made gimp_config_sync() and gimp_config_connect() also work on objects of different types. Properties with the same name and the same type are synced / connected. * app/core/gimpcontext.[ch]: added convenience functions to get/set the font by name. * app/tools/gimptextoptions.[ch]: don't hold a GimpText object that duplicates properties like font and color which are in GimpContext already. Instead added all text properties that are controlled from the text tool options. Handling of the foreground color is somewhat broken and needs a GimpContext wizard (Mitch!). * app/text/gimptext.c: blurbs are not any longer needed now that the property widgets are created from the GimpTextOptions. * app/tools/gimptexttool.c: changed accordingly. * app/widgets/gimptexteditor.[ch]: use an internal GtkTextBuffer and emit "text-changed" when it changes.
This commit is contained in:
parent
af78bf373f
commit
21f26743c1
24
ChangeLog
24
ChangeLog
|
@ -1,3 +1,27 @@
|
|||
2004-03-11 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/config/gimpconfig-utils.c: made gimp_config_sync() and
|
||||
gimp_config_connect() also work on objects of different types.
|
||||
Properties with the same name and the same type are synced /
|
||||
connected.
|
||||
|
||||
* app/core/gimpcontext.[ch]: added convenience functions to get/set
|
||||
the font by name.
|
||||
|
||||
* app/tools/gimptextoptions.[ch]: don't hold a GimpText object
|
||||
that duplicates properties like font and color which are in
|
||||
GimpContext already. Instead added all text properties that are
|
||||
controlled from the text tool options. Handling of the foreground
|
||||
color is somewhat broken and needs a GimpContext wizard (Mitch!).
|
||||
|
||||
* app/text/gimptext.c: blurbs are not any longer needed now that
|
||||
the property widgets are created from the GimpTextOptions.
|
||||
|
||||
* app/tools/gimptexttool.c: changed accordingly.
|
||||
|
||||
* app/widgets/gimptexteditor.[ch]: use an internal GtkTextBuffer
|
||||
and emit "text-changed" when it changes.
|
||||
|
||||
2004-03-11 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* plug-ins/common/colortoalpha.c: when running in interactive
|
||||
|
|
|
@ -43,25 +43,35 @@ gimp_config_connect_notify (GObject *src,
|
|||
GParamSpec *param_spec,
|
||||
GObject *dest)
|
||||
{
|
||||
if ((param_spec->flags & G_PARAM_READABLE) &&
|
||||
(param_spec->flags & G_PARAM_WRITABLE) &&
|
||||
! (param_spec->flags & G_PARAM_CONSTRUCT_ONLY))
|
||||
if (param_spec->flags & G_PARAM_READABLE)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
GParamSpec *dest_spec;
|
||||
|
||||
g_value_init (&value, param_spec->value_type);
|
||||
dest_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (dest),
|
||||
param_spec->name);
|
||||
|
||||
g_object_get_property (src, param_spec->name, &value);
|
||||
if (dest_spec &&
|
||||
(dest_spec->value_type == param_spec->value_type) &&
|
||||
(dest_spec->flags & G_PARAM_WRITABLE) &&
|
||||
(dest_spec->flags & G_PARAM_CONSTRUCT_ONLY) == 0)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
|
||||
g_signal_handlers_block_by_func (dest, gimp_config_connect_notify, src);
|
||||
g_object_set_property (dest, param_spec->name, &value);
|
||||
g_signal_handlers_unblock_by_func (dest, gimp_config_connect_notify, src);
|
||||
g_value_init (&value, param_spec->value_type);
|
||||
|
||||
g_value_unset (&value);
|
||||
g_object_get_property (src, param_spec->name, &value);
|
||||
|
||||
g_signal_handlers_block_by_func (dest,
|
||||
gimp_config_connect_notify, src);
|
||||
g_object_set_property (dest, param_spec->name, &value);
|
||||
g_signal_handlers_unblock_by_func (dest,
|
||||
gimp_config_connect_notify, src);
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_config_connect:
|
||||
* @a: a #GObject
|
||||
|
@ -72,11 +82,9 @@ gimp_config_connect_notify (GObject *src,
|
|||
* one are propagated to the other. This is a two-way connection.
|
||||
*
|
||||
* If @property_name is %NULL the connection is setup for all
|
||||
* properties. It is then required that @a and @b are of the same
|
||||
* type. If a name is given, only this property is connected. In this
|
||||
* case, the two objects don't need to be of the same type but they
|
||||
* should both have a property of the same type that has the given
|
||||
* @property_name.
|
||||
* properties. It is not required that @a and @b are of the same type.
|
||||
* Only changes on properties that exist in both object classes and
|
||||
* are of the same value_type are propagated.
|
||||
**/
|
||||
void
|
||||
gimp_config_connect (GObject *a,
|
||||
|
@ -86,10 +94,7 @@ gimp_config_connect (GObject *a,
|
|||
gchar *signal_name;
|
||||
|
||||
g_return_if_fail (a != b);
|
||||
g_return_if_fail (G_IS_OBJECT (a));
|
||||
g_return_if_fail (G_IS_OBJECT (b));
|
||||
g_return_if_fail (property_name != NULL ||
|
||||
G_TYPE_FROM_INSTANCE (a) == G_TYPE_FROM_INSTANCE (b));
|
||||
g_return_if_fail (G_IS_OBJECT (a) && G_IS_OBJECT (b));
|
||||
|
||||
if (property_name)
|
||||
signal_name = g_strconcat ("notify::", property_name, NULL);
|
||||
|
@ -119,8 +124,7 @@ void
|
|||
gimp_config_disconnect (GObject *a,
|
||||
GObject *b)
|
||||
{
|
||||
g_return_if_fail (G_IS_OBJECT (a));
|
||||
g_return_if_fail (G_IS_OBJECT (b));
|
||||
g_return_if_fail (G_IS_OBJECT (a) && G_IS_OBJECT (b));
|
||||
|
||||
g_signal_handlers_disconnect_by_func (b,
|
||||
G_CALLBACK (gimp_config_connect_notify),
|
||||
|
@ -130,11 +134,50 @@ gimp_config_disconnect (GObject *a,
|
|||
b);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_config_diff_property (GObject *a,
|
||||
GObject *b,
|
||||
GParamSpec *prop_spec)
|
||||
{
|
||||
GValue a_value = { 0, };
|
||||
GValue b_value = { 0, };
|
||||
gboolean retval = FALSE;
|
||||
|
||||
g_value_init (&a_value, prop_spec->value_type);
|
||||
g_value_init (&b_value, prop_spec->value_type);
|
||||
|
||||
g_object_get_property (a, prop_spec->name, &a_value);
|
||||
g_object_get_property (b, prop_spec->name, &b_value);
|
||||
|
||||
if (g_param_values_cmp (prop_spec, &a_value, &b_value))
|
||||
{
|
||||
if ((prop_spec->flags & GIMP_PARAM_AGGREGATE) &&
|
||||
G_IS_PARAM_SPEC_OBJECT (prop_spec) &&
|
||||
g_type_interface_peek (g_type_class_peek (prop_spec->value_type),
|
||||
GIMP_TYPE_CONFIG))
|
||||
{
|
||||
if (! gimp_config_is_equal_to (g_value_get_object (&a_value),
|
||||
g_value_get_object (&b_value)))
|
||||
{
|
||||
retval = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
g_value_unset (&a_value);
|
||||
g_value_unset (&b_value);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GList *
|
||||
gimp_config_diff_internal (GimpConfig *a,
|
||||
GimpConfig *b,
|
||||
GParamFlags flags)
|
||||
gimp_config_diff_same (GimpConfig *a,
|
||||
GimpConfig *b,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpec **param_specs;
|
||||
guint n_param_specs;
|
||||
|
@ -150,36 +193,9 @@ gimp_config_diff_internal (GimpConfig *a,
|
|||
|
||||
if (! flags || ((prop_spec->flags & flags) == flags))
|
||||
{
|
||||
GValue a_value = { 0, };
|
||||
GValue b_value = { 0, };
|
||||
|
||||
g_value_init (&a_value, prop_spec->value_type);
|
||||
g_value_init (&b_value, prop_spec->value_type);
|
||||
|
||||
g_object_get_property (G_OBJECT (a), prop_spec->name, &a_value);
|
||||
g_object_get_property (G_OBJECT (b), prop_spec->name, &b_value);
|
||||
|
||||
if (g_param_values_cmp (param_specs[i], &a_value, &b_value))
|
||||
{
|
||||
if ((prop_spec->flags & GIMP_PARAM_AGGREGATE) &&
|
||||
G_IS_PARAM_SPEC_OBJECT (prop_spec) &&
|
||||
g_type_interface_peek (g_type_class_peek (prop_spec->value_type),
|
||||
GIMP_TYPE_CONFIG))
|
||||
{
|
||||
if (! gimp_config_is_equal_to (g_value_get_object (&a_value),
|
||||
g_value_get_object (&b_value)))
|
||||
{
|
||||
list = g_list_prepend (list, prop_spec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
list = g_list_prepend (list, prop_spec);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_unset (&a_value);
|
||||
g_value_unset (&b_value);
|
||||
if (gimp_config_diff_property (G_OBJECT (a),
|
||||
G_OBJECT (b), prop_spec))
|
||||
list = g_list_prepend (list, prop_spec);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,15 +204,53 @@ gimp_config_diff_internal (GimpConfig *a,
|
|||
return list;
|
||||
}
|
||||
|
||||
static GList *
|
||||
gimp_config_diff_other (GimpConfig *a,
|
||||
GimpConfig *b,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpec **param_specs;
|
||||
guint n_param_specs;
|
||||
gint i;
|
||||
GList *list = NULL;
|
||||
|
||||
param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (a),
|
||||
&n_param_specs);
|
||||
|
||||
for (i = 0; i < n_param_specs; i++)
|
||||
{
|
||||
GParamSpec *a_spec = param_specs[i];
|
||||
GParamSpec *b_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (b),
|
||||
a_spec->name);
|
||||
|
||||
if (b_spec &&
|
||||
(a_spec->value_type == b_spec->value_type) &&
|
||||
(! flags || (a_spec->flags & b_spec->flags & flags) == flags))
|
||||
{
|
||||
if (gimp_config_diff_property (G_OBJECT (a), G_OBJECT (b), b_spec))
|
||||
list = g_list_prepend (list, b_spec);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (param_specs);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_config_diff:
|
||||
* @a: a #GimpConfig
|
||||
* @b: another #GimpConfig of the same type as @a
|
||||
* @a: a #GimpConfig object
|
||||
* @b: another #GimpConfig object
|
||||
* @flags: a mask of GParamFlags
|
||||
*
|
||||
* Compares all properties of @a and @b that have all @flags set. If
|
||||
* @flags is 0, all properties are compared.
|
||||
*
|
||||
* If the two objects are not of the same type, only properties that
|
||||
* exist in both object classes and are of the same value_type are
|
||||
* compared.
|
||||
*
|
||||
* Return value: a GList of differing GParamSpecs.
|
||||
**/
|
||||
GList *
|
||||
|
@ -204,24 +258,34 @@ gimp_config_diff (GimpConfig *a,
|
|||
GimpConfig *b,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GList *diff;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_CONFIG (a), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_CONFIG (b), FALSE);
|
||||
g_return_val_if_fail (G_TYPE_FROM_INSTANCE (a) == G_TYPE_FROM_INSTANCE (b),
|
||||
FALSE);
|
||||
|
||||
return g_list_reverse (gimp_config_diff_internal (a, b, flags));
|
||||
if (G_TYPE_FROM_INSTANCE (a) == G_TYPE_FROM_INSTANCE (b))
|
||||
diff = gimp_config_diff_same (a, b, flags);
|
||||
else
|
||||
diff = gimp_config_diff_other (a, b, flags);
|
||||
|
||||
return g_list_reverse (diff);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_config_sync:
|
||||
* @src: a #GimpConfig
|
||||
* @dest: another #GimpConfig of the same type as @src
|
||||
* @src: a #GimpConfig object
|
||||
* @dest: another #GimpConfig object
|
||||
* @flags: a mask of GParamFlags
|
||||
*
|
||||
* Compares all read- and write-able properties from @src and @dest
|
||||
* that have all @flags set. Differing values are then copied from
|
||||
* @src to @dest. If @flags is 0, all differing read/write properties
|
||||
* are synced.
|
||||
* @src to @dest. If @flags is 0, all differing read/write properties.
|
||||
*
|
||||
* Properties marked as "construct-only" are not touched.
|
||||
*
|
||||
* If the two objects are not of the same type, only
|
||||
* properties that exist in both object classes and are of the same
|
||||
* value_type are synchronized
|
||||
*
|
||||
* Return value: %TRUE if @dest was modified, %FALSE otherwise
|
||||
**/
|
||||
|
@ -235,15 +299,16 @@ gimp_config_sync (GimpConfig *src,
|
|||
|
||||
g_return_val_if_fail (GIMP_IS_CONFIG (src), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_CONFIG (dest), FALSE);
|
||||
g_return_val_if_fail (G_TYPE_FROM_INSTANCE (src) == G_TYPE_FROM_INSTANCE (dest),
|
||||
FALSE);
|
||||
|
||||
/* we use the internal version here for a number of reasons:
|
||||
/* we use the internal versions here for a number of reasons:
|
||||
* - it saves a g_list_reverse()
|
||||
* - it avoids duplicated parameter checks
|
||||
* - it makes GimpTemplateEditor work (resolution is set before size)
|
||||
*/
|
||||
diff = gimp_config_diff_internal (src, dest, (flags | G_PARAM_READWRITE));
|
||||
if (G_TYPE_FROM_INSTANCE (src) == G_TYPE_FROM_INSTANCE (dest))
|
||||
diff = gimp_config_diff_same (src, dest, (flags | G_PARAM_READWRITE));
|
||||
else
|
||||
diff = gimp_config_diff_other (src, dest, flags);
|
||||
|
||||
if (!diff)
|
||||
return FALSE;
|
||||
|
@ -275,7 +340,8 @@ gimp_config_sync (GimpConfig *src,
|
|||
* @config: a #GimpConfig
|
||||
*
|
||||
* Resets all writable properties of @object to the default values as
|
||||
* defined in their #GParamSpec.
|
||||
* defined in their #GParamSpec. Properties marked as "construct-only"
|
||||
* are not touched.
|
||||
**/
|
||||
void
|
||||
gimp_config_reset_properties (GimpConfig *config)
|
||||
|
|
|
@ -87,8 +87,8 @@ static void gimp_context_get_property (GObject *object,
|
|||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static gint64 gimp_context_get_memsize (GimpObject *object,
|
||||
gint64 *gui_size);
|
||||
static gint64 gimp_context_get_memsize (GimpObject *object,
|
||||
gint64 *gui_size);
|
||||
|
||||
static gboolean gimp_context_serialize (GimpConfig *config,
|
||||
GimpConfigWriter *writer,
|
||||
|
@ -1124,11 +1124,11 @@ gimp_context_serialize_property (GimpConfig *config,
|
|||
|
||||
context = GIMP_CONTEXT (config);
|
||||
|
||||
#if 0
|
||||
//#if 0
|
||||
/* serialize nothing if the property is not defined */
|
||||
if (! ((1 << property_id) & context->defined_props))
|
||||
return TRUE;
|
||||
#endif
|
||||
//#endif
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
|
@ -2694,6 +2694,28 @@ gimp_context_set_font (GimpContext *context,
|
|||
gimp_context_real_set_font (context, font);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_context_get_font_name (GimpContext *context)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
|
||||
|
||||
return (context->font ?
|
||||
gimp_object_get_name (GIMP_OBJECT (context->font)) : NULL);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_set_font_name (GimpContext *context,
|
||||
const gchar *name)
|
||||
{
|
||||
GimpObject *font;
|
||||
|
||||
g_return_if_fail (GIMP_IS_CONTEXT (context));
|
||||
|
||||
font = gimp_container_get_child_by_name (context->gimp->fonts, name);
|
||||
|
||||
gimp_context_set_font (context, GIMP_FONT (font));
|
||||
}
|
||||
|
||||
void
|
||||
gimp_context_font_changed (GimpContext *context)
|
||||
{
|
||||
|
@ -2704,7 +2726,7 @@ gimp_context_font_changed (GimpContext *context)
|
|||
context->font);
|
||||
}
|
||||
|
||||
/* the active palette was modified */
|
||||
/* the active font was modified */
|
||||
static void
|
||||
gimp_context_font_dirty (GimpFont *font,
|
||||
GimpContext *context)
|
||||
|
|
|
@ -265,6 +265,9 @@ void gimp_context_palette_changed (GimpContext *context);
|
|||
GimpFont * gimp_context_get_font (GimpContext *context);
|
||||
void gimp_context_set_font (GimpContext *context,
|
||||
GimpFont *font);
|
||||
const gchar * gimp_context_get_font_name (GimpContext *context);
|
||||
void gimp_context_set_font_name (GimpContext *context,
|
||||
const gchar *name);
|
||||
void gimp_context_font_changed (GimpContext *context);
|
||||
|
||||
|
||||
|
|
|
@ -41,8 +41,6 @@
|
|||
|
||||
#include "gimptext.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -174,17 +172,11 @@ gimp_text_class_init (GimpTextClass *klass)
|
|||
TRUE, FALSE, GIMP_UNIT_PIXEL,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_HINTING,
|
||||
"hinting",
|
||||
N_("Hinting alters the font outline to "
|
||||
"produce a crisp bitmap at small "
|
||||
"sizes"),
|
||||
"hinting", NULL,
|
||||
TRUE,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_AUTOHINT,
|
||||
"autohint",
|
||||
N_("If available, hints from the font are "
|
||||
"used but you may prefer to always use "
|
||||
"the automatic hinter"),
|
||||
"autohint", NULL,
|
||||
FALSE,
|
||||
GIMP_PARAM_DEFAULTS);
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ANTIALIAS,
|
||||
|
@ -200,8 +192,7 @@ gimp_text_class_init (GimpTextClass *klass)
|
|||
language,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_BASE_DIR,
|
||||
"base-direction",
|
||||
NULL,
|
||||
"base-direction", NULL,
|
||||
GIMP_TYPE_TEXT_DIRECTION,
|
||||
GIMP_TEXT_DIRECTION_LTR,
|
||||
0);
|
||||
|
@ -215,24 +206,20 @@ gimp_text_class_init (GimpTextClass *klass)
|
|||
GIMP_TEXT_OUTLINE_NONE,
|
||||
GIMP_PARAM_DEFAULTS);
|
||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_JUSTIFICATION,
|
||||
"justify",
|
||||
NULL,
|
||||
"justify", NULL,
|
||||
GIMP_TYPE_TEXT_JUSTIFICATION,
|
||||
GIMP_TEXT_JUSTIFY_LEFT,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_INDENTATION,
|
||||
"indent",
|
||||
N_("Indentation of the first line"),
|
||||
"indent", NULL,
|
||||
-8192.0, 8192.0, 0.0,
|
||||
GIMP_PARAM_DEFAULTS);
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_LINE_SPACING,
|
||||
"line-spacing",
|
||||
N_("Modify line spacing"),
|
||||
"line-spacing", NULL,
|
||||
-8192.0, 8192.0, 0.0,
|
||||
GIMP_PARAM_DEFAULTS);
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_LETTER_SPACING,
|
||||
"letter-spacing",
|
||||
N_("Modify letter spacing"),
|
||||
"letter-spacing", NULL,
|
||||
-8192.0, 8192.0, 0.0,
|
||||
GIMP_PARAM_DEFAULTS);
|
||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_BOX_MODE,
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "tools-types.h"
|
||||
|
@ -52,31 +53,37 @@
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_TEXT
|
||||
PROP_FONT_SIZE,
|
||||
PROP_UNIT,
|
||||
PROP_HINTING,
|
||||
PROP_AUTOHINT,
|
||||
PROP_ANTIALIAS,
|
||||
PROP_LANGUAGE,
|
||||
PROP_BASE_DIR,
|
||||
PROP_JUSTIFICATION,
|
||||
PROP_INDENTATION,
|
||||
PROP_LINE_SPACING,
|
||||
PROP_COLOR
|
||||
};
|
||||
|
||||
|
||||
static void gimp_text_options_init (GimpTextOptions *options);
|
||||
static void gimp_text_options_class_init (GimpTextOptionsClass *options_class);
|
||||
static void gimp_text_options_class_init (GimpTextOptionsClass *options_class);
|
||||
static void gimp_text_options_init (GimpTextOptions *options);
|
||||
|
||||
static void gimp_text_options_finalize (GObject *object);
|
||||
static void gimp_text_options_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_text_options_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_text_options_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_text_options_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_text_options_reset (GimpToolOptions *options);
|
||||
|
||||
static void gimp_text_options_notify_font (GimpContext *context,
|
||||
GParamSpec *pspec,
|
||||
GimpText *text);
|
||||
static void gimp_text_options_notify_text_font (GimpText *text,
|
||||
GParamSpec *pspec,
|
||||
GimpContext *context);
|
||||
static void gimp_text_options_notify_color (GObject *object,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_text_options_notify_font (GimpContext *context,
|
||||
GParamSpec *pspec,
|
||||
GimpText *text);
|
||||
|
||||
|
||||
static GimpToolOptionsClass *parent_class = NULL;
|
||||
|
@ -99,7 +106,7 @@ gimp_text_options_get_type (void)
|
|||
NULL, /* class_data */
|
||||
sizeof (GimpTextOptions),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_text_options_init,
|
||||
(GInstanceInitFunc) gimp_text_options_init
|
||||
};
|
||||
|
||||
type = g_type_register_static (GIMP_TYPE_TOOL_OPTIONS,
|
||||
|
@ -113,80 +120,81 @@ gimp_text_options_get_type (void)
|
|||
static void
|
||||
gimp_text_options_class_init (GimpTextOptionsClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
GimpToolOptionsClass *options_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
options_class = GIMP_TOOL_OPTIONS_CLASS (klass);
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpRGB black;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gimp_text_options_finalize;
|
||||
object_class->set_property = gimp_text_options_set_property;
|
||||
object_class->get_property = gimp_text_options_get_property;
|
||||
|
||||
options_class->reset = gimp_text_options_reset;
|
||||
GIMP_CONFIG_INSTALL_PROP_UNIT (object_class, PROP_UNIT,
|
||||
"font-size-unit", NULL,
|
||||
TRUE, FALSE, GIMP_UNIT_PIXEL,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_FONT_SIZE,
|
||||
"font-size", NULL,
|
||||
0.0, 8192.0, 18.0,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_HINTING,
|
||||
"hinting",
|
||||
N_("Hinting alters the font outline to "
|
||||
"produce a crisp bitmap at small "
|
||||
"sizes"),
|
||||
TRUE,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_AUTOHINT,
|
||||
"autohint",
|
||||
N_("If available, hints from the font are "
|
||||
"used but you may prefer to always use "
|
||||
"the automatic hinter"),
|
||||
FALSE,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ANTIALIAS,
|
||||
"antialias", NULL,
|
||||
TRUE,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_LANGUAGE,
|
||||
"language", NULL,
|
||||
(const gchar *) gtk_get_default_language (),
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_BASE_DIR,
|
||||
"base-direction", NULL,
|
||||
GIMP_TYPE_TEXT_DIRECTION,
|
||||
GIMP_TEXT_DIRECTION_LTR,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_JUSTIFICATION,
|
||||
"justify", NULL,
|
||||
GIMP_TYPE_TEXT_JUSTIFICATION,
|
||||
GIMP_TEXT_JUSTIFY_LEFT,
|
||||
0);
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_INDENTATION,
|
||||
"indent",
|
||||
N_("Indentation of the first line"),
|
||||
-8192.0, 8192.0, 0.0,
|
||||
GIMP_PARAM_DEFAULTS);
|
||||
GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_LINE_SPACING,
|
||||
"line-spacing",
|
||||
N_("Modify line spacing"),
|
||||
-8192.0, 8192.0, 0.0,
|
||||
GIMP_PARAM_DEFAULTS);
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_TEXT,
|
||||
"text", NULL,
|
||||
GIMP_TYPE_TEXT,
|
||||
GIMP_PARAM_AGGREGATE);
|
||||
gimp_rgba_set (&black, 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE);
|
||||
|
||||
g_object_class_install_property (object_class, PROP_COLOR,
|
||||
gimp_param_spec_color ("color", NULL, NULL,
|
||||
&black,
|
||||
G_PARAM_READWRITE));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_options_init (GimpTextOptions *options)
|
||||
{
|
||||
options->text = g_object_new (GIMP_TYPE_TEXT, NULL);
|
||||
options->buffer = gimp_prop_text_buffer_new (G_OBJECT (options->text),
|
||||
"text", -1);
|
||||
gimp_context_get_foreground (GIMP_CONTEXT (options), &options->color);
|
||||
|
||||
g_signal_connect_object (options, "notify::font",
|
||||
G_CALLBACK (gimp_text_options_notify_font),
|
||||
options->text, 0);
|
||||
g_signal_connect_object (options->text, "notify::font",
|
||||
G_CALLBACK (gimp_text_options_notify_text_font),
|
||||
options, 0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_options_finalize (GObject *object)
|
||||
{
|
||||
GimpTextOptions *options = GIMP_TEXT_OPTIONS (object);
|
||||
|
||||
if (options->buffer)
|
||||
{
|
||||
g_object_unref (options->buffer);
|
||||
options->buffer = NULL;
|
||||
}
|
||||
|
||||
if (options->text)
|
||||
{
|
||||
g_object_unref (options->text);
|
||||
options->text = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_options_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpTextOptions *options = GIMP_TEXT_OPTIONS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TEXT:
|
||||
if (g_value_get_object (value))
|
||||
gimp_config_sync (GIMP_CONFIG (g_value_get_object (value)),
|
||||
GIMP_CONFIG (options->text), 0);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
g_signal_connect (options, "notify::foreground",
|
||||
G_CALLBACK (gimp_text_options_notify_color),
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -199,8 +207,38 @@ gimp_text_options_get_property (GObject *object,
|
|||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_TEXT:
|
||||
g_value_set_object (value, options->text);
|
||||
case PROP_FONT_SIZE:
|
||||
g_value_set_double (value, options->font_size);
|
||||
break;
|
||||
case PROP_UNIT:
|
||||
g_value_set_int (value, options->unit);
|
||||
break;
|
||||
case PROP_HINTING:
|
||||
g_value_set_boolean (value, options->hinting);
|
||||
break;
|
||||
case PROP_AUTOHINT:
|
||||
g_value_set_boolean (value, options->autohint);
|
||||
break;
|
||||
case PROP_ANTIALIAS:
|
||||
g_value_set_boolean (value, options->antialias);
|
||||
break;
|
||||
case PROP_LANGUAGE:
|
||||
g_value_set_string (value, options->language);
|
||||
break;
|
||||
case PROP_BASE_DIR:
|
||||
g_value_set_enum (value, options->base_dir);
|
||||
break;
|
||||
case PROP_JUSTIFICATION:
|
||||
g_value_set_enum (value, options->justify);
|
||||
break;
|
||||
case PROP_INDENTATION:
|
||||
g_value_set_double (value, options->indent);
|
||||
break;
|
||||
case PROP_LINE_SPACING:
|
||||
g_value_set_double (value, options->line_spacing);
|
||||
break;
|
||||
case PROP_COLOR:
|
||||
g_value_set_boxed (value, &options->color);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -209,21 +247,66 @@ gimp_text_options_get_property (GObject *object,
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_text_options_reset (GimpToolOptions *options)
|
||||
gimp_text_options_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpTextOptions *text_options = GIMP_TEXT_OPTIONS (options);
|
||||
gchar *text;
|
||||
GimpTextOptions *options = GIMP_TEXT_OPTIONS (object);
|
||||
GimpRGB *color;
|
||||
|
||||
g_object_freeze_notify (G_OBJECT (text_options->text));
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_FONT_SIZE:
|
||||
options->font_size = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_UNIT:
|
||||
options->unit = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_HINTING:
|
||||
options->hinting = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_AUTOHINT:
|
||||
options->autohint = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_ANTIALIAS:
|
||||
options->antialias = g_value_get_boolean (value);
|
||||
break;
|
||||
case PROP_BASE_DIR:
|
||||
options->base_dir = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_LANGUAGE:
|
||||
g_free (options->language);
|
||||
options->language = g_value_dup_string (value);
|
||||
break;
|
||||
case PROP_JUSTIFICATION:
|
||||
options->justify = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_INDENTATION:
|
||||
options->indent = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_LINE_SPACING:
|
||||
options->line_spacing = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_COLOR:
|
||||
color = g_value_get_boxed (value);
|
||||
options->color = *color;
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
text = text_options->text->text;
|
||||
text_options->text->text = NULL;
|
||||
static void
|
||||
gimp_text_options_notify_color (GObject *object,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
GIMP_TOOL_OPTIONS_CLASS (parent_class)->reset (options);
|
||||
gimp_context_get_foreground (GIMP_CONTEXT (object), &color);
|
||||
|
||||
text_options->text->text = text;
|
||||
|
||||
g_object_thaw_notify (G_OBJECT (text_options->text));
|
||||
g_object_set (object, "color", &color, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -231,48 +314,65 @@ gimp_text_options_notify_font (GimpContext *context,
|
|||
GParamSpec *pspec,
|
||||
GimpText *text)
|
||||
{
|
||||
GimpFont *font = gimp_context_get_font (context);
|
||||
|
||||
g_signal_handlers_block_by_func (text,
|
||||
gimp_text_options_notify_text_font,
|
||||
context);
|
||||
|
||||
g_object_set (text,
|
||||
"font", font ? gimp_object_get_name (GIMP_OBJECT (font)) : NULL,
|
||||
NULL);
|
||||
|
||||
g_signal_handlers_unblock_by_func (text,
|
||||
gimp_text_options_notify_text_font,
|
||||
context);
|
||||
g_object_set (text, "font", gimp_context_get_font_name (context), NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_options_notify_text_font (GimpText *text,
|
||||
GParamSpec *pspec,
|
||||
GimpContext *context)
|
||||
GimpText *
|
||||
gimp_text_options_create_text (GimpTextOptions *options)
|
||||
{
|
||||
GimpObject *font;
|
||||
gchar *value;
|
||||
GimpText *text;
|
||||
|
||||
g_object_get (text,
|
||||
"font", &value,
|
||||
NULL);
|
||||
g_return_val_if_fail (GIMP_IS_TEXT_OPTIONS (options), NULL);
|
||||
|
||||
font = gimp_container_get_child_by_name (context->gimp->fonts, value);
|
||||
text = g_object_new (GIMP_TYPE_TEXT,
|
||||
"font",
|
||||
gimp_context_get_font_name (GIMP_CONTEXT (options)),
|
||||
NULL);
|
||||
|
||||
g_free (value);
|
||||
gimp_config_sync (GIMP_CONFIG (options), GIMP_CONFIG (text), 0);
|
||||
|
||||
g_signal_handlers_block_by_func (context,
|
||||
gimp_text_options_notify_font,
|
||||
text);
|
||||
return text;
|
||||
}
|
||||
|
||||
g_object_set (context,
|
||||
"font", font,
|
||||
NULL);
|
||||
void
|
||||
gimp_text_options_connect_text (GimpTextOptions *options,
|
||||
GimpText *text)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_TEXT_OPTIONS (options));
|
||||
g_return_if_fail (GIMP_IS_TEXT (text));
|
||||
|
||||
g_signal_handlers_unblock_by_func (context,
|
||||
gimp_text_options_notify_font,
|
||||
text);
|
||||
g_signal_handlers_block_by_func (options,
|
||||
gimp_text_options_notify_color, NULL);
|
||||
|
||||
gimp_config_sync (GIMP_CONFIG (text), GIMP_CONFIG (options), 0);
|
||||
gimp_context_set_font_name (GIMP_CONTEXT (options), text->font);
|
||||
|
||||
gimp_config_connect (G_OBJECT (options), G_OBJECT (text), NULL);
|
||||
|
||||
g_signal_connect_object (options, "notify::font",
|
||||
G_CALLBACK (gimp_text_options_notify_font),
|
||||
text, 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_text_options_disconnect_text (GimpTextOptions *options,
|
||||
GimpText *text)
|
||||
{
|
||||
GimpRGB color;
|
||||
|
||||
g_return_if_fail (GIMP_IS_TEXT_OPTIONS (options));
|
||||
g_return_if_fail (GIMP_IS_TEXT (text));
|
||||
|
||||
gimp_config_disconnect (G_OBJECT (options), G_OBJECT (text));
|
||||
|
||||
g_signal_handlers_disconnect_by_func (options,
|
||||
gimp_text_options_notify_font, text);
|
||||
|
||||
gimp_context_get_foreground (GIMP_CONTEXT (options), &color);
|
||||
g_object_set (options, "color", &color, NULL);
|
||||
|
||||
g_signal_handlers_unblock_by_func (options,
|
||||
gimp_text_options_notify_color, NULL);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
|
@ -292,7 +392,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
|
|||
gint row = 0;
|
||||
|
||||
options = GIMP_TEXT_OPTIONS (tool_options);
|
||||
config = G_OBJECT (options->text);
|
||||
config = G_OBJECT (options);
|
||||
|
||||
vbox = gimp_tool_options_gui (tool_options);
|
||||
|
||||
|
@ -316,7 +416,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
|
|||
_("_Font:"), 1.0, 0.5,
|
||||
button, 2, TRUE);
|
||||
|
||||
digits = gimp_unit_get_digits (options->text->unit);
|
||||
digits = gimp_unit_get_digits (options->unit);
|
||||
spinbutton = gimp_prop_spin_button_new (config, "font-size",
|
||||
1.0, 10.0, digits);
|
||||
gimp_table_attach_aligned (GTK_TABLE (table), 0, row,
|
||||
|
@ -343,7 +443,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
|
|||
gtk_widget_show (auto_button);
|
||||
row++;
|
||||
|
||||
gtk_widget_set_sensitive (auto_button, options->text->hinting);
|
||||
gtk_widget_set_sensitive (auto_button, options->hinting);
|
||||
g_object_set_data (G_OBJECT (button), "set_sensitive", auto_button);
|
||||
|
||||
button = gimp_prop_check_button_new (config, "antialias", _("Antialiasing"));
|
||||
|
@ -352,8 +452,7 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
|
|||
gtk_widget_show (button);
|
||||
row++;
|
||||
|
||||
button = gimp_prop_color_button_new (config, "color",
|
||||
_("Text Color"),
|
||||
button = gimp_prop_color_button_new (config, "color", _("Text Color"),
|
||||
-1, 24, GIMP_COLOR_AREA_FLAT);
|
||||
gimp_color_panel_set_context (GIMP_COLOR_PANEL (button),
|
||||
GIMP_CONTEXT (options));
|
||||
|
@ -389,24 +488,30 @@ gimp_text_options_gui (GimpToolOptions *tool_options)
|
|||
return vbox;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_options_text_changed (GimpTextEditor *editor,
|
||||
GimpTextOptions *options)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_options_dir_changed (GimpTextEditor *editor,
|
||||
GimpText *text)
|
||||
gimp_text_options_dir_changed (GimpTextEditor *editor,
|
||||
GimpTextOptions *options)
|
||||
{
|
||||
g_object_set (text,
|
||||
g_object_set (options,
|
||||
"base-direction", editor->base_dir,
|
||||
NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_options_notify_dir (GimpText *text,
|
||||
GParamSpec *pspec,
|
||||
GimpTextEditor *editor)
|
||||
gimp_text_options_notify_dir (GimpTextOptions *options,
|
||||
GParamSpec *pspec,
|
||||
GimpTextEditor *editor)
|
||||
{
|
||||
GimpTextDirection dir;
|
||||
|
||||
g_object_get (text,
|
||||
g_object_get (options,
|
||||
"base-direction", &dir,
|
||||
NULL);
|
||||
|
||||
|
@ -420,18 +525,24 @@ gimp_text_options_editor_new (GimpTextOptions *options,
|
|||
GtkWidget *editor;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_TEXT_OPTIONS (options), NULL);
|
||||
g_return_val_if_fail (title != NULL, NULL);
|
||||
|
||||
editor = gimp_text_editor_new (title, options->buffer);
|
||||
editor = gimp_text_editor_new (title);
|
||||
|
||||
gimp_text_editor_set_direction (GIMP_TEXT_EDITOR (editor),
|
||||
options->text->base_dir);
|
||||
options->base_dir);
|
||||
|
||||
g_signal_connect_object (editor, "text_changed",
|
||||
G_CALLBACK (gimp_text_options_text_changed),
|
||||
options, 0);
|
||||
|
||||
g_signal_connect_object (editor, "dir_changed",
|
||||
G_CALLBACK (gimp_text_options_dir_changed),
|
||||
options->text, 0);
|
||||
g_signal_connect_object (options->text, "notify::base-direction",
|
||||
options, 0);
|
||||
g_signal_connect_object (options, "notify::base-direction",
|
||||
G_CALLBACK (gimp_text_options_notify_dir),
|
||||
editor, 0);
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
|
|
@ -36,19 +36,35 @@ typedef struct _GimpToolOptionsClass GimpTextOptionsClass;
|
|||
|
||||
struct _GimpTextOptions
|
||||
{
|
||||
GimpToolOptions tool_options;
|
||||
GimpToolOptions tool_options;
|
||||
|
||||
GimpText *text;
|
||||
GtkTextBuffer *buffer;
|
||||
GimpUnit unit;
|
||||
gdouble font_size;
|
||||
gboolean hinting;
|
||||
gboolean autohint;
|
||||
gboolean antialias;
|
||||
gchar *language;
|
||||
GimpTextDirection base_dir;
|
||||
GimpTextJustification justify;
|
||||
gdouble indent;
|
||||
gdouble line_spacing;
|
||||
|
||||
GimpRGB color;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_text_options_get_type (void) G_GNUC_CONST;
|
||||
GType gimp_text_options_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_text_options_gui (GimpToolOptions *tool_options);
|
||||
GimpText * gimp_text_options_create_text (GimpTextOptions *options);
|
||||
void gimp_text_options_connect_text (GimpTextOptions *options,
|
||||
GimpText *text);
|
||||
void gimp_text_options_disconnect_text (GimpTextOptions *options,
|
||||
GimpText *text);
|
||||
|
||||
GtkWidget * gimp_text_options_editor_new (GimpTextOptions *options,
|
||||
const gchar *title);
|
||||
GtkWidget * gimp_text_options_gui (GimpToolOptions *tool_options);
|
||||
|
||||
GtkWidget * gimp_text_options_editor_new (GimpTextOptions *options,
|
||||
const gchar *title);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEXT_OPTIONS_H__ */
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimptexteditor.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
|
||||
|
@ -83,7 +84,7 @@ static void gimp_text_tool_create_vectors (GimpTextTool *text_tool);
|
|||
static void gimp_text_tool_create_layer (GimpTextTool *text_tool);
|
||||
|
||||
static void gimp_text_tool_editor (GimpTextTool *text_tool);
|
||||
static void gimp_text_tool_buffer_changed (GtkTextBuffer *buffer,
|
||||
static void gimp_text_tool_text_changed (GimpTextEditor *editor,
|
||||
GimpTextTool *text_tool);
|
||||
|
||||
|
||||
|
@ -101,7 +102,7 @@ gimp_text_tool_register (GimpToolRegisterCallback callback,
|
|||
(* callback) (GIMP_TYPE_TEXT_TOOL,
|
||||
GIMP_TYPE_TEXT_OPTIONS,
|
||||
gimp_text_options_gui,
|
||||
GIMP_CONTEXT_FONT_MASK,
|
||||
GIMP_CONTEXT_FOREGROUND_MASK | GIMP_CONTEXT_FONT_MASK,
|
||||
"gimp-text-tool",
|
||||
_("Text"),
|
||||
_("Add text to the image"),
|
||||
|
@ -145,9 +146,7 @@ gimp_text_tool_get_type (void)
|
|||
static void
|
||||
gimp_text_tool_class_init (GimpTextToolClass *klass)
|
||||
{
|
||||
GimpToolClass *tool_class;
|
||||
|
||||
tool_class = GIMP_TOOL_CLASS (klass);
|
||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
|
@ -251,21 +250,21 @@ gimp_text_tool_cursor_update (GimpTool *tool,
|
|||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
/* FIXME: should do something fancy here... */
|
||||
|
||||
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_tool_create_vectors (GimpTextTool *text_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (text_tool);
|
||||
GimpTool *tool = GIMP_TOOL (text_tool);
|
||||
GimpImage *gimage = tool->gdisp->gimage;
|
||||
GimpVectors *vectors;
|
||||
GimpImage *gimage;
|
||||
|
||||
if (! text_tool->text)
|
||||
return;
|
||||
|
||||
gimage = tool->gdisp->gimage;
|
||||
|
||||
gimp_tool_control_set_preserve (tool->control, TRUE);
|
||||
|
||||
vectors = gimp_text_vectors_new (gimage, text_tool->text);
|
||||
|
@ -295,10 +294,14 @@ gimp_text_tool_create_layer (GimpTextTool *text_tool)
|
|||
|
||||
gimage = tool->gdisp->gimage;
|
||||
|
||||
text = gimp_config_duplicate (GIMP_CONFIG (options->text));
|
||||
text = gimp_text_options_create_text (options);
|
||||
|
||||
g_object_set (text,
|
||||
"text",
|
||||
gimp_text_editor_get_text (GIMP_TEXT_EDITOR (text_tool->editor)),
|
||||
NULL);
|
||||
|
||||
layer = gimp_text_layer_new (gimage, text);
|
||||
|
||||
g_object_unref (text);
|
||||
|
||||
if (! layer)
|
||||
|
@ -353,28 +356,20 @@ gimp_text_tool_connect (GimpTextTool *text_tool,
|
|||
text_tool);
|
||||
}
|
||||
|
||||
gimp_config_disconnect (G_OBJECT (options->text),
|
||||
G_OBJECT (text_tool->text));
|
||||
gimp_text_options_disconnect_text (options, text_tool->text);
|
||||
|
||||
g_object_unref (text_tool->text);
|
||||
text_tool->text = NULL;
|
||||
|
||||
text_tool->offset_x = 0;
|
||||
text_tool->offset_y = 0;
|
||||
|
||||
g_object_set (options->text, "text", NULL, NULL);
|
||||
}
|
||||
|
||||
if (text)
|
||||
{
|
||||
text_tool->text = g_object_ref (text);
|
||||
|
||||
gimp_config_sync (GIMP_CONFIG (text_tool->text),
|
||||
GIMP_CONFIG (options->text), 0);
|
||||
|
||||
gimp_config_connect (G_OBJECT (options->text),
|
||||
G_OBJECT (text_tool->text),
|
||||
NULL);
|
||||
gimp_text_options_connect_text (options, text);
|
||||
|
||||
text_tool->offset_x = off_x;
|
||||
text_tool->offset_y = off_y;
|
||||
|
@ -412,25 +407,36 @@ gimp_text_tool_editor (GimpTextTool *text_tool)
|
|||
"gimp-text-tool-dialog",
|
||||
text_tool->editor);
|
||||
|
||||
gtk_widget_show (text_tool->editor);
|
||||
|
||||
if (! text_tool->text)
|
||||
{
|
||||
GClosure *closure;
|
||||
|
||||
closure = g_cclosure_new (G_CALLBACK (gimp_text_tool_buffer_changed),
|
||||
text_tool, NULL);
|
||||
g_object_watch_closure (G_OBJECT (text_tool->editor), closure);
|
||||
g_signal_connect_closure (options->buffer, "changed", closure, FALSE);
|
||||
g_signal_connect_object (text_tool->editor, "text_changed",
|
||||
G_CALLBACK (gimp_text_tool_text_changed),
|
||||
text_tool, 0);
|
||||
}
|
||||
|
||||
gtk_widget_show (text_tool->editor);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_tool_buffer_changed (GtkTextBuffer *buffer,
|
||||
GimpTextTool *text_tool)
|
||||
gimp_text_tool_text_changed (GimpTextEditor *editor,
|
||||
GimpTextTool *text_tool)
|
||||
{
|
||||
if (! text_tool->text)
|
||||
gimp_text_tool_create_layer (text_tool);
|
||||
if (text_tool->text)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
text = gimp_text_editor_get_text (GIMP_TEXT_EDITOR (text_tool->editor));
|
||||
|
||||
g_object_set (text_tool->text,
|
||||
"text", text,
|
||||
NULL);
|
||||
|
||||
g_free (text);
|
||||
}
|
||||
else
|
||||
{
|
||||
gimp_text_tool_create_layer (text_tool);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
|
||||
enum
|
||||
{
|
||||
TEXT_CHANGED,
|
||||
DIR_CHANGED,
|
||||
LAST_SIGNAL
|
||||
};
|
||||
|
@ -51,8 +52,9 @@ enum
|
|||
|
||||
static void gimp_text_editor_class_init (GimpTextEditorClass *klass);
|
||||
static void gimp_text_editor_init (GimpTextEditor *editor);
|
||||
static void gimp_text_editor_dispose (GObject *object);
|
||||
|
||||
static void gimp_text_editor_text_changed (GtkTextBuffer *buffer,
|
||||
GimpTextEditor *editor);
|
||||
static void gimp_text_editor_dir_changed (GtkWidget *widget,
|
||||
GimpTextEditor *editor);
|
||||
|
||||
|
@ -61,7 +63,7 @@ static void gimp_text_editor_load (GtkWidget *widget,
|
|||
static void gimp_text_editor_load_response (GtkWidget *dialog,
|
||||
gint response_id,
|
||||
GimpTextEditor *editor);
|
||||
static gboolean gimp_text_editor_load_file (GtkTextBuffer *buffer,
|
||||
static gboolean gimp_text_editor_load_file (GimpTextEditor *editor,
|
||||
const gchar *filename);
|
||||
static void gimp_text_editor_clear (GtkWidget *widget,
|
||||
GimpTextEditor *editor);
|
||||
|
@ -102,12 +104,16 @@ gimp_text_editor_get_type (void)
|
|||
static void
|
||||
gimp_text_editor_class_init (GimpTextEditorClass *klass)
|
||||
{
|
||||
GObjectClass *object_class;
|
||||
|
||||
object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
text_editor_signals[TEXT_CHANGED] =
|
||||
g_signal_new ("text_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET (GimpTextEditorClass, text_changed),
|
||||
NULL, NULL,
|
||||
gimp_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
text_editor_signals[DIR_CHANGED] =
|
||||
g_signal_new ("dir_changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -117,15 +123,13 @@ gimp_text_editor_class_init (GimpTextEditorClass *klass)
|
|||
gimp_marshal_VOID__VOID,
|
||||
G_TYPE_NONE, 0);
|
||||
|
||||
object_class->dispose = gimp_text_editor_dispose;
|
||||
|
||||
klass->dir_changed = NULL;
|
||||
klass->text_changed = NULL;
|
||||
klass->dir_changed = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_editor_init (GimpTextEditor *editor)
|
||||
{
|
||||
editor->buffer = NULL;
|
||||
editor->view = NULL;
|
||||
editor->group = NULL;
|
||||
editor->file_dialog = NULL;
|
||||
|
@ -142,25 +146,11 @@ gimp_text_editor_init (GimpTextEditor *editor)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_editor_dispose (GObject *object)
|
||||
{
|
||||
GimpTextEditor *editor = GIMP_TEXT_EDITOR (object);
|
||||
|
||||
if (editor->buffer)
|
||||
{
|
||||
g_object_unref (editor->buffer);
|
||||
editor->buffer = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_text_editor_new (const gchar *title,
|
||||
GtkTextBuffer *buffer)
|
||||
gimp_text_editor_new (const gchar *title)
|
||||
{
|
||||
GimpTextEditor *editor;
|
||||
GtkTextBuffer *buffer;
|
||||
GtkToolbar *toolbar;
|
||||
GtkWidget *scrolled_window;
|
||||
GtkWidget *box;
|
||||
|
@ -169,7 +159,6 @@ gimp_text_editor_new (const gchar *title,
|
|||
GList *list;
|
||||
|
||||
g_return_val_if_fail (title != NULL, NULL);
|
||||
g_return_val_if_fail (GTK_IS_TEXT_BUFFER (buffer), NULL);
|
||||
|
||||
editor = g_object_new (GIMP_TYPE_TEXT_EDITOR,
|
||||
"title", title,
|
||||
|
@ -239,11 +228,16 @@ gimp_text_editor_new (const gchar *title,
|
|||
scrolled_window, TRUE, TRUE, 0);
|
||||
gtk_widget_show (scrolled_window);
|
||||
|
||||
editor->buffer = g_object_ref (buffer);
|
||||
editor->view = gtk_text_view_new_with_buffer (buffer);
|
||||
editor->view = gtk_text_view_new ();
|
||||
gtk_container_add (GTK_CONTAINER (scrolled_window), editor->view);
|
||||
gtk_widget_show (editor->view);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (editor->view));
|
||||
|
||||
g_signal_connect (buffer, "changed",
|
||||
G_CALLBACK (gimp_text_editor_text_changed),
|
||||
editor);
|
||||
|
||||
switch (editor->base_dir)
|
||||
{
|
||||
case GIMP_TEXT_DIRECTION_LTR:
|
||||
|
@ -259,6 +253,47 @@ gimp_text_editor_new (const gchar *title,
|
|||
return GTK_WIDGET (editor);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_text_editor_set_text (GimpTextEditor *editor,
|
||||
const gchar *text,
|
||||
gint len)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
g_return_if_fail (GIMP_IS_TEXT_EDITOR (editor));
|
||||
g_return_if_fail (text != NULL || len == 0);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (editor->view));
|
||||
|
||||
if (text)
|
||||
gtk_text_buffer_set_text (buffer, text, len);
|
||||
else
|
||||
gtk_text_buffer_set_text (buffer, "", 0);
|
||||
}
|
||||
|
||||
gchar *
|
||||
gimp_text_editor_get_text (GimpTextEditor *editor)
|
||||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter start_iter;
|
||||
GtkTextIter end_iter;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_TEXT_EDITOR (editor), NULL);
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (editor->view));
|
||||
|
||||
gtk_text_buffer_get_bounds (buffer, &start_iter, &end_iter);
|
||||
|
||||
return gtk_text_buffer_get_text (buffer, &start_iter, &end_iter, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_editor_text_changed (GtkTextBuffer *buffer,
|
||||
GimpTextEditor *editor)
|
||||
{
|
||||
g_signal_emit (editor, text_editor_signals[TEXT_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_text_editor_set_direction (GimpTextEditor *editor,
|
||||
GimpTextDirection base_dir)
|
||||
|
@ -293,6 +328,14 @@ gimp_text_editor_set_direction (GimpTextEditor *editor,
|
|||
g_signal_emit (editor, text_editor_signals[DIR_CHANGED], 0);
|
||||
}
|
||||
|
||||
GimpTextDirection
|
||||
gimp_text_editor_get_direction (GimpTextEditor *editor)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_TEXT_EDITOR (editor), GIMP_TEXT_DIRECTION_LTR);
|
||||
|
||||
return editor->base_dir;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_text_editor_dir_changed (GtkWidget *widget,
|
||||
GimpTextEditor *editor)
|
||||
|
@ -351,7 +394,7 @@ gimp_text_editor_load_response (GtkWidget *dialog,
|
|||
|
||||
filename = gtk_file_selection_get_filename (GTK_FILE_SELECTION (dialog));
|
||||
|
||||
if (! gimp_text_editor_load_file (editor->buffer, filename))
|
||||
if (! gimp_text_editor_load_file (editor, filename))
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -359,13 +402,16 @@ gimp_text_editor_load_response (GtkWidget *dialog,
|
|||
}
|
||||
|
||||
static gboolean
|
||||
gimp_text_editor_load_file (GtkTextBuffer *buffer,
|
||||
const gchar *filename)
|
||||
gimp_text_editor_load_file (GimpTextEditor *editor,
|
||||
const gchar *filename)
|
||||
{
|
||||
FILE *file;
|
||||
gchar buf[2048];
|
||||
gint remaining = 0;
|
||||
GtkTextIter iter;
|
||||
GtkTextBuffer *buffer;
|
||||
FILE *file;
|
||||
gchar buf[2048];
|
||||
gint remaining = 0;
|
||||
GtkTextIter iter;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (editor->view));
|
||||
|
||||
file = fopen (filename, "r");
|
||||
|
||||
|
@ -410,5 +456,9 @@ static void
|
|||
gimp_text_editor_clear (GtkWidget *widget,
|
||||
GimpTextEditor *editor)
|
||||
{
|
||||
gtk_text_buffer_set_text (editor->buffer, "", 0);
|
||||
GtkTextBuffer *buffer;
|
||||
|
||||
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (editor->view));
|
||||
|
||||
gtk_text_buffer_set_text (buffer, "", 0);
|
||||
}
|
||||
|
|
|
@ -34,10 +34,8 @@ struct _GimpTextEditor
|
|||
{
|
||||
GimpDialog parent_instance;
|
||||
|
||||
GimpTextDirection base_dir;
|
||||
|
||||
/*< private >*/
|
||||
GtkTextBuffer *buffer;
|
||||
GimpTextDirection base_dir;
|
||||
GtkWidget *group;
|
||||
GtkWidget *view;
|
||||
GtkWidget *file_dialog;
|
||||
|
@ -47,15 +45,22 @@ struct _GimpTextEditorClass
|
|||
{
|
||||
GimpDialogClass parent_class;
|
||||
|
||||
void (* dir_changed) (GimpTextEditor *editor);
|
||||
void (* text_changed) (GimpTextEditor *editor);
|
||||
void (* dir_changed) (GimpTextEditor *editor);
|
||||
};
|
||||
|
||||
|
||||
GType gimp_text_editor_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget * gimp_text_editor_new (const gchar *title,
|
||||
GtkTextBuffer *buffer);
|
||||
void gimp_text_editor_set_direction (GimpTextEditor *editor,
|
||||
GimpTextDirection base_dir);
|
||||
GType gimp_text_editor_get_type (void) G_GNUC_CONST;
|
||||
GtkWidget * gimp_text_editor_new (const gchar *title);
|
||||
|
||||
void gimp_text_editor_set_text (GimpTextEditor *editor,
|
||||
const gchar *text,
|
||||
gint len);
|
||||
gchar * gimp_text_editor_get_text (GimpTextEditor *editor);
|
||||
|
||||
void gimp_text_editor_set_direction (GimpTextEditor *editor,
|
||||
GimpTextDirection base_dir);
|
||||
GimpTextDirection gimp_text_editor_get_direction (GimpTextEditor *editor);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEXT_EDITOR_H__ */
|
||||
|
|
|
@ -43,25 +43,35 @@ gimp_config_connect_notify (GObject *src,
|
|||
GParamSpec *param_spec,
|
||||
GObject *dest)
|
||||
{
|
||||
if ((param_spec->flags & G_PARAM_READABLE) &&
|
||||
(param_spec->flags & G_PARAM_WRITABLE) &&
|
||||
! (param_spec->flags & G_PARAM_CONSTRUCT_ONLY))
|
||||
if (param_spec->flags & G_PARAM_READABLE)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
GParamSpec *dest_spec;
|
||||
|
||||
g_value_init (&value, param_spec->value_type);
|
||||
dest_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (dest),
|
||||
param_spec->name);
|
||||
|
||||
g_object_get_property (src, param_spec->name, &value);
|
||||
if (dest_spec &&
|
||||
(dest_spec->value_type == param_spec->value_type) &&
|
||||
(dest_spec->flags & G_PARAM_WRITABLE) &&
|
||||
(dest_spec->flags & G_PARAM_CONSTRUCT_ONLY) == 0)
|
||||
{
|
||||
GValue value = { 0, };
|
||||
|
||||
g_signal_handlers_block_by_func (dest, gimp_config_connect_notify, src);
|
||||
g_object_set_property (dest, param_spec->name, &value);
|
||||
g_signal_handlers_unblock_by_func (dest, gimp_config_connect_notify, src);
|
||||
g_value_init (&value, param_spec->value_type);
|
||||
|
||||
g_value_unset (&value);
|
||||
g_object_get_property (src, param_spec->name, &value);
|
||||
|
||||
g_signal_handlers_block_by_func (dest,
|
||||
gimp_config_connect_notify, src);
|
||||
g_object_set_property (dest, param_spec->name, &value);
|
||||
g_signal_handlers_unblock_by_func (dest,
|
||||
gimp_config_connect_notify, src);
|
||||
|
||||
g_value_unset (&value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_config_connect:
|
||||
* @a: a #GObject
|
||||
|
@ -72,11 +82,9 @@ gimp_config_connect_notify (GObject *src,
|
|||
* one are propagated to the other. This is a two-way connection.
|
||||
*
|
||||
* If @property_name is %NULL the connection is setup for all
|
||||
* properties. It is then required that @a and @b are of the same
|
||||
* type. If a name is given, only this property is connected. In this
|
||||
* case, the two objects don't need to be of the same type but they
|
||||
* should both have a property of the same type that has the given
|
||||
* @property_name.
|
||||
* properties. It is not required that @a and @b are of the same type.
|
||||
* Only changes on properties that exist in both object classes and
|
||||
* are of the same value_type are propagated.
|
||||
**/
|
||||
void
|
||||
gimp_config_connect (GObject *a,
|
||||
|
@ -86,10 +94,7 @@ gimp_config_connect (GObject *a,
|
|||
gchar *signal_name;
|
||||
|
||||
g_return_if_fail (a != b);
|
||||
g_return_if_fail (G_IS_OBJECT (a));
|
||||
g_return_if_fail (G_IS_OBJECT (b));
|
||||
g_return_if_fail (property_name != NULL ||
|
||||
G_TYPE_FROM_INSTANCE (a) == G_TYPE_FROM_INSTANCE (b));
|
||||
g_return_if_fail (G_IS_OBJECT (a) && G_IS_OBJECT (b));
|
||||
|
||||
if (property_name)
|
||||
signal_name = g_strconcat ("notify::", property_name, NULL);
|
||||
|
@ -119,8 +124,7 @@ void
|
|||
gimp_config_disconnect (GObject *a,
|
||||
GObject *b)
|
||||
{
|
||||
g_return_if_fail (G_IS_OBJECT (a));
|
||||
g_return_if_fail (G_IS_OBJECT (b));
|
||||
g_return_if_fail (G_IS_OBJECT (a) && G_IS_OBJECT (b));
|
||||
|
||||
g_signal_handlers_disconnect_by_func (b,
|
||||
G_CALLBACK (gimp_config_connect_notify),
|
||||
|
@ -130,11 +134,50 @@ gimp_config_disconnect (GObject *a,
|
|||
b);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_config_diff_property (GObject *a,
|
||||
GObject *b,
|
||||
GParamSpec *prop_spec)
|
||||
{
|
||||
GValue a_value = { 0, };
|
||||
GValue b_value = { 0, };
|
||||
gboolean retval = FALSE;
|
||||
|
||||
g_value_init (&a_value, prop_spec->value_type);
|
||||
g_value_init (&b_value, prop_spec->value_type);
|
||||
|
||||
g_object_get_property (a, prop_spec->name, &a_value);
|
||||
g_object_get_property (b, prop_spec->name, &b_value);
|
||||
|
||||
if (g_param_values_cmp (prop_spec, &a_value, &b_value))
|
||||
{
|
||||
if ((prop_spec->flags & GIMP_PARAM_AGGREGATE) &&
|
||||
G_IS_PARAM_SPEC_OBJECT (prop_spec) &&
|
||||
g_type_interface_peek (g_type_class_peek (prop_spec->value_type),
|
||||
GIMP_TYPE_CONFIG))
|
||||
{
|
||||
if (! gimp_config_is_equal_to (g_value_get_object (&a_value),
|
||||
g_value_get_object (&b_value)))
|
||||
{
|
||||
retval = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retval = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
g_value_unset (&a_value);
|
||||
g_value_unset (&b_value);
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
static GList *
|
||||
gimp_config_diff_internal (GimpConfig *a,
|
||||
GimpConfig *b,
|
||||
GParamFlags flags)
|
||||
gimp_config_diff_same (GimpConfig *a,
|
||||
GimpConfig *b,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpec **param_specs;
|
||||
guint n_param_specs;
|
||||
|
@ -150,36 +193,9 @@ gimp_config_diff_internal (GimpConfig *a,
|
|||
|
||||
if (! flags || ((prop_spec->flags & flags) == flags))
|
||||
{
|
||||
GValue a_value = { 0, };
|
||||
GValue b_value = { 0, };
|
||||
|
||||
g_value_init (&a_value, prop_spec->value_type);
|
||||
g_value_init (&b_value, prop_spec->value_type);
|
||||
|
||||
g_object_get_property (G_OBJECT (a), prop_spec->name, &a_value);
|
||||
g_object_get_property (G_OBJECT (b), prop_spec->name, &b_value);
|
||||
|
||||
if (g_param_values_cmp (param_specs[i], &a_value, &b_value))
|
||||
{
|
||||
if ((prop_spec->flags & GIMP_PARAM_AGGREGATE) &&
|
||||
G_IS_PARAM_SPEC_OBJECT (prop_spec) &&
|
||||
g_type_interface_peek (g_type_class_peek (prop_spec->value_type),
|
||||
GIMP_TYPE_CONFIG))
|
||||
{
|
||||
if (! gimp_config_is_equal_to (g_value_get_object (&a_value),
|
||||
g_value_get_object (&b_value)))
|
||||
{
|
||||
list = g_list_prepend (list, prop_spec);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
list = g_list_prepend (list, prop_spec);
|
||||
}
|
||||
}
|
||||
|
||||
g_value_unset (&a_value);
|
||||
g_value_unset (&b_value);
|
||||
if (gimp_config_diff_property (G_OBJECT (a),
|
||||
G_OBJECT (b), prop_spec))
|
||||
list = g_list_prepend (list, prop_spec);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -188,15 +204,53 @@ gimp_config_diff_internal (GimpConfig *a,
|
|||
return list;
|
||||
}
|
||||
|
||||
static GList *
|
||||
gimp_config_diff_other (GimpConfig *a,
|
||||
GimpConfig *b,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GParamSpec **param_specs;
|
||||
guint n_param_specs;
|
||||
gint i;
|
||||
GList *list = NULL;
|
||||
|
||||
param_specs = g_object_class_list_properties (G_OBJECT_GET_CLASS (a),
|
||||
&n_param_specs);
|
||||
|
||||
for (i = 0; i < n_param_specs; i++)
|
||||
{
|
||||
GParamSpec *a_spec = param_specs[i];
|
||||
GParamSpec *b_spec = g_object_class_find_property (G_OBJECT_GET_CLASS (b),
|
||||
a_spec->name);
|
||||
|
||||
if (b_spec &&
|
||||
(a_spec->value_type == b_spec->value_type) &&
|
||||
(! flags || (a_spec->flags & b_spec->flags & flags) == flags))
|
||||
{
|
||||
if (gimp_config_diff_property (G_OBJECT (a), G_OBJECT (b), b_spec))
|
||||
list = g_list_prepend (list, b_spec);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (param_specs);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gimp_config_diff:
|
||||
* @a: a #GimpConfig
|
||||
* @b: another #GimpConfig of the same type as @a
|
||||
* @a: a #GimpConfig object
|
||||
* @b: another #GimpConfig object
|
||||
* @flags: a mask of GParamFlags
|
||||
*
|
||||
* Compares all properties of @a and @b that have all @flags set. If
|
||||
* @flags is 0, all properties are compared.
|
||||
*
|
||||
* If the two objects are not of the same type, only properties that
|
||||
* exist in both object classes and are of the same value_type are
|
||||
* compared.
|
||||
*
|
||||
* Return value: a GList of differing GParamSpecs.
|
||||
**/
|
||||
GList *
|
||||
|
@ -204,24 +258,34 @@ gimp_config_diff (GimpConfig *a,
|
|||
GimpConfig *b,
|
||||
GParamFlags flags)
|
||||
{
|
||||
GList *diff;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_CONFIG (a), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_CONFIG (b), FALSE);
|
||||
g_return_val_if_fail (G_TYPE_FROM_INSTANCE (a) == G_TYPE_FROM_INSTANCE (b),
|
||||
FALSE);
|
||||
|
||||
return g_list_reverse (gimp_config_diff_internal (a, b, flags));
|
||||
if (G_TYPE_FROM_INSTANCE (a) == G_TYPE_FROM_INSTANCE (b))
|
||||
diff = gimp_config_diff_same (a, b, flags);
|
||||
else
|
||||
diff = gimp_config_diff_other (a, b, flags);
|
||||
|
||||
return g_list_reverse (diff);
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_config_sync:
|
||||
* @src: a #GimpConfig
|
||||
* @dest: another #GimpConfig of the same type as @src
|
||||
* @src: a #GimpConfig object
|
||||
* @dest: another #GimpConfig object
|
||||
* @flags: a mask of GParamFlags
|
||||
*
|
||||
* Compares all read- and write-able properties from @src and @dest
|
||||
* that have all @flags set. Differing values are then copied from
|
||||
* @src to @dest. If @flags is 0, all differing read/write properties
|
||||
* are synced.
|
||||
* @src to @dest. If @flags is 0, all differing read/write properties.
|
||||
*
|
||||
* Properties marked as "construct-only" are not touched.
|
||||
*
|
||||
* If the two objects are not of the same type, only
|
||||
* properties that exist in both object classes and are of the same
|
||||
* value_type are synchronized
|
||||
*
|
||||
* Return value: %TRUE if @dest was modified, %FALSE otherwise
|
||||
**/
|
||||
|
@ -235,15 +299,16 @@ gimp_config_sync (GimpConfig *src,
|
|||
|
||||
g_return_val_if_fail (GIMP_IS_CONFIG (src), FALSE);
|
||||
g_return_val_if_fail (GIMP_IS_CONFIG (dest), FALSE);
|
||||
g_return_val_if_fail (G_TYPE_FROM_INSTANCE (src) == G_TYPE_FROM_INSTANCE (dest),
|
||||
FALSE);
|
||||
|
||||
/* we use the internal version here for a number of reasons:
|
||||
/* we use the internal versions here for a number of reasons:
|
||||
* - it saves a g_list_reverse()
|
||||
* - it avoids duplicated parameter checks
|
||||
* - it makes GimpTemplateEditor work (resolution is set before size)
|
||||
*/
|
||||
diff = gimp_config_diff_internal (src, dest, (flags | G_PARAM_READWRITE));
|
||||
if (G_TYPE_FROM_INSTANCE (src) == G_TYPE_FROM_INSTANCE (dest))
|
||||
diff = gimp_config_diff_same (src, dest, (flags | G_PARAM_READWRITE));
|
||||
else
|
||||
diff = gimp_config_diff_other (src, dest, flags);
|
||||
|
||||
if (!diff)
|
||||
return FALSE;
|
||||
|
@ -275,7 +340,8 @@ gimp_config_sync (GimpConfig *src,
|
|||
* @config: a #GimpConfig
|
||||
*
|
||||
* Resets all writable properties of @object to the default values as
|
||||
* defined in their #GParamSpec.
|
||||
* defined in their #GParamSpec. Properties marked as "construct-only"
|
||||
* are not touched.
|
||||
**/
|
||||
void
|
||||
gimp_config_reset_properties (GimpConfig *config)
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
2004-03-11 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* POTFILES.in: removed app/text/gimptext.c.
|
||||
|
||||
2004-03-11 Gustavo Maciel Dias Vieira <gdvieira@zaz.com.br>
|
||||
|
||||
* pt_BR.po: Updated Brazilian Portuguese translation done by Joao
|
||||
|
|
|
@ -185,7 +185,6 @@ app/text/text-enums.c
|
|||
app/text/gimpfont.c
|
||||
app/text/gimptext-compat.c
|
||||
app/text/gimptext-parasite.c
|
||||
app/text/gimptext.c
|
||||
app/text/gimptextlayer.c
|
||||
app/text/gimptextlayer-transform.c
|
||||
app/text/gimptextlayer-xcf.c
|
||||
|
|
Loading…
Reference in New Issue