Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Tue, 12 Dec 2023 23:36:00 UTC Commit: 3b10790a41d570bb52cd1a40952914dd3641a743 https://github.com/geany/geany/commit/3b10790a41d570bb52cd1a40952914dd3641a7...
Log Message: ----------- prefs: Remove separate checkbox for default open encoding
Show and use the "Detect from file" combo member instead of having a dedicated checkbox for this.
I don't see the value of having a separate checkbox for this: * We don't save two values anyway, so the value when detection is enabled is artificial; * It makes the UI more complex by having more controls; * It takes screen estate; * We already have the code for adding a "Detect from file" in the combo box.
Modified Paths: -------------- data/geany.glade doc/geany.txt src/prefs.c
Modified: data/geany.glade 16 lines changed, 0 insertions(+), 16 deletions(-) =================================================================== @@ -4566,22 +4566,6 @@ <property name="position">0</property> </packing> </child> - <child> - <object class="GtkCheckButton" id="check_open_encoding"> - <property name="label" translatable="yes">Use fixed encoding when opening non-Unicode files</property> - <property name="visible">True</property> - <property name="can-focus">True</property> - <property name="receives-default">False</property> - <property name="tooltip-text" translatable="yes">This option disables the automatic detection of the file encoding when opening non-Unicode files and opens the file with the specified encoding (usually not needed)</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="GtkVBox" id="vbox45"> <property name="visible">True</property>
Modified: doc/geany.txt 10 lines changed, 5 insertions(+), 5 deletions(-) =================================================================== @@ -2470,12 +2470,12 @@ Open new documents from the command-line Default encoding (new files) The type of file encoding you wish to use when creating files.
-Used fixed encoding when opening files - Assume all files you are opening are using the type of encoding specified below. - Default encoding (existing files) - Opens all files with the specified encoding instead of auto-detecting it. - Use this option when it's not possible for Geany to detect the exact encoding. + Selects the encoding used when opening existing files. If set to something + other than *Detect from file*, all files will be opened with the specified + encoding instead of auto-detecting it. + Use a specific encoding when it's not possible for Geany to detect the + correct one.
Default end of line characters The end of line characters to which should be used for new files.
Modified: src/prefs.c 40 lines changed, 9 insertions(+), 31 deletions(-) =================================================================== @@ -89,7 +89,6 @@ static void on_show_notebook_tabs_toggled(GtkToggleButton *togglebutton, gpointe 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_check_line_end_toggled(GtkToggleButton *togglebutton, gpointer user_data); -static void on_open_encoding_toggled(GtkToggleButton *togglebutton, gpointer user_data); static void on_sidebar_visible_toggled(GtkToggleButton *togglebutton, gpointer user_data); static void on_prefs_print_radio_button_toggled(GtkToggleButton *togglebutton, gpointer user_data); static void on_prefs_print_page_header_toggled(GtkToggleButton *togglebutton, gpointer user_data); @@ -533,18 +532,11 @@ static void prefs_init_dialog(void) widget = ui_lookup_widget(ui_widgets.prefs_dialog, "combo_new_encoding"); ui_encodings_combo_box_set_active_encoding(GTK_COMBO_BOX(widget), file_prefs.default_new_encoding);
- widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_open_encoding"); - gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), - (file_prefs.default_open_encoding >= 0) ? TRUE : FALSE); - on_open_encoding_toggled(GTK_TOGGLE_BUTTON(widget), NULL); - widget = ui_lookup_widget(ui_widgets.prefs_dialog, "combo_open_encoding"); if (file_prefs.default_open_encoding >= 0) - { ui_encodings_combo_box_set_active_encoding(GTK_COMBO_BOX(widget), file_prefs.default_open_encoding); - } else - ui_encodings_combo_box_set_active_encoding(GTK_COMBO_BOX(widget), GEANY_ENCODING_UTF_8); + ui_encodings_combo_box_set_active_encoding(GTK_COMBO_BOX(widget), GEANY_ENCODINGS_MAX);
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "combo_eol"); if (file_prefs.default_eol_character >= 0 && file_prefs.default_eol_character < 3) @@ -1006,13 +998,9 @@ on_prefs_dialog_response(GtkDialog *dialog, gint response, gpointer user_data) widget = ui_lookup_widget(ui_widgets.prefs_dialog, "combo_new_encoding"); file_prefs.default_new_encoding = ui_encodings_combo_box_get_active_encoding(GTK_COMBO_BOX(widget));
- widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_open_encoding"); - if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) - { - widget = ui_lookup_widget(ui_widgets.prefs_dialog, "combo_open_encoding"); - file_prefs.default_open_encoding = ui_encodings_combo_box_get_active_encoding(GTK_COMBO_BOX(widget)); - } - else + widget = ui_lookup_widget(ui_widgets.prefs_dialog, "combo_open_encoding"); + file_prefs.default_open_encoding = ui_encodings_combo_box_get_active_encoding(GTK_COMBO_BOX(widget)); + if (file_prefs.default_open_encoding >= GEANY_ENCODINGS_MAX) file_prefs.default_open_encoding = -1;
widget = ui_lookup_widget(ui_widgets.prefs_dialog, "combo_eol"); @@ -1547,15 +1535,6 @@ static void on_enable_plugins_toggled(GtkToggleButton *togglebutton, gpointer us }
-static void on_open_encoding_toggled(GtkToggleButton *togglebutton, gpointer user_data) -{ - gboolean sens = gtk_toggle_button_get_active(togglebutton); - - gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets.prefs_dialog, "eventbox3"), sens); - gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets.prefs_dialog, "label_open_encoding"), sens); -} - - static void on_sidebar_visible_toggled(GtkToggleButton *togglebutton, gpointer user_data) { gboolean sens = gtk_toggle_button_get_active(togglebutton); @@ -1664,23 +1643,24 @@ void prefs_show_dialog(void) { struct { const gchar *combo, *renderer; + gboolean has_detect; } names[] = { - { "combo_new_encoding", "combo_new_encoding_renderer" }, - { "combo_open_encoding", "combo_open_encoding_renderer" } + { "combo_new_encoding", "combo_new_encoding_renderer", FALSE }, + { "combo_open_encoding", "combo_open_encoding_renderer", TRUE } }; guint i; - GtkTreeStore *encoding_list = encodings_encoding_store_new(FALSE);
for (i = 0; i < G_N_ELEMENTS(names); i++) { + GtkTreeStore *encoding_list = encodings_encoding_store_new(names[i].has_detect); GtkWidget *combo = ui_lookup_widget(ui_widgets.prefs_dialog, names[i].combo);
gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(combo), ui_builder_get_object(names[i].renderer), encodings_encoding_store_cell_data_func, NULL, NULL); gtk_combo_box_set_model(GTK_COMBO_BOX(combo), GTK_TREE_MODEL(encoding_list)); + g_object_unref(encoding_list); } - g_object_unref(encoding_list); }
/* init the eol character combo box */ @@ -1813,8 +1793,6 @@ void prefs_show_dialog(void) "toggled", G_CALLBACK(on_use_folding_toggled), NULL); g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "check_line_end"), "toggled", G_CALLBACK(on_check_line_end_toggled), NULL); - g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "check_open_encoding"), - "toggled", G_CALLBACK(on_open_encoding_toggled), NULL); g_signal_connect(ui_lookup_widget(ui_widgets.prefs_dialog, "check_sidebar_visible"), "toggled", G_CALLBACK(on_sidebar_visible_toggled), NULL);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).