GNOME Bugzilla – Bug 360225
Support for allowing GtkNotebook to drop tabs anywhere
Last modified: 2006-12-28 16:45:54 UTC
Hi!, I've been sketching a patch to allow GtkNotebook drop tabs anywhere (not only in the root window). Although the patch somewhat works, I feel some additions to gtk_drag_* would be welcome. Issues with the patch: - all the action happens in ::drag-end and internal flag is used to know whether the drag operation succeeded or not, but it's not able to differ between when the drag failed and when the user cancelled the drag. - To avoid the drag failed animation, the code unmaps the drag window, but: 1) This won't work if the user sets a pixbuf or stock icon as the DnD icon (this behavior can be seen in tests/testnotebookdnd) 2) we still have to wait for the animation timeout to happen before ::drag-end gets called. My proposed solution would be to add a ::drag-failed signal, emitted as soon as we know the drag failed and reporting the nature of the failure (no common target found, GUI user cancelled, timeout exceeded...), the API user could return TRUE in the handler to tell that the failure has been already handled (ie, do not show animation) or FALSE to let the default implementation handle the failure. of course ::drag-end would get called anyways and wouldn't be used for nasty things it wasn't thought for :) Any suggestions?
Created attachment 74166 [details] [review] patch sketch, something like what's proposed is badly needed here...
Created attachment 74296 [details] [review] patch, implements ::drag-failed and makes GtkNotebook use it
::drag-failed sounds like a reasonable idea. Might be good to add a generic GTK_DRAG_RESULT_ERROR to the enumeration, in case some other error case comes up later. The only slight terminological issue here is that, at least in the case of notebook dnd, handling the dnd-failed signal leads to a successful end result... I guess thats just fine. + * @returns: whether the failed drag operation has been already handled. I prefer "Return value: ..." over "@returns: ...", but thats just cosmetic + * failed. The signal handler may hook custom code to handle a failed DnD I think we mostly use DND (all-caps) in the docs. The signal docs need a "Since: " tag, and the enumeration needs docs, too. It would be good to mention that the return value of the signal handler has an effect on the drag-cancel animation.
Created attachment 76613 [details] [review] updated patch Hi!, this patch fixes the mentioned issues and compiles against HEAD
It might be worth pointing out that with this patch there are only 3 padding pointers available in GtkWidgetClass, maybe it's not worth to expose this method pointer?
Created attachment 76717 [details] [review] updated patch, doesn't expose the method pointer in GtkWidgetClass
*** Bug 379246 has been marked as a duplicate of this bug. ***
Created attachment 78940 [details] [review] updated patch, fixes an introduced compiler warning in gtkwidget.c and a possible crasher inside GtkNotebook
Looks good.
I've just committed it to HEAD, thanks :) 2006-12-28 Carlos Garnacho <carlosg@gnome.org> Make GtkNotebook able to drop detached tabs anywhere. Bug #360225. * gtk/gtkwidget.c (gtk_widget_class_init): add "drag-failed" signal. * gtk/gtkmarshalers.list: add new marshaler definition. * gtk/gtkenums.h: add GtkDragResult enum. * gtk/gtkdnd.c (gtk_drag_drop_finished): emit "drag-failed" if DND operation wasn't successful. (_gtk_drag_source_handle_event) (gtk_drag_drop) (gtk_drag_selection_get) (gtk_drag_cancel) (gtk_drag_key_cb) (gtk_drag_grab_broken_event_cb) (gtk_drag_grab_notify_cb) (gtk_drag_button_release_cb) (gtk_drag_abort_timeout): tell gtk_drag_drop_finished() the operation result. * gtk/gtknotebook.c (gtk_notebook_drag_failed): new function. (gtk_notebook_drag_data_get): do not call window creation hook here. (gtk_notebook_init): do not set "application/x-rootwindow-drop" target, instead connect to "drag-failed". (gtk_notebook_draw_focus): fix potential crasher if cur_page is NULL.