summaryrefslogtreecommitdiff
path: root/src/gui_gtk_x11.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2017-10-22 15:36:14 +0200
committerBram Moolenaar <Bram@vim.org>2017-10-22 15:36:14 +0200
commitca05aa24af88836f8aa792360b3780589f294981 (patch)
treece6adba1fb6d37113612655d77136f10b83cd505 /src/gui_gtk_x11.c
parentf8e8c0643b1cd97db11912bc4f773e1328a0da02 (diff)
downloadvim-git-ca05aa24af88836f8aa792360b3780589f294981.tar.gz
patch 8.0.1211: cannot reorder tab pages with drag & dropv8.0.1211
Problem: Cannot reorder tab pages with drag & drop. Solution: Support drag & drop for GTK and MS-Windows. (Ken Takata, Masamichi Abe)
Diffstat (limited to 'src/gui_gtk_x11.c')
-rw-r--r--src/gui_gtk_x11.c31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 9225375a1..9be54b90e 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -3567,8 +3567,29 @@ on_select_tab(
gpointer data UNUSED)
{
if (!ignore_tabline_evt)
- {
send_tabline_event(idx + 1);
+}
+
+/*
+ * Handle reordering the tabs (using D&D).
+ */
+ static void
+on_tab_reordered(
+ GtkNotebook *notebook UNUSED,
+# if GTK_CHECK_VERSION(3,0,0)
+ gpointer *page UNUSED,
+# else
+ GtkNotebookPage *page UNUSED,
+# endif
+ gint idx,
+ gpointer data UNUSED)
+{
+ if (!ignore_tabline_evt)
+ {
+ if ((tabpage_index(curtab) - 1) < idx)
+ tabpage_move(idx + 1);
+ else
+ tabpage_move(idx);
}
}
@@ -3658,6 +3679,9 @@ gui_mch_update_tabline(void)
page,
event_box,
nr++);
+ gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(gui.tabline),
+ page,
+ TRUE);
}
event_box = gtk_notebook_get_tab_label(GTK_NOTEBOOK(gui.tabline), page);
@@ -4093,14 +4117,19 @@ gui_mch_init(void)
# endif
gtk_container_add(GTK_CONTAINER(event_box), label);
gtk_notebook_set_tab_label(GTK_NOTEBOOK(gui.tabline), page, event_box);
+ gtk_notebook_set_tab_reorderable(GTK_NOTEBOOK(gui.tabline), page, TRUE);
}
# if GTK_CHECK_VERSION(3,0,0)
g_signal_connect(G_OBJECT(gui.tabline), "switch-page",
G_CALLBACK(on_select_tab), NULL);
+ g_signal_connect(G_OBJECT(gui.tabline), "page-reordered",
+ G_CALLBACK(on_tab_reordered), NULL);
# else
gtk_signal_connect(GTK_OBJECT(gui.tabline), "switch_page",
GTK_SIGNAL_FUNC(on_select_tab), NULL);
+ gtk_signal_connect(GTK_OBJECT(gui.tabline), "page-reordered",
+ GTK_SIGNAL_FUNC(on_tab_reordered), NULL);
# endif
/* Create a popup menu for the tab line and connect it. */