action menu demo (again)

I didn't get any response about the problems I was having with dynamic accel changes with my action menu demo, so I investigated it a bit further. It looks like _gtk_widget_get_accel_path() was returning NULL for my menu items even though I had called gtk_menu_item_set_accel_path() on them.

As a quick fix, I applied the following patch, which checks menu_item->accel_path if _gtk_widget_get_accel_path() returns NULL. With this patch applied, the code works perfectly.

I put the updated version up at:

As well as not beeping when you try to change accels (provided the patch below has been applied), this version also loads/saves changed accels.

Overall, I am quite happy with the new accelerators API.


Index: gtkmenu.c
RCS file: /cvs/gnome/gtk+/gtk/gtkmenu.c,v
retrieving revision 1.78
diff -u -p -r1.78 gtkmenu.c
--- gtkmenu.c    2001/11/29 20:36:12    1.78
+++ gtkmenu.c    2001/12/07 06:42:03
@@ -1661,6 +1661,8 @@ gtk_menu_key_press (GtkWidget    *widget,

      path = _gtk_widget_get_accel_path (menu_item);
      if (!path)
+    path = GTK_MENU_ITEM (menu_item)->accel_path;
+      if (!path)
      /* can't change accelerators on menu_items without paths
       * (basically, those items are accelerator-locked).

Email: james daa com au

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