GNOME Bugzilla – Bug 386935
gtk_notebook_set_window_creation_hook only allows one hook per program
Last modified: 2007-06-04 14:39:35 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.
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
I have to agree with Christian that a signal is nicer. Here is a patch that adds it.
Created attachment 87214 [details] [review] create-window.patch
Carlos, please provide the group property as an independent patch, since that is less controversial.
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.
Doh! Matthias, sorry and thanks, didn't notice comment #4 at all :)
Any comment on my signal patch ?
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)