Note: This post is mainly for people interested in the GIMP's source. For others, just take my word that there is some progress =)
So, how is single window mode implemented in GIMP?
The heirarchy is the following:
The heirarchy of the user interface containers inside GIMP GimpDockable's inside GimpDockbook's inside GimpDock's |
GimpDock - which is very similar to a GtkVBox
|-- GimpDockbook - this is a small area which allows tabbing of several GimpDockable's
|--GimpDockable - This holds the actual content and user interface elements
Single window mode, introduced two new containers - left and right. In each of these 2 new containers, we can store several GimpDock's in a row (see the image from my previous post, to see how this looks).
Here is a typical part of the sessionrc file, a file in GIMP which holds your session preferences:
(session-info "toplevel" (factory-entry "gimp-dock-window") (position 0 25) (size 200 523) (open-on-exit) (aux-info (show-image-menu "false") (follow-active-image "true")) (gimp-dock (book (current-page 0) (dockable "gimp-layer-list" (tab-style icon) (preview-size 32)) (dockable "gimp-channel-list" (tab-style icon) (preview-size 32))) (book (position 236) (current-page 0) (dockable "gimp-color-editor" (tab-style preview) (aux-info (current-page "GimpColorSelect"))) (dockable "gimp-brush-grid" (tab-style preview)) (dockable "gimp-pattern-grid" (tab-style preview)))))So, here is a short analysis of what's going on:
(session-info "toplevel"...) - means we are talking about a top-level window
(factory-entry "gimp-dock-window") - means we are talking on a dock window (other windows are also saved, for example the location of the save dialog)
(current-page 0) - means that the current open tab is the first one
The rest is pretty self explanatory...
So, how am I supposed to implement saving a single window mode?
"Simply", add two parameters directly after (factory-entry "gimp-dock-window"). This entries are single-window-mode-position which can be one of "left", "right" and "floating" (since you can still have floating docks in single window mode). And, for docks which have one of either "left" or "right" value, I'll have to add a "dock-index" property which indicates their index in that side (left/right).
Here is the bad part - I'll need to add these configuration properties to the docks themselves, and to the configuration file. Then, I'll also have to support parsing these parameters when activating single window mode. This is going to be long, and annoying but it also has a bright side - I know how to do this =)
And with this somehow optimistic summary of what needs to be done - I'll go to sleep (I should really find times to update this blog during the day instead of writing at midnight :P).
Edited - Jun 16, 3:59 AM:
1. fixed a wrong class name inside the image of the gui
2. Got thumbs up about this way of implementation from martin (aka enselic) - the guru behind the single window mode.
Edited - Jun 18, 12:22 PM:
Loading the settings of single window mode works! BUT, saving them doesn't :-( The problem is that if we are currently in single window mode, dock windows are not saved at all (even the fact that they exist is not saved).
I believe they (the dock windows) are being destroyed during the switch to single window mode, after the dockables inside them were attached to the "uber" image window (that's how it's called in the code, I haven't chosen uber myself).
If I'm true, this will also explain why when I quit after switching to single window mode, the settings that were loaded for single window mode, are lost (since they were associated with the dock windows and these were destroyed).
There is no easy way out of this - I am starting to understand why mitch said this problem is so evil...
This is great and sounds sane to me :) Go go go!
ReplyDeleteWhen you go to Windows -> Single-Window Mode it probably runs a command, isn't there a way to run the same "thing" after opening GIMP(if you check that the single-window mode was enabled when you quited GIMP the last time)?
ReplyDelete@Thales Oliveira:
ReplyDeleteIf it would be so simple, it wouldn't have taken so much time to fix, wouldn't it? (At least that's what I hope).
The problem is that when switching from one mode to another, we loose all the information of the previous one. We need to implement saving on switching (not that hard) and also to implement saving the layout of a single window mode layout - and that's the hard part.
It's not impossible, but it requires someone that we'll have some time to sit working just on it, because there is lots of UI code to change, and if you switch to do something else you'll have hard time to get back to it. We need someone to have several (1? 2? more?) days to fix single window mode with nothing else on his mind.