Showing posts with label single-window. Show all posts
Showing posts with label single-window. Show all posts

Wednesday, June 16, 2010

Progress - Saving Single Window Mode settings in GIMP

Two days ago, I promised to try and work on the single window mode in GIMP. Well, I have worked on it, and I know basically know what needs to be done.

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...

Sunday, June 13, 2010

Single window mode - wonderful for the user, horrible for the developer

Some of you may have seen the single window mode introduced in 2.7. It's wonderful to use (no need to suffer anymore from the huge amount of floating docks!). You can dock all the dialogs on the sides and customize the location and size of every one of them. All, inside the main window!

New features in this screenshot are layer groups, resource tagging, on-canvas text editing and on canvas dialogs, single window mode and paint-dynamics dialog (you can configure each dynamics settings in more way than you can imagine :D)
But, here is the catch - you can't save this layout! Every time you start Gimp, you will have to go to Windows->Single-Window Mode to enable this, and the location of the docks won't be saved. In other words, you have to rearrange the window layout every time, when using single window mode.
And to make it worse, when trying to fix this mitch warned me:
you actually picked the most evil current problem ;-)
Having to set your layout again every time IS VERY ANNOYING.  I'll try to fix this, but after looking at it I'm sure it's not going to be easy. Oh well, someone has to do this =) Starting this at the middle of the night (an hour ago) wasn't so smart - I'll go to sleep and do this (or at least try to) sometime during this week...