GNOME Bugzilla – Bug 341723
[PATCH] Support gtk.ToggleAction and gtk.RadioAction
Last modified: 2011-02-04 04:08:02 UTC
Please describe the problem: Gazpacho does not support adding ToggleActions and RadioActions, so it is not possible to use those as menu items or toolbars. Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
Created attachment 65425 [details] [review] initial patch Initial patch, needs some work still: - remove code duplication in subclasses of GAction - add support and UI for additional ToggleAction and RadioAction properties - cleanup the Gazpacho toolbar/menu UI for adding the different actions (i.e. don't have three "Add" buttons/menu items in a row).
Looking for comments on the way I have started to implement this...
This sounds great. I haven't got time to look at the code right now (I'll see if I can find some time later this week, please remind me if I forget). About adding the actions. It would probably be best to reuse the same dialog for the different actions? Just add a combobox for selecting the type of action you want to create and make sure the content of the dialog reflects the chosen action type. It should probably not be possible to change the action type after the action have been created. cheers
I've taken a (quick) look at the code now and it seems to me that you're on the right track. As you mentioned earlier, there are a few things left to do but it's a good start. The action tree view should probably be modified a bit to make it possible to see the action types. And if you have time to write a couple unit tests to verify that the code is correct that would be greatly appreciated. :)
Created attachment 66601 [details] [review] updated patch with UI improvements and loading/saving support Still not complete, but a good step down that road... This one adds UI for setting Toggle and Radio action properties (although setting the radio group is broken) and removes the additional "New Blah Action" buttons/menu items - the New/Edit Action dialog now has a combo to select the action type (not sensitive when editing an action) and the UI for the additional properties is shown/hidden as appropriate. This makes GActionDialog's internals kinda ugly, but I don't see any good way of avoiding this. Radio and toggle properties are getting saved/loaded as well, so the TODO is now: - remove code duplication in subclasses of GAction - make setting radio group work - write some unit tests (of course :)
Comment on attachment 66601 [details] [review] updated patch with UI improvements and loading/saving support Some general comments: * You're still repeating code in actioneditor, the toggle and radio handling should be refactored methods. * I recently migrated all xml writing code to xmlwriter, you need to remove the code from your copy, GAction.write() is no longer called for instance.
Created attachment 66606 [details] [review] Fixed to use filewriter for writing actions Ah, thanks for pointing that out Johan, I didn't test saving after updating from svn. Whoops. I'm not sure what you mean about duplicated code in actioneditor, however. Are you talking about in _load_widgets, et al? Eg, adding methods like _load_radio_widgets for each of those?
About the action tree view, I'll look at doing that next. For toggles, I could just append the text " (Toggle)" after the id, or use an icon or similar. Either that or add an additional column to the view, but that seems like overkill. For radio actions, it would be good to show the groups in the tree, something like: ActionGroup |- Action |- Action \- Radio Group |- Radio Action \- Radio Action From the user's perspective, it would be nice if the groups had a name that they could specify, but the groups are just a list, so that would not be possible. Maybe Gazpacho should just generate the names for radio groups on the fly (something like "Radio Group n"), which would be displayed in the action tree and in GActionDialog when selecting a group.
Mike: code looks better now. The UI modifications are looking quite good too, but I have a couple of suggestions that would make it even better: - draw-as-radio is not very useful, I can't really see a use case when you want a toggle drawn as a radio button or a radio not drawn as a radio. I think this is mostly an internal property which shouldn't be messed with. - value makes sense for toggle actions as well, right? - mark the group in radio as insensitive if there are no other radio actions - it's unfortunate that the interface resizes when you switch action, is it possible to avoid that? Can you add some tests too, modify test/glade/uimanager.glade to include at least one radio and one toggle action.
I would like to see ToggleAction support in Gazpacho. Currently I have to patch my glade file after every edit, because Gazpacho 0.7.1 replaces my GtkToggleAction with a regular GtkAction. :(
Gazpacho development has been stalled and it has been unmaintained for a few years now. Maintainers don't have future development plan so i am closing the bugs as WONTFIX. Please feel free to reopen the bugs in future if anyone takes the responsibility for active development.