[gtk+/gtk-2-90] Don't use GtkItemFactory in testsocket



commit bed35704f9b08246739b088f631c67ef79397eb7
Author: Christian Dywan <christian twotoasts de>
Date:   Wed Mar 31 16:44:40 2010 +0200

    Don't use GtkItemFactory in testsocket

 tests/testsocket.c        |   30 +++++++++++---------------
 tests/testsocket_common.c |   51 +++++++++++++++++++++++++++-----------------
 2 files changed, 44 insertions(+), 37 deletions(-)
---
diff --git a/tests/testsocket.c b/tests/testsocket.c
index fab0e41..1493215 100644
--- a/tests/testsocket.c
+++ b/tests/testsocket.c
@@ -62,12 +62,6 @@ quit_cb (gpointer        callback_data,
   gtk_widget_destroy (message_dialog);
 }
 
-static GtkItemFactoryEntry menu_items[] =
-{
-  { "/_File",            NULL,         NULL,                  0, "<Branch>" },
-  { "/File/_Quit",       "<control>Q", quit_cb,               0 },
-};
-
 static void
 socket_destroyed (GtkWidget *widget,
 		  Socket    *socket)
@@ -312,10 +306,12 @@ main (int argc, char *argv[])
   GtkWidget *button;
   GtkWidget *hbox;
   GtkWidget *vbox;
+  GtkWidget *menubar;
+  GtkWidget *menuitem;
+  GtkWidget *menu;
   GtkWidget *entry;
   GtkWidget *checkbutton;
   GtkAccelGroup *accel_group;
-  GtkItemFactory *item_factory;
 
   gtk_init (&argc, &argv);
 
@@ -329,18 +325,18 @@ main (int argc, char *argv[])
   vbox = gtk_vbox_new (FALSE, 0);
   gtk_container_add (GTK_CONTAINER (window), vbox);
 
+  menubar = gtk_menu_bar_new ();
+  menuitem = gtk_menu_item_new_with_mnemonic ("_File");
+  menu = gtk_menu_new ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
+  menuitem = gtk_menu_item_new_with_mnemonic ("_Quit");
+  g_signal_connect (menuitem, "clicked", G_CALLBACK (quit_cb), window);
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+  gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
+
   accel_group = gtk_accel_group_new ();
   gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
-  item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>", accel_group);
-
-  
-  gtk_item_factory_create_items (item_factory,
-				 G_N_ELEMENTS (menu_items), menu_items,
-				 NULL);
-      
-  gtk_box_pack_start (GTK_BOX (vbox),
-		      gtk_item_factory_get_widget (item_factory, "<main>"),
-		      FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, FALSE, 0);
 
   button = gtk_button_new_with_label ("Add Active Child");
   gtk_box_pack_start (GTK_BOX(vbox), button, FALSE, FALSE, 0);
diff --git a/tests/testsocket_common.c b/tests/testsocket_common.c
index 866d1aa..148b033 100644
--- a/tests/testsocket_common.c
+++ b/tests/testsocket_common.c
@@ -60,17 +60,6 @@ print_hello (GtkWidget *w,
     }
 }
 
-static GtkItemFactoryEntry menu_items[] = {
-  { "/_File",         NULL,         NULL,           0, "<Branch>" },
-  { "/File/_New",     "<control>N", print_hello,    ACTION_FILE_NEW, "<Item>" },
-  { "/File/_Open",    "<control>O", print_hello,    ACTION_FILE_OPEN, "<Item>" },
-  { "/File/sep1",     NULL,         NULL,           0, "<Separator>" },
-  { "/File/Quit",     "<control>Q", gtk_main_quit,  0, "<Item>" },
-  { "/O_K",            "<control>K",print_hello,    ACTION_OK, "<Item>" },
-  { "/_Help",         NULL,         NULL,           0, "<LastBranch>" },
-  { "/_Help/About",   NULL,         print_hello,    ACTION_HELP_ABOUT, "<Item>" },
-};
-
 static void
 remove_buttons (GtkWidget *widget, GtkWidget *other_button)
 {
@@ -171,19 +160,41 @@ create_combo (void)
 static GtkWidget *
 create_menubar (GtkWindow *window)
 {
-  GtkItemFactory *item_factory;
   GtkAccelGroup *accel_group=NULL;
   GtkWidget *menubar;
-  
+  GtkWidget *menuitem;
+  GtkWidget *menu;
+
   accel_group = gtk_accel_group_new ();
-  item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>",
-                                       accel_group);
-  gtk_item_factory_create_items (item_factory,
-				 G_N_ELEMENTS (menu_items),
-				 menu_items, NULL);
-  
   gtk_window_add_accel_group (window, accel_group);
-  menubar = gtk_item_factory_get_widget (item_factory, "<main>");
+
+  menubar = gtk_menu_bar_new ();
+
+  menuitem = gtk_menu_item_new_with_mnemonic ("_File");
+  gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
+  menu = gtk_menu_new ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
+  menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, NULL);
+  g_signal_connect (menuitem, "clicked", G_CALLBACK (print_hello), window);
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+  menuitem = gtk_separator_menu_item_new ();
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+  menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL);
+  g_signal_connect (menuitem, "clicked", G_CALLBACK (gtk_main_quit), window);
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
+
+  menuitem = gtk_menu_item_new_with_mnemonic ("O_K");
+  gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
+  menu = gtk_menu_new ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
+
+  menuitem = gtk_menu_item_new_with_mnemonic ("_Help");
+  gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
+  menu = gtk_menu_new ();
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
+  menuitem = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL);
+  g_signal_connect (menuitem, "clicked", G_CALLBACK (print_hello), window);
+  gtk_menu_shell_append (GTK_MENU_SHELL (menu), menuitem);
 
   return menubar;
 }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]