[geany/geany] 417dd0: Add ability to scroll over document tabs
Luke Horwell
git-noreply at geany.org
Mon Apr 11 10:24:43 UTC 2022
Branch: refs/heads/master
Author: Luke Horwell <code at horwell.me>
Committer: Luke Horwell <code at horwell.me>
Date: Mon, 11 Apr 2022 10:24:43 UTC
Commit: 417dd007255b2fbe1307b698c3f5c39d9de5eda3
https://github.com/geany/geany/commit/417dd007255b2fbe1307b698c3f5c39d9de5eda3
Log Message:
-----------
Add ability to scroll over document tabs
This commit reimplements a feature that GTK3 removed a long time ago.
Only concerns the main document tabs.
Addresses #872.
Based on this commit for MATE Caja (GPLv2):
https://github.com/mate-desktop/caja/commit/0b4c7a6b8c25afb987d08bfd2c4c9be57de23960
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