Skip to content

Commit

Permalink
Use radio buttons for the auto-sort options, and use a single paramet…
Browse files Browse the repository at this point in the history
…er for it

The options are also no longer disabled even when Show Editor Tabs is disabled.
  • Loading branch information
konsolebox committed Aug 1, 2016
1 parent b7ba772 commit a6b84e2
Show file tree
Hide file tree
Showing 7 changed files with 94 additions and 78 deletions.
87 changes: 66 additions & 21 deletions data/geany.glade
Original file line number Diff line number Diff line change
Expand Up @@ -2180,35 +2180,80 @@
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_auto_sort_tabs_by_filename">
<property name="label" translatable="yes">Automatically sort tabs by filename</property>
<object class="GtkHBox" id="hbox_notebook_auto_sort_tabs">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="label_notebook_auto_sort_tabs">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Automatically sort tabs:</property>
</object>
<packing>
<property name="position">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_notebook_auto_sort_tabs_disabled">
<property name="label" translatable="yes">Disabled</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Disable auto-sorting of tabs</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_notebook_auto_sort_tabs_by_filename">
<property name="label" translatable="yes">By Filename</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Automatically sort tabs everytime a file is opened or when a document is saved to a new file. The sorting order will be based on the filename or basename.</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">radio_notebook_auto_sort_tabs_disabled</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radio_notebook_auto_sort_tabs_by_pathname">
<property name="label" translatable="yes">By Pathname</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Automatically sort tabs everytime a file is opened or when a document is saved to a new file. The sorting order will be based on the full path of the file.</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
<property name="group">radio_notebook_auto_sort_tabs_disabled</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">5</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="check_auto_sort_tabs_by_pathname">
<property name="label" translatable="yes">Automatically sort tabs by pathname</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">6</property>
</packing>
</child>
</object>
</child>
</object>
Expand Down
18 changes: 9 additions & 9 deletions doc/geany.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1992,15 +1992,15 @@ Double-clicking hides all additional widgets
Whether to call the View->Toggle All Additional Widgets command
when double-clicking on a notebook tab.

Automatically sort tabs by filename
Whether to automatically sort editor tabs based on their filenames
everytime files are opened, or when documents are saved to a new
file.

Automatically sort tabs by pathname
Same as the one above but sort tabs based on pathname. The
resulting arrangement would be the same as the one in the documents
list when Show Paths is enabled.
Automatically sort tabs
Whether to automatically sort editor tabs everytime files are
opened, or when documents are saved to a new file.

Sorting by filename means sorting it based on the basic name of the
file and it excludes the directory parts, while sorting by pathname
means sorting it based on the full path, in which the resulting
arrangement would be the same as the one in the documents list when
Show Paths is enabled.

Tab positions
`````````````
Expand Down
13 changes: 7 additions & 6 deletions src/keyfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "geanyobject.h"
#include "main.h"
#include "msgwindow.h"
#include "notebook.h"
#include "prefs.h"
#include "printing.h"
#include "project.h"
Expand Down Expand Up @@ -173,10 +174,12 @@ static void init_pref_groups(void)
"radio_msgwin_vertical", GTK_ORIENTATION_VERTICAL,
"radio_msgwin_horizontal", GTK_ORIENTATION_HORIZONTAL,
NULL);
stash_group_add_toggle_button(group, &interface_prefs.auto_sort_tabs_by_filename,
"auto_sort_tabs_by_filename", FALSE, "check_auto_sort_tabs_by_filename");
stash_group_add_toggle_button(group, &interface_prefs.auto_sort_tabs_by_pathname,
"auto_sort_tabs_by_pathname", FALSE, "check_auto_sort_tabs_by_pathname");
stash_group_add_radio_buttons(group, &interface_prefs.notebook_auto_sort_tabs,
"notebook_auto_sort_tabs", NOTEBOOK_TAB_AUTO_SORT_DISABLED,
"radio_notebook_auto_sort_tabs_disabled", NOTEBOOK_TAB_AUTO_SORT_DISABLED,
"radio_notebook_auto_sort_tabs_by_filename", NOTEBOOK_TAB_AUTO_SORT_BY_FILENAME,
"radio_notebook_auto_sort_tabs_by_pathname", NOTEBOOK_TAB_AUTO_SORT_BY_PATHNAME,
NULL);

/* editor display */
stash_group_add_toggle_button(group, &interface_prefs.highlighting_invert_all,
Expand Down Expand Up @@ -781,8 +784,6 @@ static void load_dialog_prefs(GKeyFile *config)
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);
if (interface_prefs.auto_sort_tabs_by_filename && interface_prefs.auto_sort_tabs_by_pathname)
interface_prefs.auto_sort_tabs_by_filename = FALSE;
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);
interface_prefs.tagbar_font = utils_get_setting_string(config, PACKAGE, "tagbar_font", GEANY_DEFAULT_FONT_SYMBOL_LIST);
Expand Down
8 changes: 4 additions & 4 deletions src/notebook.c
Original file line number Diff line number Diff line change
Expand Up @@ -910,9 +910,9 @@ static void gradually_sort_tab(GeanyDocument *doc, NotebookTabSortMethod method)

static void on_document_open(GObject *obj, GeanyDocument *doc)
{
if (interface_prefs.auto_sort_tabs_by_filename)
if (interface_prefs.notebook_auto_sort_tabs == NOTEBOOK_TAB_AUTO_SORT_BY_FILENAME)
gradually_sort_tab(doc, NOTEBOOK_TAB_SORT_BY_FILENAME);
else if (interface_prefs.auto_sort_tabs_by_pathname)
else if (interface_prefs.notebook_auto_sort_tabs == NOTEBOOK_TAB_AUTO_SORT_BY_PATHNAME)
gradually_sort_tab(doc, NOTEBOOK_TAB_SORT_BY_PATHNAME);
}

Expand All @@ -927,9 +927,9 @@ static void on_document_save(GObject *obj, GeanyDocument *doc)
{
if (doc_saves_to_new_file)
{
if (interface_prefs.auto_sort_tabs_by_filename)
if (interface_prefs.notebook_auto_sort_tabs == NOTEBOOK_TAB_AUTO_SORT_BY_FILENAME)
gradually_sort_tab(doc, NOTEBOOK_TAB_SORT_BY_FILENAME);
else if (interface_prefs.auto_sort_tabs_by_pathname)
else if (interface_prefs.notebook_auto_sort_tabs == NOTEBOOK_TAB_AUTO_SORT_BY_PATHNAME)
gradually_sort_tab(doc, NOTEBOOK_TAB_SORT_BY_PATHNAME);
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/notebook.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ void on_sort_tabs_by_filename_activate(GtkMenuItem *menuitem, gpointer user_data

void on_sort_tabs_by_pathname_activate(GtkMenuItem *menuitem, gpointer user_data);

typedef enum NotebookTabAutoSortMode
{
NOTEBOOK_TAB_AUTO_SORT_DISABLED,
NOTEBOOK_TAB_AUTO_SORT_BY_FILENAME,
NOTEBOOK_TAB_AUTO_SORT_BY_PATHNAME
} NotebookTabAutoSortMode;

G_END_DECLS

#endif /* GEANY_NOTEBOOK_H */
36 changes: 0 additions & 36 deletions src/prefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@ static gboolean kb_find_duplicate(GtkTreeStore *store, GtkWidget *parent, GtkTre
guint key, GdkModifierType mods, const gchar *shortcut);
static void on_toolbar_show_toggled(GtkToggleButton *togglebutton, gpointer user_data);
static void on_show_notebook_tabs_toggled(GtkToggleButton *togglebutton, gpointer user_data);
static void on_auto_sort_tabs_by_filename_toggled(GtkToggleButton *togglebutton, gpointer user_data);
static void on_auto_sort_tabs_by_pathname_toggled(GtkToggleButton *togglebutton, gpointer user_data);
static void on_enable_plugins_toggled(GtkToggleButton *togglebutton, gpointer user_data);
static void on_use_folding_toggled(GtkToggleButton *togglebutton, gpointer user_data);
static void on_open_encoding_toggled(GtkToggleButton *togglebutton, gpointer user_data);
Expand Down Expand Up @@ -491,12 +489,6 @@ static void prefs_init_dialog(void)
on_show_notebook_tabs_toggled(GTK_TOGGLE_BUTTON(
ui_lookup_widget(ui_widgets.prefs_dialog, "check_show_notebook_tabs")), NULL);

widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_auto_sort_tabs_by_filename");
on_auto_sort_tabs_by_pathname_toggled(GTK_TOGGLE_BUTTON(widget), NULL);

widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_auto_sort_tabs_by_pathname");
on_auto_sort_tabs_by_pathname_toggled(GTK_TOGGLE_BUTTON(widget), NULL);

widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_show_tab_cross");
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), file_prefs.show_tab_cross);

Expand Down Expand Up @@ -964,12 +956,6 @@ on_prefs_dialog_response(GtkDialog *dialog, gint response, gpointer user_data)
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_show_notebook_tabs");
interface_prefs.show_notebook_tabs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_auto_sort_tabs_by_filename");
interface_prefs.auto_sort_tabs_by_filename = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_auto_sort_tabs_by_pathname");
interface_prefs.auto_sort_tabs_by_pathname = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_show_tab_cross");
file_prefs.show_tab_cross = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget));

Expand Down Expand Up @@ -1545,24 +1531,6 @@ static void on_show_notebook_tabs_toggled(GtkToggleButton *togglebutton, gpointe
/* tab placement only enabled when tabs are visible */
gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets.prefs_dialog, "combo_tab_editor"), sens);
gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets.prefs_dialog, "check_show_tab_cross"), sens);
gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets.prefs_dialog, "check_auto_sort_tabs_by_filename"), sens);
gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets.prefs_dialog, "check_auto_sort_tabs_by_pathname"), sens);
}


static void on_auto_sort_tabs_by_filename_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
if (gtk_toggle_button_get_active(togglebutton))
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui_lookup_widget(ui_widgets.prefs_dialog,
"check_auto_sort_tabs_by_pathname")), FALSE);
}


static void on_auto_sort_tabs_by_pathname_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
if (gtk_toggle_button_get_active(togglebutton))
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ui_lookup_widget(ui_widgets.prefs_dialog,
"check_auto_sort_tabs_by_filename")), FALSE);
}


Expand Down Expand Up @@ -1845,10 +1813,6 @@ void prefs_show_dialog(void)
"toggled", G_CALLBACK(on_toolbar_show_toggled), NULL);
g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "check_show_notebook_tabs"),
"toggled", G_CALLBACK(on_show_notebook_tabs_toggled), NULL);
g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "check_auto_sort_tabs_by_filename"),
"toggled", G_CALLBACK(on_auto_sort_tabs_by_filename_toggled), NULL);
g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "check_auto_sort_tabs_by_pathname"),
"toggled", G_CALLBACK(on_auto_sort_tabs_by_pathname_toggled), NULL);
g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "check_folding"),
"toggled", G_CALLBACK(on_use_folding_toggled), NULL);
g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "check_open_encoding"),
Expand Down
3 changes: 1 addition & 2 deletions src/ui_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ typedef struct GeanyInterfacePrefs
gchar *tagbar_font; /**< symbol sidebar font */
gchar *msgwin_font; /**< message window font */
gboolean show_notebook_tabs; /**< whether editor tabs are visible */
gboolean auto_sort_tabs_by_filename; /**< whether to automatically sort tabs by filename */
gboolean auto_sort_tabs_by_pathname; /**< whether to automatically sort tabs by pathname */
gint tab_pos_editor; /**< positions of editor's tabs */
gint tab_pos_msgwin; /**< positions of message window's tabs */
gint tab_pos_sidebar; /**< positions of sidebar's tabs */
Expand All @@ -72,6 +70,7 @@ typedef struct GeanyInterfacePrefs
gboolean compiler_tab_autoscroll;
gint msgwin_orientation; /**< orientation of the message window */
gint symbols_sort_mode; /**< symbol list sorting mode */
gint notebook_auto_sort_tabs; /* automatic sorting mode of notebook tabs */
}
GeanyInterfacePrefs;

Expand Down

0 comments on commit a6b84e2

Please sign in to comment.