Add preference to add new document tabs beside the current one (patch by Colomban Wendling, thanks).

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4928 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2010-05-16 17:45:39 +00:00
parent 23f4cd9213
commit fdd451f0d4
8 changed files with 115 additions and 34 deletions

View File

@ -23,6 +23,10 @@
Fix broken "Go Up" if the current path ends with a slash.
* THANKS, src/about.c, src/prefix.c:
Replace free() by g_free() (patch by Daniel Marjamaki, thanks).
* geany.glade, src/document.h, src/interface.c, src/keyfile.c,
src/main.c, src/notebook.c, src/prefs.c:
Add preference to add new document tabs beside the current one
(patch by Colomban Wendling, thanks).
2010-05-15 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>

View File

@ -4291,10 +4291,13 @@
</child>
<child>
<widget class="GtkHBox" id="hbox7">
<widget class="GtkTable" id="table21">
<property name="visible">True</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="homogeneous">False</property>
<property name="spacing">12</property>
<property name="row_spacing">0</property>
<property name="column_spacing">0</property>
<child>
<widget class="GtkLabel" id="label150">
@ -4315,50 +4318,91 @@
<property name="angle">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="left_attach">0</property>
<property name="right_attach">1</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radio_tab_left">
<widget class="GtkHBox" id="hbox7">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">File tabs will be placed on the left of the notebook</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Left</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="homogeneous">False</property>
<property name="spacing">12</property>
<child>
<widget class="GtkRadioButton" id="radio_tab_left">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">File tabs will be placed on the left of the notebook</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Left</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">True</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radio_tab_right">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">File tabs will be placed on the right of the notebook</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Right</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">radio_tab_left</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">0</property>
<property name="bottom_attach">1</property>
<property name="y_options">fill</property>
</packing>
</child>
<child>
<widget class="GtkRadioButton" id="radio_tab_right">
<widget class="GtkCheckButton" id="check_tab_beside">
<property name="visible">True</property>
<property name="tooltip" translatable="yes">File tabs will be placed on the right of the notebook</property>
<property name="tooltip" translatable="yes">Whether to place file tabs next to the current tab rather than at the edges of the notebook</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Right</property>
<property name="label" translatable="yes">Next to current</property>
<property name="use_underline">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="focus_on_click">True</property>
<property name="active">False</property>
<property name="inconsistent">False</property>
<property name="draw_indicator">True</property>
<property name="group">radio_tab_left</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">fill</property>
<property name="y_options"></property>
</packing>
</child>
</widget>

View File

@ -51,6 +51,7 @@ typedef struct GeanyFilePrefs
gboolean strip_trailing_spaces;
gboolean replace_tabs;
gboolean tab_order_ltr;
gboolean tab_order_beside;
gboolean show_tab_cross;
guint mru_length;
gint default_eol_character;

View File

@ -2355,11 +2355,13 @@ create_prefs_dialog (void)
GtkWidget *vbox26;
GtkWidget *check_show_notebook_tabs;
GtkWidget *check_show_tab_cross;
GtkWidget *hbox7;
GtkWidget *table21;
GtkWidget *label150;
GtkWidget *hbox7;
GtkWidget *radio_tab_left;
GSList *radio_tab_left_group = NULL;
GtkWidget *radio_tab_right;
GtkWidget *check_tab_beside;
GtkWidget *check_double_click_hides_widgets;
GtkWidget *label197;
GtkWidget *frame9;
@ -3121,15 +3123,23 @@ create_prefs_dialog (void)
gtk_box_pack_start (GTK_BOX (vbox26), check_show_tab_cross, FALSE, FALSE, 0);
gtk_tooltips_set_tip (tooltips, check_show_tab_cross, _("Shows a small cross button in the file tabs to easily close files when clicking on it (requires restart of Geany)"), NULL);
hbox7 = gtk_hbox_new (FALSE, 12);
gtk_widget_show (hbox7);
gtk_box_pack_start (GTK_BOX (vbox26), hbox7, FALSE, TRUE, 0);
table21 = gtk_table_new (2, 2, FALSE);
gtk_widget_show (table21);
gtk_box_pack_start (GTK_BOX (vbox26), table21, FALSE, TRUE, 0);
label150 = gtk_label_new (_("Placement of new file tabs:"));
gtk_widget_show (label150);
gtk_box_pack_start (GTK_BOX (hbox7), label150, FALSE, FALSE, 0);
gtk_table_attach (GTK_TABLE (table21), label150, 0, 1, 0, 1,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_misc_set_alignment (GTK_MISC (label150), 0, 0.5);
hbox7 = gtk_hbox_new (FALSE, 12);
gtk_widget_show (hbox7);
gtk_table_attach (GTK_TABLE (table21), hbox7, 1, 2, 0, 1,
(GtkAttachOptions) (GTK_EXPAND | GTK_FILL),
(GtkAttachOptions) (GTK_FILL), 0, 0);
radio_tab_left = gtk_radio_button_new_with_mnemonic (NULL, _("Left"));
gtk_widget_show (radio_tab_left);
gtk_box_pack_start (GTK_BOX (hbox7), radio_tab_left, FALSE, FALSE, 0);
@ -3145,6 +3155,13 @@ create_prefs_dialog (void)
gtk_radio_button_set_group (GTK_RADIO_BUTTON (radio_tab_right), radio_tab_left_group);
radio_tab_left_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radio_tab_right));
check_tab_beside = gtk_check_button_new_with_mnemonic (_("Next to current"));
gtk_widget_show (check_tab_beside);
gtk_table_attach (GTK_TABLE (table21), check_tab_beside, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (0), 0, 0);
gtk_tooltips_set_tip (tooltips, check_tab_beside, _("Whether to place file tabs next to the current tab rather than at the edges of the notebook"), NULL);
check_double_click_hides_widgets = gtk_check_button_new_with_mnemonic (_("Double-clicking hides all additional widgets"));
gtk_widget_show (check_double_click_hides_widgets);
gtk_box_pack_start (GTK_BOX (vbox26), check_double_click_hides_widgets, FALSE, FALSE, 0);
@ -4813,10 +4830,12 @@ create_prefs_dialog (void)
GLADE_HOOKUP_OBJECT (prefs_dialog, vbox26, "vbox26");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_show_notebook_tabs, "check_show_notebook_tabs");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_show_tab_cross, "check_show_tab_cross");
GLADE_HOOKUP_OBJECT (prefs_dialog, hbox7, "hbox7");
GLADE_HOOKUP_OBJECT (prefs_dialog, table21, "table21");
GLADE_HOOKUP_OBJECT (prefs_dialog, label150, "label150");
GLADE_HOOKUP_OBJECT (prefs_dialog, hbox7, "hbox7");
GLADE_HOOKUP_OBJECT (prefs_dialog, radio_tab_left, "radio_tab_left");
GLADE_HOOKUP_OBJECT (prefs_dialog, radio_tab_right, "radio_tab_right");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_tab_beside, "check_tab_beside");
GLADE_HOOKUP_OBJECT (prefs_dialog, check_double_click_hides_widgets, "check_double_click_hides_widgets");
GLADE_HOOKUP_OBJECT (prefs_dialog, label197, "label197");
GLADE_HOOKUP_OBJECT (prefs_dialog, frame9, "frame9");

View File

@ -357,6 +357,7 @@ static void save_dialog_prefs(GKeyFile *config)
g_key_file_set_boolean(config, PACKAGE, "show_notebook_tabs", interface_prefs.show_notebook_tabs);
g_key_file_set_boolean(config, PACKAGE, "show_tab_cross", file_prefs.show_tab_cross);
g_key_file_set_boolean(config, PACKAGE, "tab_order_ltr", file_prefs.tab_order_ltr);
g_key_file_set_boolean(config, PACKAGE, "tab_order_beside", file_prefs.tab_order_beside);
g_key_file_set_integer(config, PACKAGE, "tab_pos_editor", interface_prefs.tab_pos_editor);
g_key_file_set_integer(config, PACKAGE, "tab_pos_msgwin", interface_prefs.tab_pos_msgwin);
g_key_file_set_boolean(config, PACKAGE, "msgwin_status_visible", interface_prefs.msgwin_status_visible);
@ -646,6 +647,7 @@ static void load_dialog_prefs(GKeyFile *config)
interface_prefs.sidebar_openfiles_visible = utils_get_setting_boolean(config, PACKAGE, "sidebar_openfiles_visible", TRUE);
interface_prefs.statusbar_visible = utils_get_setting_boolean(config, PACKAGE, "statusbar_visible", TRUE);
file_prefs.tab_order_ltr = utils_get_setting_boolean(config, PACKAGE, "tab_order_ltr", TRUE);
file_prefs.tab_order_beside = utils_get_setting_boolean(config, PACKAGE, "tab_order_beside", FALSE);
interface_prefs.show_notebook_tabs = utils_get_setting_boolean(config, PACKAGE, "show_notebook_tabs", TRUE);
file_prefs.show_tab_cross = utils_get_setting_boolean(config, PACKAGE, "show_tab_cross", TRUE);
interface_prefs.editor_font = utils_get_setting_string(config, PACKAGE, "editor_font", GEANY_DEFAULT_FONT_EDITOR);

View File

@ -228,6 +228,7 @@ static void main_init(void)
ui_widgets.prefs_dialog = NULL;
main_status.main_window_realized = FALSE;
file_prefs.tab_order_ltr = FALSE;
file_prefs.tab_order_beside = FALSE;
main_status.quitting = FALSE;
ignore_callback = FALSE;
app->tm_workspace = tm_get_workspace();

View File

@ -466,6 +466,7 @@ gint notebook_new_tab(GeanyDocument *this)
GtkWidget *hbox, *ebox;
gint tabnum;
GtkWidget *page;
gint cur_page;
g_return_val_if_fail(this != NULL, -1);
@ -513,12 +514,16 @@ gint notebook_new_tab(GeanyDocument *this)
document_update_tab_label(this);
if (file_prefs.tab_order_beside)
cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_widgets.notebook));
else
cur_page = file_prefs.tab_order_ltr ? -2 /* hack: -2 + 1 = -1, last page */ : 0;
if (file_prefs.tab_order_ltr)
tabnum = gtk_notebook_append_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
ebox, NULL);
tabnum = gtk_notebook_insert_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
ebox, NULL, cur_page + 1);
else
tabnum = gtk_notebook_insert_page_menu(GTK_NOTEBOOK(main_widgets.notebook), page,
ebox, NULL, 0);
ebox, NULL, cur_page);
tab_count_changed();

View File

@ -482,6 +482,8 @@ static void prefs_init_dialog(void)
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_tab_left");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), TRUE);
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_tab_beside");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), file_prefs.tab_order_beside);
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "combo_new_encoding");
/* luckily the index of the combo box items match the index of the encodings array */
@ -892,6 +894,9 @@ on_prefs_button_clicked(GtkDialog *dialog, gint response, gpointer user_data)
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "radio_tab_right");
file_prefs.tab_order_ltr = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_tab_beside");
file_prefs.tab_order_beside = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "combo_new_encoding");
file_prefs.default_new_encoding = gtk_combo_box_get_active(GTK_COMBO_BOX(widget));