static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE options, rb_parent, rb_flags, rb_type, rb_buttons_type, rb_message;
    GtkWindow *parent;
    GtkDialogFlags flags;
    GtkMessageType type;
    GtkButtonsType buttons_type;
    const gchar *message;
    GtkWidget *dialog;

    rb_scan_args(argc, argv, "01", &options);
    rbg_scan_options(options,
                     "parent", &rb_parent,
                     "flags", &rb_flags,
                     "type", &rb_type,
                     "buttons_type", &rb_buttons_type,
                     "message", &rb_message,
                     NULL);
    parent = NIL_P(rb_parent) ? NULL : RVAL2GTKWINDOW(rb_parent);
    flags = NIL_P(rb_flags) ? 0 : RVAL2GTKDIALOGFLAGS(rb_flags);
    type = NIL_P(rb_type) ? GTK_MESSAGE_INFO : RVAL2GTKMESSAGETYPE(rb_type);
    buttons_type = NIL_P(rb_buttons_type) ? GTK_BUTTONS_OK : RVAL2GTKBUTTONSTYPE(rb_buttons_type);
    message = NIL_P(rb_message) ? "" : RVAL2CSTR(rb_message);

    dialog = gtk_message_dialog_new(parent, flags, type, buttons_type, "%s", message);
    RBGTK_INITIALIZE(self, dialog);

    return Qnil;
}
Exemple #2
0
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE button;
    GtkWidget *widget = NULL;

    rb_scan_args(argc, argv, "01", &button);
    if (NIL_P(button)) {
        widget = gtk_button_new();
    } else if (TYPE(button) == T_HASH) {
        VALUE label, mnemonic, stock_id, buffer;
        rbg_scan_options(button,
                         "label", &label,
                         "mnemonic", &mnemonic,
                         "stock_id", &stock_id,
                         NULL);

        if (!NIL_P(label))
            widget = gtk_button_new_with_label(RVAL2CSTR(label));
        else if (!NIL_P(mnemonic))
            widget = gtk_button_new_with_mnemonic(RVAL2CSTR(mnemonic));
        else if (!NIL_P(stock_id))
            widget = gtk_button_new_from_stock(RVAL2GLIBID(stock_id, buffer));
    }
    if (!widget)
        rb_raise(rb_eArgError, "Invalid arguments.");

    RBGTK_INITIALIZE(self, widget); 

    return Qnil;
}
Exemple #3
0
static VALUE
rg_initialize(gint argc, VALUE *argv, VALUE self)
{
    GError *error = NULL;
    GRegex *regex = NULL;

    VALUE rb_pattern, rb_compile_options, rb_match_options;
    VALUE rb_options;
    const char *pattern;
    GRegexCompileFlags compile_options = 0;
    GRegexMatchFlags match_options = 0;

    rb_scan_args(argc, argv, "11", &rb_pattern, &rb_options);
    rbg_scan_options(rb_options,
                     "compile_options", &rb_compile_options,
                     "match_options", &rb_match_options,
                     NULL);

    pattern = RVAL2CSTR(rb_pattern);
    if (!NIL_P(rb_compile_options))
        compile_options = RVAL2GREGEXCOMPILEOPTIONSFLAGS(rb_compile_options);
    if (!NIL_P(rb_match_options))
        match_options = RVAL2GREGEXMATCHOPTIONSFLAGS(rb_match_options);

    regex = g_regex_new(pattern,
                        compile_options,
                        match_options,
                        &error);
    if (error)
        RAISE_GERROR(error);

    G_INITIALIZE(self, regex);
    return Qnil;
}
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE options, rb_parent, rb_file, rb_flags, rb_content_type;
    GtkWindow *parent;
    GtkDialogFlags flags;
    GtkWidget *widget = NULL;

    rb_scan_args(argc, argv, "01", &options);
    rbg_scan_options(options,
                     "parent", &rb_parent,
                     "flags", &rb_flags,
                     "file", &rb_file,
                     "content_type", &rb_content_type,
                     NULL);
    parent = NIL_P(rb_parent) ? NULL : RVAL2GTKWINDOW(rb_parent);
    flags = NIL_P(rb_flags) ? 0 : RVAL2GTKDIALOGFLAGS(rb_flags);

    if (!NIL_P(rb_file))
        widget = gtk_app_chooser_dialog_new(parent, flags, RVAL2GFILE(rb_file));
    else
        widget = gtk_app_chooser_dialog_new_for_content_type(parent,
                                                             flags,
                                                             RVAL2CSTR(rb_content_type));
    RBGTK_INITIALIZE(self, widget);

    return Qnil;
}
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE arg, buffer;
    GtkToolItem *item = NULL;

    rb_scan_args(argc, argv, "01", &arg);
    if (NIL_P(arg)) {
        item = gtk_toggle_tool_button_new();
    } else if (TYPE(arg) == T_HASH) {
        VALUE stock_id;
        rbg_scan_options(arg,
                         "stock_id", &stock_id,
                         NULL);

        if (!NIL_P(stock_id))
            item = gtk_toggle_tool_button_new_from_stock(RVAL2GLIBID(stock_id, buffer));
    } else {
        item = gtk_toggle_tool_button_new_from_stock(RVAL2GLIBID(arg, buffer));
    }
    if (!item)
        rb_raise(rb_eArgError, "Invalid arguments.");

    RBGTK_INITIALIZE(self, item);

    return Qnil;
}
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE arg;
    GtkToolItem *item = NULL;

    rb_scan_args(argc, argv, "01", &arg);
    if (NIL_P(arg)) {
        item = gtk_tool_button_new(NULL, NULL);
    } else if (TYPE(arg) == T_HASH) {
        VALUE icon_widget, label, stock_id, buffer;
        rbg_scan_options(arg,
                         "icon_widget", &icon_widget,
                         "label", &label,
                         "stock_id", &stock_id,
                         NULL);

        if (!NIL_P(icon_widget))
            item = gtk_tool_button_new(RVAL2GTKWIDGET(icon_widget),
                                       RVAL2CSTR_ACCEPT_NIL(label));
        else if (!NIL_P(stock_id))
            item = gtk_tool_button_new_from_stock(RVAL2GLIBID(stock_id, buffer));
    }
    if (!item)
        rb_raise(rb_eArgError, "Invalid arguments.");

    RBGTK_INITIALIZE(self, item);

    return Qnil;
}
Exemple #7
0
static VALUE
rg_s_reference_gobject(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass)
{
    VALUE rb_gobject;
    VALUE rb_options, rb_sink;
    gpointer gobject;
    gboolean sink;

    rb_scan_args(argc, argv, "11",
                 &rb_gobject, &rb_options);
    rbg_scan_options(rb_options,
                     "sink", &rb_sink,
                     NULL);

    gobject = RVAL2GOBJ(rb_gobject);

    if (NIL_P(rb_sink)) {
        sink = FALSE;
    } else {
        sink = RVAL2CBOOL(rb_sink);
    }

    if (sink) {
        g_object_ref_sink(gobject);
    } else {
        g_object_ref(gobject);
    }

    return Qnil;
}
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE options, rb_title, rb_parent, rb_manager, rb_button_ary;
    const gchar *title;
    GtkWindow *parent;
    GtkRecentManager *manager;
    GtkWidget *dialog;

    rb_scan_args(argc, argv, "01", &options);
    rbg_scan_options(options,
                     "title", &rb_title,
                     "parent", &rb_parent,
                     "manager", &rb_manager,
                     "buttons", &rb_button_ary,
                     NULL);
    title = RVAL2CSTR_ACCEPT_NIL(rb_title);
    parent = NIL_P(rb_parent) ? NULL : RVAL2GTKWINDOW(rb_parent);
    manager = NIL_P(rb_manager) ? NULL : RVAL2GTKRECENTMANAGER(rb_manager);

    if (manager) {
        dialog = gtk_recent_chooser_dialog_new_for_manager(title, parent, manager, NULL, NULL);
    } else {
        dialog = gtk_recent_chooser_dialog_new(title, parent, NULL, NULL);
    }
    RBGTK_INITIALIZE(self, dialog);
    if (!NIL_P(rb_button_ary))
        rb_funcall2(self, rb_intern("add_buttons"),
                    RARRAY_LEN(rb_button_ary), RARRAY_PTR(rb_button_ary));

    return Qnil;
}
Exemple #9
0
static VALUE
rg_s_show_uri(G_GNUC_UNUSED VALUE self, VALUE rb_uri_or_options)
{
    VALUE rb_screen = Qnil;
    VALUE rb_uri = Qnil;
    VALUE rb_timestamp = Qnil;
    GdkScreen *screen = NULL;
    const gchar *uri = NULL;
    guint32 timestamp = GDK_CURRENT_TIME;
    GError *error = NULL;

    if (TYPE(rb_uri_or_options) == T_HASH) {
        rbg_scan_options(rb_uri_or_options,
                         "screen", &rb_screen,
                         "uri", &rb_uri,
                         "timestamp", &rb_timestamp,
                         NULL);
    } else {
        rb_uri = rb_uri_or_options;
    }

    screen = RVAL2GOBJ(rb_screen);
    uri = StringValueCStr(rb_uri);
    if (!NIL_P(rb_timestamp)) {
        timestamp = NUM2UINT(rb_timestamp);
    }

    if (!gtk_show_uri(screen, uri, timestamp, &error)) {
        RAISE_GERROR(error);
    }

    return self;
}
Exemple #10
0
static VALUE
rg_match_all(gint argc, VALUE *argv, VALUE self)
{
    VALUE rb_string, rb_start_position, rb_match_options, rb_options;
    VALUE rb_frozen_string, rb_match_info;
    GMatchInfo *match_info = NULL;
    GError *error = NULL;
    const gchar *string;
    gssize string_len = -1;
    gint start_position = 0;
    GRegexMatchFlags match_options = 0;

    rb_scan_args(argc, argv, "11", &rb_string, &rb_options);

    rbg_scan_options(rb_options,
                     "start_position", &rb_start_position,
                     "match_options", &rb_match_options,
                     NULL);

    if (OBJ_FROZEN(rb_string)) {
        rb_frozen_string = rb_string;
    } else {
        rb_frozen_string = rb_str_dup(rb_string);
        rb_str_freeze(rb_frozen_string);
    }

    string = RVAL2CSTR(rb_frozen_string);
    string_len = RSTRING_LEN(rb_frozen_string);


    if (!NIL_P(rb_start_position))
        start_position = NUM2INT(rb_start_position);
    if (!NIL_P(rb_match_options))
        match_options = RVAL2GREGEXMATCHOPTIONSFLAGS(rb_match_options);

    g_regex_match_all_full(_SELF(self),
                           string,
                           string_len,
                           start_position,
                           match_options,
                           &match_info,
                           &error);

    if (error)
        RAISE_GERROR(error);

    if (!match_info)
        return Qnil;

    rb_match_info = GMATCHINFO2RVAL(match_info);
    g_match_info_unref(match_info);
    rb_iv_set(rb_match_info, "@string", rb_frozen_string);
    return rb_match_info;
}
Exemple #11
0
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE image;
    GtkWidget *widget = NULL;

    rb_scan_args(argc, argv, "01", &image);
    if (NIL_P(image)) {
        widget = gtk_image_new();
    } else if (TYPE(image) == T_HASH) {
        VALUE stock, icon_name, icon_set, gicon, file, pixbuf, animation, size, buffer;
        rbg_scan_options(image,
                         "stock", &stock,
                         "icon_name", &icon_name,
                         "icon_set", &icon_set,
                         "gicon", &gicon,
                         "file", &file,
                         "pixbuf", &pixbuf,
                         "animation", &animation,
                         "size", &size,
                         NULL);

        if (!NIL_P(stock))
            widget = gtk_image_new_from_stock(RVAL2GLIBID(stock, buffer), RVAL2GTKICONSIZE(size));
        else if (!NIL_P(icon_name))
            widget = gtk_image_new_from_icon_name(RVAL2CSTR(icon_name), RVAL2GTKICONSIZE(size));
        else if (!NIL_P(icon_set))
            widget = gtk_image_new_from_icon_set(RVAL2GTKICONSET(icon_set), RVAL2GTKICONSIZE(size));
        else if (!NIL_P(gicon))
            widget = gtk_image_new_from_gicon(RVAL2GICON(gicon), RVAL2GTKICONSIZE(size));
        else if (!NIL_P(file))
            widget = gtk_image_new_from_file(RVAL2CSTR(file));
        else if (!NIL_P(pixbuf))
            widget = gtk_image_new_from_pixbuf(RVAL2GDKPIXBUF(pixbuf));
        else if (!NIL_P(animation))
            widget = gtk_image_new_from_animation(RVAL2GDKPIXBUFANIMATION(animation));
    } else {
        GType gtype = RVAL2GTYPE(image);

        if (gtype == GDK_TYPE_PIXBUF)
            widget = gtk_image_new_from_pixbuf(RVAL2GDKPIXBUF(image));
        else if (g_type_is_a(gtype, GDK_TYPE_PIXBUF_ANIMATION))
            widget = gtk_image_new_from_animation(RVAL2GDKPIXBUFANIMATION(image));
    }
    if (!widget)
        rb_raise(rb_eArgError, "Invalid arguments.");

    RBGTK_INITIALIZE(self, widget);

    return Qnil;
}
Exemple #12
0
static VALUE
rg_fork_command(int argc, VALUE *argv, VALUE self)
{
    VALUE options, rb_pty_flags, rb_working_directory, rb_command_argv, rb_envv, rb_spawn_flags;
    int pty_flags, spawn_flags;
    char *working_directory;
    char **command_argv;
    char **envv;
    GPid child_pid;
    gboolean result;
    GError *error = NULL;

    rb_scan_args(argc, argv, "01", &options);
    rbg_scan_options(options,
                     "pty_flags", &rb_pty_flags,
                     "working_directory", &rb_working_directory,
                     "argv", &rb_command_argv,
                     "envv", &rb_envv,
                     "spawn_flags", &rb_spawn_flags,
                     NULL);
    pty_flags = NIL_P(rb_pty_flags) ?
                VTE_PTY_DEFAULT :
                RVAL2VTEPTYFLAGS(rb_pty_flags);
    working_directory = RVAL2CSTR_ACCEPT_NIL(rb_working_directory);
    command_argv = rval2cstrary(NIL_P(rb_command_argv) ? fork_command_default_argv() : rb_command_argv);
    envv = rval2cstrary(rb_envv);
    spawn_flags = NIL_P(rb_spawn_flags) ?
                G_SPAWN_CHILD_INHERITS_STDIN | G_SPAWN_SEARCH_PATH :
                NUM2INT(rb_spawn_flags);

    result = vte_terminal_fork_command_full(_SELF(self),
                                            pty_flags,
                                            working_directory,
                                            command_argv,
                                            envv,
                                            spawn_flags,
                                            NULL,
                                            NULL,
                                            &child_pid,
                                            &error);
    free_cstrary(command_argv);
    free_cstrary(envv);
    if (error)
        RAISE_GERROR(error);

    return INT2NUM(child_pid);
}
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE options, rb_title;
    const gchar *title;
    GtkWidget *dialog;

    rb_scan_args(argc, argv, "01", &options);
    rbg_scan_options(options,
                     "title", &rb_title,
                     NULL);
    title = RVAL2CSTR_ACCEPT_NIL(rb_title);

    dialog = gtk_color_selection_dialog_new(title);
    RBGTK_INITIALIZE(self, dialog);

    return Qnil;
}
static VALUE
rbglib_m_format_size(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
{
    VALUE rb_size, rb_options;

    rb_scan_args(argc, argv, "11", &rb_size, &rb_options);
    if (NIL_P(rb_options)) {
      return CSTR2RVAL_FREE(g_format_size(NUM2ULONG(rb_size)));
    } else {
      VALUE rb_flags;
      rbg_scan_options(rb_options,
                       "flags", &rb_flags,
                       NULL);

      return CSTR2RVAL_FREE(g_format_size_full(NUM2ULONG(rb_size),
                                               RVAL2GFORMATSIZEFLAGS(rb_flags)));
    }
}
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE options, entry;
    GtkWidget *widget = NULL;

    rb_scan_args(argc, argv, "01", &options);
    rbg_scan_options(options,
                     "entry", &entry,
                     NULL);

    if (RVAL2CBOOL(entry))
        widget = gtk_combo_box_text_new_with_entry();
    else
        widget = gtk_combo_box_text_new();
    RBGTK_INITIALIZE(self, widget);

    return Qnil;
}
Exemple #16
0
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE name, options, label, tooltip, stock_id, buffer;

    rb_scan_args(argc, argv, "11", &name, &options);
    rbg_scan_options(options,
                     "label", &label,
                     "tooltip", &tooltip,
                     "stock_id", &stock_id,
                     NULL);

    G_INITIALIZE(self, gtk_action_new(RVAL2CSTR(name),
                                      RVAL2CSTR_ACCEPT_NIL(label),
                                      RVAL2CSTR_ACCEPT_NIL(tooltip),
                                      RVAL2GLIBID_ACCEPT_NIL(stock_id, buffer)));

    return Qnil;
}
Exemple #17
0
static VALUE
rg_split(gint argc, VALUE *argv, VALUE self)
{
    VALUE rb_string, rb_start_position, rb_match_options, rb_max_tokens, rb_options;
    GError *error = NULL;
    gchar **strings;
    const gchar *string;
    gssize string_len = -1;
    gint start_position = 0;
    GRegexMatchFlags match_options = 0;
    gint max_tokens = 0;

    rb_scan_args(argc, argv, "11", &rb_string, &rb_options);

    rbg_scan_options(rb_options,
                     "start_position", &rb_start_position,
                     "match_options", &rb_match_options,
                     "max_tokens", &rb_max_tokens,
                     NULL);
    string = RVAL2CSTR(rb_string);
    string_len = RSTRING_LEN(rb_string);

    if (!NIL_P(rb_start_position))
        start_position = NUM2INT(rb_start_position);
    if (!NIL_P(rb_match_options))
        match_options = RVAL2GREGEXMATCHOPTIONSFLAGS(rb_match_options);
    if (!NIL_P(rb_max_tokens))
        max_tokens = NUM2INT(rb_max_tokens);

    strings = g_regex_split_full(_SELF(self),
                                 string,
                                 string_len,
                                 start_position,
                                 match_options,
                                 max_tokens,
                                 &error);

    if (error)
        RAISE_GERROR(error);

    return STRV2RVAL_FREE(strings);
}
static VALUE
rg_initialize(int argc, VALUE *argv, VALUE self)
{
    VALUE options, rb_title, rb_parent;
    const gchar *title;
    GtkWindow *parent;
    GtkWidget *dialog;

    rb_scan_args(argc, argv, "01", &options);
    rbg_scan_options(options,
                     "title", &rb_title,
                     "parent", &rb_parent,
                     NULL);
    title = RVAL2CSTR_ACCEPT_NIL(rb_title);
    parent = NIL_P(rb_parent) ? NULL : RVAL2GTKWINDOW(rb_parent);

    dialog = gtk_print_unix_dialog_new(title, parent);
    RBGTK_INITIALIZE(self, dialog);

    return Qnil;
}
Exemple #19
0
static VALUE
rg_s_define_struct(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass)
{
    VALUE rb_size, rb_name, rb_module;
    VALUE rb_options, rb_parent;
    VALUE rb_class;

    rb_scan_args(argc, argv, "31", &rb_size, &rb_name, &rb_module, &rb_options);
    rbg_scan_options(rb_options,
                     "parent", &rb_parent,
                     NULL);

    rb_size = rb_to_int(rb_size);
    if (NIL_P(rb_parent)) {
        rb_parent = rb_cObject;
    }
    rb_class = rb_define_class_under(rb_module, RVAL2CSTR(rb_name), rb_parent);
    rb_iv_set(rb_class, "@size", rb_size);
    rb_define_alloc_func(rb_class, struct_alloc);
    return rb_class;
}
static VALUE
rg_set_tooltip(VALUE self, VALUE tooltip)
{
    if (TYPE(tooltip) == T_HASH) {
        VALUE text, markup;
        rbg_scan_options(tooltip,
                         "text", &text,
                         "markup", &markup,
                         NULL);
        if (!NIL_P(text))
            gtk_tool_item_set_tooltip_text(_SELF(self), RVAL2CSTR(text));
        else if (!NIL_P(markup))
            gtk_tool_item_set_tooltip_markup(_SELF(self), RVAL2CSTR(markup));
        else
            rb_raise(rb_eArgError, "Invalid arguments.");
    } else {
        rb_raise(rb_eArgError, "Invalid arguments.");
    }

    return self;
}
Exemple #21
0
static VALUE
rg_s_define_class(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass)
{
    VALUE rb_class;
    VALUE rb_gtype, rb_name, rb_module;
    VALUE rb_options, rb_parent, rb_size;
    GType gtype;

    rb_scan_args(argc, argv, "31", &rb_gtype, &rb_name, &rb_module, &rb_options);
    rbg_scan_options(rb_options,
                     "parent", &rb_parent,
                     "size", &rb_size,
                     NULL);

    gtype = NUM2ULONG(rb_to_int(rb_gtype));
    rb_class = G_DEF_CLASS_WITH_PARENT(gtype, RVAL2CSTR(rb_name),
                                       rb_module, rb_parent);
    if (!NIL_P(rb_size)) {
        rb_iv_set(rb_class, "@size", rb_size);
    }
    return rb_class;
}
Exemple #22
0
static VALUE
rg_s_define_error(int argc, VALUE *argv, G_GNUC_UNUSED VALUE klass)
{
    VALUE rb_domain, rb_name, rb_module;
    VALUE rb_options, rb_parent, rb_gtype;
    GQuark domain;
    const gchar *name;
    GType gtype = G_TYPE_INVALID;

    rb_scan_args(argc, argv, "31",
                 &rb_domain, &rb_name, &rb_module, &rb_options);
    rbg_scan_options(rb_options,
                     "parent", &rb_parent,
                     "gtype", &rb_gtype,
                     NULL);

    if (RB_TYPE_P(rb_domain, RUBY_T_STRING)) {
        domain = g_quark_from_string(RVAL2CSTR(rb_domain));
        if (domain == 0) {
            rb_raise(rb_eArgError,
                     "invalid domain name: <%s>",
                     rbg_inspect(rb_domain));
        }
    } else {
        domain = NUM2UINT(rb_domain);
    }

    name = RVAL2CSTR(rb_name);

    if (NIL_P(rb_parent)) {
        rb_parent = rb_eStandardError;
    }

    if (!NIL_P(rb_gtype)) {
        gtype = NUM2ULONG(rb_funcall(rb_gtype, rb_intern("to_i"), 0));
    }

    return G_DEF_ERROR(domain, name, rb_module, rb_parent, gtype);
}
Exemple #23
0
static VALUE
rg_replace(gint argc, VALUE *argv, VALUE self)
{
    VALUE rb_string;
    VALUE rb_replacement;
    VALUE rb_options;
    VALUE rb_start_position;
    VALUE rb_match_options;
    VALUE rb_literal;
    GError *error = NULL;
    gchar *modified_string;
    const gchar *string;
    const gchar *replacement;
    gssize string_len = -1;
    gint start_position = 0;
    GRegexMatchFlags match_options = 0;


    if (rb_block_given_p()) {
        RGRegexEvalCallbackData data;

        rb_scan_args(argc, argv, "11", &rb_string, &rb_options);
        rbg_scan_options(rb_options,
                         "start_position", &rb_start_position,
                         "match_options", &rb_match_options,
                         NULL);

        string = RVAL2CSTR(rb_string);
        string_len = RSTRING_LEN(rb_string);

        if (!NIL_P(rb_start_position))
            start_position = NUM2INT(rb_start_position);
        if (!NIL_P(rb_match_options))
            match_options = RVAL2GREGEXMATCHOPTIONSFLAGS(rb_match_options);

        data.callback = rb_block_proc();
        data.status = 0;

        modified_string = g_regex_replace_eval(_SELF(self),
                                               string,
                                               string_len,
                                               start_position,
                                               match_options,
                                               rg_regex_eval_callback,
                                               &data,
                                               &error);
        if (!(data.status == 0 || data.status == RUBY_TAG_BREAK)) {
            if (error)
                g_error_free(error);
            g_free(modified_string);
            rb_jump_tag(data.status);
        }
    } else {
        rb_scan_args(argc, argv, "21", &rb_string, &rb_replacement, &rb_options);

        rbg_scan_options(rb_options,
                         "start_position", &rb_start_position,
                         "match_options", &rb_match_options,
                         "literal", &rb_literal,
                         NULL);

        string = RVAL2CSTR(rb_string);
        string_len = RSTRING_LEN(rb_string);
        replacement = RVAL2CSTR(rb_replacement);

        if (!NIL_P(rb_start_position))
            start_position = NUM2INT(rb_start_position);
        if (!NIL_P(rb_match_options))
            match_options = RVAL2GREGEXMATCHOPTIONSFLAGS(rb_match_options);

        if (RVAL2CBOOL(rb_literal)) {
            modified_string = g_regex_replace_literal(_SELF(self),
                                                      string,
                                                      string_len,
                                                      start_position,
                                                      replacement,
                                                      match_options,
                                                      &error);

        } else {
            modified_string = g_regex_replace(_SELF(self),
                                              string,
                                              string_len,
                                              start_position,
                                              replacement,
                                              match_options,
                                              &error);
        }
    }

    if (error)
        RAISE_GERROR(error);

    return CSTR2RVAL_FREE(modified_string);
}
VALUE
rb_gi_function_info_invoke_raw(GIFunctionInfo *info, VALUE rb_options,
                               GIArgument *return_value)
{
    GICallableInfo *callable_info;
    GIArgument receiver;
    GArray *in_args, *out_args;
    GPtrArray *args_metadata;
    VALUE rb_out_args = Qnil;
    gboolean succeeded;
    GError *error = NULL;
    gboolean unlock_gvl = FALSE;
    VALUE rb_receiver, rb_arguments, rb_unlock_gvl;

    if (RB_TYPE_P(rb_options, RUBY_T_ARRAY)) {
        rb_receiver = Qnil;
        rb_arguments = rb_options;
        rb_unlock_gvl = Qnil;
    } else if (NIL_P(rb_options)) {
        rb_receiver = Qnil;
        rb_arguments = rb_ary_new();
        rb_unlock_gvl = Qnil;
    } else {
        rb_options = rbg_check_hash_type(rb_options);
        rbg_scan_options(rb_options,
                         "receiver", &rb_receiver,
                         "arguments", &rb_arguments,
                         "unlock_gvl", &rb_unlock_gvl,
                         NULL);
    }

    if (NIL_P(rb_receiver)) {
        receiver.v_pointer = NULL;
    } else {
        if (gobject_based_p((GIBaseInfo *)info)) {
            receiver.v_pointer = RVAL2GOBJ(rb_receiver);
        } else {
            receiver.v_pointer = DATA_PTR(rb_receiver);
        }
    }
    rb_arguments = rbg_to_array(rb_arguments);
    if (!NIL_P(rb_unlock_gvl) && RVAL2CBOOL(rb_unlock_gvl)) {
        unlock_gvl = TRUE;
    }

    callable_info = (GICallableInfo *)info;
    arguments_init(&in_args, &out_args, &args_metadata);
    if (receiver.v_pointer) {
        g_array_append_val(in_args, receiver);
    }
    arguments_from_ruby(callable_info, rb_arguments,
                        in_args, out_args, args_metadata);
    {
        InvokeData data;
        data.info = info;
        data.in_args = in_args;
        data.out_args = out_args;
        data.return_value = return_value;
        data.error = &error;
        if (unlock_gvl) {
            rb_thread_call_without_gvl(
                rb_gi_function_info_invoke_raw_call_without_gvl_body, &data,
                NULL, NULL);
        } else {
            rb_gi_function_info_invoke_raw_call(&data);
        }
        succeeded = data.succeeded;
    }

    if (succeeded) {
        rb_out_args = out_arguments_to_ruby(callable_info,
                                            in_args, out_args,
                                            args_metadata);
    }
    arguments_free(in_args, out_args, args_metadata);
    if (!succeeded) {
        RG_RAISE_ERROR(error);
    }

    if (!NIL_P(rb_out_args) && RARRAY_LEN(rb_out_args) == 1) {
        VALUE rb_out_arg;
        rb_out_arg = RARRAY_PTR(rb_out_args)[0];
        if (rb_obj_is_kind_of(rb_out_arg, rb_eException)) {
            rb_exc_raise(rb_out_arg);
        }
    }

    return rb_out_args;
}