Hi Bram,
2016/3/16 Wed 1:19:07 UTC+9 Ken Takata wrote:
> Hi,
>
> 2015/11/24 Tue 23:19:13 UTC+9 Bram Moolenaar wrote:
> > Ken Takata wrote:
> >
> > > I'm afraid that you are missing the following patch because the todo item
> > > is
> > > not updated:
> > > https://groups.google.com/d/msg/vim_dev/_X0cpMreBiw/n4juz5_eBAAJ
> > >
> > > > BTW, Below is also need to be modified, so that, Abe fixed this.
> > > > > Patch for drag&drop reordering of GUI tab pages reordering.
> > > > > (Ken Takata, 2013 Nov 22, second one, also by Masamichi Abe)
> > > >
> > > > https://gist.github.com/nocd5/165286495c782b815b94
> > >
> > > The tabline-dnd patch needed to be updated after 7.4.709, and Masamichi
> > > Abe
> > > did it. I confirmed that Masamichi's latest patch works fine with 7.4.936
> > > (both on Windows and Linux).
> > > https://gist.github.com/nocd5/165286495c782b815b94
> >
> > I'll add the github link to the todo item.
>
> I have updated the tabline-dnd patch to support GTK3.
> Please check the attached patch.
I have updated the tabline-dnd patch. An error when using cproto has been
fixed. I'm waiting this patch to be included for a long time. I think this
patch is very useful especially for beginners.
Regards,
Ken Takata
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
# HG changeset patch
# Parent 5537e50173cf0443f342aaea8e86a604520868bf
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -3557,6 +3557,33 @@ on_select_tab(
}
/*
+ * 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);
+ }
+ }
+}
+
+/*
* Show or hide the tabline.
*/
void
@@ -3642,6 +3669,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);
@@ -4081,14 +4111,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. */
diff --git a/src/gui_w32.c b/src/gui_w32.c
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -257,6 +257,7 @@ typedef int FINDREPLACE;
typedef int HANDLE;
typedef int HBITMAP;
typedef int HBRUSH;
+typedef int HCURSOR;
typedef int HDROP;
typedef int INT;
typedef int LOGFONT[];
@@ -8395,6 +8396,34 @@ initialise_tabline(void)
# endif
}
+/*
+ * Get tabpage_T from POINT.
+ */
+ static tabpage_T *
+GetTabFromPoint(
+ HWND hWnd,
+ POINT pt)
+{
+ tabpage_T *ptp = NULL;
+
+ if (gui_mch_showing_tabline())
+ {
+ TCHITTESTINFO htinfo;
+ htinfo.pt = pt;
+ /* ignore if a window under cusor is not tabcontrol. */
+ if (s_tabhwnd == hWnd)
+ {
+ int idx = TabCtrl_HitTest(s_tabhwnd, &htinfo);
+ if (idx != -1)
+ ptp = find_tabpage(idx + 1);
+ }
+ }
+ return ptp;
+}
+
+static POINT s_pt = {0, 0};
+static HCURSOR s_hCursor = NULL;
+
static LRESULT CALLBACK
tabline_wndproc(
HWND hwnd,
@@ -8402,7 +8431,73 @@ tabline_wndproc(
WPARAM wParam,
LPARAM lParam)
{
+ POINT pt;
+ tabpage_T *tp;
+ RECT rect;
+ int nCenter;
+ int idx0;
+ int idx1;
+
HandleMouseHide(uMsg, lParam);
+
+ switch (uMsg)
+ {
+ case WM_LBUTTONDOWN:
+ {
+ s_pt.x = GET_X_LPARAM(lParam);
+ s_pt.y = GET_Y_LPARAM(lParam);
+ SetCapture(hwnd);
+ s_hCursor = GetCursor(); /* backup default cursor */
+ break;
+ }
+ case WM_MOUSEMOVE:
+ if (GetCapture() == hwnd
+ && ((wParam & MK_LBUTTON)) != 0)
+ {
+ pt.x = GET_X_LPARAM(lParam);
+ pt.y = s_pt.y;
+ if (abs(pt.x - s_pt.x) > GetSystemMetrics(SM_CXDRAG))
+ {
+ SetCursor(LoadCursor(NULL, IDC_SIZEWE));
+
+ tp = GetTabFromPoint(hwnd, pt);
+ if (tp != NULL)
+ {
+ idx0 = tabpage_index(curtab) - 1;
+ idx1 = tabpage_index(tp) - 1;
+
+ TabCtrl_GetItemRect(hwnd, idx1, &rect);
+ nCenter = rect.left + (rect.right - rect.left) / 2;
+
+ /* Check if the mouse cursor goes over the center of
+ * the next tab to prevent "flickering". */
+ if ((idx0 < idx1) && (nCenter < pt.x))
+ {
+ tabpage_move(idx1 + 1);
+ update_screen(0);
+ }
+ else if ((idx1 < idx0) && (pt.x < nCenter))
+ {
+ tabpage_move(idx1);
+ update_screen(0);
+ }
+ }
+ }
+ }
+ break;
+ case WM_LBUTTONUP:
+ {
+ if (GetCapture() == hwnd)
+ {
+ SetCursor(s_hCursor);
+ ReleaseCapture();
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
return CallWindowProc(s_tabline_wndproc, hwnd, uMsg, wParam, lParam);
}
#endif