[gtkmvc-users] Working with subviews
Brought to you by:
cavada
From: Steve M. <smc...@gm...> - 2012-05-25 15:26:25
|
Greetings, I've been trying to figure out the best way to deal with subviews using gtkmvc with gtkbuilder, and I came across this message on the mailing list archive: >> I personally use always the third. My latest preferences actually go to: >> >> 1. Separate glade 'builder' files per each view >> 2. Subview instantiated and connected in parent views >> 3. menu and toolbars not designed in glade, but constructed in ui manager >> 3.1 The top-level view has the space to accomodate the "tools" subview >> (menu and toolbars) >> 3.2 There is a glade (builder) file associated to one or more views to >> represent menu ad toolbars. The glade file contains actions, action >> groups and one uimanager object. >> 3.3 The view(s) for the menu and toolbars sets up the action groups, the >> actions, the accelerators, and using the uimanager instance create menus >> and toolbars out of xml files. The view has also the methods for >> dynamically change menu and toolbars throught visibility and sensitivity >> of actions and action groups. >> >> Cheers, >> r. I'm having some trouble getting my head around a few things though. Is there any published code out there using this pattern? I'm not entirely certain how to break everything down, especially dealing with the menu and toolbars. Right now, I have three views with their own glade files. There is a main window, and two subviews which each contain a set of controls to pack into a vbox in the main window. The top level objects in each subview's glade file are containers, one uses a vbox, one uses a table. In my main view's constructor, I pack them into the main window's vbox. This part seems to work alright, except that if a subview's controls have accelerator keys defined, I get this warning: "GtkWarning: IA__gtk_window_add_accel_group: assertion `GTK_IS_WINDOW (window)' failed" My motivation for creating the subviews was so that I could create matching subcontrollers, to split up my controller class before it got too big and messy. This leads me to the toolbar/menu problem. Some toolbar and menu actions should be handled directly be the various subcontrollers, so defining them in the main view and and using the main controller to pass events down to the subcontrollers seems inelegant. I'd like to find a way to define pieces of the toolbar/menubar in each subview, and connect their signals directly to handlers in the subcontrollers. Does anyone have any insight or examples? Thanks, -Steve McGrath -- If it ain't broke, you're not using a new enough version |