Skip to content
Permalink
Browse files

Make notebook tabs scrollable

  • Loading branch information...
likorisd authored and raveit65 committed Feb 5, 2018
1 parent 1d82cc7 commit ed34d929a420da68b49e232a08bc3ca8f980200c
Showing with 60 additions and 1 deletion.
  1. +14 −0 pluma/pluma-notebook.c
  2. +22 −0 pluma/pluma-tab-label.c
  3. +24 −1 pluma/pluma-window.c
@@ -838,6 +838,16 @@ close_button_clicked_cb (PlumaTabLabel *tab_label, PlumaNotebook *notebook)
g_signal_emit (notebook, signals[TAB_CLOSE_REQUEST], 0, tab);
}

static gboolean
tab_label_scroll_cb (PlumaTabLabel *tab_label,
GdkEventScroll *event,
PlumaNotebook *notebook)
{
g_signal_emit_by_name (notebook, "scroll-event", &event);

return FALSE;
}

static GtkWidget *
create_tab_label (PlumaNotebook *nb,
PlumaTab *tab)
@@ -850,6 +860,10 @@ create_tab_label (PlumaNotebook *nb,
"close-clicked",
G_CALLBACK (close_button_clicked_cb),
nb);
g_signal_connect (tab_label,
"scroll-event",
G_CALLBACK (tab_label_scroll_cb),
nb);

g_object_set_data (G_OBJECT (tab), "tab-label", tab_label);

@@ -114,6 +114,16 @@ close_button_clicked_cb (GtkWidget *widget,
g_signal_emit (tab_label, signals[CLOSE_CLICKED], 0, NULL);
}

static gboolean
scroll_event_cb(GtkWidget *widget,
GdkEventScroll *event,
PlumaTabLabel *tab_label)
{
g_signal_emit_by_name(tab_label, "scroll-event", &event);

return FALSE;
}

static void
sync_tip (PlumaTab *tab, PlumaTabLabel *tab_label)
{
@@ -265,6 +275,7 @@ pluma_tab_label_init (PlumaTabLabel *tab_label)
GTK_ORIENTATION_HORIZONTAL);

ebox = gtk_event_box_new ();
gtk_widget_add_events (ebox, GDK_SCROLL_MASK);
gtk_event_box_set_visible_window (GTK_EVENT_BOX (ebox), FALSE);
gtk_box_pack_start (GTK_BOX (tab_label), ebox, TRUE, TRUE, 0);
tab_label->priv->ebox = ebox;
@@ -273,6 +284,7 @@ pluma_tab_label_init (PlumaTabLabel *tab_label)
gtk_container_add (GTK_CONTAINER (ebox), hbox);

close_button = pluma_close_button_new ();
gtk_widget_add_events (close_button, GDK_SCROLL_MASK);
gtk_widget_set_tooltip_text (close_button, _("Close document"));
gtk_box_pack_start (GTK_BOX (tab_label), close_button, FALSE, FALSE, 0);
tab_label->priv->close_button = close_button;
@@ -281,6 +293,16 @@ pluma_tab_label_init (PlumaTabLabel *tab_label)
"clicked",
G_CALLBACK (close_button_clicked_cb),
tab_label);

g_signal_connect (close_button,
"scroll-event",
G_CALLBACK (scroll_event_cb),
tab_label);

g_signal_connect (ebox,
"scroll-event",
G_CALLBACK (scroll_event_cb),
tab_label);

spinner = gtk_spinner_new ();
gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0);
@@ -36,6 +36,7 @@
#include <sys/types.h>
#include <string.h>

#include <gdk/gdk.h>
#include <glib/gi18n.h>
#include <gio/gio.h>
#include <gtk/gtk.h>
@@ -3490,6 +3491,23 @@ notebook_button_press_event (GtkNotebook *notebook,
return FALSE;
}

static gboolean
notebook_scroll_event (GtkNotebook *notebook,
GdkEventScroll *event,
PlumaWindow *window)
{
if (event->direction == GDK_SCROLL_UP || event->direction == GDK_SCROLL_LEFT)
{
gtk_notebook_prev_page (notebook);
}
else if (event->direction == GDK_SCROLL_DOWN || event->direction == GDK_SCROLL_RIGHT)
{
gtk_notebook_next_page (notebook);
}

return FALSE;
}

static gboolean
notebook_popup_menu (GtkNotebook *notebook,
PlumaWindow *window)
@@ -3856,6 +3874,10 @@ connect_notebook_signals (PlumaWindow *window,
"popup-menu",
G_CALLBACK (notebook_popup_menu),
window);
g_signal_connect (notebook,
"scroll-event",
G_CALLBACK (notebook_scroll_event),
window);
}

static void
@@ -3868,7 +3890,8 @@ add_notebook (PlumaWindow *window,
TRUE);

gtk_widget_show (notebook);


gtk_widget_add_events (notebook, GDK_SCROLL_MASK);
connect_notebook_signals (window, notebook);
}

0 comments on commit ed34d92

Please sign in to comment.
You can’t perform that action at this time.