After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 358141 - Add session management for plug-in windows
Add session management for plug-in windows
Status: RESOLVED OBSOLETE
Product: GIMP
Classification: Other
Component: Plugins
git master
Other All
: High enhancement
: 2.10
Assigned To: GIMP Bugs
GIMP Bugs
: 700970 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-09-28 15:11 UTC by gg
Modified: 2018-05-24 12:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
allocate-gimp-dialog_2_9.patch (12.08 KB, patch)
2013-06-08 11:30 UTC, Hartmut Kuhse
none Details | Review
allocate-gimp-dialog_2_9_1.patch (12.08 KB, patch)
2013-07-10 19:55 UTC, Hartmut Kuhse
none Details | Review
allocate-gimp-dialog_2_9_1__1.patch (12.93 KB, patch)
2015-02-22 16:48 UTC, Hartmut Kuhse
none Details | Review

Description gg 2006-09-28 15:11:40 UTC
user screens and desktop layout vary widely. Default size and position of plug-in windows will often need changing. (eg preview is too small to be of real use or dlg obscures something else we need on the screen - maybe outside Gimp.)

It is infuriating and distruptive to work flow if the user needs to repeatedly resize and reposition every time he calls up a tool or filter.

Plug-ins need to retain these settings from one call to the next. Preferably across sessions as well.


Other information:
 [Gimp-developer] UI improvements :

> specific: Filters | Motion Blur ...  I resize to get a more visible  
> preview size and move it out of the way of other things on the screen.  
> Next time I use it I dont want to start again.
>  
> While this is probably down to the plugin writer, at least the "common"  
> filters should be vetted/modded to retain size/pos before being  
> integrated. And it should be recommended for all plug-ins.

Raphaël suggests this could go in pluginrc.
Comment 1 Michael Natterer 2006-09-28 15:22:50 UTC
I suggest this should go into sessionrc.

Both ends of that could be implemented quite trivially, even
passing the stored values to the plug-in would be a quick hack.
The problem is how to get the values from the plug-in back to
the app. The only way i see is to call a PDB function whenever 
the plug-in's dialog receives GtkWidget::configure-event.
Comment 2 Sven Neumann 2006-09-28 17:09:38 UTC
We need GimpPlugInDialog for this. AFAIK Mitch has already started to work on it. But this won't go into the tree before the 2.4 release.

The file pluginrc is of course the wrong place for this even though the name might imply that it's the right place. pluginrc is nothing but a cache of plug-in procedure registration.
Comment 3 Sven Neumann 2008-05-30 12:01:39 UTC
Bumping to 2.8.
Comment 4 Martin Nordholts 2010-01-23 09:38:15 UTC
Not enough resources or 2.8 and not a very important feature. Bumping to Future.
Comment 5 Hartmut Kuhse 2013-06-08 11:30:59 UTC
Created attachment 246299 [details] [review]
allocate-gimp-dialog_2_9.patch

How about something like this?
1. It creates a new folder in user directory.
2. When a gimp-dialog comes up, it tries to read it's rc file from the newly created folder and moves/resizes the dialog.
2. when a gimp-dialog closes, it takes the current values and writes a rc file in the newly created folder.
Comment 6 Michael Natterer 2013-06-08 13:48:35 UTC
Wow :)

Since the "real" solution (refactoring the plug-in API, having a GimpPlugIn
object etc blah) won't happen for 2.10, this approach is really nice and
just the right thing for 2.10).

Several comments:

- Please don't use tabs in the source
- Add spaces before all '('
- The config values should be "pos-x" not "pos_x"
- Use g_build_filename() not g_strconcat() (window backslashes)
- Format function headers properly
- Most importantly: make sure this only happens to plug-in windows,
  GimpDialog is used all over in the code too.
- I'm not sure if the help-id works everywhere, need to double check that
- I think the folder should simply be created when writing the config
  files, no need to do this in the core.
Comment 7 Michael Natterer 2013-06-08 13:58:19 UTC
In the "core" not in the "code.
Comment 8 Michael Natterer 2013-06-18 22:01:59 UTC
*** Bug 700970 has been marked as a duplicate of this bug. ***
Comment 9 Hartmut Kuhse 2013-07-10 19:55:46 UTC
Created attachment 248873 [details] [review]
allocate-gimp-dialog_2_9_1.patch

Next try:
I hope, now there are no more tabs in the source. My dev-environment sometimes ignores my wishes. And hopefully, a space is before every '('.
For the most importatnt thing: Of course I agree with you but I didn't find an other way than to blacklist every known internal call to gimp_dialog_new. I cannot see in the code, how to differ plugins from internal calls.
And you are right, of course, not every plug-in uses a help-id, e.g. the famous plug-in 'gmic', so I changed to 'role'. It must not be NULL (as allowed for help-id) and it is unique enough. And 'role' is with X11 for the purpose of reallocating known windows.
I changed the location of folder creation.
Comment 10 Hartmut Kuhse 2013-07-10 20:06:51 UTC
The patch works in the newest master.
There is a small limitation:
Script-fu dialogs are opened in the same position. I think, this must be also the case on linux, because the title and the role is always the same. So now it shows the same behaviour. And there can be only one script-fu dialog active, so the limitation is acceptable.
Comment 11 Jehan 2015-02-17 18:58:17 UTC
Mitch, I have not checked the patch myself, but last time you said it was good and it just needed some tweaks, which Harmut did. What about now? Let's not leave good patches rot. :-)
Comment 12 Michael Natterer 2015-02-18 07:17:29 UTC
The patch still uses manual blacklisting of plug-in dialogs, instead of
generically excluding them. This can't stay like that. The code needs
to figure if it runs in the plug-in process generically.
Comment 13 Michael Natterer 2015-02-18 07:19:11 UTC
I meant to say "menual blacklisting of core dialogs". Also, it should be
using GIO not FILE*.
Comment 14 Michael Natterer 2015-02-18 07:20:12 UTC
Additionally, it should honor the new preference about where to place
windows on multiple monitors, and store the window position relative
to the window's monitor, like core session management does.
Comment 15 Massimo 2015-02-21 19:17:23 UTC
(In reply to Michael Natterer from comment #12)
> The patch still uses manual blacklisting of plug-in dialogs, instead of
> generically excluding them. This can't stay like that. The code needs
> to figure if it runs in the plug-in process generically.

gimp calls g_set_prgname 

https://git.gnome.org/browse/gimp/tree/app/main.c#n355

so it should be possible to use g_get_prgname

https://git.gnome.org/browse/glib/tree/glib/gutils.c#n999
Comment 16 Hartmut Kuhse 2015-02-22 11:34:50 UTC
Good idea, but the return value has to be compared to an other value, and I don't know, how to get that value from gimp, because calling "gimp_dialog_new" from a plug-in is an other process.
Comment 17 Massimo 2015-02-22 12:11:01 UTC
(In reply to Hartmut Kuhse from comment #16)
> Good idea, but the return value has to be compared to an other value, and I
> don't know, how to get that value from gimp, because calling
> "gimp_dialog_new" from a plug-in is an other process.

my idea was to compare its return value with "gimp" or "gimp-2.9"
"gimp-2.9.exe".

But GIMP could also set an env variable GIMP_PRGNAME to
the same as what it sets as glib prgname. So a plug-in
has g_set_prgname return value comparing different from
the env variable whereas in gimp it would be identical

Other ideas could be gimp setting an env var GIMP_PLUGIN=1
in the environment of plug-ins it launches, or 
GIMP_PLUGIN_SAVE_WINDOW_PLACEMENT=1/0 and obviously not setting it
in the core process.
Comment 18 Hartmut Kuhse 2015-02-22 16:48:48 UTC
Created attachment 297580 [details] [review]
allocate-gimp-dialog_2_9_1__1.patch

@massimo: That works. I defined an environment variable with the basename of gimp.
As plug-ins get an own name via gimp_ui_init, I can compare them in gimp_dialog_new_valist. So blacklisting is gone so far.
I changed the storing/reading of position rc files to gio.
I do not have more than one monitor, so I cannot realize the demand to "honor the new preference where to place windows on multiple monitors, and store the window position relative to the window's monitor, like core session management does".
Comment 19 GNOME Infrastructure Team 2018-05-24 12:00:20 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/gimp/issues/214.