static VALUE rg_insert(int argc, VALUE *argv, VALUE self) { GtkWidget* ret = NULL; VALUE type = Qnil; VALUE pos, widget, stock_id, element_type, text, ttext, ptext, icon, func; if (argc > 1) type = argv[1]; if (NIL_P(type) || TYPE(type) == T_STRING){ rb_scan_args(argc, argv, "15", &pos, &text, &ttext, &ptext, &icon, &func); if (NIL_P(func)) func = rb_block_proc(); G_RELATIVE(self, func); ret = gtk_toolbar_insert_item(_SELF(self),N_RVAL2CSTR(text), N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), N_RVAL2WIDGET(icon), GTK_SIGNAL_FUNC(exec_callback), (gpointer)func, NUM2INT(pos)); } else if (TYPE(type) == T_FIXNUM) { rb_scan_args(argc, argv, "17", &pos, &element_type, &widget, &text, &ttext, &ptext, &icon, &func); if (NIL_P(func)) func = rb_block_proc(); G_RELATIVE(self, func); ret = gtk_toolbar_insert_element(_SELF(self), RVAL2GENUM(element_type, GTK_TYPE_TOOLBAR_CHILD_TYPE), N_RVAL2WIDGET(widget), N_RVAL2CSTR(text), N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), N_RVAL2WIDGET(icon), GTK_SIGNAL_FUNC(exec_callback), (gpointer)func, NUM2INT(pos)); if (RVAL2GENUM(element_type, GTK_TYPE_TOOLBAR_CHILD_TYPE) == GTK_TOOLBAR_CHILD_SPACE) ret = NULL; } else if (TYPE(type) == T_SYMBOL) { rb_scan_args(argc, argv, "14", &pos, &stock_id, &ttext, &ptext, &func); if (NIL_P(func)) func = rb_block_proc(); G_RELATIVE(self, func); ret = gtk_toolbar_insert_stock(_SELF(self), rb_id2name(SYM2ID(stock_id)), N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), GTK_SIGNAL_FUNC(exec_callback), (gpointer)func, NUM2INT(pos)); #if GTK_CHECK_VERSION(2,4,0) } else if (rb_obj_is_kind_of(type, GTYPE2CLASS(GTK_TYPE_TOOL_ITEM))){ rb_scan_args(argc, argv, "20", &pos, &widget); gtk_toolbar_insert(_SELF(self), GTK_TOOL_ITEM(RVAL2GOBJ(widget)), NUM2INT(pos)); return widget; #endif } else { rb_scan_args(argc, argv, "22", &pos, &widget, &ttext, &ptext); gtk_toolbar_insert_widget(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget)), N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), NUM2INT(pos)); return widget; } return ret ? GOBJ2RVAL(ret) : Qnil; }
static GtkWidget * gtk2perl_toolbar_insert_internal (GtkToolbar * toolbar, SV * type, SV * widget, SV * text, SV * tooltip_text, SV * tooltip_private_text, SV * icon, SV * callback, SV * user_data, SV * position, WhichInsert which, WhichOp op) { GtkWidget * w = NULL; const char * real_tooltip_text = NULL; const char * real_tooltip_private_text = NULL; /* _ornull is not always right for text, but is for the others. */ real_tooltip_text = SvGChar_ornull (tooltip_text); real_tooltip_private_text = SvGChar_ornull (tooltip_private_text); switch (which) { case STOCK: /* stock with NULL text (the stock id) makes no sense, * so let's make sure perl will issue an uninitialized * value warning for undef passed here for text. */ w = gtk_toolbar_insert_stock (toolbar, SvGChar (text), real_tooltip_text, real_tooltip_private_text, NULL, NULL, SvIV (position)); break; case ITEM: { const gchar * real_text = SvGChar_ornull (text); GtkWidget * real_icon = SvGtkWidget_ornull (icon); switch (op) { case PREPEND: w = gtk_toolbar_prepend_item (toolbar, real_text, real_tooltip_text, real_tooltip_private_text, real_icon, NULL, NULL); break; case APPEND: w = gtk_toolbar_append_item (toolbar, real_text, real_tooltip_text, real_tooltip_private_text, real_icon, NULL, NULL); break; case INSERT: w = gtk_toolbar_insert_item (toolbar, real_text, real_tooltip_text, real_tooltip_private_text, real_icon, NULL, NULL, SvIV (position)); break; default: g_assert_not_reached (); } } break; case ELEMENT: { GtkToolbarChildType real_type = SvGtkToolbarChildType(type); const gchar * real_text = SvGChar_ornull (text); GtkWidget * real_widget = SvGtkWidget_ornull (widget); GtkWidget * real_icon = SvGtkWidget_ornull (icon); switch (op) { case PREPEND: w = gtk_toolbar_prepend_element (toolbar, real_type, real_widget, real_text, real_tooltip_text, real_tooltip_private_text, real_icon, NULL, NULL); break; case APPEND: w = gtk_toolbar_append_element (toolbar, real_type, real_widget, real_text, real_tooltip_text, real_tooltip_private_text, real_icon, NULL, NULL); break; case INSERT: w = gtk_toolbar_insert_element (toolbar, real_type, real_widget, real_text, real_tooltip_text, real_tooltip_private_text, real_icon, NULL, NULL, SvIV (position)); break; default: g_assert_not_reached (); } } break; case WIDGET: { w = SvGtkWidget (widget); switch (op) { case PREPEND: gtk_toolbar_prepend_widget (toolbar, w, real_tooltip_text, real_tooltip_private_text); break; case APPEND: gtk_toolbar_append_widget (toolbar, w, real_tooltip_text, real_tooltip_private_text); break; case INSERT: gtk_toolbar_insert_widget (toolbar, w, real_tooltip_text, real_tooltip_private_text, SvIV (position)); break; default: g_assert_not_reached (); } } break; default: g_assert_not_reached (); } if (gperl_sv_is_defined (callback)) gperl_signal_connect (newSVGtkWidget (w), "clicked", callback, user_data, 0); return w; }