Index: ChangeLog =================================================================== --- ChangeLog (revision 24177) +++ ChangeLog (working copy) @@ -1,3 +1,19 @@ +2006-12-25 Nick Schermer + * 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. You can also dro inside the vte window, the new tab position + will be calculated and the screen will be added. + * terminal/terminal-tab-header.{c,h}, terminal/terminal-screen.{c,h}: Move + the structures to the header file so we can set the signal id's in terminal-window.c. + * 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. + + 2006-12-21 Benedikt Meurer * NEWS, configure.in.in, terminal/terminal-app.c, @@ -314,7 +330,7 @@ hidden setting "MiscTabPosition" which specifies the position where the notebook tabs should be placed (can be either GTK_POS_TOP, GTK_POS_BOTTOM, GTK_POS_RIGHT or GTK_POS_LEFT). - * terminal/terminal-tab-header.c: Use vertical labels if the tab + * terminal/terminal-tab-header.c: Use vertical labels if the tab position is GTK_POS_RIGHT or GTK_POS_LEFT. * doc/C/Terminal.xml.in: Add new hidden options to the manual. @@ -679,7 +695,7 @@ * terminal/Makefile.am, terminal/terminal-marshal.list: Add custom marshallers for the "get-context-menu" and "open-uri" signals. * terminal/terminal-helper-dialog.c, terminal/terminal-helper.c, - terminal/terminal-helper.h, terminal/terminal-icons.c, + terminal/terminal-helper.h, terminal/terminal-icons.c, terminal/terminal-preferences.c, terminal/terminal-widget.c, terminal/terminal-widget.h, terminal/terminal-window.c: Use the simple way of handling custom helpers just like other helpers. Connect the @@ -687,7 +703,7 @@ improvements. This finally closes bug #52. * terminal/terminal-screen.c: Forward the "get-context-menu" and "open-uri" signals from TerminalWidget. - * terminal/terminal-widget.c(terminal_widget_button_press_event): + * terminal/terminal-widget.c(terminal_widget_button_press_event): Middle-clicking on an URI now fires the associated helper. * po/: Update translations. * NEWS: Add note about the new "URL clicking"-support. More details @@ -696,7 +712,7 @@ 2005-03-12 Benedikt Meurer * helpers/epiphany.desktop.in: Add Epiphany. - * helpers/firefox.desktop.in, helpers/konqueror.desktop.in, + * helpers/firefox.desktop.in, helpers/konqueror.desktop.in, helpers/opera-browser.desktop.in, helpers/mozilla-browser.desktop.in, helpers/mutt.desktop.in, helpers/lynx.desktop.in, helpers/thunderbird.desktop.in, helpers/opera-mailer.desktop.in, @@ -724,13 +740,13 @@ terminal/terminal-helper.h, terminal/terminal-helper-dialog.c, terminal/terminal-helper-dialog.h, Makefile.am, configure.ac, Terminal.ui, terminal/Makefile.am, terminal/stock-icons/Makefile.am, - terminal/terminal-icons.c, terminal/terminal-icons.h, + terminal/terminal-icons.c, terminal/terminal-icons.h, terminal/terminal-preferences.c, terminal/terminal-window.c: Initial import of the helper application framework, which will allow users to open URLs from within Terminal, and which will probably be ported to Xfce later. The new framework still needs to be connected to the TerminalWidget. - * po/fi.po: Update finish translations, thanks to Jari Rahkonen + * po/fi.po: Update finish translations, thanks to Jari Rahkonen . 2005-03-09 Benedikt Meurer @@ -771,7 +787,7 @@ * terminal/Makefile.am, terminal/HACKING, po/POTFILES.in: Added rules to properly auto-generate the built files. These autogeneration rules - are only available if --enable-maintainer-mode is specified for + are only available if --enable-maintainer-mode is specified for configure (which is usually the case for autogen runs, but not for enduser configure runs). * configure.ac, terminal/terminal-dbus.c, terminal/terminal-dbus.h, @@ -834,7 +850,7 @@ * terminal/main.c: Be sure to initialize the locale first, using gtk_set_locale(), because else usage() will not use the available translations. - * po/ru.po, po/ru.gmo, terminal/terminal-window.c: Added russian + * po/ru.po, po/ru.gmo, terminal/terminal-window.c: Added russian translations, thanks to Anthony Ivanoff . 2005-01-21 Benedikt Meurer @@ -1609,7 +1625,7 @@ * configure.ac, NEWS: Version 0.1.6, depends on exo-0.1 >= 0.1.1. * po/de.po: Translation updates. - * terminal/terminal-window.c: Setup correct translation domain + * terminal/terminal-window.c: Setup correct translation domain for the actions. * HACKING: Added note to update translations to Release process section. Index: terminal/terminal-screen.c =================================================================== --- terminal/terminal-screen.c (revision 24177) +++ terminal/terminal-screen.c (working copy) @@ -131,27 +131,8 @@ void (*selection_changed) (TerminalScreen *screen); }; -struct _TerminalScreen -{ - GtkHBox __parent__; - TerminalPreferences *preferences; - GtkWidget *terminal; - GtkWidget *scrollbar; - GPid pid; - gchar *working_directory; - gchar **custom_command; - gchar *custom_title; - - gboolean hold; - - guint background_timer_id; - guint launch_idle_id; -}; - - - static guint screen_signals[LAST_SIGNAL]; @@ -995,7 +976,7 @@ terminal_dialogs_show_error (GTK_WIDGET (screen), error, _("Failed to execute child")); g_error_free (error); } - else + else { g_object_get (G_OBJECT (screen->preferences), "command-update-records", &update, @@ -1264,6 +1245,22 @@ /** + * terminal_screen_get_terminal: + * @screen : A #TerminalScreen. + * + * Return value: The terminal (vte) widget of @screen + **/ +GtkWidget * +terminal_screen_get_terminal (TerminalScreen *screen) +{ + g_return_val_if_fail (TERMINAL_IS_SCREEN (screen), NULL); + + return screen->terminal; +} + + + +/** * terminal_screen_get_working_directory: * @screen : A #TerminalScreen. * @@ -1308,7 +1305,9 @@ { g_free (screen->working_directory); screen->working_directory = g_get_current_dir (); - chdir (cwd); + + if (G_UNLIKELY (chdir (cwd) < 0)) + g_warning (_("Failed to enter directory %s"), cwd); } g_free (cwd); Index: terminal/terminal-screen.h =================================================================== --- terminal/terminal-screen.h (revision 24177) +++ terminal/terminal-screen.h (working copy) @@ -36,6 +36,35 @@ typedef struct _TerminalScreenClass TerminalScreenClass; typedef struct _TerminalScreen TerminalScreen; +struct _TerminalScreen +{ + GtkHBox __parent__; + TerminalPreferences *preferences; + GtkWidget *terminal; + GtkWidget *scrollbar; + + GPid pid; + gchar *working_directory; + + gchar **custom_command; + gchar *custom_title; + + gboolean hold; + + guint background_timer_id; + guint launch_idle_id; + +#if GTK_CHECK_VERSION(2,10,0) + /* id's and bindings we need to reconnect after a dnd */ + ExoBinding *tab_pos_binding; + gint get_context_menu_id; + gint notify_title_id; + gint open_uri_id; + gint selection_changed_id; + gint drag_data_received_id; +#endif +}; + GType terminal_screen_get_type (void) G_GNUC_CONST; GtkWidget *terminal_screen_new (void); @@ -62,7 +91,7 @@ GtkWindow *window); gchar *terminal_screen_get_title (TerminalScreen *screen); - +GtkWidget *terminal_screen_get_terminal (TerminalScreen *screen); const gchar *terminal_screen_get_working_directory (TerminalScreen *screen); void terminal_screen_set_working_directory (TerminalScreen *screen, const gchar *directory); Index: terminal/terminal-tab-header.c =================================================================== --- terminal/terminal-tab-header.c (revision 24177) +++ terminal/terminal-tab-header.c (working copy) @@ -78,22 +78,8 @@ void (*set_title) (TerminalTabHeader *header); }; -struct _TerminalTabHeader -{ - GtkHBox __parent__; - TerminalPreferences *preferences; - GtkTooltips *tooltips; - GtkWidget *ebox; - GtkWidget *label; - - /* the popup menu */ - GtkWidget *menu; -}; - - - static guint header_signals[LAST_SIGNAL]; @@ -380,7 +366,7 @@ /** * terminal_tab_header_new: - * + * * Allocates a new #TerminalTabHeader object. * * Return value : Pointer to the allocated #TerminalTabHeader object. Index: terminal/terminal-tab-header.h =================================================================== --- terminal/terminal-tab-header.h (revision 24177) +++ terminal/terminal-tab-header.h (working copy) @@ -36,6 +36,26 @@ typedef struct _TerminalTabHeaderClass TerminalTabHeaderClass; typedef struct _TerminalTabHeader TerminalTabHeader; +struct _TerminalTabHeader +{ + GtkHBox __parent__; + + TerminalPreferences *preferences; + + GtkTooltips *tooltips; + GtkWidget *ebox; + GtkWidget *label; + + /* the popup menu */ + GtkWidget *menu; + +#if GTK_CHECK_VERSION(2,10,0) + /* window related signals */ + gint detach_tab_id; + gint set_title_id; +#endif +}; + GType terminal_tab_header_get_type (void) G_GNUC_CONST; GtkWidget *terminal_tab_header_new (void); Index: terminal/terminal-window.c =================================================================== --- terminal/terminal-window.c (revision 24177) +++ terminal/terminal-window.c (working copy) @@ -58,8 +58,14 @@ #include #include +/* terminal tab dnd support */ +#if GTK_CHECK_VERSION(2,10,0) +#define TERMINAL_GROUP_ID 1 +#define TERMINAL_TAB_DND +#endif + /* Property identifiers */ enum { @@ -103,11 +109,27 @@ GtkNotebookPage *page, guint page_num, TerminalWindow *window); -#if GTK_CHECK_VERSION (2,10,0) +#ifdef TERMINAL_TAB_DND static void terminal_window_page_reordered (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, TerminalWindow *window); +static void terminal_window_page_added (GtkNotebook *notebook, + GtkWidget *child, + guint page_num, + TerminalWindow *window); +static void terminal_window_page_removed (GtkNotebook *notebook, + GtkWidget *child, + guint page_num, + TerminalWindow *window); +static void terminal_window_drag_data_received (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time, + TerminalWindow *window); #endif static GtkWidget *terminal_window_get_context_menu (TerminalScreen *screen, TerminalWindow *window); @@ -182,7 +204,7 @@ GtkActionGroup *action_group; GtkUIManager *ui_manager; - + GtkWidget *menubar; GtkWidget *toolbars; GtkWidget *notebook; @@ -201,8 +223,8 @@ static const GtkActionEntry action_entries[] = { { "file-menu", NULL, N_ ("_File"), NULL, NULL, NULL, }, - { "new-tab", TERMINAL_STOCK_NEWTAB, N_ ("Open _Tab"), NULL, N_ ("Open a new terminal tab"), G_CALLBACK (terminal_window_action_new_tab), }, - { "new-window", TERMINAL_STOCK_NEWWINDOW, N_ ("Open T_erminal"), "N", N_ ("Open a new terminal window"), G_CALLBACK (terminal_window_action_new_window), }, + { "new-tab", TERMINAL_STOCK_NEWTAB, N_ ("Open _Tab"), NULL, N_ ("Open a new terminal tab"), G_CALLBACK (terminal_window_action_new_tab), }, + { "new-window", TERMINAL_STOCK_NEWWINDOW, N_ ("Open T_erminal"), "N", N_ ("Open a new terminal window"), G_CALLBACK (terminal_window_action_new_window), }, { "detach-tab", NULL, N_ ("_Detach Tab"), NULL, N_ ("Open a new window for the current terminal tab"), G_CALLBACK (terminal_window_action_detach_tab), }, { "close-tab", TERMINAL_STOCK_CLOSETAB, N_ ("C_lose Tab"), NULL, N_ ("Close the current terminal tab"), G_CALLBACK (terminal_window_action_close_tab), }, { "close-window", TERMINAL_STOCK_CLOSEWINDOW, N_ ("_Close Window"), NULL, N_ ("Close the terminal window"), G_CALLBACK (terminal_window_action_close_window), }, @@ -236,8 +258,15 @@ { "fullscreen", TERMINAL_STOCK_FULLSCREEN, N_ ("_Fullscreen"), NULL, N_ ("Toggle fullscreen mode"), G_CALLBACK (terminal_window_action_fullscreen), FALSE, }, }; +#ifdef TERMINAL_TAB_DND +static const GtkTargetEntry drag_targets[] = +{ + { "GTK_NOTEBOOK_TAB", GTK_TARGET_SAME_APP, 0 }, +}; +#endif + G_DEFINE_TYPE (TerminalWindow, terminal_window, GTK_TYPE_WINDOW); @@ -247,7 +276,7 @@ { GtkWidgetClass *gtkwidget_class; GObjectClass *gobject_class; - + gobject_class = G_OBJECT_CLASS (klass); gobject_class->dispose = terminal_window_dispose; gobject_class->finalize = terminal_window_finalize; @@ -407,9 +436,17 @@ g_signal_connect (G_OBJECT (window->notebook), "remove", G_CALLBACK (terminal_window_screen_removed), window); -#if GTK_CHECK_VERSION (2,10,0) +#ifdef TERMINAL_TAB_DND + /* signals for tab dnd and reorder */ g_signal_connect (G_OBJECT (window->notebook), "page-reordered", G_CALLBACK (terminal_window_page_reordered), window); + g_signal_connect (G_OBJECT (window->notebook), "page-removed", + G_CALLBACK (terminal_window_page_removed), window); + g_signal_connect (G_OBJECT (window->notebook), "page-added", + G_CALLBACK (terminal_window_page_added), window); + + /* you can only exchange tabs between 2 notebooks when they have the same group id */ + gtk_notebook_set_group_id (GTK_NOTEBOOK (window->notebook), TERMINAL_GROUP_ID); #endif gtk_box_pack_start (GTK_BOX (vbox), window->notebook, TRUE, TRUE, 0); @@ -616,7 +653,7 @@ TerminalScreen *active; gint grid_width; gint grid_height; - + /* The trick is rather simple here. This is called before any Gtk+ resizing operation takes * place, so the columns/rows on the active terminal screen are still set to their old values. * We simply query these values and force them to be set with the new style. @@ -794,12 +831,20 @@ gchar name[32]; gchar *path; gint npages; + gboolean always_show_tabs; gint n; + /* check if we should always display tabs */ + g_object_get (G_OBJECT (window->preferences), "misc-always-show-tabs", &always_show_tabs, NULL); + + /* change the visibility of the tabs accordingly */ + npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->notebook), always_show_tabs || (npages > 1)); + + /* stop when there is no menu widget */ if (G_UNLIKELY (window->gomenu == NULL)) return; - npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)); for (n = 0; n < npages; ++n) { terminal = gtk_notebook_get_nth_page (GTK_NOTEBOOK (window->notebook), n); @@ -851,7 +896,22 @@ static gboolean terminal_window_delete_event (TerminalWindow *window) { - return !terminal_window_confirm_close (window); + gboolean result = terminal_window_confirm_close (window); + + if (result == TRUE) + { + /* disconnect the "remove" signal */ + g_signal_handlers_disconnect_by_func (G_OBJECT (window->notebook), + G_CALLBACK (terminal_window_screen_removed), window); + +#ifdef TERMINAL_TAB_DND + /* disconnect the "page-removed" signal */ + g_signal_handlers_disconnect_by_func (G_OBJECT (window->notebook), + G_CALLBACK (terminal_window_page_removed), window); +#endif + } + + return !result; } @@ -910,19 +970,188 @@ -#if GTK_CHECK_VERSION (2,10,0) +#ifdef TERMINAL_TAB_DND static void terminal_window_page_reordered (GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, TerminalWindow *window) { - - /* Regenerate the "Go" menu. - * This also updates the accelerators. - */ + /* regenerate the "Go" menu */ terminal_window_rebuild_gomenu (window); } + + + +static void +terminal_window_page_added (GtkNotebook *notebook, + GtkWidget *child, + guint page_num, + TerminalWindow *window) +{ + TerminalTabHeader *header; + TerminalScreen *screen = TERMINAL_SCREEN (child); + GtkAction *action; + + g_return_if_fail (TERMINAL_IS_WINDOW (window)); + g_return_if_fail (TERMINAL_IS_SCREEN (screen)); + + /* get the header */ + header = TERMINAL_TAB_HEADER (gtk_notebook_get_tab_label (notebook, child)); + + if (G_UNLIKELY (header->detach_tab_id > 0)) + { + /* disconnect the old header signals */ + g_signal_handler_disconnect (G_OBJECT (header), header->detach_tab_id); + g_signal_handler_disconnect (G_OBJECT (header), header->set_title_id); + } + + /* get the new action group */ + action = gtk_action_group_get_action (window->action_group, "set-title"); + + /* connect the new signals to the header */ + header->detach_tab_id = + g_signal_connect_swapped (G_OBJECT (header), "detach-tab", + G_CALLBACK (terminal_window_detach_screen), window); + header->set_title_id = + g_signal_connect_swapped (G_OBJECT (header), "set-title", + G_CALLBACK (gtk_action_activate), action); + + /* connect the new screen signals */ + screen->tab_pos_binding = + exo_binding_new (G_OBJECT (window->notebook), "tab-pos", G_OBJECT (header), "tab-pos"); + screen->get_context_menu_id = + g_signal_connect (G_OBJECT (screen), "get-context-menu", + G_CALLBACK (terminal_window_get_context_menu), window); + screen->notify_title_id = + g_signal_connect (G_OBJECT (screen), "notify::title", + G_CALLBACK (terminal_window_notify_title), window); + screen->open_uri_id = + g_signal_connect_swapped (G_OBJECT (screen), "open-uri", + G_CALLBACK (terminal_window_open_uri), window); + screen->selection_changed_id = + g_signal_connect_swapped (G_OBJECT (screen), "selection-changed", + G_CALLBACK (terminal_window_update_actions), window); + screen->drag_data_received_id = + g_signal_connect (G_OBJECT (terminal_screen_get_terminal (screen)), "drag-data-received", + G_CALLBACK (terminal_window_drag_data_received), window); + + /* regenerate the "Go" menu */ + terminal_window_rebuild_gomenu (window); + + /* update all screen sensitive actions (Copy, Prev Tab, ...) */ + terminal_window_update_actions (window); +} + + + +static void +terminal_window_page_removed (GtkNotebook *notebook, + GtkWidget *child, + guint page_num, + TerminalWindow *window) +{ + TerminalScreen *screen = TERMINAL_SCREEN (child); + + g_return_if_fail (TERMINAL_IS_WINDOW (window)); + g_return_if_fail (TERMINAL_IS_SCREEN (screen)); + + /* remove the exo binding */ + if (screen->tab_pos_binding) + { + exo_binding_unbind (screen->tab_pos_binding); + screen->tab_pos_binding = NULL; + } + + /* disconnect the signals */ + g_signal_handler_disconnect (G_OBJECT (screen), screen->get_context_menu_id); + g_signal_handler_disconnect (G_OBJECT (screen), screen->notify_title_id); + g_signal_handler_disconnect (G_OBJECT (screen), screen->open_uri_id); + g_signal_handler_disconnect (G_OBJECT (screen), screen->selection_changed_id); + g_signal_handler_disconnect (G_OBJECT (terminal_screen_get_terminal (screen)), + screen->drag_data_received_id); + + /* regenerate the "Go" menu */ + terminal_window_rebuild_gomenu (window); + + /* update all screen sensitive actions (Copy, Prev Tab, ...) */ + terminal_window_update_actions (window); +} + + + +static void +terminal_window_drag_data_received (GtkWidget *widget, + GdkDragContext *context, + gint x, + gint y, + GtkSelectionData *selection_data, + guint info, + guint time, + TerminalWindow *window) +{ + GtkWidget *notebook; + GtkWidget **child; + GtkWidget *header; + gint page_num, n_pages; + gint width, offset; + guint i; + + g_return_if_fail (TERMINAL_IS_WINDOW (window)); + + /* get drag souce and data information */ + notebook = gtk_drag_get_source_widget (context); + child = (GtkWidget **) selection_data->data; + + /* get the header */ + header = gtk_notebook_get_tab_label (GTK_NOTEBOOK (notebook), *child); + + /* take a reference */ + g_object_ref (G_OBJECT (*child)); + g_object_ref (G_OBJECT (header)); + + /* remove the terminal from the old window */ + gtk_container_remove (GTK_CONTAINER (notebook), *child); + + /* get size of the drop window (it's not the real drop area size, I know...) */ + gtk_window_get_size (GTK_WINDOW (window), &width, NULL); + + /* get the current number of pages + 1 */ + n_pages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)) + 1; + + /* calculate the offset */ + offset = width / n_pages; + + /* get the new page number */ + for (i = 0; i < n_pages; i++) + if (x < (offset * (i+1))) + break; + + /* append to the new window */ + page_num = gtk_notebook_insert_page (GTK_NOTEBOOK (window->notebook), *child, header, i); + + gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (window->notebook), + *child, + TRUE, TRUE, GTK_PACK_START); + + /* allow sorting the tab in the same window */ + gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (window->notebook), + *child, TRUE); + + /* allow dragging the tab to another window */ + gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (window->notebook), + *child, TRUE); + + /* release our reference */ + g_object_unref (G_OBJECT (*child)); + g_object_unref (G_OBJECT (header)); + + /* switch to the dropped tab */ + gtk_notebook_set_current_page (GTK_NOTEBOOK (window->notebook), page_num); + + /* tell the peer that we handled the drop */ + gtk_drag_finish (context, TRUE, TRUE, time); +} #endif @@ -1068,7 +1297,6 @@ TerminalWindow *window) { TerminalScreen *active; - gboolean always_show_tabs; gint npages; gint grid_width; gint grid_height; @@ -1080,12 +1308,6 @@ } else { - /* check tabs should always be visible */ - g_object_get (G_OBJECT (window->preferences), "misc-always-show-tabs", &always_show_tabs, NULL); - - /* change the visibility of the tabs accordingly */ - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->notebook), always_show_tabs || (npages > 1)); - /* meh, Gtk+, who wants focus on the notebook? */ GTK_WIDGET_UNSET_FLAGS (window->notebook, GTK_CAN_FOCUS); @@ -1096,11 +1318,13 @@ terminal_window_set_size_force_grid (window, active, grid_width, grid_height); } +#ifndef TERMINAL_TAB_DND /* regenerate the "Go" menu */ terminal_window_rebuild_gomenu (window); /* update all screen sensitive actions (Copy, Prev Tab, ...) */ terminal_window_update_actions (window); +#endif } } @@ -1173,7 +1397,12 @@ terminal = terminal_window_get_active (window); if (G_LIKELY (terminal != NULL)) - gtk_widget_destroy (GTK_WIDGET (terminal)); + { +#ifdef TERMINAL_TAB_DND + terminal->tab_pos_binding = NULL; +#endif + gtk_widget_destroy (GTK_WIDGET (terminal)); + } } @@ -1183,7 +1412,19 @@ TerminalWindow *window) { if (terminal_window_confirm_close (window)) - gtk_widget_destroy (GTK_WIDGET (window)); + { + /* disconnect the "remove" signal */ + g_signal_handlers_disconnect_by_func (G_OBJECT (window->notebook), + G_CALLBACK (terminal_window_screen_removed), window); + +#ifdef TERMINAL_TAB_DND + /* disconnect the "page-removed" signal */ + g_signal_handlers_disconnect_by_func (G_OBJECT (window->notebook), + G_CALLBACK (terminal_window_page_removed), window); +#endif + + gtk_widget_destroy (GTK_WIDGET (window)); + } } @@ -1275,7 +1516,7 @@ TerminalWindow *window) { /* check if we already have a preferences dialog instance */ - if (G_UNLIKELY (window->preferences_dialog != NULL)) + if (G_UNLIKELY (window->preferences_dialog != NULL)) { /* move to the current screen and make transient for this window */ gtk_window_set_screen (GTK_WINDOW (window->preferences_dialog), gtk_widget_get_screen (GTK_WIDGET (window))); @@ -1556,7 +1797,7 @@ TerminalWindow *window; GtkAction *action; gboolean setting; - + window = g_object_new (TERMINAL_TYPE_WINDOW, NULL); /* setup full screen */ @@ -1606,12 +1847,12 @@ { TerminalScreen *active; GtkWidget *header; - GtkAction *action; - gboolean always_show_tabs; - gint npages; gint page; gint grid_width; gint grid_height; +#ifndef TERMINAL_TAB_DND + GtkAction *action; +#endif g_return_if_fail (TERMINAL_IS_WINDOW (window)); g_return_if_fail (TERMINAL_IS_SCREEN (screen)); @@ -1623,39 +1864,53 @@ terminal_screen_set_size (screen, grid_width, grid_height); } +#ifndef TERMINAL_TAB_DND action = gtk_action_group_get_action (window->action_group, "set-title"); +#endif header = terminal_tab_header_new (); exo_binding_new (G_OBJECT (screen), "title", G_OBJECT (header), "title"); + g_signal_connect_swapped (G_OBJECT (header), "close-tab", G_CALLBACK (gtk_widget_destroy), screen); + +#ifndef TERMINAL_TAB_DND exo_binding_new (G_OBJECT (window->notebook), "tab-pos", G_OBJECT (header), "tab-pos"); - g_signal_connect_swapped (G_OBJECT (header), "close-tab", G_CALLBACK (gtk_widget_destroy), screen); + g_signal_connect_swapped (G_OBJECT (header), "detach-tab", G_CALLBACK (terminal_window_detach_screen), window); g_signal_connect_swapped (G_OBJECT (header), "set-title", G_CALLBACK (gtk_action_activate), action); +#endif + g_object_set_data_full (G_OBJECT (header), "terminal-window-screen", g_object_ref (G_OBJECT (screen)), (GDestroyNotify) g_object_unref); gtk_widget_show (header); page = gtk_notebook_append_page (GTK_NOTEBOOK (window->notebook), GTK_WIDGET (screen), header); + gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK (window->notebook), GTK_WIDGET (screen), TRUE, TRUE, GTK_PACK_START); -#if GTK_CHECK_VERSION(2,10,0) +#ifdef TERMINAL_TAB_DND + /* allow sorting the tab in the same window */ gtk_notebook_set_tab_reorderable (GTK_NOTEBOOK (window->notebook), GTK_WIDGET (screen), TRUE); -#endif - /* check if we should always display tabs */ - g_object_get (G_OBJECT (window->preferences), "misc-always-show-tabs", &always_show_tabs, NULL); + /* allow dragging the tab to another window */ + gtk_notebook_set_tab_detachable (GTK_NOTEBOOK (window->notebook), + GTK_WIDGET (screen), + TRUE); - /* change the visibility of the tabs accordingly */ - npages = gtk_notebook_get_n_pages (GTK_NOTEBOOK (window->notebook)); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (window->notebook), always_show_tabs || (npages > 1)); + /* allow dropping a tab in the vte widget */ + gtk_drag_dest_set (terminal_screen_get_terminal (screen), + GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_DROP, + drag_targets, G_N_ELEMENTS (drag_targets), + GDK_ACTION_MOVE); +#endif /* yep, still no focus on the notebook! */ GTK_WIDGET_UNSET_FLAGS (window->notebook, GTK_CAN_FOCUS); +#ifndef TERMINAL_TAB_DND g_signal_connect (G_OBJECT (screen), "get-context-menu", G_CALLBACK (terminal_window_get_context_menu), window); g_signal_connect (G_OBJECT (screen), "notify::title", @@ -1664,8 +1919,11 @@ G_CALLBACK (terminal_window_open_uri), window); g_signal_connect_swapped (G_OBJECT (screen), "selection-changed", G_CALLBACK (terminal_window_update_actions), window); +#endif +#ifndef TERMINAL_TAB_DND terminal_window_rebuild_gomenu (window); +#endif /* need to save the grid size here for detached screens */ terminal_screen_get_size (screen, &grid_width, &grid_height); Index: NEWS =================================================================== --- NEWS (revision 24177) +++ NEWS (working copy) @@ -2,6 +2,8 @@ ========== - Add support for real transparency with GTK+ 2.10 and a compositing manager, i.e. the one built into xfwm4 (Bug #2671). +- Fix compiler warnings. +- Support for DND tabs between two windows with GTK+ 2.10. 0.2.5.8rc2 @@ -218,7 +220,7 @@ 0.1.7 ===== -- New icons for the preferences dialog by Francois Le +- New icons for the preferences dialog by Francois Le Clainche , available as PNG and scalable images. - Online documentation updated. All of Terminal is now documented.