本文整理汇总了C++中GOBJ2RVAL函数的典型用法代码示例。如果您正苦于以下问题:C++ GOBJ2RVAL函数的具体用法?C++ GOBJ2RVAL怎么用?C++ GOBJ2RVAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GOBJ2RVAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rb_rsvg_pixbuf_from_file
/* Convenience API */
static VALUE
rb_rsvg_pixbuf_from_file(VALUE self, VALUE file_name)
{
VALUE rb_pixbuf;
GdkPixbuf *pixbuf;
GError *error = NULL;
pixbuf = rsvg_pixbuf_from_file(RVAL2CSTR(file_name), &error);
if (error) RAISE_GERROR(error);
rb_pixbuf = GOBJ2RVAL(pixbuf);
g_object_unref(pixbuf);
return rb_pixbuf;
}
示例2: rc_property_parser
/*
* Gtk::Settings.install_property(...) do |spec, str|
* #parse str
* new_val = .... # parse value from string.
* new_val # return new_val or nil if you can't convert the value.
* end
*/
static gboolean
rc_property_parser(const GParamSpec *pspec, const GString *rc_string, GValue *property_value)
{
VALUE spec = GOBJ2RVAL((gpointer)pspec);
VALUE func = rb_hash_aref(prop_func_table, spec);
VALUE ret = rb_funcall(func, id_call, 2, spec, CSTR2RVAL(rc_string->str));
if (NIL_P(ret)) {
return FALSE;
} else if (RVAL2CBOOL(ret)){
rbgobj_rvalue_to_gvalue(ret, property_value);
return TRUE;
} else {
rb_raise(rb_eArgError, "Gtk::Settings#install_property() block should return new value or nil");
}
}
示例3: term_is_selected_cb
static gboolean
term_is_selected_cb(VteTerminal *terminal, glong column, glong row,
gpointer data)
{
gboolean result = TRUE;
VALUE callback = (VALUE)data;
if (!NIL_P(callback)) {
VALUE rb_result;
rb_result = rb_funcall(callback, id_call, 3, GOBJ2RVAL(terminal),
LONG2NUM(column), LONG2NUM(row));
result = RVAL2CBOOL(rb_result);
}
return result;
}
示例4: si_get_geometry
static VALUE
si_get_geometry(VALUE self)
{
GdkScreen* screen;
GdkRectangle area;
GtkOrientation orientation;
gboolean ret = gtk_status_icon_get_geometry(_SELF(self), &screen,
&area, &orientation);
if (ret) {
return rb_ary_new3(3, GOBJ2RVAL(screen),
BOXED2RVAL(&area, GDK_TYPE_RECTANGLE),
GENUM2RVAL(orientation, GTK_TYPE_ORIENTATION));
} else {
return rb_ary_new3(3, Qnil, Qnil, Qnil);
}
}
示例5: menu_pos_func
static void
menu_pos_func(GtkMenu *menu, gint *px, gint *py, gboolean *push_in, gpointer data)
{
VALUE arr = rb_funcall((VALUE)data, id_call, 4, GOBJ2RVAL(menu),
INT2FIX(*px), INT2FIX(*py),
CBOOL2RVAL(*push_in));
if (TYPE(arr) == T_ARRAY && (RARRAY_LEN(arr) == 2 || RARRAY_LEN(arr) == 3)){
*px = NUM2INT(RARRAY_PTR(arr)[0]);
*py = NUM2INT(RARRAY_PTR(arr)[1]);
if (RARRAY_LEN(arr) == 3)
*push_in = RVAL2CBOOL(RARRAY_PTR(arr)[2]);
} else {
rb_raise(rb_eArgError, "block should return [x, y, push_in]");
}
}
示例6: each_printer
static gboolean
each_printer(GtkPrinter *printer, gpointer data)
{
VALUE result;
VALUE argv[1];
struct callback_arg arg;
argv[0] = GOBJ2RVAL(printer);
arg.callback = (VALUE)data;
arg.argc = 1;
arg.argv = argv;
result = G_PROTECT_CALLBACK(invoke_callback, &arg);
return NIL_P(rb_errinfo()) ? TRUE : RVAL2CBOOL(result);
}
示例7: rg_get_path_at_pos
static VALUE
rg_get_path_at_pos(VALUE self, VALUE x, VALUE y)
{
GtkTreePath* path;
GtkTreeViewColumn* column;
gint cell_x, cell_y;
gboolean ret;
ret = gtk_tree_view_get_path_at_pos(_SELF(self),
NUM2INT(x), NUM2INT(y),
&path, &column, &cell_x, &cell_y);
return ret ? rb_ary_new3(4,
path ? GTKTREEPATH2RVAL(path) : Qnil,
column ? GOBJ2RVAL(column) : Qnil,
INT2NUM(cell_x), INT2NUM(cell_y)) : Qnil;
}
示例8: asyncinitable_initialize_finish
static VALUE
asyncinitable_initialize_finish(VALUE self, VALUE result)
{
GError *error = NULL;
GObject *object;
VALUE rbobject;
object = g_async_initable_new_finish(_SELF(self),
RVAL2GASYNCRESULT(result),
&error);
if (object == NULL)
rbgio_raise_error(error);
rbobject = GOBJ2RVAL(object);
g_object_unref(object);
return rbobject;
}
示例9: signal_rows_reordered_func
static VALUE
signal_rows_reordered_func(G_GNUC_UNUSED guint num, const GValue *values)
{
GtkTreeModel* model = g_value_get_object(&values[0]);
GtkTreePath* path = g_value_get_boxed(&values[1]);
GtkTreeIter* iter = g_value_get_boxed(&values[2]);
gint* new_orders = (gint*)g_value_get_pointer(&values[3]);
gint len = gtk_tree_model_iter_n_children(model, iter);
VALUE orders = Qnil;
int i;
iter->user_data3 = model;
orders = rb_ary_new2(len);
for (i = 0; i < len; i++, new_orders++) {
rb_ary_push(orders, INT2NUM(*new_orders));
}
return rb_ary_new3(4, GOBJ2RVAL(model), GTKTREEPATH2RVAL(path), GTKTREEITER2RVAL(iter), orders);
}
示例10: rg_s_pixbuf_from_file_at_zoom
static VALUE
rg_s_pixbuf_from_file_at_zoom(G_GNUC_UNUSED VALUE self, VALUE file_name,
VALUE x_zoom, VALUE y_zoom)
{
VALUE rb_pixbuf;
GdkPixbuf *pixbuf;
GError *error = NULL;
pixbuf = rsvg_pixbuf_from_file_at_zoom(RVAL2CSTR(file_name),
NUM2DBL(x_zoom),
NUM2DBL(y_zoom),
&error);
if (error) RAISE_GERROR(error);
rb_pixbuf = GOBJ2RVAL(pixbuf);
g_object_unref(pixbuf);
return rb_pixbuf;
}
示例11: rg_s_pixbuf_from_file_at_size
static VALUE
rg_s_pixbuf_from_file_at_size(G_GNUC_UNUSED VALUE self, VALUE file_name,
VALUE width, VALUE height)
{
VALUE rb_pixbuf;
GdkPixbuf *pixbuf;
GError *error = NULL;
pixbuf = rsvg_pixbuf_from_file_at_size(RVAL2CSTR(file_name),
NUM2INT(width),
NUM2INT(height),
&error);
if (error) RAISE_GERROR(error);
rb_pixbuf = GOBJ2RVAL(pixbuf);
g_object_unref(pixbuf);
return rb_pixbuf;
}
示例12: rg_each
static VALUE
rg_each(VALUE self)
{
PopplerDocument *document;
int i, n_pages;
document = RVAL2DOC(self);
n_pages = poppler_document_get_n_pages(document);
for (i = 0; i < n_pages; i++) {
PopplerPage *page;
VALUE rb_page;
page = poppler_document_get_page(document, i);
rb_page = GOBJ2RVAL(page);
if (page)
g_object_unref(page);
rb_yield(rb_page);
}
return self;
}
示例13: rg_open_signal_func
static VALUE
rg_open_signal_func(G_GNUC_UNUSED guint num, const GValue *values)
{
VALUE rb_files;
GFile **files;
gint i, n_files;
files = g_value_get_pointer(&(values[1]));
n_files = g_value_get_int(&(values[2]));
rb_files = rb_ary_new2(n_files);
for (i = 0; i < n_files; i++) {
GFile *file = files[i];
rb_ary_push(rb_files, GOBJ2RVAL(file));
}
return rb_ary_new3(3,
GVAL2RVAL(&values[0]),
rb_files,
GVAL2RVAL(&values[3]));
}
示例14: rb_rsvg_pixbuf_from_file_at_max_size_ex
static VALUE
rb_rsvg_pixbuf_from_file_at_max_size_ex(VALUE self, VALUE file_name,
VALUE max_width, VALUE max_height)
{
VALUE rb_pixbuf;
GdkPixbuf *pixbuf;
GError *error = NULL;
pixbuf = rsvg_pixbuf_from_file_at_max_size_ex(_SELF(self),
RVAL2CSTR(file_name),
NUM2INT(max_width),
NUM2INT(max_height),
&error);
if (error) RAISE_GERROR(error);
rb_pixbuf = GOBJ2RVAL(pixbuf);
g_object_unref(pixbuf);
return rb_pixbuf;
}
示例15: rg_s_open
static VALUE
rg_s_open(G_GNUC_UNUSED VALUE self, VALUE display_name)
{
GdkDisplay* gdisplay = gdk_display_open(RVAL2CSTR(display_name));
if (! gdisplay) {
rb_raise(rb_eRuntimeError, "The display `%s' could not be opened.",
RVAL2CSTR(display_name));
} else {
VALUE display;
g_object_ref(gdisplay);
display = GOBJ2RVAL(gdisplay);
if (rb_block_given_p()) {
rb_ensure(rb_yield, display, rg_close, display);
return Qnil;
} else {
return display;
}
}
}