From 1ea072e1258057516445fcfcd392b84409d0a17b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= Date: Mon, 11 Jan 2016 23:36:50 +0100 Subject: [PATCH] Make it possible to define default symbol_list_sort_mode Both sorting by name and appearance makes sense for most languages. Some users may prefer sorting by appearance so make it configurable in preferences (the possibility to override the settings for specific filetypes is preserved). Thanks to Colomban Wendling for lots of improvements of this patch. Fixes #313. --- data/geany.glade | 68 ++++++++++++++++++++++++++++++++++++++++++++++-- src/callbacks.c | 8 ++++++ src/document.c | 5 +++- src/filetypes.c | 2 +- src/keyfile.c | 6 +++++ src/prefs.c | 3 +-- src/ui_utils.h | 1 + 7 files changed, 87 insertions(+), 6 deletions(-) diff --git a/data/geany.glade b/data/geany.glade index 06cf3978a0..a9b27516ee 100644 --- a/data/geany.glade +++ b/data/geany.glade @@ -1543,7 +1543,7 @@ False 12 - + True False @@ -1555,6 +1555,7 @@ Toggle the symbol list on and off True True + False @@ -1562,6 +1563,69 @@ 0 + + + True + False + 12 + + + True + False + Default symbol sorting mode + 12 + + + True + False + Default sorting mode: + + + False + True + 0 + + + + + Name + True + True + False + True + True + + + False + True + 1 + + + + + Appearance + True + True + False + True + True + radio_symbols_sort_by_name + + + False + True + 2 + + + + + + + True + True + 1 + + Show documents list @@ -1575,7 +1639,7 @@ False False - 1 + 2 diff --git a/src/callbacks.c b/src/callbacks.c index 0848c7f0c0..1ee9bc186e 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -1902,6 +1902,14 @@ static void on_detect_type_from_file_activate(GtkMenuItem *menuitem, gpointer us } +static void on_show_symbol_list_toggled(GtkToggleButton *button, gpointer user_data) +{ + GtkWidget *widget = ui_lookup_widget(ui_widgets.prefs_dialog, "box_show_symbol_list_children"); + + gtk_widget_set_sensitive(widget, gtk_toggle_button_get_active(button)); +} + + static void on_detect_width_from_file_activate(GtkMenuItem *menuitem, gpointer user_data) { GeanyDocument *doc = document_get_current(); diff --git a/src/document.c b/src/document.c index ff3f5e8593..60ea5825d2 100644 --- a/src/document.c +++ b/src/document.c @@ -2734,7 +2734,10 @@ static void document_load_config(GeanyDocument *doc, GeanyFiletype *type, editor_set_indentation_guides(doc->editor); build_menu_update(doc); queue_colourise(doc); - doc->priv->symbol_list_sort_mode = type->priv->symbol_list_sort_mode; + if (type->priv->symbol_list_sort_mode == SYMBOLS_SORT_USE_PREVIOUS) + doc->priv->symbol_list_sort_mode = interface_prefs.symbols_sort_mode; + else + doc->priv->symbol_list_sort_mode = type->priv->symbol_list_sort_mode; } document_update_tags(doc); diff --git a/src/filetypes.c b/src/filetypes.c index 5cfe4bc8d9..2454cdb993 100644 --- a/src/filetypes.c +++ b/src/filetypes.c @@ -965,7 +965,7 @@ static void load_settings(guint ft_id, GKeyFile *config, GKeyFile *configh) } ft->priv->symbol_list_sort_mode = utils_get_setting(integer, configh, config, "settings", - "symbol_list_sort_mode", SYMBOLS_SORT_BY_NAME); + "symbol_list_sort_mode", SYMBOLS_SORT_USE_PREVIOUS); ft->priv->xml_indent_tags = utils_get_setting(boolean, configh, config, "settings", "xml_indent_tags", FALSE); diff --git a/src/keyfile.c b/src/keyfile.c index 654e68ad6c..8421fda934 100644 --- a/src/keyfile.c +++ b/src/keyfile.c @@ -48,6 +48,7 @@ #include "sciwrappers.h" #include "stash.h" #include "support.h" +#include "symbols.h" #include "templates.h" #include "toolbar.h" #include "ui_utils.h" @@ -161,6 +162,11 @@ static void init_pref_groups(void) "radio_sidebar_left", GTK_POS_LEFT, "radio_sidebar_right", GTK_POS_RIGHT, NULL); + stash_group_add_radio_buttons(group, &interface_prefs.symbols_sort_mode, + "symbols_sort_mode", SYMBOLS_SORT_BY_NAME, + "radio_symbols_sort_by_name", SYMBOLS_SORT_BY_NAME, + "radio_symbols_sort_by_appearance", SYMBOLS_SORT_BY_APPEARANCE, + NULL); stash_group_add_radio_buttons(group, &interface_prefs.msgwin_orientation, "msgwin_orientation", GTK_ORIENTATION_VERTICAL, "radio_msgwin_vertical", GTK_ORIENTATION_VERTICAL, diff --git a/src/prefs.c b/src/prefs.c index ffa53379c1..2d5b12c37f 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -1558,8 +1558,7 @@ static void on_sidebar_visible_toggled(GtkToggleButton *togglebutton, gpointer u { gboolean sens = gtk_toggle_button_get_active(togglebutton); - gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets.prefs_dialog, "check_list_openfiles"), sens); - gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets.prefs_dialog, "check_list_symbol"), sens); + gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets.prefs_dialog, "box_sidebar_visible_children"), sens); } diff --git a/src/ui_utils.h b/src/ui_utils.h index a4c0f9bd12..746c6ce43a 100644 --- a/src/ui_utils.h +++ b/src/ui_utils.h @@ -68,6 +68,7 @@ typedef struct GeanyInterfacePrefs /** whether compiler messages window is automatically scrolled to show new messages */ gboolean compiler_tab_autoscroll; gint msgwin_orientation; /**< orientation of the message window */ + gint symbols_sort_mode; /**< symbol list sorting mode */ } GeanyInterfacePrefs;