static VALUE rg_prepend(int argc, VALUE *argv, VALUE self) { GtkWidget* ret = NULL; VALUE type = Qnil; VALUE widget, stock_id, element_type, text, ttext, ptext, icon, func; if (argc > 0) type = argv[0]; if (NIL_P(type) || TYPE(type) == T_STRING){ rb_scan_args(argc, argv, "05", &text, &ttext, &ptext, &icon, &func); if (NIL_P(func)) func = rb_block_proc(); G_RELATIVE(self, func); ret = gtk_toolbar_prepend_item(_SELF(self), N_RVAL2CSTR(text), N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext), N_RVAL2WIDGET(icon), GTK_SIGNAL_FUNC(exec_callback), (gpointer)func); } else if (TYPE(type) == T_FIXNUM) { rb_scan_args(argc, argv, "07", &element_type, &widget, &text, &ttext, &ptext, &icon, &func); if (NIL_P(func)) func = rb_block_proc(); G_RELATIVE(self, func); ret = gtk_toolbar_prepend_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); 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, "13", &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, 0); } else { rb_scan_args(argc, argv, "12", &widget, &ttext, &ptext); gtk_toolbar_prepend_widget(_SELF(self), GTK_WIDGET(RVAL2GOBJ(widget)), N_RVAL2CSTR(ttext), N_RVAL2CSTR(ptext)); 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; }