[Libreoffice-commits] core.git: vcl/unx
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Nov 28 13:36:01 UTC 2018
vcl/unx/gtk3/gtk3gtkinst.cxx | 50 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
New commits:
commit f6e0212285f48beab3c47a00e5b2f9549654a066
Author: Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Nov 28 11:50:19 2018 +0000
Commit: Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Nov 28 14:35:37 2018 +0100
Resolves: tdf#121752 let scroll wheel change active notebook tab
Change-Id: If8437346a58ea14266f11293b94082740303e5a9
Reviewed-on: https://gerrit.libreoffice.org/64158
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 6eb623efe088..286206f7c4a5 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -3012,6 +3012,7 @@ private:
GtkNotebook* m_pNotebook;
gulong m_nSwitchPageSignalId;
gulong m_nSizeAllocateSignalId;
+ gulong m_nScrollSignalId;
mutable std::vector<std::unique_ptr<GtkInstanceContainer>> m_aPages;
static void signalSwitchPage(GtkNotebook*, GtkWidget*, guint nNewPage, gpointer widget)
@@ -3033,6 +3034,50 @@ private:
m_aEnterPageHdl.Call(sNewIdent);
}
+ static gboolean signalScroll(GtkWidget*, GdkEventScroll* event, gpointer widget)
+ {
+ GtkInstanceNotebook* pThis = static_cast<GtkInstanceNotebook*>(widget);
+ return pThis->signal_scroll(event);
+ }
+
+ bool signal_scroll(GdkEventScroll* event)
+ {
+ bool bNext(false), bPrev(false);
+ switch (event->direction)
+ {
+ case GDK_SCROLL_RIGHT:
+ case GDK_SCROLL_DOWN:
+ bNext = true;
+ break;
+ case GDK_SCROLL_LEFT:
+ case GDK_SCROLL_UP:
+ bPrev = true;
+ break;
+ case GDK_SCROLL_SMOOTH:
+ {
+ switch (gtk_notebook_get_tab_pos(m_pNotebook))
+ {
+ case GTK_POS_LEFT:
+ case GTK_POS_RIGHT:
+ bNext = event->delta_y > 0;
+ bPrev = event->delta_y < 0;
+ break;
+ case GTK_POS_TOP:
+ case GTK_POS_BOTTOM:
+ bNext = event->delta_x > 0;
+ bPrev = event->delta_x < 0;
+ break;
+ }
+ break;
+ }
+ }
+ if (bNext)
+ gtk_notebook_next_page(m_pNotebook);
+ else if (bPrev)
+ gtk_notebook_prev_page(m_pNotebook);
+ return true;
+ }
+
OString get_page_ident(guint nPage) const
{
const GtkWidget* pTabWidget = gtk_notebook_get_tab_label(m_pNotebook, gtk_notebook_get_nth_page(m_pNotebook, nPage));
@@ -3097,6 +3142,8 @@ public:
, m_pNotebook(pNotebook)
, m_nSwitchPageSignalId(g_signal_connect(pNotebook, "switch-page", G_CALLBACK(signalSwitchPage), this))
{
+ gtk_widget_add_events(GTK_WIDGET(pNotebook), GDK_SCROLL_MASK);
+ m_nScrollSignalId = g_signal_connect(pNotebook, "scroll-event", G_CALLBACK(signalScroll), this);
if (get_n_pages() > 6)
m_nSizeAllocateSignalId = g_signal_connect(pNotebook, "size-allocate", G_CALLBACK(signalSizeAllocate), this);
else
@@ -3188,9 +3235,10 @@ public:
virtual ~GtkInstanceNotebook() override
{
- g_signal_handler_disconnect(m_pNotebook, m_nSwitchPageSignalId);
if (m_nSizeAllocateSignalId)
g_signal_handler_disconnect(m_pNotebook, m_nSizeAllocateSignalId);
+ g_signal_handler_disconnect(m_pNotebook, m_nScrollSignalId);
+ g_signal_handler_disconnect(m_pNotebook, m_nSwitchPageSignalId);
}
};
More information about the Libreoffice-commits
mailing list