]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtktexttag.c
Get rid of incorrect calls to g_value_init(). (#100669, Johan Dahlin,
[~andy/gtk] / gtk / gtktexttag.c
index 82fdc836f2be1449c68088a2b3c90e26bcc45e5b..38c314e8e083cfb76bf4fba1f2778aa4abded84b 100644 (file)
 #include "gtktexttag.h"
 #include "gtktexttypes.h"
 #include "gtktexttagtable.h"
-#include "gtksignal.h"
 #include "gtkmain.h"
 #include "gtkintl.h"
 #include "gtkmarshalers.h"
-#include "gtktypebuiltins.h"
 
 #include <stdlib.h>
 #include <string.h>
@@ -171,10 +169,8 @@ gtk_text_tag_get_type (void)
         (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;
@@ -197,7 +193,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    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));
 
@@ -215,7 +211,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    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));
 
@@ -249,7 +245,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    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));
 
@@ -283,7 +279,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    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));
 
@@ -308,7 +304,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    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));
@@ -317,7 +313,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    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));
@@ -326,7 +322,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    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,
@@ -337,7 +333,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    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));
@@ -346,7 +342,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    PROP_SIZE,
                                    g_param_spec_int ("size",
                                                      _("Font size"),
-                                                     _("Font size"),
+                                                     _("Font size in Pango units"),
                                                      0,
                                                      G_MAXINT,
                                                      0,
@@ -356,7 +352,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    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,
@@ -385,7 +381,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    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));  
 
@@ -425,7 +421,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    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,
@@ -500,7 +496,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
                                    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));
 
@@ -620,7 +616,7 @@ gtk_text_tag_class_init (GtkTextTagClass *klass)
     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,
                   G_TYPE_BOOLEAN,
@@ -653,9 +649,7 @@ gtk_text_tag_new (const gchar *name)
 {
   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;
 }
@@ -958,10 +952,10 @@ gtk_text_tag_set_property (GObject      *object,
         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;
           }
@@ -978,10 +972,10 @@ gtk_text_tag_set_property (GObject      *object,
         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;
           }
@@ -999,6 +993,8 @@ gtk_text_tag_set_property (GObject      *object,
           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;
       }
@@ -1166,7 +1162,7 @@ gtk_text_tag_set_property (GObject      *object,
     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:
@@ -1191,6 +1187,7 @@ gtk_text_tag_set_property (GObject      *object,
       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");
@@ -1212,7 +1209,7 @@ gtk_text_tag_set_property (GObject      *object,
       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;
@@ -1222,7 +1219,7 @@ gtk_text_tag_set_property (GObject      *object,
       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;
@@ -1347,22 +1344,11 @@ gtk_text_tag_set_property (GObject      *object,
    */
 
   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,
@@ -1380,11 +1366,11 @@ gtk_text_tag_get_property (GObject      *object,
       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:
@@ -1746,7 +1732,7 @@ gtk_text_tag_event (GtkTextTag        *tag,
   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,
@@ -1866,6 +1852,19 @@ gtk_text_attributes_copy (GtkTextAttributes *src)
   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
@@ -1888,18 +1887,18 @@ gtk_text_attributes_copy_values (GtkTextAttributes *src,
   /* 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);
@@ -1955,10 +1954,10 @@ gtk_text_attributes_unref (GtkTextAttributes *values)
       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);
@@ -2042,9 +2041,9 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
       
       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;
@@ -2052,9 +2051,9 @@ _gtk_text_attributes_fill_from_tags (GtkTextAttributes *dest,
 
       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;
         }