? 342123-always-draw-checkbox.patch
? cvslog
? po/cvslog
? src/337376-make-move-cursor-a-hand.patch
? src/341648-dead-code-in-resize-popup.patch
? src/prefs-patch-ip.patch
Index: src/menu.c
===================================================================
RCS file: /cvs/gnome/metacity/src/menu.c,v
retrieving revision 1.44
diff -u -5 -r1.44 menu.c
--- src/menu.c	20 Feb 2006 02:15:14 -0000	1.44
+++ src/menu.c	8 Jun 2006 14:46:14 -0000
@@ -29,50 +29,130 @@
 #include "util.h"
 #include "core.h"
 #include "themewidget.h"
 #include "metaaccellabel.h"
 
-typedef struct _MenuItem MenuItem;
-typedef struct _MenuData MenuData;
-
-struct _MenuItem
+typedef enum
+{
+  MENU_ITEM_SEPARATOR = 0,
+  MENU_ITEM_CHECKBOX,
+  MENU_ITEM_IMAGE,
+  MENU_ITEM_NORMAL
+} MetaMenuItemType;
+
+/* Each item in the window menu is a MenuItem. Not all attributes in
+  the MenuItem is used by each MenuItem instance. Only MenuItems of
+  type MENU_ITEM_IMAGE uses stock_id to locate the image to
+  draw. MENU_ITEM_CHECKBOX uses checked to determine whether the
+  MenuItems checkbox should be drawn crossed or not.
+*/
+typedef struct
 {
+  MetaMenuItemType type;
   MetaMenuOp op;
   const char *stock_id;
   const gboolean checked;
   const char *label;
-};
-
+} MenuItem;
 
-struct _MenuData
+typedef struct
 {
   MetaWindowMenu *menu;
   MetaMenuOp op;
-};
-
-static void activate_cb (GtkWidget *menuitem, gpointer data);
+} MenuData;
 
 static MenuItem menuitems[] = {
-  { META_MENU_OP_MINIMIZE, METACITY_STOCK_MINIMIZE, FALSE, N_("Mi_nimize") },
-  { META_MENU_OP_MAXIMIZE, METACITY_STOCK_MAXIMIZE, FALSE, N_("Ma_ximize") },
-  { META_MENU_OP_UNMAXIMIZE, NULL, FALSE, N_("Unma_ximize") },
-  { META_MENU_OP_SHADE, NULL, FALSE, N_("Roll _Up") },
-  { META_MENU_OP_UNSHADE, NULL, FALSE, N_("_Unroll") },
-  { META_MENU_OP_ABOVE, NULL, FALSE, N_("On _Top") },
-  { META_MENU_OP_UNABOVE, NULL, TRUE, N_("On _Top") },
-  { META_MENU_OP_MOVE, NULL, FALSE, N_("_Move") },
-  { META_MENU_OP_RESIZE, NULL, FALSE, N_("_Resize") },
-  { META_MENU_OP_RECOVER, NULL, FALSE, N_("Move Titlebar On_screen") },
-  { 0, NULL, FALSE, NULL }, /* separator */
-  { META_MENU_OP_DELETE, METACITY_STOCK_DELETE, FALSE, N_("_Close") },
-  { META_MENU_OP_WORKSPACES, NULL, FALSE, NULL }, /* separator */
-  { META_MENU_OP_STICK, NULL, FALSE, N_("_Always on Visible Workspace") },
-  { META_MENU_OP_UNSTICK, NULL, FALSE,  N_("_Only on This Workspace") },
-  { META_MENU_OP_MOVE_LEFT, NULL, FALSE, N_("Move to Workspace _Left") },
-  { META_MENU_OP_MOVE_RIGHT, NULL, FALSE, N_("Move to Workspace R_ight") },
-  { META_MENU_OP_MOVE_UP, NULL, FALSE, N_("Move to Workspace _Up") },
-  { META_MENU_OP_MOVE_DOWN, NULL, FALSE, N_("Move to Workspace _Down") }
+  { MENU_ITEM_IMAGE,
+    META_MENU_OP_MINIMIZE,
+    METACITY_STOCK_MINIMIZE,
+    FALSE,
+    N_("Mi_nimize") },
+  { MENU_ITEM_IMAGE,
+    META_MENU_OP_MAXIMIZE,
+    METACITY_STOCK_MAXIMIZE,
+    FALSE,
+    N_("Ma_ximize") },
+  { MENU_ITEM_IMAGE,
+    META_MENU_OP_UNMAXIMIZE,
+    NULL,
+    FALSE,
+    N_("Unma_ximize") },
+  { MENU_ITEM_NORMAL,
+    META_MENU_OP_SHADE,
+    NULL,
+    FALSE,
+    N_("Roll _Up") },
+  { MENU_ITEM_NORMAL,
+    META_MENU_OP_UNSHADE,
+    NULL,
+    FALSE,
+    N_("_Unroll") },
+  { MENU_ITEM_CHECKBOX,
+    META_MENU_OP_ABOVE,
+    NULL,
+    FALSE,
+    N_("On _Top") },
+  { MENU_ITEM_CHECKBOX,
+    META_MENU_OP_UNABOVE,
+    NULL,
+    TRUE,
+    N_("On _Top") },
+  { MENU_ITEM_NORMAL,
+    META_MENU_OP_MOVE,
+    NULL,
+    FALSE,
+    N_("_Move") },
+  { MENU_ITEM_NORMAL,
+    META_MENU_OP_RESIZE,
+    NULL,
+    FALSE,
+    N_("_Resize") },
+  { MENU_ITEM_NORMAL,
+    META_MENU_OP_RECOVER,
+    NULL,
+    FALSE,
+    N_("Move Titlebar On_screen") },
+  
+  { MENU_ITEM_SEPARATOR, 0, NULL, FALSE, NULL },
+  
+  { MENU_ITEM_IMAGE,
+    META_MENU_OP_DELETE,
+    METACITY_STOCK_DELETE,
+    FALSE, N_("_Close") },
+  
+  { MENU_ITEM_SEPARATOR, META_MENU_OP_WORKSPACES, NULL, FALSE, NULL },
+  
+  { MENU_ITEM_CHECKBOX,
+    META_MENU_OP_STICK,
+    NULL,
+    FALSE,
+    N_("_Always on Visible Workspace") },
+  { MENU_ITEM_CHECKBOX,
+    META_MENU_OP_UNSTICK,
+    NULL,
+    TRUE,
+    N_("_Always on Visible Workspace") },
+  { MENU_ITEM_NORMAL,
+    META_MENU_OP_MOVE_LEFT,
+    NULL,
+    FALSE,
+    N_("Move to Workspace _Left") },
+  { MENU_ITEM_NORMAL,
+    META_MENU_OP_MOVE_RIGHT,
+    NULL,
+    FALSE,
+    N_("Move to Workspace R_ight") },
+  { MENU_ITEM_NORMAL,
+    META_MENU_OP_MOVE_UP,
+    NULL,
+    FALSE,
+    N_("Move to Workspace _Up") },
+  { MENU_ITEM_NORMAL,
+    META_MENU_OP_MOVE_DOWN,
+    NULL,
+    FALSE,
+    N_("Move to Workspace _Down") }
 };
 
 static void
 popup_position_func (GtkMenu   *menu,
                      gint      *x,
@@ -218,40 +298,56 @@
 
       return new_name;
     }
 }
 
+/* Create a GtkWidget from the MenuItem definition menuitem which can
+  be added to a GTK menu. workspace_idx is a number which is used by
+  meta_core_get_menu_accelerator to decide which keybinding to give
+  the menuitem. It should be -1 if the MenuItems op should be used to
+  find the keybinding instead.
+*/
 static GtkWidget*
-menu_item_new (const char         *label,
-               gboolean            with_image,
-	       gboolean		   with_check,
-               unsigned int        key,
-               MetaVirtualModifier mods)
+menu_item_new (MenuItem *menuitem, int workspace_idx)
 {
-  GtkWidget *menu_item;
+  unsigned int key;
+  MetaVirtualModifier mods;
+  const char *i18n_label;
+  GtkWidget *mi;
   GtkWidget *accel_label;
 
-  if (with_check)
+  if (menuitem->type == MENU_ITEM_IMAGE)
+    {
+      GtkWidget *image;
+      mi = gtk_image_menu_item_new ();
+      image = gtk_image_new_from_stock (menuitem->stock_id,
+                                        GTK_ICON_SIZE_MENU);
+      gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi), image);
+      gtk_widget_show (image);
+    }
+  else if (menuitem->type == MENU_ITEM_CHECKBOX)
     {
-      menu_item = gtk_check_menu_item_new ();    
-      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (menu_item),
-                                      TRUE);
+      mi = gtk_check_menu_item_new ();    
+      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mi),
+                                      menuitem->checked);
     }
-  else if (with_image)
-    menu_item = gtk_image_menu_item_new ();
+  else if (menuitem->type == MENU_ITEM_NORMAL)
+    mi = gtk_menu_item_new ();
   else
-    menu_item = gtk_menu_item_new ();
-  accel_label = meta_accel_label_new_with_mnemonic (label);
-  gtk_misc_set_alignment (GTK_MISC (accel_label), 0.0, 0.5);
+    return gtk_separator_menu_item_new ();
 
-  gtk_container_add (GTK_CONTAINER (menu_item), accel_label);
+  i18n_label = _(menuitem->label);
+  meta_core_get_menu_accelerator (menuitem->op, workspace_idx, &key, &mods);
+  
+  accel_label = meta_accel_label_new_with_mnemonic (i18n_label);
+  gtk_misc_set_alignment (GTK_MISC (accel_label), 0.0, 0.5);
+  gtk_container_add (GTK_CONTAINER (mi), accel_label);
   gtk_widget_show (accel_label);
 
   meta_accel_label_set_accelerator (META_ACCEL_LABEL (accel_label),
                                     key, mods);
-  
-  return menu_item;
+  return mi;
 }
 
 MetaWindowMenu*
 meta_window_menu_new   (MetaFrames         *frames,
                         MetaMenuOp          ops,
@@ -282,125 +378,84 @@
   menu->menu = gtk_menu_new ();
 
   gtk_menu_set_screen (GTK_MENU (menu->menu),
 		       gtk_widget_get_screen (GTK_WIDGET (frames)));
 
-  i = 0;
-  while (i < (int) G_N_ELEMENTS (menuitems))
+  for (i = 0; i < (int) G_N_ELEMENTS (menuitems); i++)
     {
-      if (ops & menuitems[i].op || menuitems[i].op == 0)
+      MenuItem menuitem = menuitems[i];
+      if (ops & menuitem.op || menuitem.op == 0)
         {
-          GtkWidget *mi;
+          GtkWidget *mi = menu_item_new (&menuitem, -1);
           MenuData *md;
-          unsigned int key;
-          MetaVirtualModifier mods;
-          
-          if (menuitems[i].label == NULL)
-            {
-              mi = gtk_separator_menu_item_new ();
-            }
-          else
-            {
-              GtkWidget *image;
 
-              image = NULL;
-              
-              if (menuitems[i].stock_id)
-                {
-                  image = gtk_image_new_from_stock (menuitems[i].stock_id,
-                                                    GTK_ICON_SIZE_MENU);
-
-                }
-
-              meta_core_get_menu_accelerator (menuitems[i].op, -1,
-                                              &key, &mods);
-
-              if (image)
-                {
-                  mi = menu_item_new (_(menuitems[i].label), TRUE, FALSE, key, mods);
-                  gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
-                                                 image);
-                  gtk_widget_show (image);
-                }
-              else
-                {
-                  mi = menu_item_new (_(menuitems[i].label), FALSE, 
-                                      menuitems[i].checked, key, mods);
-                }
-              
-              if (insensitive & menuitems[i].op)
-                gtk_widget_set_sensitive (mi, FALSE);
-              
-              md = g_new (MenuData, 1);
+          if (insensitive & menuitem.op)
+            gtk_widget_set_sensitive (mi, FALSE);
+
+          md = g_new (MenuData, 1);
               
-              md->menu = menu;
-              md->op = menuitems[i].op;
+          md->menu = menu;
+          md->op = menuitem.op;
               
-              gtk_signal_connect_full (GTK_OBJECT (mi),
-                                       "activate",
-                                       GTK_SIGNAL_FUNC (activate_cb),
-                                       NULL,
-                                       md,
-                                       g_free, FALSE, FALSE);
-            }
-          
-          gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu),
-                                 mi);
-          
+          gtk_signal_connect_full (GTK_OBJECT (mi),
+                                   "activate",
+                                   GTK_SIGNAL_FUNC (activate_cb),
+                                   NULL,
+                                   md,
+                                   g_free, FALSE, FALSE);
+
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu), mi);
           gtk_widget_show (mi);
         }
-      ++i;
     }
-
   if (ops & META_MENU_OP_WORKSPACES)
     {
-
-      GtkWidget *mi;
-      Display *display;
-      Window xroot;
-      GdkScreen *screen;
       GtkWidget *submenu;
       GtkWidget *submenuitem;
-
-      meta_verbose ("Creating %d-workspace menu current space %d\n",
-                    n_workspaces, active_workspace);
-          
-      display = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (frames)->window);
-          
-      screen = gdk_drawable_get_screen (GTK_WIDGET (frames)->window);
-      xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen));
+      int i;
+      Display *display;
+      GdkScreen *screen;
+      Window xroot;
+      MenuItem to_another_workspace = {
+        MENU_ITEM_NORMAL,
+        0, NULL, FALSE,
+        N_("Move to Another _Workspace")
+      };
 
       submenu = gtk_menu_new ();
-      submenuitem = menu_item_new (_("Move to Another _Workspace"), FALSE, FALSE, 0, 0);
+      submenuitem = menu_item_new (&to_another_workspace, -1);
+
+      gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu), submenuitem);
       gtk_menu_item_set_submenu (GTK_MENU_ITEM (submenuitem), submenu);
-      gtk_menu_shell_append (GTK_MENU_SHELL (menu->menu),
-			     submenuitem);
       gtk_widget_show (submenuitem);
-           
-      i = 0;
-      while (i < n_workspaces)
+
+      screen = gdk_drawable_get_screen (GTK_WIDGET (frames)->window);
+      display = gdk_x11_drawable_get_xdisplay (GTK_WIDGET (frames)->window);
+      xroot = GDK_DRAWABLE_XID (gdk_screen_get_root_window (screen));
+      
+      for (i = 0; i < n_workspaces; i++)
         {
+          MenuItem moveitem;
+          GtkWidget *mi;
           char *label;
           MenuData *md;
-          unsigned int key;
-          MetaVirtualModifier mods;
-              
-          meta_core_get_menu_accelerator (META_MENU_OP_WORKSPACES,
-                                          i + 1,
-                                          &key, &mods);
-              
-          label = get_workspace_name_with_accel (display, xroot, i);
-          mi = menu_item_new (label, FALSE, FALSE, key, mods);
 
+          label = get_workspace_name_with_accel (display, xroot, i);
+          
+          moveitem.type = MENU_ITEM_NORMAL;
+          moveitem.op = META_MENU_OP_WORKSPACES;
+          moveitem.label = label;
+          mi = menu_item_new (&moveitem, i + 1);
           g_free (label);
 
           if (!(ops & META_MENU_OP_UNSTICK) &&
               (active_workspace == i ||
                insensitive & META_MENU_OP_WORKSPACES))
             gtk_widget_set_sensitive (mi, FALSE);
           else if (insensitive & META_MENU_OP_WORKSPACES)
             gtk_widget_set_sensitive (mi, FALSE);
+
           md = g_new (MenuData, 1);
 
           md->menu = menu;
           md->op = META_MENU_OP_WORKSPACES;
 
@@ -413,16 +468,12 @@
                                    GTK_SIGNAL_FUNC (activate_cb),
                                    NULL,
                                    md,
                                    g_free, FALSE, FALSE);
 
-          gtk_menu_shell_append (GTK_MENU_SHELL (submenu),
-                                 mi);
-          
+          gtk_menu_shell_append (GTK_MENU_SHELL (submenu), mi);
           gtk_widget_show (mi);
-          
-          ++i;
         }
     }
   else
     meta_verbose ("not creating workspace menu\n");
   
