Thursday, March 11, 2010

Nerd Food: use_action_appearance saga

While playing with Ian Remmel's instructions on how to use Gtk::Action and Gtk::ActionGroups, I've bumped into an annoying problem: for some reason my toolbar icons and menu items started behaving weirdly after adding some Gtk::Actions to them. Symptoms were blank labels on menu options and blank toolbar items, or toolbar items with words rather than stock items. After some head scratching, I think I got to the bottom of it. Basically, the toolbar or menu item is taking its caption from the Gtk::Action.


Stock item refresh not being displayed.

What is puzzling is that the Glade UI clearly says that "Use Action Appearance" is set to "No". However, close inspection of the .glade file shows no mention of this property at all, so somehow the default value for it appears to be "Yes". I proved it by manually hacking use_action_appearance, e.g.:

<property name="related_action">act_reload</property>
<property name="use_action_appearance">False</property>

This fixed all my prolems. Of course, this is not a long term solution because it gets overwritten every time you save your .glade file. A more enduring workaround may be to do this in code, possibly where you add the Gtk::Action to the Gtk::ActionGroup, at least until Glade fixes the bug.

Another puzzling aspect of this bug is that there has been a lot of work around it of late, as the release notes of glade-3 3.6.7-0ubuntu1 imply:

- Sync up remaining properties at load time (fixes use-action-appearance property and any other unmentioned property states at load time, also unvails broken orientation default value in GTK+, bug 587256).
- Fixed glitches with use-action-appearance at save time.

A quick apt-cache check reveals we're running the correct version:

$ apt-cache show glade | grep "^Version"
Version: 3.6.7-1ubuntu1

So either all of this activity around use_action_appearance did not fix the bug or there was some kind of merge mistake downstream. Here we can see the commit that tried to fix the problem - nothing obvious to the layman, unfortunately. By downloading the tarball used to make the Ubuntu package, we can easily confirm that the upstream commit is present downstream.

An upstream bug report had been filled for this problem: #582882. Shame it wasn't cross referenced in the release notes, like some others were. Perhaps the maintainers haven't gotten to the bug report just yet.

Nothing more to do other than wait for the glade maintainers...

Update: Another workaround for this problem is to set the icon / lable text directly on the action.

No comments: