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:
JosephMcc 2016-12-31 14:18:31 -08:00
parent 95a302a46f
commit 50c216b17b
9 changed files with 1508 additions and 1170 deletions

View File

@ -126,6 +126,11 @@
<summary>Bottom Panel is Visible</summary>
<description>Whether the bottom panel at the bottom of editing windows should be visible.</description>
</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">
<default>5</default>
<summary>Maximum Recent Files</summary>

View File

@ -125,6 +125,9 @@ struct _XedPreferencesDialogPrivate
GtkWidget *right_margin_position_spinbutton;
GtkWidget *right_margin_position_hbox;
/* Tab scrolling */
GtkWidget *tab_scrolling_checkbutton;
/* Plugins manager */
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)));
}
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
setup_editor_page (XedPreferencesDialog *dlg)
{
@ -251,6 +265,8 @@ setup_editor_page (XedPreferencesDialog *dlg)
xed_prefs_manager_get_auto_indent ());
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dlg->priv->backup_copy_checkbutton),
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 ();
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->auto_save_spinbutton,
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 */
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_signal_connect (dlg->priv->auto_save_spinbutton, "value_changed",
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
@ -1008,6 +1027,8 @@ xed_preferences_dialog_init (XedPreferencesDialog *dlg)
"auto_save_checkbutton", &dlg->priv->auto_save_checkbutton,
"auto_save_spinbutton", &dlg->priv->auto_save_spinbutton,
"tab_scrolling_checkbutton", &dlg->priv->tab_scrolling_checkbutton,
"default_font_checkbutton", &dlg->priv->default_font_checkbutton,
"font_button", &dlg->priv->font_button,
"font_hbox", &dlg->priv->font_hbox,

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
* xed-notebook.c
* This file is part of xed
*
* Copyright (C) 2005 - Paolo Maggi
* Copyright (C) 2005 - Paolo Maggi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,14 +16,14 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Modified by the xed Team, 2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
* Modified by the xed Team, 2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*/
/* This file is a modified version of the epiphany file ephy-notebook.c
@ -64,6 +64,7 @@ struct _XedNotebookPrivate
gint always_show_tabs : 1;
gint close_buttons_sensitive : 1;
gint tab_drag_and_drop_enabled : 1;
gint tab_scrolling_enabled : 1;
guint destroy_has_run : 1;
};
@ -205,7 +206,7 @@ find_notebook_at_pointer (gint abs_x, gint abs_y)
gdk_window_get_user_data (toplevel_win, &toplevel);
/* toplevel should be an XedWindow */
if ((toplevel != NULL) &&
if ((toplevel != NULL) &&
XED_IS_WINDOW (toplevel))
{
return XED_NOTEBOOK (_xed_window_get_notebook
@ -218,7 +219,7 @@ find_notebook_at_pointer (gint abs_x, gint abs_y)
static gboolean
is_in_notebook_window (XedNotebook *notebook,
gint abs_x,
gint abs_x,
gint abs_y)
{
XedNotebook *nb_at_pointer;
@ -231,8 +232,8 @@ is_in_notebook_window (XedNotebook *notebook,
}
static gint
find_tab_num_at_pos (XedNotebook *notebook,
gint abs_x,
find_tab_num_at_pos (XedNotebook *notebook,
gint abs_x,
gint abs_y)
{
GtkPositionType tab_pos;
@ -295,12 +296,12 @@ find_tab_num_at_pos (XedNotebook *notebook,
++page_num;
}
return AFTER_ALL_TABS;
}
static gint
find_notebook_and_tab_at_pos (gint abs_x,
static gint
find_notebook_and_tab_at_pos (gint abs_x,
gint abs_y,
XedNotebook **notebook,
gint *page_num)
@ -310,7 +311,7 @@ find_notebook_and_tab_at_pos (gint abs_x,
{
return NOT_IN_APP_WINDOWS;
}
*page_num = find_tab_num_at_pos (*notebook, abs_x, abs_y);
if (*page_num < 0)
@ -331,8 +332,8 @@ find_notebook_and_tab_at_pos (gint abs_x,
* @dest_position: the position for @tab
*
* Moves @tab from @src to @dest.
* If dest_position is greater than or equal to the number of tabs
* of the destination nootebook or negative, tab will be moved to the
* If dest_position is greater than or equal to the number of tabs
* of the destination nootebook or negative, tab will be moved to the
* end of the tabs.
*/
void
@ -341,7 +342,7 @@ xed_notebook_move_tab (XedNotebook *src,
XedTab *tab,
gint dest_position)
{
g_return_if_fail (XED_IS_NOTEBOOK (src));
g_return_if_fail (XED_IS_NOTEBOOK (src));
g_return_if_fail (XED_IS_NOTEBOOK (dest));
g_return_if_fail (src != dest);
g_return_if_fail (XED_IS_TAB (tab));
@ -360,8 +361,8 @@ xed_notebook_move_tab (XedNotebook *src,
* @dest_position: the position for @tab
*
* Reorders the page containing @tab, so that it appears in @dest_position position.
* If dest_position is greater than or equal to the number of tabs
* of the destination notebook or negative, tab will be moved to the
* If dest_position is greater than or equal to the number of tabs
* of the destination notebook or negative, tab will be moved to the
* end of the tabs.
*/
void
@ -370,24 +371,24 @@ xed_notebook_reorder_tab (XedNotebook *src,
gint dest_position)
{
gint old_position;
g_return_if_fail (XED_IS_NOTEBOOK (src));
g_return_if_fail (XED_IS_NOTEBOOK (src));
g_return_if_fail (XED_IS_TAB (tab));
old_position = gtk_notebook_page_num (GTK_NOTEBOOK (src),
old_position = gtk_notebook_page_num (GTK_NOTEBOOK (src),
GTK_WIDGET (tab));
if (old_position == dest_position)
return;
gtk_notebook_reorder_child (GTK_NOTEBOOK (src),
gtk_notebook_reorder_child (GTK_NOTEBOOK (src),
GTK_WIDGET (tab),
dest_position);
if (!src->priv->drag_in_progress)
{
g_signal_emit (G_OBJECT (src),
signals[TABS_REORDERED],
g_signal_emit (G_OBJECT (src),
signals[TABS_REORDERED],
0);
}
}
@ -412,8 +413,8 @@ drag_start (XedNotebook *notebook,
gdk_pointer_grab (gtk_widget_get_window (GTK_WIDGET (notebook)),
FALSE,
GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK,
NULL,
cursor,
NULL,
cursor,
time);
}
}
@ -423,8 +424,8 @@ drag_stop (XedNotebook *notebook)
{
if (notebook->priv->drag_in_progress)
{
g_signal_emit (G_OBJECT (notebook),
signals[TABS_REORDERED],
g_signal_emit (G_OBJECT (notebook),
signals[TABS_REORDERED],
0);
}
@ -451,10 +452,10 @@ move_current_tab (XedNotebook *notebook,
if (dest_position != cur_page_num)
{
GtkWidget *cur_tab;
cur_tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook),
cur_page_num);
xed_notebook_reorder_tab (XED_NOTEBOOK (notebook),
XED_TAB (cur_tab),
dest_position);
@ -474,11 +475,11 @@ motion_notify_cb (XedNotebook *notebook,
{
if (notebook->priv->tab_drag_and_drop_enabled == FALSE)
return FALSE;
if (gtk_drag_check_threshold (GTK_WIDGET (notebook),
notebook->priv->x_start,
notebook->priv->y_start,
event->x_root,
event->x_root,
event->y_root))
{
drag_start (notebook, event->time);
@ -490,16 +491,16 @@ motion_notify_cb (XedNotebook *notebook,
result = find_notebook_and_tab_at_pos ((gint)event->x_root,
(gint)event->y_root,
&dest,
&dest,
&page_num);
if (result != NOT_IN_APP_WINDOWS)
{
if (dest != notebook)
{
move_current_tab_to_another_notebook (notebook,
move_current_tab_to_another_notebook (notebook,
dest,
event,
event,
page_num);
}
else
@ -530,7 +531,7 @@ move_current_tab_to_another_notebook (XedNotebook *src,
g_return_if_fail (dest != src);
cur_page = gtk_notebook_get_current_page (GTK_NOTEBOOK (src));
tab = XED_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (src),
tab = XED_TAB (gtk_notebook_get_nth_page (GTK_NOTEBOOK (src),
cur_page));
/* stop drag in origin window */
@ -574,8 +575,8 @@ button_release_cb (XedNotebook *notebook,
{
/* Tab was detached */
g_signal_emit (G_OBJECT (notebook),
signals[TAB_DETACHED],
0,
signals[TAB_DETACHED],
0,
cur_page);
}
@ -606,27 +607,27 @@ button_press_cb (XedNotebook *notebook,
tab_clicked = find_tab_num_at_pos (notebook,
event->x_root,
event->y_root);
if ((event->button == 1) &&
(event->type == GDK_BUTTON_PRESS) &&
if ((event->button == 1) &&
(event->type == GDK_BUTTON_PRESS) &&
(tab_clicked >= 0))
{
notebook->priv->x_start = event->x_root;
notebook->priv->y_start = event->y_root;
notebook->priv->motion_notify_handler_id =
g_signal_connect (G_OBJECT (notebook),
"motion-notify-event",
G_CALLBACK (motion_notify_cb),
G_CALLBACK (motion_notify_cb),
NULL);
}
else if ((event->type == GDK_BUTTON_PRESS) &&
else if ((event->type == GDK_BUTTON_PRESS) &&
(event->button == 3 || event->button == 2))
{
if (tab_clicked == -1)
{
// CHECK: do we really need it?
/* consume event, so that we don't pop up the context menu when
* the mouse if not over a tab label
*/
@ -635,7 +636,7 @@ button_press_cb (XedNotebook *notebook,
else
{
/* Switch to the page the mouse is over, but don't consume the event */
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook),
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook),
tab_clicked);
}
}
@ -643,6 +644,42 @@ button_press_cb (XedNotebook *notebook,
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:
*
@ -689,7 +726,7 @@ xed_notebook_switch_page_cb (GtkNotebook *notebook,
* and the pref is not set.
*/
static void
update_tabs_visibility (XedNotebook *nb,
update_tabs_visibility (XedNotebook *nb,
gboolean before_inserting)
{
gboolean show_tabs;
@ -711,28 +748,33 @@ xed_notebook_init (XedNotebook *notebook)
notebook->priv->close_buttons_sensitive = 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_show_border (GTK_NOTEBOOK (notebook), FALSE);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
notebook->priv->always_show_tabs = TRUE;
g_signal_connect (notebook,
g_signal_connect (notebook,
"button-press-event",
(GCallback)button_press_cb,
(GCallback)button_press_cb,
NULL);
g_signal_connect (notebook,
g_signal_connect (notebook,
"button-release-event",
(GCallback)button_release_cb,
NULL);
gtk_widget_add_events (GTK_WIDGET (notebook),
gtk_widget_add_events (GTK_WIDGET (notebook),
GDK_BUTTON1_MOTION_MASK);
g_signal_connect_after (G_OBJECT (notebook),
g_signal_connect_after (G_OBJECT (notebook),
"switch_page",
G_CALLBACK (xed_notebook_switch_page_cb),
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
@ -755,17 +797,17 @@ xed_notebook_change_current_page (GtkNotebook *notebook,
{
gboolean wrap_around;
gint current;
current = gtk_notebook_get_current_page (notebook);
if (current != -1)
{
current = current + offset;
g_object_get (gtk_widget_get_settings (GTK_WIDGET (notebook)),
"gtk-keynav-wrap-around", &wrap_around,
NULL);
if (wrap_around)
{
if (current < 0)
@ -777,7 +819,7 @@ xed_notebook_change_current_page (GtkNotebook *notebook,
current = 0;
}
}
gtk_notebook_set_current_page (notebook, current);
}
else
@ -849,7 +891,7 @@ remove_tab_label (XedNotebook *nb,
* Sets the visibility of the tabs in the @nb.
*/
void
xed_notebook_set_always_show_tabs (XedNotebook *nb,
xed_notebook_set_always_show_tabs (XedNotebook *nb,
gboolean show_tabs)
{
g_return_if_fail (XED_IS_NOTEBOOK (nb));
@ -880,7 +922,7 @@ xed_notebook_add_tab (XedNotebook *nb,
g_return_if_fail (XED_IS_TAB (tab));
tab_label = create_tab_label (nb, tab);
gtk_notebook_insert_page (GTK_NOTEBOOK (nb),
gtk_notebook_insert_page (GTK_NOTEBOOK (nb),
GTK_WIDGET (tab),
tab_label,
position);
@ -889,19 +931,19 @@ xed_notebook_add_tab (XedNotebook *nb,
g_signal_emit (G_OBJECT (nb), signals[TAB_ADDED], 0, tab);
/* The signal handler may have reordered the tabs */
position = gtk_notebook_page_num (GTK_NOTEBOOK (nb),
position = gtk_notebook_page_num (GTK_NOTEBOOK (nb),
GTK_WIDGET (tab));
if (jump_to)
{
XedView *view;
gtk_notebook_set_current_page (GTK_NOTEBOOK (nb), position);
g_object_set_data (G_OBJECT (tab),
g_object_set_data (G_OBJECT (tab),
"jump_to",
GINT_TO_POINTER (jump_to));
view = xed_tab_get_view (tab);
gtk_widget_grab_focus (GTK_WIDGET (view));
}
}
@ -930,7 +972,7 @@ smart_tab_switching_on_closure (XedNotebook *nb,
child = GTK_WIDGET (l->data);
page_num = gtk_notebook_page_num (GTK_NOTEBOOK (nb),
child);
gtk_notebook_set_current_page (GTK_NOTEBOOK (nb),
gtk_notebook_set_current_page (GTK_NOTEBOOK (nb),
page_num);
}
}
@ -996,9 +1038,9 @@ xed_notebook_remove_tab (XedNotebook *nb,
*/
void
xed_notebook_remove_all_tabs (XedNotebook *nb)
{
{
g_return_if_fail (XED_IS_NOTEBOOK (nb));
g_list_free (nb->priv->focused_pages);
nb->priv->focused_pages = NULL;
@ -1072,13 +1114,13 @@ xed_notebook_set_tab_drag_and_drop_enabled (XedNotebook *nb,
gboolean enable)
{
g_return_if_fail (XED_IS_NOTEBOOK (nb));
enable = (enable != FALSE);
if (enable == nb->priv->tab_drag_and_drop_enabled)
return;
nb->priv->tab_drag_and_drop_enabled = enable;
nb->priv->tab_drag_and_drop_enabled = enable;
}
/**
@ -1089,11 +1131,49 @@ xed_notebook_set_tab_drag_and_drop_enabled (XedNotebook *nb,
*
* Returns: %TRUE if the drag and drop is enabled.
*/
gboolean
gboolean
xed_notebook_get_tab_drag_and_drop_enabled (XedNotebook *nb)
{
g_return_val_if_fail (XED_IS_NOTEBOOK (nb), TRUE);
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;
}

View File

@ -2,7 +2,7 @@
* xed-notebook.h
* This file is part of xed
*
* Copyright (C) 2005 - Paolo Maggi
* Copyright (C) 2005 - Paolo Maggi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -16,14 +16,14 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Modified by the xed Team, 2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
* Modified by the xed Team, 2005. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*/
/* This file is a modified version of the epiphany file ephy-notebook.h
@ -34,7 +34,7 @@
* Copyright (C) 2003, 2004 Christian Persch
*
*/
#ifndef XED_NOTEBOOK_H
#define XED_NOTEBOOK_H
@ -62,7 +62,7 @@ typedef struct _XedNotebookPrivate XedNotebookPrivate;
* Main object structure
*/
typedef struct _XedNotebook XedNotebook;
struct _XedNotebook
{
GtkNotebook notebook;
@ -113,14 +113,14 @@ void xed_notebook_remove_all_tabs (XedNotebook *nb);
void xed_notebook_reorder_tab (XedNotebook *src,
XedTab *tab,
gint dest_position);
void xed_notebook_move_tab (XedNotebook *src,
XedNotebook *dest,
XedTab *tab,
gint dest_position);
/* FIXME: do we really need this function ? */
void xed_notebook_set_always_show_tabs
void xed_notebook_set_always_show_tabs
(XedNotebook *nb,
gboolean show_tabs);
@ -138,6 +138,10 @@ void xed_notebook_set_tab_drag_and_drop_enabled
gboolean xed_notebook_get_tab_drag_and_drop_enabled
(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
#endif /* XED_NOTEBOOK_H */

View File

@ -43,6 +43,7 @@
#include "xed-debug.h"
#include "xed-view.h"
#include "xed-window.h"
#include "xed-notebook.h"
#include "xed-window-private.h"
#include "xed-plugins-engine.h"
#include "xed-style-scheme-manager.h"
@ -84,6 +85,10 @@ static void xed_prefs_manager_smart_home_end_changed (GSettings *settings,
gchar *key,
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,
gchar *key,
gpointer user_data);
@ -660,6 +665,9 @@ xed_prefs_manager_app_init (void)
G_CALLBACK (xed_prefs_manager_smart_home_end_changed),
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,
"changed::" GPM_HIGHLIGHT_CURRENT_LINE,
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
xed_prefs_manager_syntax_hl_enable_changed (GSettings *settings,
gchar *key,

View File

@ -3,7 +3,7 @@
* xed-prefs-manager.c
* This file is part of xed
*
* Copyright (C) 2002 Paolo Maggi
* Copyright (C) 2002 Paolo Maggi
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -17,14 +17,14 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
/*
* Modified by the xed Team, 2002. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
* Modified by the xed Team, 2002. See the AUTHORS file for a
* list of people on the xed Team.
* See the ChangeLog files for a list of changes.
*/
#ifdef HAVE_CONFIG_H
@ -65,7 +65,7 @@ xed_prefs_manager_ ## name ## _can_set (void) \
xed_debug (DEBUG_PREFS); \
\
return xed_prefs_manager_key_is_writable (key); \
}
}
@ -92,7 +92,7 @@ xed_prefs_manager_ ## name ## _can_set (void) \
xed_debug (DEBUG_PREFS); \
\
return xed_prefs_manager_key_is_writable (key); \
}
}
@ -119,7 +119,7 @@ xed_prefs_manager_ ## name ## _can_set (void) \
xed_debug (DEBUG_PREFS); \
\
return xed_prefs_manager_key_is_writable (key); \
}
}
XedPrefsManager *xed_prefs_manager = NULL;
@ -162,7 +162,7 @@ xed_prefs_manager_shutdown (void)
xed_prefs_manager->interface_settings = NULL;
}
static gboolean
static gboolean
xed_prefs_manager_get_bool (const gchar* key)
{
xed_debug (DEBUG_PREFS);
@ -170,7 +170,7 @@ xed_prefs_manager_get_bool (const gchar* key)
return g_settings_get_boolean (xed_prefs_manager->settings, key);
}
static gint
static gint
xed_prefs_manager_get_int (const gchar* key)
{
xed_debug (DEBUG_PREFS);
@ -186,7 +186,7 @@ xed_prefs_manager_get_string (const gchar* key)
return g_settings_get_string (xed_prefs_manager->settings, key);
}
static void
static void
xed_prefs_manager_set_bool (const gchar* key, gboolean value)
{
xed_debug (DEBUG_PREFS);
@ -197,7 +197,7 @@ xed_prefs_manager_set_bool (const gchar* key, gboolean value)
g_settings_set_boolean (xed_prefs_manager->settings, key, value);
}
static void
static void
xed_prefs_manager_set_int (const gchar* key, gint value)
{
xed_debug (DEBUG_PREFS);
@ -208,20 +208,20 @@ xed_prefs_manager_set_int (const gchar* key, gint value)
g_settings_set_int (xed_prefs_manager->settings, key, value);
}
static void
static void
xed_prefs_manager_set_string (const gchar* key, const gchar* value)
{
xed_debug (DEBUG_PREFS);
g_return_if_fail (value != NULL);
g_return_if_fail (g_settings_is_writable (
xed_prefs_manager->settings, key));
g_settings_set_string (xed_prefs_manager->settings, key, value);
}
static gboolean
static gboolean
xed_prefs_manager_key_is_writable (const gchar* key)
{
xed_debug (DEBUG_PREFS);
@ -267,13 +267,13 @@ DEFINE_INT_PREF (auto_save_interval,
DEFINE_INT_PREF (undo_actions_limit,
GPM_UNDO_ACTIONS_LIMIT)
static GtkWrapMode
static GtkWrapMode
get_wrap_mode_from_string (const gchar* str)
{
GtkWrapMode res;
g_return_val_if_fail (str != NULL, GTK_WRAP_WORD);
if (strcmp (str, "GTK_WRAP_NONE") == 0)
res = GTK_WRAP_NONE;
else
@ -293,9 +293,9 @@ xed_prefs_manager_get_wrap_mode (void)
{
gchar *str;
GtkWrapMode res;
xed_debug (DEBUG_PREFS);
str = xed_prefs_manager_get_string (GPM_WRAP_MODE);
res = get_wrap_mode_from_string (str);
@ -304,12 +304,12 @@ xed_prefs_manager_get_wrap_mode (void)
return res;
}
void
xed_prefs_manager_set_wrap_mode (GtkWrapMode wp)
{
const gchar * str;
xed_debug (DEBUG_PREFS);
switch (wp)
@ -329,30 +329,30 @@ xed_prefs_manager_set_wrap_mode (GtkWrapMode wp)
xed_prefs_manager_set_string (GPM_WRAP_MODE,
str);
}
gboolean
xed_prefs_manager_wrap_mode_can_set (void)
{
xed_debug (DEBUG_PREFS);
return xed_prefs_manager_key_is_writable (GPM_WRAP_MODE);
}
/* Tabs size */
DEFINE_INT_PREF (tabs_size,
DEFINE_INT_PREF (tabs_size,
GPM_TABS_SIZE)
/* Insert spaces */
DEFINE_BOOL_PREF (insert_spaces,
DEFINE_BOOL_PREF (insert_spaces,
GPM_INSERT_SPACES)
/* Auto indent */
DEFINE_BOOL_PREF (auto_indent,
DEFINE_BOOL_PREF (auto_indent,
GPM_AUTO_INDENT)
/* Display line numbers */
DEFINE_BOOL_PREF (display_line_numbers,
DEFINE_BOOL_PREF (display_line_numbers,
GPM_DISPLAY_LINE_NUMBERS)
/* Toolbar visibility */
@ -362,15 +362,18 @@ DEFINE_BOOL_PREF (toolbar_visible,
/* Statusbar visiblity */
DEFINE_BOOL_PREF (statusbar_visible,
GPM_STATUSBAR_VISIBLE)
/* Side Pane visiblity */
DEFINE_BOOL_PREF (side_pane_visible,
GPM_SIDE_PANE_VISIBLE)
/* Bottom Panel visiblity */
DEFINE_BOOL_PREF (bottom_panel_visible,
GPM_BOTTOM_PANEL_VISIBLE)
/* Tab scrolling */
DEFINE_BOOL_PREF (enable_tab_scrolling, GPM_ENABLE_TAB_SCROLLING)
/* Print syntax highlighting */
DEFINE_BOOL_PREF (print_syntax_hl,
GPM_PRINT_SYNTAX)
@ -386,9 +389,9 @@ xed_prefs_manager_get_print_wrap_mode (void)
{
gchar *str;
GtkWrapMode res;
xed_debug (DEBUG_PREFS);
str = xed_prefs_manager_get_string (GPM_PRINT_WRAP_MODE);
if (strcmp (str, "GTK_WRAP_NONE") == 0)
@ -405,7 +408,7 @@ xed_prefs_manager_get_print_wrap_mode (void)
return res;
}
void
xed_prefs_manager_set_print_wrap_mode (GtkWrapMode pwp)
{
@ -434,11 +437,11 @@ gboolean
xed_prefs_manager_print_wrap_mode_can_set (void)
{
xed_debug (DEBUG_PREFS);
return xed_prefs_manager_key_is_writable (GPM_PRINT_WRAP_MODE);
}
/* Print line numbers */
/* Print line numbers */
DEFINE_INT_PREF (print_line_numbers,
GPM_PRINT_LINE_NUMBERS)
@ -481,8 +484,8 @@ xed_prefs_manager_get_default_print_font_numbers (void)
return xed_prefs_manager_get_default_string_value (GPM_PRINT_FONT_NUMBERS);
}
/* Max number of files in "Recent Files" menu.
* This is configurable only using gsettings, dconf or dconf-editor
/* Max number of files in "Recent Files" menu.
* This is configurable only using gsettings, dconf or dconf-editor
*/
gint
xed_prefs_manager_get_max_recents (void)
@ -556,16 +559,16 @@ xed_prefs_manager_get_auto_detected_encodings (void)
strings = xed_prefs_manager_get_gslist (xed_prefs_manager->settings, GPM_AUTO_DETECTED_ENCODINGS);
if (strings != NULL)
{
{
GSList *tmp;
const XedEncoding *enc;
tmp = strings;
while (tmp)
{
const char *charset = tmp->data;
if (strcmp (charset, "CURRENT") == 0)
g_get_charset (&charset);
@ -583,7 +586,7 @@ xed_prefs_manager_get_auto_detected_encodings (void)
}
g_slist_foreach (strings, (GFunc) g_free, NULL);
g_slist_free (strings);
g_slist_free (strings);
res = g_slist_reverse (res);
}
@ -607,12 +610,12 @@ xed_prefs_manager_get_shown_in_menu_encodings (void)
strings = xed_prefs_manager_get_gslist (xed_prefs_manager->settings, GPM_SHOWN_IN_MENU_ENCODINGS);
if (strings != NULL)
{
{
GSList *tmp;
const XedEncoding *enc;
tmp = strings;
while (tmp)
{
const char *charset = tmp->data;
@ -633,7 +636,7 @@ xed_prefs_manager_get_shown_in_menu_encodings (void)
}
g_slist_foreach (strings, (GFunc) g_free, NULL);
g_slist_free (strings);
g_slist_free (strings);
res = g_slist_reverse (res);
}
@ -643,9 +646,9 @@ xed_prefs_manager_get_shown_in_menu_encodings (void)
void
xed_prefs_manager_set_shown_in_menu_encodings (const GSList *encs)
{
{
GSList *list = NULL;
g_return_if_fail (xed_prefs_manager != NULL);
g_return_if_fail (xed_prefs_manager->settings != NULL);
g_return_if_fail (xed_prefs_manager_shown_in_menu_encodings_can_set ());
@ -654,7 +657,7 @@ xed_prefs_manager_set_shown_in_menu_encodings (const GSList *encs)
{
const XedEncoding *enc;
const gchar *charset;
enc = (const XedEncoding *)encs->data;
charset = xed_encoding_get_charset (enc);
@ -676,7 +679,7 @@ gboolean
xed_prefs_manager_shown_in_menu_encodings_can_set (void)
{
xed_debug (DEBUG_PREFS);
return xed_prefs_manager_key_is_writable (GPM_SHOWN_IN_MENU_ENCODINGS);
}
@ -688,12 +691,12 @@ DEFINE_BOOL_PREF (highlight_current_line,
/* Highlight matching bracket */
DEFINE_BOOL_PREF (bracket_matching,
GPM_BRACKET_MATCHING)
/* Display Right Margin */
DEFINE_BOOL_PREF (display_right_margin,
GPM_DISPLAY_RIGHT_MARGIN)
/* Right Margin Position */
/* Right Margin Position */
DEFINE_INT_PREF (right_margin_position,
GPM_RIGHT_MARGIN_POSITION)
@ -732,7 +735,7 @@ xed_prefs_manager_get_smart_home_end (void)
return res;
}
void
xed_prefs_manager_set_smart_home_end (GtkSourceSmartHomeEndType smart_he)
{
@ -765,7 +768,7 @@ gboolean
xed_prefs_manager_smart_home_end_can_set (void)
{
xed_debug (DEBUG_PREFS);
return xed_prefs_manager_key_is_writable (GPM_SMART_HOME_END);
}
@ -785,7 +788,7 @@ GSList *
xed_prefs_manager_get_writable_vfs_schemes (void)
{
GSList *strings;
xed_debug (DEBUG_PREFS);
g_return_val_if_fail (xed_prefs_manager != NULL, NULL);
@ -794,8 +797,8 @@ xed_prefs_manager_get_writable_vfs_schemes (void)
strings = xed_prefs_manager_get_gslist (xed_prefs_manager->settings, GPM_WRITABLE_VFS_SCHEMES);
/* The 'file' scheme is writable by default. */
strings = g_slist_prepend (strings, g_strdup ("file"));
strings = g_slist_prepend (strings, g_strdup ("file"));
xed_debug_message (DEBUG_PREFS, "Done");
return strings;
@ -829,7 +832,7 @@ xed_prefs_manager_get_active_plugins (void)
void
xed_prefs_manager_set_active_plugins (const GSList *plugins)
{
{
g_return_if_fail (xed_prefs_manager != NULL);
g_return_if_fail (xed_prefs_manager->settings != NULL);
g_return_if_fail (xed_prefs_manager_active_plugins_can_set ());

View File

@ -81,6 +81,8 @@
#define GPM_BOTTOM_PANEL_VISIBLE "bottom-panel-visible"
#define GPM_ENABLE_TAB_SCROLLING "enable-tab-scrolling"
#define GPM_MAX_RECENTS "max-recents"
/* Print */
@ -201,6 +203,12 @@ gboolean xed_prefs_manager_side_pane_visible_can_set (void);
gboolean xed_prefs_manager_get_bottom_panel_visible (void);
void xed_prefs_manager_set_bottom_panel_visible (gboolean tv);
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 */
gboolean xed_prefs_manager_get_print_syntax_hl (void);
void xed_prefs_manager_set_print_syntax_hl (gboolean ps);

View File

@ -3368,6 +3368,9 @@ add_notebook (XedWindow *window,
{
gtk_paned_pack1 (GTK_PANED(window->priv->vpaned), notebook, TRUE, TRUE);
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);
}