/* Inserts in notebook a new page whose content is child, whose bookmark is * tab_label, and whose menu label is menu_label. The page is inserted just * before the page number position, starting with 0. If position is out of * bounds, it is assumed to be the current number of pages. */ int clip_GTK_NOTEBOOKINSERTPAGEMENU(ClipMachine * ClipMachineMemory) { C_widget *cntb = _fetch_cw_arg(ClipMachineMemory); C_widget *cchild = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 2)); C_widget *ctab_label; GtkWidget *tab_label; C_widget *cmenu_label; GtkWidget *menu_label; gint position = _clip_parni(ClipMachineMemory, 5); CHECKCWID(cntb, GTK_IS_NOTEBOOK); CHECKARG2(2, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType); CHECKCWID(cchild, GTK_IS_WIDGET); CHECKARG3(3, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType, CHARACTER_type_of_ClipVarType); CHECKARG3(4, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType, CHARACTER_type_of_ClipVarType); CHECKOPT(5, NUMERIC_type_of_ClipVarType); if (_clip_parinfo(ClipMachineMemory, 3) == CHARACTER_type_of_ClipVarType) { char *caption = _clip_parc(ClipMachineMemory, 3); LOCALE_TO_UTF(caption); tab_label = gtk_label_new(caption); FREE_TEXT(caption); } else { ctab_label = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 3)); CHECKCWID(ctab_label, GTK_IS_WIDGET); if (ctab_label) tab_label = ctab_label->widget; } if (_clip_parinfo(ClipMachineMemory, 4) == CHARACTER_type_of_ClipVarType) { char *menu_text = _clip_parc(ClipMachineMemory, 4); LOCALE_TO_UTF(menu_text); menu_label = gtk_label_new(menu_text); FREE_TEXT(menu_text); } else { cmenu_label = _fetch_cwidget(ClipMachineMemory, _clip_spar(ClipMachineMemory, 4)); CHECKCWID(cmenu_label, GTK_IS_WIDGET); if (cmenu_label) menu_label = cmenu_label->widget; } if (_clip_parinfo(ClipMachineMemory, 5) == UNDEF_type_of_ClipVarType) position = 1; gtk_notebook_insert_page_menu(GTK_NOTEBOOK(cntb->widget), cchild->widget, tab_label, menu_label, position - 1); return 0; err: return 1; }
void addGroup (const gchar *name, const gchar *icon_path, const gchar *nick, const gchar *sort_key) { // calculate position int pos; { std::list <std::string>::iterator it; for (it = sort_keys.begin(), pos = 0; it != sort_keys.end(); it++, pos++) if (strcmp (it->c_str(), sort_key) >= 0) break; sort_keys.insert (it, sort_key); } // label widget GtkWidget *tab_label, *image, *label; GdkPixbuf *icon = NULL; if (icon_path) { GError *error = 0; std::string path = ICONS + std::string (icon_path) + ".png"; icon = gdk_pixbuf_new_from_file (path.c_str(), &error); if (!icon) g_warning ("Could not load icon: %s.\nReason: %s", icon_path, error->message); } tab_label = gtk_hbox_new (FALSE, 0); label = gtk_label_new (name); if (icon) image = gtk_image_new_from_pixbuf (icon); if (icon) gtk_box_pack_start (GTK_BOX (tab_label), image, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (tab_label), label, TRUE, TRUE, icon ? 6 : 0); // page widget GtkListStore *store = gtk_list_store_new (3, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING); m_stores [nick] = store; GtkWidget *icons_view; icons_view = gtk_icon_view_new_with_model (GTK_TREE_MODEL (store)); gtk_icon_view_set_text_column (GTK_ICON_VIEW (icons_view), 0); gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (icons_view), 1); g_signal_connect(G_OBJECT (icons_view), "item-activated", G_CALLBACK (executeCommand), this); GtkWidget *page; page = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (page), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (page), GTK_SHADOW_IN); gtk_container_add (GTK_CONTAINER (page), icons_view); // add those to the notebook gtk_widget_show_all (tab_label); gtk_notebook_insert_page_menu (GTK_NOTEBOOK (m_widget), page, tab_label, NULL, pos); }
static VALUE rg_insert_page_menu(int argc, VALUE *argv, VALUE self) { VALUE pos, child, tab_label, menu_label; rb_scan_args(argc, argv, "22", &pos, &child, &tab_label, &menu_label); gtk_notebook_insert_page_menu(_SELF(self), RVAL2WIDGET(child), RVAL2WIDGET(tab_label), RVAL2WIDGET(menu_label), NUM2INT(pos)); return self; }