Re: Table menu patch for GtkMenu



Hi Kristian,

I played some more with your new table menu patch. Here are some of the
problems I noticed:

- serious redraw problem. Opening the same menu twice yields a
  gray rectangle.
- keyboard-induced scrolling doesn't work (already mentioned)
- keyboard navigation into and out of submenus doesn't work anymore.
- using arrow keys to navigate in more complicated spanning menus 
  doesn't behave as expected (see the "items" submenu in the patch 
  below)
- the cell (1,2,2,3) in the "items" submenu appears unoccupied 
  although it shouldn't.

Matthias





Index: testgtk.c
===================================================================
RCS file: /cvs/gnome/gtk+/tests/testgtk.c,v
retrieving revision 1.334
diff -u -p -r1.334 testgtk.c
--- testgtk.c	1 Jul 2003 20:02:31 -0000	1.334
+++ testgtk.c	24 Jul 2003 22:14:13 -0000
@@ -3465,6 +3465,138 @@ create_menu (GdkScreen *screen, gint dep
   return menu;
 }
 
+static GtkWidget*
+create_table_menu (GdkScreen *screen, gint cols, gint rows, gboolean tearoff)
+{
+  GtkWidget *menu;
+  GtkWidget *menuitem;
+  GtkWidget *submenu;
+  GtkWidget *image;
+  char buf[32];
+  int i, j;
+
+  menu = gtk_menu_new ();
+  gtk_menu_set_screen (GTK_MENU (menu), screen);
+
+  j = 0;
+  if (tearoff)
+    {
+      menuitem = gtk_tearoff_menu_item_new ();
+      gtk_menu_attach (GTK_MENU (menu), menuitem, 0, cols, j, j + 1);
+      gtk_widget_show (menuitem);
+      j++;
+    }
+  
+  menuitem = gtk_menu_item_new_with_label ("items");
+  gtk_menu_attach (GTK_MENU (menu), menuitem, 0, cols, j, j + 1);
+
+  submenu = gtk_menu_new ();
+  gtk_menu_set_screen (GTK_MENU (submenu), screen);
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
+  gtk_widget_show (menuitem);
+  j++;
+
+  /* now fill the items submenu */
+  image = gtk_image_new_from_stock (GTK_STOCK_HELP,
+				    GTK_ICON_SIZE_MENU);
+  gtk_widget_show (image);
+  menuitem = gtk_image_menu_item_new_with_label ("Image");
+  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 0, 1, 0, 1);
+  gtk_widget_show (menuitem);
+
+  menuitem = gtk_menu_item_new_with_label ("x");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 1, 2, 0, 1);
+  gtk_widget_show (menuitem);
+
+  menuitem = gtk_menu_item_new_with_label ("x");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 0, 1, 1, 2);
+  gtk_widget_show (menuitem);
+  
+  image = gtk_image_new_from_stock (GTK_STOCK_HELP,
+				    GTK_ICON_SIZE_MENU);
+  gtk_widget_show (image);
+  menuitem = gtk_image_menu_item_new_with_label ("Image");
+  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menuitem), image);
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 1, 2, 1, 2);
+  gtk_widget_show (menuitem);
+
+  menuitem = gtk_radio_menu_item_new_with_label (NULL, "Radio");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 0, 1, 2, 3);
+  gtk_widget_show (menuitem);
+
+  menuitem = gtk_menu_item_new_with_label ("x");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 1, 2, 2, 3);
+  gtk_widget_show (menuitem);
+
+  menuitem = gtk_menu_item_new_with_label ("x");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 0, 1, 3, 4);
+  gtk_widget_show (menuitem);
+  
+  menuitem = gtk_radio_menu_item_new_with_label (NULL, "Radio");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 1, 2, 3, 4);
+  gtk_widget_show (menuitem);
+
+  menuitem = gtk_check_menu_item_new_with_label ("Check");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 0, 1, 4, 5);
+  gtk_widget_show (menuitem);
+
+  menuitem = gtk_menu_item_new_with_label ("x");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 1, 2, 4, 5);
+  gtk_widget_show (menuitem);
+
+  menuitem = gtk_menu_item_new_with_label ("x");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 0, 1, 5, 6);
+  gtk_widget_show (menuitem);
+  
+  menuitem = gtk_check_menu_item_new_with_label ("Check");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 1, 2, 5, 6);
+  gtk_widget_show (menuitem);
+  /* end of items submenu */
+
+  menuitem = gtk_menu_item_new_with_label ("spanning");
+  gtk_menu_attach (GTK_MENU (menu), menuitem, 0, cols, j, j + 1);
+
+  submenu = gtk_menu_new ();
+  gtk_menu_set_screen (GTK_MENU (submenu), screen);
+  gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), submenu);
+  gtk_widget_show (menuitem);
+  j++;
+
+  /* now fill the spanning submenu */
+  menuitem = gtk_menu_item_new_with_label ("a");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 0, 2, 0, 1);
+  gtk_widget_show (menuitem);
+
+  menuitem = gtk_menu_item_new_with_label ("b");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 2, 3, 0, 2);
+  gtk_widget_show (menuitem);
+
+  menuitem = gtk_menu_item_new_with_label ("c");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 0, 1, 1, 3);
+  gtk_widget_show (menuitem);
+
+  menuitem = gtk_menu_item_new_with_label ("d");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 1, 2, 1, 2);
+  gtk_widget_show (menuitem);
+
+  menuitem = gtk_menu_item_new_with_label ("e");
+  gtk_menu_attach (GTK_MENU (submenu), menuitem, 1, 3, 2, 3);
+  gtk_widget_show (menuitem);
+  /* end of spanning submenu */
+  
+  for (; j < rows; j++)
+      for (i = 0; i < cols; i++)
+      {
+	sprintf (buf, "(%d %d)", i, j);
+	menuitem = gtk_menu_item_new_with_label (buf);
+	gtk_menu_attach (GTK_MENU (menu), menuitem, i, i + 1, j, j + 1);
+	gtk_widget_show (menuitem);
+      }
+  
+  return menu;
+}
+
 static void
 create_menus (GtkWidget *widget)
 {
@@ -3513,6 +3645,13 @@ create_menus (GtkWidget *widget)
       menu = create_menu (screen, 2, 50, TRUE);
       
       menuitem = gtk_menu_item_new_with_label ("test\nline2");
+      gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
+      gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
+      gtk_widget_show (menuitem);
+
+      menu = create_table_menu (screen, 2, 50, TRUE);
+      
+      menuitem = gtk_menu_item_new_with_label ("table");
       gtk_menu_item_set_submenu (GTK_MENU_ITEM (menuitem), menu);
       gtk_menu_shell_append (GTK_MENU_SHELL (menubar), menuitem);
       gtk_widget_show (menuitem);


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