Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Mon, 22 Apr 2024 20:26:55 UTC
Commit: 9a507b47bc514514d15838d0dbf442317ed987fd
https://github.com/geany/geany/commit/9a507b47bc514514d15838d0dbf442317ed98…
Log Message:
-----------
meson: Use host instead of target
They are gonna be the same in practice, but it's not how "target" is
supposed to be used, see [1] and [2].
Streamline this to use "host", which also makes things match our
Autotools closer.
[1] https://mesonbuild.com/Cross-compilation.html
[2] https://www.gnu.org/software/autoconf/manual/html_node/Specifying-Target-Tr…
Modified Paths:
--------------
meson.build
Modified: meson.build
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -168,7 +168,7 @@ cdata.set_quoted('REVISION', revision)
python_command = get_option('python-command')
if python_command == '' or python_command == 'auto'
- if target_machine.system() == 'windows'
+ if host_machine.system() == 'windows'
python_command = 'py'
else
python_command = 'python'
@@ -213,7 +213,7 @@ endforeach
geany_cflags = def_cflags
have_gcc4_visibility = cc.has_argument('-fvisibility=hidden')
geany_cflags += '-DGEANY_PRIVATE'
-if target_machine.system() == 'windows'
+if host_machine.system() == 'windows'
geany_cflags += '-DGEANY_EXPORT_SYMBOL=__declspec(dllexport)'
elif have_gcc4_visibility
geany_cflags += '-fvisibility=hidden'
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Tue, 12 Dec 2023 23:36:00 UTC
Commit: 3b10790a41d570bb52cd1a40952914dd3641a743
https://github.com/geany/geany/commit/3b10790a41d570bb52cd1a40952914dd3641a…
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).
Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Tue, 12 Dec 2023 23:36:00 UTC
Commit: 3a019a43e96b8df423ce7af2d6a74231bbac0205
https://github.com/geany/geany/commit/3a019a43e96b8df423ce7af2d6a74231bbac0…
Log Message:
-----------
encodings: Add a flag for whether the encoding is supported
This adds support for checking whether an encoding is actually
supported on the system, as some are commonly not supported everywhere,
e.g. ISO-IR-111, ISO-8859-8-I or HZ.
Here we assume that a conversion to UTF-8 means it also works the other
way around (e.g. from UTF-8, assuming the data can be represented, of
course). This is a valid assumption if GNU libc or GNU libiconv is
used, and might or might not hold for other implementations.
This assumption however makes the code a fair bit simpler, and should
have little impact in reality as this flag is mostly a suggestion that
can be used to hide UI elements or skip attempts, and that in most
situations it doesn't make much sense for us to be able to *write* to
an encoding we cannot read.
As for startup performances, checking all encodings takes about 10ms on
my machine, which sounds Good Enough™.
This is currently unused, but subsequent commits will start using this.
Modified Paths:
--------------
src/encodings.c
src/encodingsprivate.h
Modified: src/encodings.c
27 lines changed, 26 insertions(+), 1 deletions(-)
===================================================================
@@ -59,12 +59,24 @@ static gboolean pregs_loaded = FALSE;
GeanyEncoding encodings[GEANY_ENCODINGS_MAX];
+static gboolean conversion_supported(const gchar *to, const gchar *from)
+{
+ GIConv conv = g_iconv_open(to, from);
+ if (conv == (GIConv) -1)
+ return FALSE;
+
+ g_iconv_close(conv);
+ return TRUE;
+}
+
+
#define fill(Order, Group, Idx, Charset, Name) \
encodings[Idx].idx = Idx; \
encodings[Idx].order = Order; \
encodings[Idx].group = Group; \
encodings[Idx].charset = Charset; \
- encodings[Idx].name = Name;
+ encodings[Idx].name = Name; \
+ encodings[Idx].supported = FALSE;
static void init_encodings(void)
{
@@ -140,6 +152,19 @@ static void init_encodings(void)
fill(14, EASTASIAN, GEANY_ENCODING_UHC, "UHC", _("Korean"));
fill(0, NONE, GEANY_ENCODING_NONE, "None", _("Without encoding"));
+
+ /* fill the flags member */
+ for (guint i = 0; i < G_N_ELEMENTS(encodings); i++)
+ {
+ if (i == GEANY_ENCODING_NONE || conversion_supported("UTF-8", encodings[i].charset))
+ encodings[i].supported = TRUE;
+ else
+ {
+ /* geany_debug() doesn't really work at this point, unless G_MESSAGES_DEBUG
+ * is set explicitly by the caller, but that's better than nothing */
+ geany_debug("Encoding %s is not supported by the system", encodings[i].charset);
+ }
+ }
}
Modified: src/encodingsprivate.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -46,6 +46,7 @@ typedef struct GeanyEncoding
GeanyEncodingGroup group; /* Internally used member for grouping */
const gchar *charset; /* String representation of the encoding, e.g. "ISO-8859-3" */
const gchar *name; /* Translatable and descriptive name of the encoding, e.g. "South European" */
+ gboolean supported; /* Whether this encoding is supported on the system */
}
GeanyEncoding;
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
Branch: refs/heads/master
Author: Colomban Wendling <ban(a)herbesfolles.org>
Committer: Colomban Wendling <ban(a)herbesfolles.org>
Date: Tue, 12 Dec 2023 23:36:00 UTC
Commit: c8365fd881b0e0880be14f8a850a1f3c179f3966
https://github.com/geany/geany/commit/c8365fd881b0e0880be14f8a850a1f3c179f3…
Log Message:
-----------
Don't try knowingly unsupported encodings
Modified Paths:
--------------
src/encodings.c
Modified: src/encodings.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -770,7 +770,7 @@ static gchar *encodings_convert_to_utf8_with_suggestion(const gchar *buffer, gss
else
continue;
}
- else if (i >= 0)
+ else if (i >= 0 && encodings[i].supported)
charset = encodings[i].charset;
else /* in this case we have i == -2, continue to increase i and go ahead */
continue;
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).