* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free
- * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.Free
*
* Original Tk license:
*
#define PIXEL_BOUND(d) (((d) + PANGO_SCALE - 1) / PANGO_SCALE)
-static void gtk_text_layout_finalize (GObject *object);
-
static guint signals[LAST_SIGNAL] = { 0 };
PangoAttrType gtk_text_attr_appearance_type = 0;
G_DEFINE_TYPE (GtkTextLayout, gtk_text_layout, G_TYPE_OBJECT)
+static void
+gtk_text_layout_dispose (GObject *object)
+{
+ GtkTextLayout *layout;
+
+ layout = GTK_TEXT_LAYOUT (object);
+
+ gtk_text_layout_set_buffer (layout, NULL);
+
+ if (layout->default_style != NULL)
+ {
+ gtk_text_attributes_unref (layout->default_style);
+ layout->default_style = NULL;
+ }
+
+ g_clear_object (&layout->ltr_context);
+ g_clear_object (&layout->rtl_context);
+
+ if (layout->one_display_cache)
+ {
+ GtkTextLineDisplay *tmp_display = layout->one_display_cache;
+ layout->one_display_cache = NULL;
+ gtk_text_layout_free_line_display (layout, tmp_display);
+ }
+
+ if (layout->preedit_attrs != NULL)
+ {
+ pango_attr_list_unref (layout->preedit_attrs);
+ layout->preedit_attrs = NULL;
+ }
+
+ G_OBJECT_CLASS (gtk_text_layout_parent_class)->dispose (object);
+}
+
+static void
+gtk_text_layout_finalize (GObject *object)
+{
+ GtkTextLayout *layout;
+
+ layout = GTK_TEXT_LAYOUT (object);
+
+ g_free (layout->preedit_string);
+
+ G_OBJECT_CLASS (gtk_text_layout_parent_class)->finalize (object);
+}
+
static void
gtk_text_layout_class_init (GtkTextLayoutClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->dispose = gtk_text_layout_dispose;
object_class->finalize = gtk_text_layout_finalize;
klass->wrap = gtk_text_layout_real_wrap;
G_TYPE_INT,
G_TYPE_INT,
G_TYPE_INT);
+ g_signal_set_va_marshaller (signals[CHANGED], G_TYPE_FROM_CLASS (klass),
+ _gtk_marshal_VOID__INT_INT_INTv);
signals[ALLOCATE_CHILD] =
g_signal_new (I_("allocate-child"),
}
}
-static void
-gtk_text_layout_finalize (GObject *object)
-{
- GtkTextLayout *layout;
-
- layout = GTK_TEXT_LAYOUT (object);
-
- gtk_text_layout_set_buffer (layout, NULL);
-
- if (layout->default_style)
- gtk_text_attributes_unref (layout->default_style);
- layout->default_style = NULL;
-
- if (layout->ltr_context)
- {
- g_object_unref (layout->ltr_context);
- layout->ltr_context = NULL;
- }
- if (layout->rtl_context)
- {
- g_object_unref (layout->rtl_context);
- layout->rtl_context = NULL;
- }
-
- if (layout->one_display_cache)
- {
- GtkTextLineDisplay *tmp_display = layout->one_display_cache;
- layout->one_display_cache = NULL;
- gtk_text_layout_free_line_display (layout, tmp_display);
- }
-
- if (layout->preedit_string)
- {
- g_free (layout->preedit_string);
- layout->preedit_string = NULL;
- }
-
- if (layout->preedit_attrs)
- {
- pango_attr_list_unref (layout->preedit_attrs);
- layout->preedit_attrs = NULL;
- }
-
-
- G_OBJECT_CLASS (gtk_text_layout_parent_class)->finalize (object);
-}
-
/**
* gtk_text_layout_set_buffer:
* @buffer: (allow-none):
}
static void
-convert_color (GdkColor *result,
+convert_color (GdkRGBA *result,
PangoAttrColor *attr)
{
- result->red = attr->color.red;
- result->blue = attr->color.blue;
- result->green = attr->color.green;
+ result->red = attr->color.red / 65535.;
+ result->blue = attr->color.blue / 65535.;
+ result->green = attr->color.green / 65535.;
+ result->alpha = 1;
}
/* This function is used to convert the preedit string attributes, which are
while (tmp_list)
{
PangoAttribute *attr = tmp_list->data;
+ GdkRGBA rgba;
switch (attr->klass->type)
{
case PANGO_ATTR_FOREGROUND:
- convert_color (&appearance.fg_color, (PangoAttrColor *)attr);
+ convert_color (&rgba, (PangoAttrColor *)attr);
+ if (appearance.rgba[1])
+ gdk_rgba_free (appearance.rgba[1]);
+ appearance.rgba[1] = gdk_rgba_copy (&rgba);
break;
case PANGO_ATTR_BACKGROUND:
- convert_color (&appearance.bg_color, (PangoAttrColor *)attr);
+ convert_color (&rgba, (PangoAttrColor *)attr);
+ if (appearance.rgba[0])
+ gdk_rgba_free (appearance.rgba[0]);
+ appearance.rgba[0] = gdk_rgba_copy (&rgba);
appearance.draw_bg = TRUE;
break;
case PANGO_ATTR_UNDERLINE:
DV (g_print ("creating one line display cache (%s)\n", G_STRLOC));
- display = g_new0 (GtkTextLineDisplay, 1);
+ display = g_slice_new0 (GtkTextLineDisplay);
display->size_only = size_only;
display->line = line;
if (display->pg_bg_rgba)
gdk_rgba_free (display->pg_bg_rgba);
- g_free (display);
+ g_slice_free (GtkTextLineDisplay, display);
}
}