[geany/geany] 9ce7c7: Merge pull request #3134 from lah7/tab-scroll-gtk3
Enrico Tröger
git-noreply at geany.org
Mon Apr 11 21:36:17 UTC 2022
Branch: refs/heads/master
Author: Enrico Tröger <enrico.troeger at uvena.de>
Committer: GitHub <noreply at github.com>
Date: Mon, 11 Apr 2022 21:36:17 UTC
Commit: 9ce7c72064c6da5a70e61aa54bf5657ae2ed1b8f
https://github.com/geany/geany/commit/9ce7c72064c6da5a70e61aa54bf5657ae2ed1b8f
Log Message:
-----------
Merge pull request #3134 from lah7/tab-scroll-gtk3
Add ability to scroll over document tabs
Modified Paths:
--------------
src/notebook.c
Modified: src/notebook.c
34 lines changed, 34 insertions(+), 0 deletions(-)
===================================================================
@@ -544,6 +544,33 @@ static gboolean notebook_tab_bar_click_cb(GtkWidget *widget, GdkEventButton *eve
}
+static gboolean notebook_tab_bar_scroll_cb(GtkWidget *widget, GdkEventScroll *event)
+{
+ GtkNotebook *notebook = GTK_NOTEBOOK(widget);
+ GtkWidget *child;
+
+ child = gtk_notebook_get_nth_page(notebook, gtk_notebook_get_current_page(notebook));
+ if (child == NULL)
+ return FALSE;
+
+ switch (event->direction)
+ {
+ case GDK_SCROLL_RIGHT:
+ case GDK_SCROLL_DOWN:
+ gtk_notebook_next_page(notebook);
+ break;
+ case GDK_SCROLL_LEFT:
+ case GDK_SCROLL_UP:
+ gtk_notebook_prev_page(notebook);
+ break;
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
+
void notebook_init(void)
{
g_signal_connect_after(main_widgets.notebook, "button-press-event",
@@ -558,6 +585,9 @@ void notebook_init(void)
g_signal_connect(geany_object, "document-close",
G_CALLBACK(on_document_close), NULL);
+ gtk_widget_add_events(main_widgets.notebook, GDK_SCROLL_MASK);
+ g_signal_connect(main_widgets.notebook, "scroll-event", G_CALLBACK(notebook_tab_bar_scroll_cb), NULL);
+
/* in case the switch dialog misses an event while drawing the dialog */
g_signal_connect(main_widgets.window, "key-release-event", G_CALLBACK(on_key_release_event), NULL);
@@ -693,6 +723,10 @@ gint notebook_new_tab(GeanyDocument *this)
g_signal_connect_after(ebox, "button-release-event",
G_CALLBACK(focus_sci), NULL);
+ /* switch tab by scrolling - GTK2 behaviour for GTK3 */
+ gtk_widget_add_events(GTK_WIDGET(ebox), GDK_SCROLL_MASK);
+ gtk_widget_add_events(GTK_WIDGET(this->priv->tab_label), GDK_SCROLL_MASK);
+
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 2);
gtk_box_pack_start(GTK_BOX(hbox), this->priv->tab_label, FALSE, FALSE, 0);
gtk_container_add(GTK_CONTAINER(ebox), hbox);
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list