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 693414 - Keep track of child windows to avoid opening multiple duplicate child windows
Keep track of child windows to avoid opening multiple duplicate child windows
Status: RESOLVED WONTFIX
Product: gtk+
Classification: Platform
Component: Widget: Other
3.7.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-02-08 12:30 UTC by Timothy Arceri
Modified: 2013-02-11 22:56 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Timothy Arceri 2013-02-08 12:30:58 UTC
I'm not sure how to go about implementing this in GTK but it seems silly to have to duplicate code in every GTK application that wants to only open one instance of certain child windows. 

An example of such an implementation is the file properties window in Nautilus. The code is in nautilus-propeties-window.c some of the code use to achieve one instance can be seen in the function nautilus_properties_window_present() it uses a hash table to keep track of existing windows and brings the existing window into focus if you try to open it again.

Multiple GTK applications and dialogs do not go to such effort to avoid the sloppyness of opening multiple useless windows. Examples are the "open with" dialog in Nautilus, Open file (filechooser) in Firefox. I can't think of any reason of why you would what to open multiple instance of these dialogs but its possible which just doesn't seem right to me.

I'm interested to hear what the GTK gurus think about this?
Comment 1 Timothy Arceri 2013-02-08 12:54:04 UTC
Another Nautilus example of opening multiple windows.

https://bugzilla.gnome.org/show_bug.cgi?id=627259
Comment 2 Matthias Clasen 2013-02-11 04:38:32 UTC
that seems entirely application responsibility to me.
And not even very hard to do.
Comment 3 Timothy Arceri 2013-02-11 06:13:15 UTC
I give up contributing to GTK. You devs are happier to just close bugs than to discuss changes. Yes its an applications responsibility to say if a window can be opened multiple times, but how much better would it be if GTK provided an parameter to say that only one instance can be created and move on rather than implementing the same thing over and over in an application then hundreds to thousands of times across multiple applications. Just because its not hard to do doesn't mean its not messy to have to implement the some thing repeatably.

As far as contributing to GTK/Gnome I'm sick of no one ever reviewing patches whats the point in trying to get people to contribute if you constantly ignore review requests. Time to cut my losses and move on I'm sure their are plenty of other projects that are actually grateful for contributions.
Comment 4 Chris Wilson 2013-02-11 13:16:48 UTC
I have to disagree with the idea that this is the responsibility of the application. I think GTK should provide a mechanism for the developer to specify which windows they want to be singleton. The issue isn't just about whether or not a developer implements such a feature in their app, but whether or not they do it correctly.

I believe that application toolkits like GTK should make it as easy as possible for developers to build great apps using the technology, and asking those devs to implement something like this goes against that idea.

A possible solution could be thus:

When we refer to a 'child window', we're generally referring to a dialog, and not a secondary main window. When constructing a new GtkDialog, there is the option to set the GtkDialogFlags. Why not add an optional flag to make the dialog singleton, and the list of singleton dialogs could be maintained by the GtkWindow. When a new singleton dialog is created, it gets added to this list. When the user tries to create a new one, the entry in this list gets returned instead. When the dialog is closed, it's entry gets removed from the list.

Hoe does this sound?
Comment 5 Timothy Arceri 2013-02-11 22:56:12 UTC
Just for reference with a quick search here are few of the annoying bugs (in addition to what I already described) my suggestion was attempting to avoid.

https://bugzilla.gnome.org/show_bug.cgi?id=580178
https://bugzilla.gnome.org/show_bug.cgi?id=676278
https://bugzilla.gnome.org/show_bug.cgi?id=627259
https://bugzilla.gnome.org/show_bug.cgi?id=674474
https://bugzilla.gnome.org/show_bug.cgi?id=633588
https://bugzilla.gnome.org/show_bug.cgi?id=586911 (Looks like someone gave up half way though fixing this one)
https://bugzilla.gnome.org/show_bug.cgi?id=667156

Although slightly different bug the following still suggests the importance of considering a better solution for easily implementing transparent tracking of existing windows. The bug report suggests: Never show multiple error dialogs at once
https://bugzilla.gnome.org/show_bug.cgi?id=676259


I'm sure there is many more bugs of the same type and even more instances that no one has bothered to report. A developer will usually know if I dialog is meant to be displayed more than once I don't understand why you don't think its a good idea to make the task easier to achieve isn't that the purpose of a took kit in the fist place.