Re: GtkToolbar drag and drop



Soeren Sandmann <sandmann daimi au dk> writes:

> 	- 116297, handle pack end in gtk_toolbar_get_drop_index()
> 
> 	Currently the toolbar can, given mouse coordinates, report the
> 	index a newly dropped tool item should be positioned at. At
> 	the moment this function doesn't handle pack_end items
> 	correctly. This is just a bug that should be fixed.

It turns out I misunderstood this. The issue is that the current dnd
implementation simply ignores pack_end items, ie. you can't drop new
items at the pack end location. James explains it in the bug:

        The idea of items packed at the end was to support things like
        throbbers in nautilus or web browsers.  If you are customising
        the toolbar of apps like this, you most likely want to ignore
        the throbber completely, which is why I implemented
        find_drop_pos() as it is.

which I agree with, so I plan to NOTABUG.

If we do want a "flexible space" feature, we can still add that the
way Owen suggests, by adding an expandable, non-drawing separator
item, leaving pack_end for throbber-like items.

> 	- 116298, toolbar should not handle arbitrary targets
> 	- 110919, shift existing items over

[...]

> To fix these bugs, I propose this:
> 
>         * Make the application responsible for handling drops on the
>           toolbar. This means remove all drag_motion handler etc. from
>           the toolbar and require the application to implement it
>           through the standard gtk_drag_* API.
> 
>           This would enable applications and toolbar editors to decide
>           what can be dropped on a toolbar.
> 
>         * Add new API
> 
>                 gtk_toolbar_highlight_drop_location (
>                         GtkToolbar *toolbar, gint x, gint y, 
>                         gint width);
> 
>                 gtk_toolbar_unhighlight_drop_location ();
> 
>           This API would allow the implementation of Mac OS X style
>           sliding toolbar buttons.

So here is a patch that implements this (including Mac OS X style
sliding) with the difference that
gtk_toolbar_highlight_drop_location() takes an extra "height"
parameter so it can work with vertical toolbars.

It would be nice if someone would review the patch.


Questions (mostly for Marco, I guess):

        - Is this API usable for the toolbar editor, ie. will it be
          possible for the toolbar editor to generate the correct
          width and height for the new item?

        - would it be better to pass in the new GtkToolItem instead of
          the (width, height) pair? This would allow more flexibility
          in the exact highlighting algorithm since the toolbar could
          know everything about the new toolbar, not just its width
          and height.

        There is a simple example of how to use the new API in
        tests/testtoolbar.c (if you apply the patch).


Søren



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]