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 386935 - gtk_notebook_set_window_creation_hook only allows one hook per program
gtk_notebook_set_window_creation_hook only allows one hook per program
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkNotebook
2.10.x
Other All
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 386930
 
 
Reported: 2006-12-17 21:02 UTC by Christian Hammond
Modified: 2007-06-04 14:39 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
beyond all hope (9.66 KB, patch)
2007-02-28 01:53 UTC, Carlos Garnacho
none Details | Review
create-window.patch (6.02 KB, patch)
2007-04-29 02:56 UTC, Matthias Clasen
none Details | Review

Description Christian Hammond 2006-12-17 21:02:27 UTC
gtk_notebook_set_window_creation_hook is a global function that allows the setting of one global window creation hook. This is fine for really basic programs, but for anything more complex (a program with multiple notebooks or a program that allows for plugins) this completely falls apart. Two different parts of a codebase or different plugins won't be able to provide their own window creation logic for their notebooks. It would be up to the main program to handle each separate notebook, which is impossible with plugins.

I propose we deprecate this function, but continue to support it. In its place, we should provide a create-window signal on GtkNotebook that allows a signal handler to return the GtkNotebook (as the current GtkNotebookWindowCreationHook requires). This could work like many of the gtk+ signals with collectors. If a handler returns NULL, move on to the next. If it returns a GtkNotebook, use that.

There are two reasons I'd propose a signal instead of a new function.

First, the existing name (gtk_notebook_set_window_creation_hook) already looks as if it applies to a particular GtkNotebook and any new name is going to be confusing next to that. (Things will be confusing anyway, though...)

Second, there are cases that could easily come into use where a specialized GtkNotebook subclass in an application has a default handler for window creation, but that one use of that widget may want to override that and provide a different type of window depending on the tab that was dragged out, or even just a modified version of the same window.

I hope to provide a proposed patch over the Christmas break.
Comment 1 Carlos Garnacho 2007-02-28 01:53:35 UTC
Created attachment 83512 [details] [review]
beyond all hope

This patch adds gtk_notebook_set_window_creation_func() and gtk_notebook_[gs]et_group(), and deprecates gtk_notebook_set_window_creation_hook() and gtk_notebook_[gs]et_group_id(), Fixes this bug and #386930
Comment 2 Matthias Clasen 2007-04-29 02:56:05 UTC
I have to agree with Christian that a signal is nicer.
Here is a patch that adds it.
Comment 3 Matthias Clasen 2007-04-29 02:56:34 UTC
Created attachment 87214 [details] [review]
create-window.patch
Comment 4 Matthias Clasen 2007-04-29 03:01:35 UTC
Carlos, please provide the group property as an independent patch, since that is
less controversial.
Comment 5 Matthias Clasen 2007-05-19 05:21:40 UTC
group part committed:

2007-05-19  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtk.symbols:
        * gtk/gtknotebook.[hc]: Deprecate gtk_notebook_[gs]et_group_id
        in favour of new functions gtk_notebook_[gs]et_group, which
        takes a pointer as group identifier and makes it easier to
        avoid group id collisions.  (#386930, Christian Hammond)

        * tests/testnotebookdnd.c: Use new grouping api.

Comment 6 Carlos Garnacho 2007-05-19 13:33:46 UTC
Doh! Matthias, sorry and thanks, didn't notice comment #4 at all :)
Comment 7 Matthias Clasen 2007-05-19 19:57:34 UTC
Any comment on my signal patch ? 
Comment 8 Matthias Clasen 2007-06-04 14:39:35 UTC
2007-06-04  Matthias Clasen  <mclasen@redhat.com>

        * gtk/gtkmarshalers.list:
        * gtk/gtknotebook.[hc]: Add a create-window signal that allows
        to override the global create-window-hook on a per-notebook
        basis. The default handler falls back to the global hook.
        (#386935, Christian Hammond)