Allow scrolling on notebook tabs to change the active page
This is enabled by default but has a setting in the preferences so it can be disabled.
This commit is contained in:
parent
95a302a46f
commit
50c216b17b
|
@ -126,6 +126,11 @@
|
||||||
<summary>Bottom Panel is Visible</summary>
|
<summary>Bottom Panel is Visible</summary>
|
||||||
<description>Whether the bottom panel at the bottom of editing windows should be visible.</description>
|
<description>Whether the bottom panel at the bottom of editing windows should be visible.</description>
|
||||||
</key>
|
</key>
|
||||||
|
<key name="enable-tab-scrolling" type="b">
|
||||||
|
<default>true</default>
|
||||||
|
<summary>Allow changing active tabs by scrolling</summary>
|
||||||
|
<description>Whether you can change active tabs by scrolling.</description>
|
||||||
|
</key>
|
||||||
<key name="max-recents" type="i">
|
<key name="max-recents" type="i">
|
||||||
<default>5</default>
|
<default>5</default>
|
||||||
<summary>Maximum Recent Files</summary>
|
<summary>Maximum Recent Files</summary>
|
||||||
|
|
|
@ -125,6 +125,9 @@ struct _XedPreferencesDialogPrivate
|
||||||
GtkWidget *right_margin_position_spinbutton;
|
GtkWidget *right_margin_position_spinbutton;
|
||||||
GtkWidget *right_margin_position_hbox;
|
GtkWidget *right_margin_position_hbox;
|
||||||
|
|
||||||
|
/* Tab scrolling */
|
||||||
|
GtkWidget *tab_scrolling_checkbutton;
|
||||||
|
|
||||||
/* Plugins manager */
|
/* Plugins manager */
|
||||||
GtkWidget *plugin_manager_place_holder;
|
GtkWidget *plugin_manager_place_holder;
|
||||||
|
|
||||||
|
@ -234,6 +237,17 @@ auto_save_spinbutton_value_changed (GtkSpinButton *spin_button,
|
||||||
xed_prefs_manager_set_auto_save_interval (MAX (1, gtk_spin_button_get_value_as_int (spin_button)));
|
xed_prefs_manager_set_auto_save_interval (MAX (1, gtk_spin_button_get_value_as_int (spin_button)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
tab_scrolling_checkbutton_toggled (GtkToggleButton *button,
|
||||||
|
XedPreferencesDialog *dlg)
|
||||||
|
{
|
||||||
|
xed_debug (DEBUG_PREFS);
|
||||||
|
|
||||||
|
g_return_if_fail (button == GTK_TOGGLE_BUTTON (dlg->priv->tab_scrolling_checkbutton));
|
||||||
|
|
||||||
|
xed_prefs_manager_set_enable_tab_scrolling (gtk_toggle_button_get_active (button));
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
setup_editor_page (XedPreferencesDialog *dlg)
|
setup_editor_page (XedPreferencesDialog *dlg)
|
||||||
{
|
{
|
||||||
|
@ -251,6 +265,8 @@ setup_editor_page (XedPreferencesDialog *dlg)
|
||||||
xed_prefs_manager_get_auto_indent ());
|
xed_prefs_manager_get_auto_indent ());
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->backup_copy_checkbutton),
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->backup_copy_checkbutton),
|
||||||
xed_prefs_manager_get_create_backup_copy ());
|
xed_prefs_manager_get_create_backup_copy ());
|
||||||
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->tab_scrolling_checkbutton),
|
||||||
|
xed_prefs_manager_get_enable_tab_scrolling ());
|
||||||
|
|
||||||
auto_save = xed_prefs_manager_get_auto_save ();
|
auto_save = xed_prefs_manager_get_auto_save ();
|
||||||
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->auto_save_checkbutton), auto_save);
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->auto_save_checkbutton), auto_save);
|
||||||
|
@ -271,6 +287,7 @@ setup_editor_page (XedPreferencesDialog *dlg)
|
||||||
gtk_widget_set_sensitive (dlg->priv->autosave_hbox, xed_prefs_manager_auto_save_can_set ());
|
gtk_widget_set_sensitive (dlg->priv->autosave_hbox, xed_prefs_manager_auto_save_can_set ());
|
||||||
gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton,
|
gtk_widget_set_sensitive (dlg->priv->auto_save_spinbutton,
|
||||||
auto_save && xed_prefs_manager_auto_save_interval_can_set ());
|
auto_save && xed_prefs_manager_auto_save_interval_can_set ());
|
||||||
|
gtk_widget_set_sensitive (dlg->priv->tab_scrolling_checkbutton, xed_prefs_manager_enable_tab_scrolling_can_set ());
|
||||||
|
|
||||||
/* Connect signal */
|
/* Connect signal */
|
||||||
g_signal_connect (dlg->priv->tabs_width_spinbutton, "value_changed",
|
g_signal_connect (dlg->priv->tabs_width_spinbutton, "value_changed",
|
||||||
|
@ -285,6 +302,8 @@ setup_editor_page (XedPreferencesDialog *dlg)
|
||||||
G_CALLBACK (backup_copy_checkbutton_toggled), dlg);
|
G_CALLBACK (backup_copy_checkbutton_toggled), dlg);
|
||||||
g_signal_connect (dlg->priv->auto_save_spinbutton, "value_changed",
|
g_signal_connect (dlg->priv->auto_save_spinbutton, "value_changed",
|
||||||
G_CALLBACK (auto_save_spinbutton_value_changed), dlg);
|
G_CALLBACK (auto_save_spinbutton_value_changed), dlg);
|
||||||
|
g_signal_connect (dlg->priv->tab_scrolling_checkbutton, "toggled",
|
||||||
|
G_CALLBACK (tab_scrolling_checkbutton_toggled), dlg);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1008,6 +1027,8 @@ xed_preferences_dialog_init (XedPreferencesDialog *dlg)
|
||||||
"auto_save_checkbutton", &dlg->priv->auto_save_checkbutton,
|
"auto_save_checkbutton", &dlg->priv->auto_save_checkbutton,
|
||||||
"auto_save_spinbutton", &dlg->priv->auto_save_spinbutton,
|
"auto_save_spinbutton", &dlg->priv->auto_save_spinbutton,
|
||||||
|
|
||||||
|
"tab_scrolling_checkbutton", &dlg->priv->tab_scrolling_checkbutton,
|
||||||
|
|
||||||
"default_font_checkbutton", &dlg->priv->default_font_checkbutton,
|
"default_font_checkbutton", &dlg->priv->default_font_checkbutton,
|
||||||
"font_button", &dlg->priv->font_button,
|
"font_button", &dlg->priv->font_button,
|
||||||
"font_hbox", &dlg->priv->font_hbox,
|
"font_hbox", &dlg->priv->font_hbox,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -64,6 +64,7 @@ struct _XedNotebookPrivate
|
||||||
gint always_show_tabs : 1;
|
gint always_show_tabs : 1;
|
||||||
gint close_buttons_sensitive : 1;
|
gint close_buttons_sensitive : 1;
|
||||||
gint tab_drag_and_drop_enabled : 1;
|
gint tab_drag_and_drop_enabled : 1;
|
||||||
|
gint tab_scrolling_enabled : 1;
|
||||||
guint destroy_has_run : 1;
|
guint destroy_has_run : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -643,6 +644,42 @@ button_press_cb (XedNotebook *notebook,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
notebook_scroll_event_cb (XedNotebook *notebook,
|
||||||
|
GdkEventScroll *event,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
GtkWidget *event_widget;
|
||||||
|
|
||||||
|
if (!notebook->priv->tab_scrolling_enabled)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
event_widget = gtk_get_event_widget ((GdkEvent *) event);
|
||||||
|
|
||||||
|
if (event_widget == NULL)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (event->direction)
|
||||||
|
{
|
||||||
|
case GDK_SCROLL_DOWN:
|
||||||
|
case GDK_SCROLL_RIGHT:
|
||||||
|
gtk_notebook_next_page (GTK_NOTEBOOK (notebook));
|
||||||
|
break;
|
||||||
|
case GDK_SCROLL_UP:
|
||||||
|
case GDK_SCROLL_LEFT:
|
||||||
|
gtk_notebook_prev_page (GTK_NOTEBOOK (notebook));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xed_notebook_new:
|
* xed_notebook_new:
|
||||||
*
|
*
|
||||||
|
@ -711,6 +748,7 @@ xed_notebook_init (XedNotebook *notebook)
|
||||||
|
|
||||||
notebook->priv->close_buttons_sensitive = TRUE;
|
notebook->priv->close_buttons_sensitive = TRUE;
|
||||||
notebook->priv->tab_drag_and_drop_enabled = TRUE;
|
notebook->priv->tab_drag_and_drop_enabled = TRUE;
|
||||||
|
notebook->priv->tab_scrolling_enabled = TRUE;
|
||||||
|
|
||||||
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
|
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
|
||||||
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
|
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
|
||||||
|
@ -733,6 +771,10 @@ xed_notebook_init (XedNotebook *notebook)
|
||||||
"switch_page",
|
"switch_page",
|
||||||
G_CALLBACK (xed_notebook_switch_page_cb),
|
G_CALLBACK (xed_notebook_switch_page_cb),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
gtk_widget_add_events (GTK_WIDGET (notebook), GDK_SCROLL_MASK);
|
||||||
|
g_signal_connect (notebook, "scroll-event",
|
||||||
|
G_CALLBACK (notebook_scroll_event_cb), NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -1097,3 +1139,41 @@ xed_notebook_get_tab_drag_and_drop_enabled (XedNotebook *nb)
|
||||||
return nb->priv->tab_drag_and_drop_enabled;
|
return nb->priv->tab_drag_and_drop_enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xed_notebook_set_tab_scrolling_enabled:
|
||||||
|
* @nb: a #XedNotebook
|
||||||
|
* @enable: %TRUE to enable tab scrolling
|
||||||
|
*
|
||||||
|
* Sets whether tab scrolling in the @nb is enabled.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
xed_notebook_set_tab_scrolling_enabled (XedNotebook *nb,
|
||||||
|
gboolean enable)
|
||||||
|
{
|
||||||
|
g_return_if_fail (XED_IS_NOTEBOOK (nb));
|
||||||
|
|
||||||
|
enable = (enable != FALSE);
|
||||||
|
|
||||||
|
if (enable == nb->priv->tab_scrolling_enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nb->priv->tab_scrolling_enabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xed_notebook_get_tab_scrolling_enabled:
|
||||||
|
* @nb: a #XedNotebook
|
||||||
|
*
|
||||||
|
* Whether notebook tab scrolling is enabled
|
||||||
|
*
|
||||||
|
* Returns: %TRUE if tab scrolling is enabled
|
||||||
|
*/
|
||||||
|
gboolean
|
||||||
|
xed_notebook_get_tab_scrolling_enabled (XedNotebook *nb)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (XED_IS_NOTEBOOK (nb), TRUE);
|
||||||
|
|
||||||
|
return nb->priv->tab_scrolling_enabled;
|
||||||
|
}
|
||||||
|
|
|
@ -138,6 +138,10 @@ void xed_notebook_set_tab_drag_and_drop_enabled
|
||||||
gboolean xed_notebook_get_tab_drag_and_drop_enabled
|
gboolean xed_notebook_get_tab_drag_and_drop_enabled
|
||||||
(XedNotebook *nb);
|
(XedNotebook *nb);
|
||||||
|
|
||||||
|
void xed_notebook_set_tab_scrolling_enabled (XedNotebook *nb,
|
||||||
|
gboolean enable);
|
||||||
|
gboolean xed_notebook_get_tab_scrolling_enabled (XedNotebook *nb);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* XED_NOTEBOOK_H */
|
#endif /* XED_NOTEBOOK_H */
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include "xed-debug.h"
|
#include "xed-debug.h"
|
||||||
#include "xed-view.h"
|
#include "xed-view.h"
|
||||||
#include "xed-window.h"
|
#include "xed-window.h"
|
||||||
|
#include "xed-notebook.h"
|
||||||
#include "xed-window-private.h"
|
#include "xed-window-private.h"
|
||||||
#include "xed-plugins-engine.h"
|
#include "xed-plugins-engine.h"
|
||||||
#include "xed-style-scheme-manager.h"
|
#include "xed-style-scheme-manager.h"
|
||||||
|
@ -84,6 +85,10 @@ static void xed_prefs_manager_smart_home_end_changed (GSettings *settings,
|
||||||
gchar *key,
|
gchar *key,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
|
static void xed_prefs_manager_enable_tab_scrolling_changed (GSettings *settings,
|
||||||
|
gchar *key,
|
||||||
|
gpointer user_data);
|
||||||
|
|
||||||
static void xed_prefs_manager_hl_current_line_changed (GSettings *settings,
|
static void xed_prefs_manager_hl_current_line_changed (GSettings *settings,
|
||||||
gchar *key,
|
gchar *key,
|
||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
@ -660,6 +665,9 @@ xed_prefs_manager_app_init (void)
|
||||||
G_CALLBACK (xed_prefs_manager_smart_home_end_changed),
|
G_CALLBACK (xed_prefs_manager_smart_home_end_changed),
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
g_signal_connect (xed_prefs_manager->settings, "changed::" GPM_ENABLE_TAB_SCROLLING,
|
||||||
|
G_CALLBACK (xed_prefs_manager_enable_tab_scrolling_changed), NULL);
|
||||||
|
|
||||||
g_signal_connect (xed_prefs_manager->settings,
|
g_signal_connect (xed_prefs_manager->settings,
|
||||||
"changed::" GPM_HIGHLIGHT_CURRENT_LINE,
|
"changed::" GPM_HIGHLIGHT_CURRENT_LINE,
|
||||||
G_CALLBACK (xed_prefs_manager_hl_current_line_changed),
|
G_CALLBACK (xed_prefs_manager_hl_current_line_changed),
|
||||||
|
@ -1168,6 +1176,35 @@ xed_prefs_manager_smart_home_end_changed (GSettings *settings,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xed_prefs_manager_enable_tab_scrolling_changed (GSettings *settings,
|
||||||
|
gchar *key,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
xed_debug (DEBUG_PREFS);
|
||||||
|
|
||||||
|
g_printerr ("Tab scrolling changed\n");
|
||||||
|
|
||||||
|
if (strcmp (key, GPM_ENABLE_TAB_SCROLLING) == 0)
|
||||||
|
{
|
||||||
|
gboolean enable;
|
||||||
|
const GList *windows;
|
||||||
|
|
||||||
|
enable = g_settings_get_boolean (settings, key);
|
||||||
|
|
||||||
|
windows = xed_app_get_windows (xed_app_get_default ());
|
||||||
|
while (windows != NULL)
|
||||||
|
{
|
||||||
|
XedNotebook *notebook;
|
||||||
|
|
||||||
|
notebook = XED_NOTEBOOK (_xed_window_get_notebook (windows->data));
|
||||||
|
xed_notebook_set_tab_scrolling_enabled (notebook, enable);
|
||||||
|
|
||||||
|
windows = g_list_next (windows);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xed_prefs_manager_syntax_hl_enable_changed (GSettings *settings,
|
xed_prefs_manager_syntax_hl_enable_changed (GSettings *settings,
|
||||||
gchar *key,
|
gchar *key,
|
||||||
|
|
|
@ -371,6 +371,9 @@ DEFINE_BOOL_PREF (side_pane_visible,
|
||||||
DEFINE_BOOL_PREF (bottom_panel_visible,
|
DEFINE_BOOL_PREF (bottom_panel_visible,
|
||||||
GPM_BOTTOM_PANEL_VISIBLE)
|
GPM_BOTTOM_PANEL_VISIBLE)
|
||||||
|
|
||||||
|
/* Tab scrolling */
|
||||||
|
DEFINE_BOOL_PREF (enable_tab_scrolling, GPM_ENABLE_TAB_SCROLLING)
|
||||||
|
|
||||||
/* Print syntax highlighting */
|
/* Print syntax highlighting */
|
||||||
DEFINE_BOOL_PREF (print_syntax_hl,
|
DEFINE_BOOL_PREF (print_syntax_hl,
|
||||||
GPM_PRINT_SYNTAX)
|
GPM_PRINT_SYNTAX)
|
||||||
|
|
|
@ -81,6 +81,8 @@
|
||||||
|
|
||||||
#define GPM_BOTTOM_PANEL_VISIBLE "bottom-panel-visible"
|
#define GPM_BOTTOM_PANEL_VISIBLE "bottom-panel-visible"
|
||||||
|
|
||||||
|
#define GPM_ENABLE_TAB_SCROLLING "enable-tab-scrolling"
|
||||||
|
|
||||||
#define GPM_MAX_RECENTS "max-recents"
|
#define GPM_MAX_RECENTS "max-recents"
|
||||||
|
|
||||||
/* Print */
|
/* Print */
|
||||||
|
@ -201,6 +203,12 @@ gboolean xed_prefs_manager_side_pane_visible_can_set (void);
|
||||||
gboolean xed_prefs_manager_get_bottom_panel_visible (void);
|
gboolean xed_prefs_manager_get_bottom_panel_visible (void);
|
||||||
void xed_prefs_manager_set_bottom_panel_visible (gboolean tv);
|
void xed_prefs_manager_set_bottom_panel_visible (gboolean tv);
|
||||||
gboolean xed_prefs_manager_bottom_panel_visible_can_set(void);
|
gboolean xed_prefs_manager_bottom_panel_visible_can_set(void);
|
||||||
|
|
||||||
|
/* Tab scrolling enabled */
|
||||||
|
gboolean xed_prefs_manager_get_enable_tab_scrolling (void);
|
||||||
|
void xed_prefs_manager_set_enable_tab_scrolling (gboolean tv);
|
||||||
|
gboolean xed_prefs_manager_enable_tab_scrolling_can_set (void);
|
||||||
|
|
||||||
/* Print syntax highlighting */
|
/* Print syntax highlighting */
|
||||||
gboolean xed_prefs_manager_get_print_syntax_hl (void);
|
gboolean xed_prefs_manager_get_print_syntax_hl (void);
|
||||||
void xed_prefs_manager_set_print_syntax_hl (gboolean ps);
|
void xed_prefs_manager_set_print_syntax_hl (gboolean ps);
|
||||||
|
|
|
@ -3368,6 +3368,9 @@ add_notebook (XedWindow *window,
|
||||||
{
|
{
|
||||||
gtk_paned_pack1 (GTK_PANED(window->priv->vpaned), notebook, TRUE, TRUE);
|
gtk_paned_pack1 (GTK_PANED(window->priv->vpaned), notebook, TRUE, TRUE);
|
||||||
gtk_widget_show (notebook);
|
gtk_widget_show (notebook);
|
||||||
|
|
||||||
|
xed_notebook_set_tab_scrolling_enabled (XED_NOTEBOOK (notebook), xed_prefs_manager_get_enable_tab_scrolling ());
|
||||||
|
|
||||||
connect_notebook_signals (window, notebook);
|
connect_notebook_signals (window, notebook);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue