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 360225 - Support for allowing GtkNotebook to drop tabs anywhere
Support for allowing GtkNotebook to drop tabs anywhere
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Widget: GtkNotebook
2.10.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
: 379246 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2006-10-06 17:27 UTC by Carlos Garnacho
Modified: 2006-12-28 16:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
patch sketch, something like what's proposed is badly needed here... (4.09 KB, patch)
2006-10-06 17:28 UTC, Carlos Garnacho
none Details | Review
patch, implements ::drag-failed and makes GtkNotebook use it (13.20 KB, patch)
2006-10-08 15:18 UTC, Carlos Garnacho
none Details | Review
updated patch (14.36 KB, patch)
2006-11-15 01:24 UTC, Carlos Garnacho
none Details | Review
updated patch, doesn't expose the method pointer in GtkWidgetClass (13.24 KB, patch)
2006-11-16 18:27 UTC, Carlos Garnacho
none Details | Review
updated patch, fixes an introduced compiler warning in gtkwidget.c and a possible crasher inside GtkNotebook (13.35 KB, patch)
2006-12-27 10:36 UTC, Carlos Garnacho
committed Details | Review

Description Carlos Garnacho 2006-10-06 17:27:00 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?
Comment 1 Carlos Garnacho 2006-10-06 17:28:00 UTC
Created attachment 74166 [details] [review]
patch sketch, something like what's proposed is badly needed here...
Comment 2 Carlos Garnacho 2006-10-08 15:18:46 UTC
Created attachment 74296 [details] [review]
patch, implements ::drag-failed and makes GtkNotebook use it
Comment 3 Matthias Clasen 2006-11-14 16:36:11 UTC
::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.
Comment 4 Carlos Garnacho 2006-11-15 01:24:01 UTC
Created attachment 76613 [details] [review]
updated patch

Hi!, this patch fixes the mentioned issues and compiles against HEAD
Comment 5 Carlos Garnacho 2006-11-15 14:20:35 UTC
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?
Comment 6 Carlos Garnacho 2006-11-16 18:27:09 UTC
Created attachment 76717 [details] [review]
updated patch, doesn't expose the method pointer in GtkWidgetClass
Comment 7 Carlos Garnacho 2006-11-26 02:59:39 UTC
*** Bug 379246 has been marked as a duplicate of this bug. ***
Comment 8 Carlos Garnacho 2006-12-27 10:36:30 UTC
Created attachment 78940 [details] [review]
updated patch, fixes an introduced compiler warning in gtkwidget.c and a possible crasher inside GtkNotebook
Comment 9 Matthias Clasen 2006-12-28 05:23:16 UTC
Looks good. 
Comment 10 Carlos Garnacho 2006-12-28 16:45:54 UTC
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.