static VALUE rval2atkstatetype_body(VALUE value) { long i; struct rval2atkstatetype_args *args = (struct rval2atkstatetype_args *)value; for (i = 0; i < args->n; i++) args->result[i] = RVAL2GENUM(RARRAY_PTR(args->ary)[i], ATK_TYPE_STATE_TYPE); return Qnil; }
static VALUE style_s_draw_insertion_cursor(VALUE self, VALUE widget, VALUE drawable, VALUE area, VALUE location, VALUE is_primary, VALUE direction, VALUE draw_arrow) { gtk_draw_insertion_cursor(GTK_WIDGET(RVAL2GOBJ(widget)), GDK_WINDOW(RVAL2GOBJ(drawable)), RVAL2REC(area), RVAL2REC(location), RVAL2CBOOL(is_primary), RVAL2GENUM(direction, GTK_TYPE_TEXT_DIRECTION), RVAL2CBOOL(draw_arrow)); return self; }
static VALUE rg_set_function(VALUE self, VALUE func) { GdkFunction f; f = (GdkFunction)(RVAL2GENUM(func, GDK_TYPE_FUNCTION)); if (f > GDK_SET) rb_raise(rb_eArgError, "function out of range"); gdk_gc_set_function(_SELF(self), f); return self; }
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; }
static VALUE style_paint_resize_grip(VALUE self, VALUE gdkwindow, VALUE state_type, VALUE area, VALUE widget, VALUE detail, VALUE edge, VALUE x, VALUE y, VALUE width, VALUE height) { gtk_paint_resize_grip(_SELF(self), GDK_WINDOW(RVAL2GOBJ(gdkwindow)), RVAL2STATE(state_type), RVAL2REC(area), GTK_WIDGET(RVAL2GOBJ(widget)), NIL_P(detail) ? NULL : RVAL2CSTR(detail), RVAL2GENUM(edge, GDK_TYPE_WINDOW_EDGE), NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); return self; }
static VALUE rbclt_layout_manager_allocate (VALUE self, VALUE container, VALUE actorbox, VALUE flags) { ClutterLayoutManager *manager = CLUTTER_LAYOUT_MANAGER (RVAL2GOBJ (self)); ClutterContainer *g_container = CLUTTER_CONTAINER (RVAL2GOBJ (container)); ClutterActorBox g_actorbox = *(ClutterActorBox *) RVAL2BOXED (actorbox, CLUTTER_TYPE_ACTOR_BOX); ClutterAllocationFlags g_flags = RVAL2GENUM (flags, CLUTTER_TYPE_ALLOCATION_FLAGS); clutter_layout_manager_allocate (manager, g_container, &g_actorbox, g_flags); return Qnil; }
static VALUE rg_drag_motion(VALUE self, VALUE dest_window, VALUE protocol, VALUE x_root, VALUE y_root, VALUE suggested_action, VALUE possible_actions, VALUE time) { gboolean ret = gdk_drag_motion(_SELF(self), GDK_WINDOW(RVAL2GOBJ(dest_window)), RVAL2GENUM(protocol, GDK_TYPE_DRAG_PROTOCOL), NUM2INT(x_root), NUM2INT(y_root), RVAL2GFLAGS(suggested_action, GDK_TYPE_DRAG_ACTION), RVAL2GFLAGS(possible_actions, GDK_TYPE_DRAG_ACTION), NUM2UINT(time)); return CBOOL2RVAL(ret); }
static VALUE rg_draw_rectangle(VALUE self, VALUE part, VALUE x, VALUE y, VALUE width, VALUE height) { #ifdef HAVE_PANGO_RENDER_PART_GET_TYPE pango_renderer_draw_rectangle(_SELF(self), RVAL2GENUM(part, PANGO_TYPE_RENDER_PART), NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); #else pango_renderer_draw_rectangle(_SELF(self), NUM2INT(part), NUM2INT(x), NUM2INT(y), NUM2INT(width), NUM2INT(height)); #endif return self; }
static VALUE rg_draw_pixbuf(VALUE self, VALUE gc, VALUE pixbuf, VALUE src_x, VALUE src_y, VALUE dest_x, VALUE dest_y, VALUE width, VALUE height, VALUE dither, VALUE x_dither, VALUE y_dither) { gdk_draw_pixbuf(_SELF(self), GDK_GC(RVAL2GOBJ(gc)), GDK_PIXBUF(RVAL2GOBJ(pixbuf)), NUM2INT(src_x), NUM2INT(src_y), NUM2INT(dest_x), NUM2INT(dest_y), NUM2INT(width), NUM2INT(height), RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER), NUM2INT(x_dither), NUM2INT(y_dither)); return self; }
static VALUE rg_initialize(VALUE self, VALUE type, VALUE visual, VALUE w, VALUE h) { GdkImage* image = gdk_image_new((GdkImageType)RVAL2GENUM(type, GDK_TYPE_IMAGE_TYPE), GDK_VISUAL(RVAL2GOBJ(visual)), NUM2INT(w), NUM2INT(h)); if (image) G_INITIALIZE(self, image); else rb_raise(rb_eArgError, "The image could not be created."); return Qnil; }
static VALUE rg_draw_trapezoid(VALUE self, VALUE part, VALUE y1, VALUE x11, VALUE x21, VALUE y2, VALUE x12, VALUE x22) { #ifdef HAVE_PANGO_RENDER_PART_GET_TYPE pango_renderer_draw_trapezoid(_SELF(self), RVAL2GENUM(part, PANGO_TYPE_RENDER_PART), NUM2DBL(y1), NUM2DBL(x11), NUM2DBL(x21), NUM2DBL(y2), NUM2DBL(x12), NUM2DBL(x22)); #else pango_renderer_draw_trapezoid(_SELF(self), NUM2INT(part), NUM2DBL(y1), NUM2DBL(x11), NUM2DBL(x21), NUM2DBL(y2), NUM2DBL(x12), NUM2DBL(x22)); #endif return self; }
/* GdkEvent */ static VALUE gdkevent_initialize(VALUE self, VALUE type) { GdkEventType event_type; VALUE klass; event_type = RVAL2GENUM(type, GDK_TYPE_EVENT_TYPE); klass = rb_gdk_event_type_to_class(event_type); if (!RVAL2CBOOL(rb_obj_is_kind_of(self, klass))) { rb_raise(rb_eArgError, "Wrong event type for this class: %s: %s", RBG_INSPECT(type), RBG_INSPECT(klass)); } G_INITIALIZE(self, gdk_event_new(event_type)); return Qnil; }
static VALUE geo_set(VALUE self, VALUE min_width, VALUE min_height, VALUE max_width, VALUE max_height, VALUE base_width, VALUE base_height, VALUE width_inc, VALUE height_inc, VALUE min_aspect, VALUE max_aspect, VALUE gravity) { GdkGeometry *geo = _SELF(self); geo->min_width = NUM2INT(min_width); geo->min_height = NUM2INT(min_height); geo->max_width = NUM2INT(max_width); geo->max_height = NUM2INT(max_height); geo->base_width = NUM2INT(base_width); geo->base_height = NUM2INT(base_height); geo->width_inc = NUM2INT(width_inc); geo->height_inc = NUM2INT(height_inc); geo->min_aspect = NUM2DBL(min_aspect); geo->max_aspect = NUM2DBL(max_aspect); geo->win_gravity = RVAL2GENUM(gravity, GDK_TYPE_GRAVITY); return self; }
static VALUE rbatkrel_initialize(VALUE self, VALUE targets, VALUE relationship) { gint i; gint len = RARRAY_LEN(targets); AtkObject* objects = g_new(AtkObject, len); for (i = 0; i < len; i++) { objects = (AtkObject*)RARRAY_PTR(targets)[i]; objects++; } G_INITIALIZE(self, atk_relation_new(&objects, len, RVAL2GENUM(relationship, ATK_TYPE_RELATION_TYPE))); g_free(objects); return Qnil; }
static VALUE rg_backward_search(int argc, VALUE *argv, VALUE self) { GtkTextIter m_start, m_end; VALUE str, flags, limit; gboolean ret; rb_scan_args(argc, argv, "21", &str, &flags, &limit); if (is_compat_240){ ret = gtk_text_iter_backward_search(_SELF(self), RVAL2CSTR(str), RVAL2GFLAGS(flags, GTK_TYPE_TEXT_SEARCH_FLAGS), &m_start, &m_end, NIL_P(limit) ? NULL : _SELF(limit)); } else { ret = gtk_text_iter_backward_search(_SELF(self), RVAL2CSTR(str), RVAL2GENUM(flags, GTK_TYPE_TEXT_SEARCH_FLAGS), &m_start, &m_end, NIL_P(limit) ? NULL : _SELF(limit)); } return ret ? rb_ary_new3(2, ITR2RVAL(&m_start), ITR2RVAL(&m_end)) : Qnil; }
static VALUE rg_write_contents(int argc, VALUE *argv, VALUE self) { VALUE stream, flags, rb_cancellable; GCancellable *cancellable; gboolean result; GError *error = NULL; rb_scan_args(argc, argv, "21", &stream, &flags, &rb_cancellable); cancellable = NIL_P(rb_cancellable) ? NULL : RVAL2GOBJ(rb_cancellable); result = vte_terminal_write_contents(_SELF(self), RVAL2GOBJ(stream), RVAL2GENUM(flags, VTE_TYPE_TERMINAL_WRITE_FLAGS), cancellable, &error); if (error) RAISE_GERROR(error); return CBOOL2RVAL(result); }
static VALUE po_run(int argc, VALUE *argv, VALUE self) { VALUE action, parent, rb_result; GtkPrintOperationResult result; GError *error = NULL; rb_scan_args(argc, argv, "11", &action, &parent); result = gtk_print_operation_run(_SELF(self), RVAL2GENUM(action, GTK_TYPE_PRINT_OPERATION_ACTION), RVAL2GOBJ(parent), &error); rb_result = GENUM2RVAL(result, GTK_TYPE_PRINT_OPERATION_RESULT); if (rb_block_given_p()) { return rb_yield(rb_result); } else { if (result == GTK_PRINT_OPERATION_RESULT_ERROR) RAISE_GERROR(error); return rb_result; } }
static VALUE device_get_axis(VALUE self, VALUE rbaxes, VALUE rbuse) { GdkDevice *device = _SELF(self); GdkAxisUse use = RVAL2GENUM(rbuse, GDK_TYPE_AXIS_USE); long n; gdouble *axes = RVAL2GDOUBLES(rbaxes, &n); gint device_n_axes = gdk_device_get_n_axes(device); gdouble value; gboolean found; if (n != device_n_axes) rb_raise(rb_eArgError, "unexpected number of axes: %ld != %d", n, device_n_axes); found = gdk_device_get_axis(device, axes, use, &value); g_free(axes); return found ? DBL2NUM(value) : Qnil; }
static VALUE rg_m_change(int argc, VALUE *argv, VALUE self) { int fmt, len; void* dat; GdkAtom ntype; VALUE win, property, type, size= Qnil, mode, src; if(6 == argc) rb_scan_args(argc, argv, "60", &win, &property, &type, &size, &mode, &src); else rb_scan_args(argc, argv, "50", &win, &property, &type, &mode, &src); rbgtk_atom2selectiondata(type, size, src, &ntype, &dat, &fmt, &len); gdk_property_change(GDK_WINDOW(RVAL2GOBJ(win)), RVAL2ATOM(property), ntype, fmt, RVAL2GENUM(mode, GDK_TYPE_PROP_MODE), dat, len); rbgtk_atom2selectiondata_free(ntype, dat); return self; }
static VALUE pixbuf_render_to_drawable(int argc, VALUE *argv, VALUE self) { VALUE gc, src_x, src_y, dest_x, dest_y, width, height, dither, x_dither, y_dither; #if GTK_CHECK_VERSION(2,2,0) rb_warn("Gdk::Pixbuf#render_to_drawable is obsolete. Use Gdk::Drawable#draw_pixbuf instead."); #endif rb_scan_args(argc, argv, "73", &gc, &src_x, &src_y, &dest_x, &dest_y, &width, &height, &dither, &x_dither, &y_dither); if (NIL_P(gc)) rb_raise(rb_eArgError, "arguments 1 must be non nil"); if (NIL_P(src_x)) rb_raise(rb_eArgError, "arguments 2 must be non nil"); if (NIL_P(src_y)) rb_raise(rb_eArgError, "arguments 3 must be non nil"); if (NIL_P(dest_x)) rb_raise(rb_eArgError, "arguments 4 must be non nil"); if (NIL_P(dest_y)) rb_raise(rb_eArgError, "arguments 5 must be non nil"); if (NIL_P(width)) rb_raise(rb_eArgError, "arguments 6 must be non nil"); if (NIL_P(height)) rb_raise(rb_eArgError, "arguments 7 must be non nil"); gdk_pixbuf_render_to_drawable(_SELF(self), GDK_DRAWABLE(RVAL2GOBJ(self)), GDK_GC(RVAL2GOBJ(gc)), NUM2INT(src_x), NUM2INT(src_y), NUM2INT(dest_x), NUM2INT(dest_y), NUM2INT(width), NUM2INT(height), NIL_P(dither) ? GDK_RGB_DITHER_NONE : RVAL2GENUM(dither, GDK_TYPE_RGB_DITHER), NIL_P(x_dither) ? 0 : NUM2INT(x_dither), NIL_P(y_dither) ? 0 : NUM2INT(y_dither)); return self; }
static VALUE gdkregion_initialize(int argc, VALUE *argv, VALUE self) { VALUE points_or_rectangle, fill_rule; GdkRegion* region; GdkPoint *gpoints; int i; rb_scan_args(argc, argv, "02", &points_or_rectangle, &fill_rule); if (NIL_P(points_or_rectangle)){ region = gdk_region_new(); } else if (TYPE(points_or_rectangle) == T_ARRAY){ gpoints = ALLOCA_N(GdkPoint, RARRAY_LEN(points_or_rectangle)); for (i = 0; i < RARRAY_LEN(points_or_rectangle); i++) { Check_Type(RARRAY_PTR(points_or_rectangle)[i], T_ARRAY); if (RARRAY_LEN(RARRAY_PTR(points_or_rectangle)[i]) < 2) { rb_raise(rb_eArgError, "point %d should be array of size 2", i); } gpoints[i].x = NUM2INT(RARRAY_PTR(RARRAY_PTR(points_or_rectangle)[i])[0]); gpoints[i].y = NUM2INT(RARRAY_PTR(RARRAY_PTR(points_or_rectangle)[i])[1]); } region = gdk_region_polygon(gpoints, RARRAY_LEN(points_or_rectangle), RVAL2GENUM(fill_rule, GDK_TYPE_FILL_RULE)); } 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; }
static VALUE rg_add_state(VALUE self, VALUE type) { return CBOOL2RVAL(atk_state_set_add_state(_SELF(self), RVAL2GENUM(type, ATK_TYPE_STATE_TYPE))); }
static VALUE rg_set_page_type(VALUE self, VALUE page, VALUE type) { gtk_assistant_set_page_type(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)), RVAL2GENUM(type, GTK_TYPE_ASSISTANT_PAGE_TYPE)); return self; }
static VALUE ruler_set_metric(VALUE self, VALUE metric) { gtk_ruler_set_metric(_SELF(self), RVAL2GENUM(metric, GTK_TYPE_METRIC_TYPE)); return self; }
static VALUE gdkwin_set_type_hint(VALUE self, VALUE hint) { gdk_window_set_type_hint(_SELF(self), RVAL2GENUM(hint, GDK_TYPE_WINDOW_TYPE_HINT)); return self; }
static VALUE rg_get_action_widget(VALUE self, VALUE pack_type) { return GOBJ2RVAL(gtk_notebook_get_action_widget(_SELF(self), RVAL2GENUM(pack_type, GTK_TYPE_PACK_TYPE))); }
static VALUE device_set_mode(VALUE self, VALUE mode) { return CBOOL2RVAL(gdk_device_set_mode(_SELF(self), RVAL2GENUM(mode, GDK_TYPE_INPUT_MODE))); }
static VALUE device_set_source(VALUE self, VALUE source) { gdk_device_set_source(_SELF(self), RVAL2GENUM(source, GDK_TYPE_INPUT_SOURCE)); return self; }
static VALUE rg_set_print_pages(VALUE self, VALUE print_pages) { gtk_print_settings_set_print_pages(_SELF(self), RVAL2GENUM(print_pages, GTK_TYPE_PRINT_PAGES)); return self; }
static void rb_gi_argument_from_ruby_interface(GIArgument *argument, GITypeInfo *type_info, VALUE rb_argument) { GIBaseInfo *interface_info; GIInfoType interface_type; GType gtype; interface_info = g_type_info_get_interface(type_info); interface_type = g_base_info_get_type(interface_info); gtype = g_registered_type_info_get_g_type(interface_info); switch (interface_type) { case GI_INFO_TYPE_INVALID: case GI_INFO_TYPE_FUNCTION: case GI_INFO_TYPE_CALLBACK: rb_raise(rb_eNotImpError, "TODO: Ruby -> GIArgument(interface)[%s]: <%s>", g_info_type_to_string(interface_type), g_base_info_get_name(interface_info)); break; case GI_INFO_TYPE_STRUCT: if (gtype == G_TYPE_VALUE) { GValue *gvalue; gvalue = ALLOC(GValue); memset(gvalue, 0, sizeof(GValue)); if (rb_obj_is_kind_of(rb_argument, rb_cGLibValue)) { GValue *source_gvalue; source_gvalue = RVAL2BOXED(rb_argument, G_TYPE_VALUE); g_value_init(gvalue, source_gvalue->g_type); g_value_copy(source_gvalue, gvalue); } else { rbgobj_initialize_gvalue(gvalue, rb_argument); } argument->v_pointer = gvalue; } else { argument->v_pointer = RVAL2BOXED(rb_argument, gtype); } break; case GI_INFO_TYPE_BOXED: rb_raise(rb_eNotImpError, "TODO: Ruby -> GIArgument(interface)[%s]: <%s>", g_info_type_to_string(interface_type), g_base_info_get_name(interface_info)); break; case GI_INFO_TYPE_ENUM: if (gtype == G_TYPE_NONE) { argument->v_int32 = NUM2INT(rb_argument); } else { argument->v_int32 = RVAL2GENUM(rb_argument, gtype); } break; case GI_INFO_TYPE_FLAGS: if (gtype == G_TYPE_NONE) { argument->v_int32 = NUM2INT(rb_argument); } else { argument->v_int32 = RVAL2GFLAGS(rb_argument, gtype); } break; case GI_INFO_TYPE_OBJECT: case GI_INFO_TYPE_INTERFACE: argument->v_pointer = RVAL2GOBJ(rb_argument); break; case GI_INFO_TYPE_CONSTANT: rb_raise(rb_eNotImpError, "TODO: Ruby -> GIArgument(interface)[%s]: <%s>", g_info_type_to_string(interface_type), g_base_info_get_name(interface_info)); break; case GI_INFO_TYPE_INVALID_0: g_assert_not_reached(); break; case GI_INFO_TYPE_UNION: case GI_INFO_TYPE_VALUE: case GI_INFO_TYPE_SIGNAL: case GI_INFO_TYPE_VFUNC: case GI_INFO_TYPE_PROPERTY: case GI_INFO_TYPE_FIELD: case GI_INFO_TYPE_ARG: case GI_INFO_TYPE_TYPE: case GI_INFO_TYPE_UNRESOLVED: default: rb_raise(rb_eNotImpError, "TODO: Ruby -> GIArgument(interface)[%s]: <%s>", g_info_type_to_string(interface_type), g_base_info_get_name(interface_info)); break; } g_base_info_unref(interface_info); }