#include "gtktexttag.h"
#include "gtktexttypes.h"
#include "gtktexttagtable.h"
-#include "gtksignal.h"
#include "gtkmain.h"
#include "gtkintl.h"
-#include "gtktypebuiltins.h"
+#include "gtkmarshalers.h"
#include <stdlib.h>
#include <string.h>
(GInstanceInitFunc) gtk_text_tag_init
};
- our_type = g_type_register_static (G_TYPE_OBJECT,
- "GtkTextTag",
- &our_info,
- 0);
+ our_type = g_type_register_static (G_TYPE_OBJECT, "GtkTextTag",
+ &our_info, 0);
}
return our_type;
PROP_NAME,
g_param_spec_string ("name",
_("Tag name"),
- _("Name used to refer to the text tag"),
+ _("Name used to refer to the text tag. NULL for anonymous tags"),
NULL,
G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
PROP_BACKGROUND_GDK,
g_param_spec_boxed ("background_gdk",
_("Background color"),
- _("Background color as a GdkColor"),
+ _("Background color as a (possibly unallocated) GdkColor"),
GDK_TYPE_COLOR,
G_PARAM_READABLE | G_PARAM_WRITABLE));
PROP_FOREGROUND_GDK,
g_param_spec_boxed ("foreground_gdk",
_("Foreground color"),
- _("Foreground color as a GdkColor"),
+ _("Foreground color as a (possibly unallocated) GdkColor"),
GDK_TYPE_COLOR,
G_PARAM_READABLE | G_PARAM_WRITABLE));
PROP_FONT,
g_param_spec_string ("font",
_("Font"),
- _("Font description as a string"),
+ _("Font description as a string, e.g. \"Sans Italic 12\""),
NULL,
G_PARAM_READABLE | G_PARAM_WRITABLE));
PROP_STYLE,
g_param_spec_enum ("style",
_("Font style"),
- _("Font style"),
+ _("Font style as a PangoStyle, e.g. PANGO_STYLE_ITALIC"),
PANGO_TYPE_STYLE,
PANGO_STYLE_NORMAL,
G_PARAM_READABLE | G_PARAM_WRITABLE));
PROP_VARIANT,
g_param_spec_enum ("variant",
_("Font variant"),
- _("Font variant"),
+ _("Font variant as a PangoVariant, e.g. PANGO_VARIANT_SMALL_CAPS"),
PANGO_TYPE_VARIANT,
PANGO_VARIANT_NORMAL,
G_PARAM_READABLE | G_PARAM_WRITABLE));
PROP_WEIGHT,
g_param_spec_int ("weight",
_("Font weight"),
- _("Font weight"),
+ _("Font weight as an integer, see predefined values in PangoWeight; for example, PANGO_WEIGHT_BOLD"),
0,
G_MAXINT,
PANGO_WEIGHT_NORMAL,
PROP_STRETCH,
g_param_spec_enum ("stretch",
_("Font stretch"),
- _("Font stretch"),
+ _("Font stretch as a PangoStretch, e.g. PANGO_STRETCH_CONDENSED"),
PANGO_TYPE_STRETCH,
PANGO_STRETCH_NORMAL,
G_PARAM_READABLE | G_PARAM_WRITABLE));
PROP_SIZE,
g_param_spec_int ("size",
_("Font size"),
- _("Font size"),
+ _("Font size in Pango units"),
0,
G_MAXINT,
0,
PROP_SCALE,
g_param_spec_double ("scale",
_("Font scale"),
- _("Font scale"),
+ _("Font size as a scale factor relative to the default font size. This properly adapts to theme changes etc. so is recommended. Pango predefines some scales such as PANGO_SCALE_X_LARGE"),
0.0,
G_MAXDOUBLE,
1.0,
PROP_LANGUAGE,
g_param_spec_string ("language",
_("Language"),
- _("Language engine code to use for rendering the text"),
+ _("The language this text is in, as an ISO code. Pango can use this as a hint when rendering the text. If you don't understand this parameter, you probably don't need it"),
NULL,
G_PARAM_READABLE | G_PARAM_WRITABLE));
PROP_RISE,
g_param_spec_int ("rise",
_("Rise"),
- _("Offset of text above the baseline (below the baseline if rise is negative)"),
+ _("Offset of text above the baseline (below the baseline if rise is negative) in pixels"),
G_MININT,
G_MAXINT,
0,
PROP_INVISIBLE,
g_param_spec_boolean ("invisible",
_("Invisible"),
- _("Whether this text is hidden"),
+ _("Whether this text is hidden. Not implemented in GTK 2.0"),
FALSE,
G_PARAM_READABLE | G_PARAM_WRITABLE));
g_signal_new ("event",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
- GTK_SIGNAL_OFFSET (GtkTextTagClass, event),
+ G_STRUCT_OFFSET (GtkTextTagClass, event),
_gtk_boolean_handled_accumulator, NULL,
- gtk_marshal_BOOLEAN__OBJECT_BOXED_BOXED,
+ _gtk_marshal_BOOLEAN__OBJECT_BOXED_BOXED,
G_TYPE_BOOLEAN,
3,
G_TYPE_OBJECT,
{
GtkTextTag *tag;
- tag = GTK_TEXT_TAG (g_object_new (gtk_text_tag_get_type (),
- "name", name,
- NULL));
+ tag = g_object_new (GTK_TYPE_TEXT_TAG, "name", name, NULL);
return tag;
}
if (text_tag->values->appearance.bg_stipple != bitmap)
{
if (bitmap != NULL)
- gdk_bitmap_ref (bitmap);
+ g_object_ref (bitmap);
if (text_tag->values->appearance.bg_stipple)
- gdk_bitmap_unref (text_tag->values->appearance.bg_stipple);
+ g_object_unref (text_tag->values->appearance.bg_stipple);
text_tag->values->appearance.bg_stipple = bitmap;
}
if (text_tag->values->appearance.fg_stipple != bitmap)
{
if (bitmap != NULL)
- gdk_bitmap_ref (bitmap);
+ g_object_ref (bitmap);
if (text_tag->values->appearance.fg_stipple)
- gdk_bitmap_unref (text_tag->values->appearance.fg_stipple);
+ g_object_unref (text_tag->values->appearance.fg_stipple);
text_tag->values->appearance.fg_stipple = bitmap;
}
font_desc = pango_font_description_from_string (name);
set_font_description (text_tag, font_desc);
+ if (font_desc)
+ pango_font_description_free (font_desc);
size_changed = TRUE;
}
case PROP_BG_FULL_HEIGHT:
text_tag->bg_full_height_set = TRUE;
text_tag->values->bg_full_height = g_value_get_boolean (value);
- g_object_notify (object, "bg_full_height_set");
+ g_object_notify (object, "background_full_height_set");
break;
case PROP_LANGUAGE:
break;
case PROP_INVISIBLE:
+ g_warning ("The \"invisible\" property on GtkTextTag is not supported for GTK 2.0, it will be added in a future release. see http://bugzilla.gnome.org bug #66194 for status.");
text_tag->invisible_set = TRUE;
text_tag->values->invisible = g_value_get_boolean (value);
g_object_notify (object, "invisible_set");
if (!text_tag->bg_stipple_set &&
text_tag->values->appearance.bg_stipple)
{
- g_object_unref (G_OBJECT (text_tag->values->appearance.bg_stipple));
+ g_object_unref (text_tag->values->appearance.bg_stipple);
text_tag->values->appearance.bg_stipple = NULL;
}
break;
if (!text_tag->fg_stipple_set &&
text_tag->values->appearance.fg_stipple)
{
- g_object_unref (G_OBJECT (text_tag->values->appearance.fg_stipple));
+ g_object_unref (text_tag->values->appearance.fg_stipple);
text_tag->values->appearance.fg_stipple = NULL;
}
break;
*/
if (text_tag->table)
- g_signal_emit_by_name (G_OBJECT (text_tag->table),
+ g_signal_emit_by_name (text_tag->table,
"tag_changed",
text_tag, size_changed);
}
-static void
-get_color_arg (GValue *value, GdkColor *orig)
-{
- GdkColor *color;
-
- color = g_new (GdkColor, 1);
- *color = *orig;
- g_value_init (value, GDK_TYPE_COLOR);
- g_value_set_boxed (value, color);
-}
-
static void
gtk_text_tag_get_property (GObject *object,
guint prop_id,
break;
case PROP_BACKGROUND_GDK:
- get_color_arg (value, &tag->values->appearance.bg_color);
+ g_value_set_boxed (value, &tag->values->appearance.bg_color);
break;
case PROP_FOREGROUND_GDK:
- get_color_arg (value, &tag->values->appearance.fg_color);
+ g_value_set_boxed (value, &tag->values->appearance.fg_color);
break;
case PROP_BACKGROUND_STIPPLE:
g_return_val_if_fail (G_IS_OBJECT (event_object), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
- g_signal_emit (G_OBJECT (tag),
+ g_signal_emit (tag,
signals[EVENT],
0,
event_object,
return dest;
}
+GType
+gtk_text_attributes_get_type (void)
+{
+ static GType our_type = 0;
+
+ if (our_type == 0)
+ our_type = g_boxed_type_register_static ("GtkTextAttributes",
+ (GBoxedCopyFunc) gtk_text_attributes_ref,
+ (GBoxedFreeFunc) gtk_text_attributes_unref);
+
+ return our_type;
+}
+
/**
* gtk_text_attributes_copy_values:
* @src: a #GtkTextAttributes
/* Add refs */
if (src->appearance.bg_stipple)
- gdk_bitmap_ref (src->appearance.bg_stipple);
+ g_object_ref (src->appearance.bg_stipple);
if (src->appearance.fg_stipple)
- gdk_bitmap_ref (src->appearance.fg_stipple);
+ g_object_ref (src->appearance.fg_stipple);
/* Remove refs */
if (dest->appearance.bg_stipple)
- gdk_bitmap_unref (dest->appearance.bg_stipple);
+ g_object_unref (dest->appearance.bg_stipple);
if (dest->appearance.fg_stipple)
- gdk_bitmap_unref (dest->appearance.fg_stipple);
+ g_object_unref (dest->appearance.fg_stipple);
if (dest->font)
pango_font_description_free (dest->font);
g_assert (!values->realized);
if (values->appearance.bg_stipple)
- gdk_bitmap_unref (values->appearance.bg_stipple);
+ g_object_unref (values->appearance.bg_stipple);
if (values->appearance.fg_stipple)
- gdk_bitmap_unref (values->appearance.fg_stipple);
+ g_object_unref (values->appearance.fg_stipple);
if (values->tabs)
pango_tab_array_free (values->tabs);
if (tag->bg_stipple_set)
{
- gdk_bitmap_ref (vals->appearance.bg_stipple);
+ g_object_ref (vals->appearance.bg_stipple);
if (dest->appearance.bg_stipple)
- gdk_bitmap_unref (dest->appearance.bg_stipple);
+ g_object_unref (dest->appearance.bg_stipple);
dest->appearance.bg_stipple = vals->appearance.bg_stipple;
dest->appearance.draw_bg = TRUE;
if (tag->fg_stipple_set)
{
- gdk_bitmap_ref (vals->appearance.fg_stipple);
+ g_object_ref (vals->appearance.fg_stipple);
if (dest->appearance.fg_stipple)
- gdk_bitmap_unref (dest->appearance.fg_stipple);
+ g_object_unref (dest->appearance.fg_stipple);
dest->appearance.fg_stipple = vals->appearance.fg_stipple;
}