Ejemplo n.º 1
0
void iupdrvFontFinish(void)
{
  int i, count = iupArrayCount(gtk_fonts);
  IgtkFont* fonts = (IgtkFont*)iupArrayGetData(gtk_fonts);
  for (i = 0; i < count; i++)
  {
    pango_font_description_free(fonts[i].fontdesc);
    pango_attribute_destroy(fonts[i].strikethrough);
    pango_attribute_destroy(fonts[i].underline);
  }
  iupArrayDestroy(gtk_fonts);
  g_object_unref(gtk_fonts_context);
}
Ejemplo n.º 2
0
/**
 * wbcg_edit_add_markup:
 * @wbcg: #WBCGtk
 * @attr: #PangoAttribute
 *
 * Absorbs the ref to @attr.
 **/
void
wbcg_edit_add_markup (WBCGtk *wbcg, PangoAttribute *attr)
{
	GObject *entry = (GObject *)wbcg_get_entry (wbcg);
	if (wbcg->edit_line.full_content == NULL)
		wbcg_edit_init_markup (wbcg, pango_attr_list_new ());

	if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry),
					       &attr->start_index, &attr->end_index)) {
		char const *str = gtk_entry_get_text (GTK_ENTRY (entry));

		attr->start_index = g_utf8_offset_to_pointer (str, attr->start_index) - str;
		attr->end_index = g_utf8_offset_to_pointer (str, attr->end_index) - str;
		set_or_unset (wbcg->edit_line.full_content, attr,
			      wbcg->edit_line.cell_attrs);
		set_or_unset (wbcg->edit_line.markup, attr,
			      wbcg->edit_line.cell_attrs);
	}

	/* the format to use when inserting text, we will resize it later */
	attr->start_index = 0;
	attr->end_index = INT_MAX;
	set_or_unset (wbcg->edit_line.cur_fmt, attr,
		      wbcg->edit_line.cell_attrs);
	pango_attribute_destroy (attr);
	wbc_gtk_markup_changer (wbcg);
}
Ejemplo n.º 3
0
void
Init_gtk_gdk_pango()
{
    VALUE klass;
    PangoAttribute* tmpattr;
    GdkColor color;

    VALUE mGdkPango = rb_define_module_under(mGdk, "Pango");
    VALUE context = GTYPE2CLASS(PANGO_TYPE_CONTEXT);
    VALUE layout = GTYPE2CLASS(PANGO_TYPE_LAYOUT);
    VALUE layoutline = GTYPE2CLASS(PANGO_TYPE_LAYOUT_LINE);
    VALUE pattr = ATTRTYPE2CLASS(CSTR2RVAL("Attribute"));
    VALUE pattrbool = ATTRTYPE2CLASS(CSTR2RVAL("AttrBool"));
    VALUE pattr_color = ATTRTYPE2CLASS(CSTR2RVAL("AttrColor"));

    rb_define_module_function(mGdkPango, "context", gdkpango_s_context_get, -1);

    rb_define_method(context, "set_colormap", gdkpango_context_set_colormap, 1);
    G_DEF_SETTER(context, "colormap");
    rb_define_method(layout, "get_clip_region", gdkpango_layout_get_clip_region, 3);
    rb_define_method(layoutline, "get_clip_region", gdkpango_layout_line_get_clip_region, 3);

    klass = rb_define_class_under(mGdk, "PangoAttrEmbossed", pattrbool);
    rb_define_method(klass, "initialize", gdkpango_attr_embossed_initialize, 1);
    tmpattr = gdk_pango_attr_embossed_new(TRUE);
    rb_define_method(klass, "value", gdkpango_attr_embossed_value, 0);
    RBPANGO_ADD_ATTRIBUTE(tmpattr->klass->type, klass);
    pango_attribute_destroy(tmpattr);

    klass = rb_define_class_under(mGdk, "PangoAttrStipple", pattr);
    rb_define_method(klass, "initialize", gdkpango_attr_stipple_initialize, 1);
    rb_define_method(klass, "value", gdkpango_attr_stipple_value, 0);
    tmpattr = gdk_pango_attr_stipple_new(NULL);
    RBPANGO_ADD_ATTRIBUTE(tmpattr->klass->type, klass);
    pango_attribute_destroy(tmpattr);

#if GTK_CHECK_VERSION(2, 12, 0)
    klass = rb_define_class_under(mGdk, "PangoAttrEmbossColor", pattr_color);
    rb_define_method(klass, "initialize",
		     gdkpango_attr_emboss_color_initialize, 1);
    rb_define_method(klass, "value", gdkpango_attr_emboss_color_value, 0);
    tmpattr = gdk_pango_attr_emboss_color_new(&color);
    RBPANGO_ADD_ATTRIBUTE(tmpattr->klass->type, klass);
    pango_attribute_destroy(tmpattr);
#endif
}
Ejemplo n.º 4
0
static void
add_attribute (OpenTag        *ot,
	       PangoAttribute *attr)
{
  if (ot == NULL)
    pango_attribute_destroy (attr);
  else
    ot->attrs = g_slist_prepend (ot->attrs, attr);
}
Ejemplo n.º 5
0
Gosu::pango::~pango()
{
    g_object_unref(context);
    g_object_unref(layout);
    
    if(font_description)
        pango_font_description_free(font_description);
    if(attr)
        pango_attribute_destroy(attr);
}
Ejemplo n.º 6
0
static void
cb_entry_cursor_pos (WBCGtk *wbcg)
{
	gint start, end, target_pos_in_chars, target_pos_in_bytes;
	GtkEditable *entry = GTK_EDITABLE (wbcg_get_entry (wbcg));
	char const *str = gtk_entry_get_text (GTK_ENTRY (entry));
	int edit_pos = gtk_editable_get_position (entry);

	if (str[0] == 0)
		return;

	if (edit_pos != gtk_entry_get_text_length (GTK_ENTRY (entry))) {
		/* The cursor is no longer at the end.  */
		wbcg->auto_completing = FALSE;
	}

	if (!wbcg->edit_line.full_content)
		return;

	/* 1) Use first selected character if there is a selection
	 * 2) Use the character just before the edit pos if it exists
	 * 3) Use the first character */
	if (gtk_editable_get_selection_bounds (entry, &start, &end))
		target_pos_in_chars = start;
	else {
		target_pos_in_chars = edit_pos;
		if (target_pos_in_chars > 0)
			target_pos_in_chars--;
	}

	target_pos_in_bytes = g_utf8_offset_to_pointer (str, target_pos_in_chars) - str;

	/* Make bold/italic/etc buttons show the right thing.  */
	{
		GnmStyle *style = gnm_style_new ();
		GSList *ptr, *attrs = attrs_at_byte (wbcg->edit_line.full_content, target_pos_in_bytes);
		for (ptr = attrs; ptr != NULL ; ptr = ptr->next) {
			PangoAttribute *attr = ptr->data;
			gnm_style_set_from_pango_attribute (style, attr);
			pango_attribute_destroy (attr);
		}
		wb_control_style_feedback (GNM_WBC (wbcg), style);
		gnm_style_unref (style);
		g_slist_free (attrs);
	}

	set_cur_fmt (wbcg, target_pos_in_bytes);
}
Ejemplo n.º 7
0
static VALUE
rg_attrs(VALUE self)
{
    GSList* list = pango_attr_iterator_get_attrs(_SELF(self));
    GSList* base = list;
    GSList* old = list;
    VALUE ary = rb_ary_new();

    while (list) {
        rb_ary_push(ary, ATTR2RVAL(list->data));
        list = list->next;
    }
    while (old) {
        pango_attribute_destroy((PangoAttribute*)old);
        old = old->next;
    }
    g_slist_free(base);

    return ary;
}