Here is the first attempt for dnd support of tabs, using the GTK+ 2.10 api. It seems to work quite good, but it only supports dragging from 1 notebook to another (so when notebooks are not always visible and there is only 1 screen, it doesn't work). The patch also includes some other fixes, read the ChangeLog below. TODO: * Drag into a vte screen and add the dragged screen to the window. * Drag outside window and then detach the screen (don't think that's possible with the notebook dnd api, because there is no root window).
Created attachment 909 Tabs drag and drop v1 2006-12-24 Nick Schermer <nick@xfce.org> * terminal/terminal-screen.c: Fix compiler warning because we ignore the chdir return value. * terminal-window.c: Add support for DND the tabs between two windows with GTK+ 2.10.x. * terminal-window.c: Disconnect the "remove" signal before destroying the application. This will prevent a lot of GTK+ warnings quiting with multiple tabs opened. * terminal/terminal-window.c: Move the code for checking if the tabs should be visible to the rebuild_gomenu function. This will prevent some duplicated code and works better with tab dnd. NOTE: Geany also removes trailing spaces ^_^.
Created attachment 910 terminal dnd v2 This patch will property reconnect the signals. I had to move the structures of terminal-tab-header and terminal-screen to their header files, to set the signal id's. Maybe there is another way to do this, but this seems to work fine. You can also drop a screen in the vte area now. The new tab position will be calculated and the tab will be added.
Created attachment 911 terminal dnd v2.1 This fixes some problems with the connected drag_data_received signal and tab expand.
Created attachment 912 terminal dnd v2.2 This patch fixes some minor issues from the previous one.
Well a small status update. Most of the dnd is working properly now (no crashes, signals connect w/o problems). There is only 1 vte warning when you dnd (debug must be enabled): (terminal:5110): Vte-WARNING **: Error (Invalid or incomplete multibyte or wide character) converting data for child, dropping. Stuff that needs to be done before we can even thing about commiting: * When you set MiscAlwaysShowTabs=TRUE in the rc file and you drag the last tab out of the window, some warnings are shown. We need to handle this properly. * Run this patch in valgrind and check for memory leaks. A possible TODO list: * ATM when you drop a terminal in the vte area, it will be inserted in the right position, but it's not 'visible'. It would be nice to show an empty space in the tab-bar when you're dragging over the window, like the reorder animation. * You cannot detach the terminal when you drag it out of the window. I don't think this is possible, because we have no root window(1). Anybody any ideas? Nick (1) See the gtk_notebook_set_window_creation_hook.
Created attachment 913 terminal dnd v2.3 Warnings fixed, disconnect signals in the page-removed function. I think most leaks in valgrind are from libvte, so this should be it...
I've found a way to recognize if a tab is dropped outside a window. Maybe not the cleanes way, but it seems to work... /* connect this signal when creating a new notebook */ g_signal_connect(G_OBJECT(window->notebook), "button_release_event", terminal_window_release_event, window); static gboolean terminal_window_release_event (GtkNotebook *notebook, GdkEventButton *event, TerminalWindow *window) { if (gdk_window_at_pointer (NULL, NULL) == NULL) { /* the tab is dropped outside 1 of our application windows * we can detach the tab now */ /* move the new terminal window to (event->x_root, event->y_root) */ return TRUE; } return FALSE; } Duno if this is a good way to check if a window is dropped outside 1 of the terminal windows, just an idea...
While this is nice stuff, I'm not sure if it's ready for Xfce 4.4.0. What do you think?
We should release 4.4.0 ASAP, so I keep this patch in bugzilla. It also needs detach-drop before it can be committed.
Created attachment 1381 terminal dnd v2.4 - Tab drag and drop between windows - Drop tabs on the root window, Gtk+ 2.12 only. (added a new marshal to pass the screen + coordinates) - Bump Gtk+ version to 2.10 - Cleanup GTK_CHECK_VERSION stuff - Go-to menu now uses the ui-manager (saved some code, a bit OT but I couldn't resist it ;), also included patch from Bug #3522). - Merge some code and some cleanups - Removed the terminal_window_page_switched code, it seems vte handles this without problems. Would be cool it this was tested first (I've only tried gtk 2.12 and the latest vte) before committed, since I've moved a bit with the size functions.
I'm having some resize problems with the terminal on my laptop atm (not related to the patch tho), but I'll try to figure that out first and send a new version.
Created attachment 1385 terminal dnd v2.5 Ok this patch is a lot better. No resize bug here anymore (the one I had on my laptop is definitly a vte bug), removed the menu changes (shouldn't be in the previous patch): so this is purely tab dnd, gtk 2.10 cleanups, some extra return_if_fail checks (for my personal testing, but they shoudn't hurt anyone), calls to gdk_thread_init in timeout functions and a drag finish in the existing dnd code.
Uhm, I'm not yet comfortable with the patch. It seems to contain a lot of unrelated code changes.
Well maybe the page-selected function could return to make sure we maintain the same grid, but appart from that I don't see much changes myself. But please tell me if you want to see anything changed in the patch.
Can you update the patch for the latest trunk?
Created attachment 1444 terminal dnd v2.6 Patch against latest trunk.
Committed with revision 26400. 2007-11-28 Benedikt Meurer <benny@xfce.org> * terminal/: Apply patch from Nick Schermer <nick@xfce.org> to enable Drag and Drop for tabs between Terminal windows. Bug #2684.