Bug in ItemFactory...
- From: Brian Masney <masneyb ns newwave net>
- To: gtk-list redhat com
- Subject: Bug in ItemFactory...
- Date: Wed, 12 May 1999 21:23:09 -0400 (EDT)
Hello,
While I was working on buidling dynamic menus with itemfactory, I found
a bug in the delete code. It will delete menu items fine, but it will not
delete a branch. I wrote a quick program to demonstrate this. If I am
doing something wrong, please let me know
Brian
#include <gtk/gtk.h>
void del (GtkWidget *widget, gpointer data);
void exitCB (GtkWidget *widget, gpointer data);
int main (int argc, char *argv[]) {
GtkItemFactoryEntry menu_items[] = {
{"/File", NULL, 0, 0, "<Branch>"},
{"/File/Entry", NULL, 0, 0},
{"/File/Submenu", NULL, 0, 0, "<Branch>"},
{"/File/Submenu/Entry1",NULL, 0, 0},
{"/File/Submenu/Entry2",NULL, 0, 0}};
GtkItemFactory *ifactory;
GtkWidget *box, *button, *window;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (exitCB), NULL);
box = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), box);
gtk_widget_show (box);
ifactory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", NULL);
gtk_item_factory_create_items (ifactory, 5, menu_items, NULL);
gtk_box_pack_start (GTK_BOX (box), ifactory->widget, FALSE, FALSE, FALSE);
gtk_widget_show (ifactory->widget);
button = gtk_button_new_with_label (" Delete Items ");
gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, FALSE);
gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (del), (gpointer) ifactory);
gtk_container_set_border_width (GTK_CONTAINER (button), 10);
gtk_widget_show (button);
gtk_widget_show (window);
gtk_main ();
return (0);
}
void del (GtkWidget *widget, gpointer data) {
GtkItemFactory *ifactory;
ifactory = (GtkItemFactory *) data;
gtk_item_factory_delete_item (ifactory, "/File/Submenu/Entry2");
gtk_item_factory_delete_item (ifactory, "/File/Submenu/Entry1");
gtk_item_factory_delete_item (ifactory, "/File/Submenu");
gtk_widget_set_sensitive (widget, 0);
}
void exitCB (GtkWidget *widget, gpointer data) {
gtk_main_quit ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]