Example #1
0
static VALUE
rg_modify_cursor(VALUE self, VALUE primary, VALUE seconday)
{
    gtk_widget_modify_cursor(_SELF(self),
                             RVAL2BOXED(primary, GDK_TYPE_COLOR),
                             RVAL2BOXED(seconday, GDK_TYPE_COLOR));
    return self;
}
Example #2
0
static VALUE
rg_draw_glyphs_transformed(VALUE self, VALUE gc, VALUE matrix, VALUE font, VALUE x, VALUE y, VALUE glyphs)
{
    gdk_draw_glyphs_transformed(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), 
                                NIL_P(matrix) ? (PangoMatrix*)NULL : (PangoMatrix*)(RVAL2BOXED(matrix, PANGO_TYPE_MATRIX)),
                                PANGO_FONT(RVAL2GOBJ(font)),
                                NUM2INT(x), NUM2INT(y), 
                                (PangoGlyphString*)(RVAL2BOXED(glyphs, PANGO_TYPE_GLYPH_STRING)));
    return self;
}
Example #3
0
static VALUE
rg_set_color(VALUE self, VALUE part, VALUE color)
{
#ifdef HAVE_PANGO_RENDER_PART_GET_TYPE
    pango_renderer_set_color(_SELF(self), RVAL2GENUM(part, PANGO_TYPE_RENDER_PART),
                             (PangoColor*)(NIL_P(color) ? NULL : RVAL2BOXED(color, PANGO_TYPE_COLOR)));
#else
    pango_renderer_set_color(_SELF(self), NUM2INT(part),
                             (PangoColor*)(NIL_P(color) ? NULL : RVAL2BOXED(color, PANGO_TYPE_COLOR)));
#endif
    return self;
}
Example #4
0
static VALUE
gdkwin_begin_paint(VALUE self, VALUE area)
{
    if (rb_obj_is_kind_of(area, GTYPE2CLASS(GDK_TYPE_RECTANGLE))){
        gdk_window_begin_paint_rect(_SELF(self), 
                                    (GdkRectangle*)RVAL2BOXED(area, GDK_TYPE_RECTANGLE));
    } else {
        gdk_window_begin_paint_region(_SELF(self),
                                      (GdkRegion*)RVAL2BOXED(area, GDK_TYPE_REGION));
    }
    return self;
}
Example #5
0
static VALUE
gdkwin_invalidate(VALUE self, VALUE area, VALUE invalidate_children)
{
    if (rb_obj_is_kind_of(area, GTYPE2CLASS(GDK_TYPE_REGION))){
        gdk_window_invalidate_region(_SELF(self),
                                     RVAL2BOXED(area, GDK_TYPE_REGION),
                                     RVAL2CBOOL(invalidate_children));
    } else {
        gdk_window_invalidate_rect(_SELF(self),
                                   RVAL2BOXED(area, GDK_TYPE_RECTANGLE),
                                   RVAL2CBOOL(invalidate_children));
    }
    return self;
}
Example #6
0
static VALUE
rg_set_matrix(VALUE self, VALUE matrix)
{
    pango_renderer_set_matrix(_SELF(self), 
                              (PangoMatrix*)(NIL_P(matrix) ? NULL : RVAL2BOXED(matrix, PANGO_TYPE_MATRIX)));
    return self;
}
Example #7
0
static VALUE
rg_modify_font(VALUE self, VALUE font_desc)
{
    gtk_widget_modify_font(_SELF(self),
                           (PangoFontDescription*)RVAL2BOXED(font_desc, PANGO_TYPE_FONT_DESCRIPTION));
    return self;
}
Example #8
0
static VALUE
rg_set_attributes(VALUE self, VALUE attrs)
{
    pango_layout_set_attributes(_SELF(self), 
                                (PangoAttrList*)(RVAL2BOXED(attrs, PANGO_TYPE_ATTR_LIST)));
    return self;
}
Example #9
0
static VALUE
rg_invalidate(VALUE self)
{
    GClosure* closure = RVAL2BOXED(self, G_TYPE_CLOSURE);
    g_closure_invalidate(closure);
    return self;
}
Example #10
0
static VALUE
rb_cogl_color (int argc, VALUE *argv, VALUE self)
{
  /* Accept either a single ClutterColor argument or up to four
     components */
  if (argc == 1
      && RTEST (rb_obj_is_kind_of (argv[0], GTYPE2CLASS (CLUTTER_TYPE_COLOR))))
    {
      const ClutterColor *color
        = (const ClutterColor *) RVAL2BOXED (argv[0], CLUTTER_TYPE_COLOR);

      cogl_color (color);
    }
  else
    {
      VALUE r, g, b, a;
      ClutterColor color;

      rb_scan_args (argc, argv, "04", &r, &g, &b, &a);

      color.red = NIL_P (r) ? 0 : rbclt_num_to_guint8 (r);
      color.green = NIL_P (g) ? 0 : rbclt_num_to_guint8 (g);
      color.blue = NIL_P (b) ? 0 : rbclt_num_to_guint8 (b);
      color.alpha = NIL_P (a) ? 255 : rbclt_num_to_guint8 (a);

      cogl_color (&color);
    }

  return Qnil;
}
Example #11
0
static VALUE
rg_add(VALUE self, VALUE id, VALUE icon_set)
{
    gtk_icon_factory_add(_SELF(self), RVAL2CSTR(id),
                         (GtkIconSet*)RVAL2BOXED(icon_set, GTK_TYPE_ICON_SET));
    return self;
}
Example #12
0
static VALUE
rg_set_clip_region(VALUE self, VALUE region)
{
    gdk_gc_set_clip_region(_SELF(self),
                           (GdkRegion*)RVAL2BOXED(region, GDK_TYPE_REGION));
    return self;
}
Example #13
0
static VALUE
rg_set_clip_rectangle(VALUE self, VALUE rectangle)
{
    gdk_gc_set_clip_rectangle(_SELF(self),
                              (GdkRectangle*)RVAL2BOXED(rectangle, GDK_TYPE_RECTANGLE));
    return self;
}
Example #14
0
static VALUE
rg_set_cursor(VALUE self, VALUE cursor)
{
    gdk_window_set_cursor(_SELF(self),
                          RVAL2BOXED(cursor, GDK_TYPE_CURSOR));
    return self;
}
Example #15
0
static VALUE
rbclt_stage_set_fog (int argc, VALUE *argv, VALUE self)
{
  ClutterStage *stage = CLUTTER_STAGE (RVAL2GOBJ (self));

  if (argc == 1)
    {
      ClutterFog *fog = (ClutterFog *) RVAL2BOXED (argv[0], CLUTTER_TYPE_FOG);
      clutter_stage_set_fogx (stage, fog);
    }
  else
    {
      VALUE density, z_near, z_far;
      ClutterFog *fog = (ClutterFog*) g_malloc(sizeof(ClutterFog));

      rb_scan_args (argc, argv, "03", &density, &z_near, &z_far);

      fog->z_near = NUM2FLOAT (z_near);
      fog->z_far = NUM2FLOAT (z_far);

      clutter_stage_set_fog (stage, fog);
      /* FIXME: g_free(fog); # argh, once again can't do this. another leak...? */
    }

  return self;
}
Example #16
0
static VALUE
rpango_break(VALUE self, VALUE text, VALUE analysis)
{
    gint i, len;
    glong attrs_len;
    PangoLogAttr *attrs;
    const gchar *gtext;
    VALUE ret;

    gtext = StringValuePtr(text);
    len = RSTRING_LEN(text);
    attrs_len = g_utf8_strlen(gtext, (gssize)len) + 1l;
    attrs = g_new0(PangoLogAttr, attrs_len);

    pango_break(gtext, len,
                NIL_P(analysis) ? NULL : RVAL2BOXED(analysis, PANGO_TYPE_ANALYSIS),
                attrs, attrs_len);

    ret = rb_ary_new();
    for (i = 0; i < attrs_len; i++){
        rb_ary_push(ret, BOXED2RVAL(&attrs[i], PANGO_TYPE_LOG_ATTR));
    }
    g_free(attrs);
    return ret;
}
Example #17
0
static VALUE
rbclt_text_initialize (int argc, VALUE *argv, VALUE self)
{
  VALUE font_name, text, color;
  gchar *font_name_s = NULL, *text_s = NULL;
  ClutterColor *color_s = NULL;
  ClutterActor *actor;

  rb_scan_args (argc, argv, "03", &font_name, &text, &color);

  if (!NIL_P (font_name))
    font_name_s = StringValuePtr (font_name);
  if (!NIL_P (text))
    text_s = StringValuePtr (text);
  if (!NIL_P (color))
    color_s = (ClutterColor *) RVAL2BOXED (color, CLUTTER_TYPE_COLOR);

  actor = clutter_text_new ();

  if (font_name_s)
    clutter_text_set_font_name (CLUTTER_TEXT (actor), font_name_s);
  if (text_s)
    clutter_text_set_text (CLUTTER_TEXT (actor), text_s);
  if (color_s)
    clutter_text_set_color (CLUTTER_TEXT (actor), color_s);

  rbclt_initialize_unowned (self, actor);

  return Qnil;
}
Example #18
0
static VALUE
rg_set_tabs(VALUE self, VALUE tabs)
{
    pango_layout_set_tabs(_SELF(self), 
                          (PangoTabArray*)RVAL2BOXED(tabs, PANGO_TYPE_TAB_ARRAY));
    return self;
}
Example #19
0
static VALUE
rpango_get_log_attrs(VALUE self, VALUE text, VALUE level, VALUE language)
{
    gint i, len;
    glong attrs_len;
    PangoLogAttr *attrs;
    const gchar *gtext;
    VALUE ret;

    gtext = StringValuePtr(text);
    len = RSTRING_LEN(text);
    attrs_len = g_utf8_strlen(gtext, (gssize)len) + 1l;
    attrs = g_new0(PangoLogAttr, attrs_len);

    pango_get_log_attrs(gtext, len, NUM2INT(level),
                        RVAL2BOXED(language, PANGO_TYPE_LANGUAGE),
                        attrs, attrs_len);

    ret = rb_ary_new();
    for (i = 0; i < attrs_len; i++){
        rb_ary_push(ret, BOXED2RVAL(&attrs[i], PANGO_TYPE_LOG_ATTR));
    }
    g_free(attrs);
    return ret;
}
Example #20
0
static VALUE
rbclt_stage_set_perspective (int argc, VALUE *argv, VALUE self)
{
  ClutterStage *stage = CLUTTER_STAGE (RVAL2GOBJ (self));

  if (argc == 1)
    {
      ClutterPerspective *persp
        = (ClutterPerspective *) RVAL2BOXED (argv[0], CLUTTER_TYPE_PERSPECTIVE);
      clutter_stage_set_perspective (stage, persp);
    }
  else if (argc == 4) {
    ClutterPerspective *persp = (ClutterPerspective*) g_malloc(sizeof(ClutterPerspective));
    persp->fovy = NUM2FLOAT (argv[0]);
    persp->aspect = NUM2FLOAT (argv[1]);
    persp->z_near = NUM2FLOAT (argv[2]);
    persp->z_far =  NUM2DBL (argv[3]);
    clutter_stage_set_perspective (stage, persp);
    /* FIXME: g_free(persp); # I can't do this!  It has to be a leak.  Really, support for
       inline perspective values should just go away. */
  }
  else
    rb_raise (rb_eArgError, "wrong number of arguments (%d for 1 or 4)", argc);

  return self;
}
Example #21
0
static VALUE
item_set_analysis(VALUE self, VALUE val)
{
    PangoAnalysis* ana = (PangoAnalysis*)RVAL2BOXED(val, PANGO_TYPE_ANALYSIS);
    _SELF(self)->analysis = *ana;
    return self;
}
Example #22
0
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE points_or_rectangle, rbfill_rule;
    GdkRegion *region;

    rb_scan_args(argc, argv, "02", &points_or_rectangle, &rbfill_rule);
    if (NIL_P(points_or_rectangle)) {
        region = gdk_region_new();
    } else if (TYPE(points_or_rectangle) == T_ARRAY) {
        GdkFillRule fill_rule = RVAL2GENUM(rbfill_rule, GDK_TYPE_FILL_RULE);
        long n;
        GdkPoint *points = RVAL2GDKPOINTS(points_or_rectangle, &n);

        region = gdk_region_polygon(points, n, fill_rule);

        g_free(points);
    } else if (RVAL2GTYPE(points_or_rectangle) == GDK_TYPE_RECTANGLE) {
        region = gdk_region_rectangle((GdkRectangle*)RVAL2BOXED(points_or_rectangle, 
                                                                GDK_TYPE_RECTANGLE));
    } else {
        rb_raise(rb_eArgError, 
                 "invalid argument %s (expect array of Gdk::Point or Gdk::Rectangle, nil)",
                 rb_class2name(CLASS_OF(points_or_rectangle)));
    }

    G_INITIALIZE(self, region);

    return Qnil;
}
Example #23
0
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE arg1, arg2;
    GtkPrintSettings* settings = NULL;
    GError *error = NULL;
    rb_scan_args(argc, argv, "02", &arg1, &arg2);
    if (NIL_P(arg1)){
        settings = gtk_print_settings_new();
    } else if (NIL_P(arg2)){
        settings = gtk_print_settings_new_from_file(RVAL2CSTR(arg1), &error);
        if (!settings) {
            RAISE_GERROR(error);
        }
    } else {
        settings = gtk_print_settings_new_from_key_file((GKeyFile*)RVAL2BOXED(arg1, G_TYPE_KEY_FILE),
                                                        RVAL2CSTR(arg2),
                                                        &error);
        if (!settings) {
            RAISE_GERROR(error);
        }
    }
    G_INITIALIZE(self, settings);
    return Qnil;
}
Example #24
0
static VALUE
rg_set_paper_size(VALUE self, VALUE paper_size)
{
    gtk_print_settings_set_paper_size(_SELF(self), 
                                      RVAL2BOXED(paper_size, GTK_TYPE_PAPER_SIZE));
    return self;
}
Example #25
0
static VALUE
rg_region_intersect(VALUE self, VALUE region)
{
    return BOXED2RVAL(gtk_widget_region_intersect(_SELF(self),
                                                  (GdkRegion*)RVAL2BOXED(region, GDK_TYPE_REGION)),
                      GDK_TYPE_REGION);
}
Example #26
0
static VALUE
gdkwin_shape_combine_region(VALUE self, VALUE shape_region, VALUE offset_x, VALUE offset_y)
{
    gdk_window_shape_combine_region(_SELF(self),
                                    NIL_P(shape_region) ? NULL : (GdkRegion*)RVAL2BOXED(shape_region, GDK_TYPE_REGION),
                                    INT2NUM(offset_x), INT2NUM(offset_y));
    return self;
}
static VALUE
rbclt_behaviour_path_insert_knot (VALUE self, VALUE offset, VALUE knot)
{
  ClutterBehaviourPath *bpath = CLUTTER_BEHAVIOUR_PATH (RVAL2GOBJ (self));
  clutter_behaviour_path_insert_knot (bpath, NUM2UINT (offset),
                                      RVAL2BOXED (knot, CLUTTER_TYPE_KNOT));
  return self;
}
Example #28
0
static VALUE
rg_set_cursor_location(VALUE self, VALUE area)
{
    gtk_im_context_set_cursor_location(
        _SELF(self), 
        ((GdkRectangle*)RVAL2BOXED(area, GDK_TYPE_RECTANGLE)));
    return self;
}
Example #29
0
static VALUE
rg_rect_in(VALUE self, VALUE rect)
{
    return GENUM2RVAL(gdk_region_rect_in(
                          _SELF(self),
                          (GdkRectangle*)RVAL2BOXED(rect, GDK_TYPE_RECTANGLE)),
                      GDK_TYPE_OVERLAP_TYPE);
}
Example #30
0
static VALUE
rg_draw_layout_line(VALUE self, VALUE line, VALUE x, VALUE y)
{
    pango_renderer_draw_layout_line(_SELF(self),  
                                    (PangoLayoutLine*)RVAL2BOXED(line, PANGO_TYPE_LAYOUT_LINE),
                                    NUM2INT(x), NUM2INT(y));
    return self;
}