[Glade-users] Using Actions + MenuItems + Accelerators + AccelLabels



On Mon, Oct 5, 2009 at 12:54 PM, Alexey Kurochkin
<alexey.kurochkin at pathfinderlwd.com> wrote:
On Sat, 2009-10-03 at 20:43 -0500, Manuel Alejandro Cer?n Estrada wrote:
Hello.

I have a bunch of actions and a MenuBar. Every MenuItem in the MenuBar
has an associated action. I'm using "related action" and "use action
appearance" to connect the actions with the menu. Now I want to assign
some shortcut keys to each action. I haven't found a way to do that in
Glade, so I'm doing it with code. I'm creating an ActionGroup and then
adding each action to that group using add_action_with_accel. Then I
create an AccelGroup and assign each action to it using
action.set_accel_group and connect the accelerator using
action.connect_accelerator. After that, I add the AccelGroup to the
window using window.set_accel_group. This seems to work, when I press
the keyboard shortcut the action is activated, however, the menu item
does not show the AccelLabel indicating the accelerator for that item.
How do I achieve this? Is there an easier way?

I'd like to see the answer too. Currently I create only the main menu
bar and empty sub menus with Glade, and all the menu items are created
and appended to the sub menus manually in the code. It results in
hundreds of lines of clutter which I'm looking forward to get rid of.

Hmmm ok from what I understand there is probably a bug here, plus
a couple of shortcomings in the whole builder/menu system.

If I understand correctly the menu item not updating the accelerator
when the action accel path and accel group is setup is a bug, and
should be filed for GTK+.

One of the gaps that is ridiculously easy to bridge is the fact
that we cannot setup accel groups properly in Glade, this
requires that GtkActionGroup implement GtkBuildable in order
to implement the ->add_child() method to add actions to groups
from a GtkBuilder xml... (and then some code in Glade to allow
you to parent the actions).

The other I guess is that setting accelerators on action in Glade
is not obvious, so much so that I dont have a clue how it works
honestly... all I know is that we can setup the accel group, and
we can set the accel path... and I know the accel path is a const gchar *.
so I know we can set it up from Glade.

Apart from that I have no idea what an accel path does, I've looked
at the GTK+ docs several times this past week (because I wanted
to answer this email actually), and I still have no idea what to do
with a const gchar *accel_path :-/

So that being said, sorry for the delay in answering, these loose
strings are few.. but tying them up could undoubtedly save many
people hundreds of lines of code...

I do wish I could promise to address these issues myself, as
they are pretty simple, but I really cant find the time right now.




I'm using PyGTK and glade 3.6.3

Manuel.
_______________________________________________
Glade-users maillist ?- ?Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users



_______________________________________________
Glade-users maillist ?- ?Glade-users at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/glade-users





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