[gtranslator/gtk4: 44/79] Fix gtr-view language selection
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator/gtk4: 44/79] Fix gtr-view language selection
- Date: Mon, 10 Oct 2022 16:31:20 +0000 (UTC)
commit cfe0a707bf75b4477b347b1b114a24705f35bfb5
Author: Daniel GarcĂa Moreno <dani danigm net>
Date: Wed Jul 6 18:54:47 2022 +0200
Fix gtr-view language selection
data/meson.build | 3 +--
src/gtr-view.c | 65 ++++++++++++++++++++------------------------------------
2 files changed, 24 insertions(+), 44 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 38f62194..d81c8f8f 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -61,8 +61,7 @@ install_data(
install_dir: join_paths(gtr_pkgdatadir, 'ui'),
)
-# TODO Set to gtksourceview-5 on GTK 4 port.
install_data(
'sourceview/gtranslator.lang',
- install_dir: join_paths(gtr_datadir, 'gtksourceview-4', 'language-specs'),
+ install_dir: join_paths(gtr_datadir, 'gtksourceview-5', 'language-specs'),
)
diff --git a/src/gtr-view.c b/src/gtr-view.c
index 996bc5ae..fd680835 100644
--- a/src/gtr-view.c
+++ b/src/gtr-view.c
@@ -86,7 +86,6 @@ G_DEFINE_TYPE_WITH_PRIVATE (GtrView, gtr_view, GTK_SOURCE_TYPE_VIEW)
static void
gtr_view_init (GtrView * view)
{
- g_printf("init: view started\n");
GtkSourceLanguageManager *lm;
GtkSourceLanguage *lang;
GPtrArray *dirs;
@@ -119,50 +118,32 @@ gtr_view_init (GtrView * view)
g_ptr_array_add (dirs, NULL);
langs = (gchar **) g_ptr_array_free (dirs, FALSE);
- /* CLEANUP: For debugging
- guint i = 0;
- while (*(langs+i) != NULL) {
- g_printf("%s\n",*(langs+i));
- i++;
- }
- i=0;*/
gtk_source_language_manager_set_search_path (lm, langs);
- /* CLEANUP: For debugging
- gchar * const * lang_id = gtk_source_language_manager_get_language_ids(lm);
- while (*(lang_id+i) != NULL) {
- g_printf("%s\n",*(lang_id+i));
- i++;
- }*/
- //There is not any language_id of name gtranslator when I ran above code to get all language_ids
- //lang = gtk_source_language_manager_get_language (lm, "gtranslator");
+ lang = gtk_source_language_manager_get_language (lm, "gtranslator");
g_strfreev (langs);
- //if (lang != NULL) {
- //priv->buffer = gtk_source_buffer_new_with_language (GTK_SOURCE_LANGUAGE(lang));
- //priv->buffer = gtk_source_buffer_new (NULL);
- //gtk_text_view_set_buffer (GTK_TEXT_VIEW (view),
- // GTK_TEXT_BUFFER (priv->buffer));
- priv->buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(view));
- if (priv->buffer == NULL)
- g_printf("buffer is null\n");
- gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
- /* Set syntax highlight according to preferences */
- //gtk_source_buffer_set_highlight_syntax (priv->buffer,
- //g_settings_get_boolean (priv->editor_settings,
- //GTR_SETTINGS_HIGHLIGHT_SYNTAX));
- /* Set dot char according to preferences */
- gtr_view_enable_visible_whitespace (view,
- g_settings_get_boolean (priv->editor_settings,
- GTR_SETTINGS_VISIBLE_WHITESPACE));
- font = g_settings_get_string (priv->editor_settings, GTR_SETTINGS_FONT);
- gtr_view_set_font (view, font);
-
- /* Set scheme color according to preferences */
- gtr_view_reload_scheme_color (view);
- gtk_text_view_set_monospace (GTK_TEXT_VIEW (view), TRUE);
- //}
- g_printf("init: view\n");
-}
+ priv->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+ gtk_source_buffer_set_language (priv->buffer, lang);
+ gtk_text_view_set_buffer (GTK_TEXT_VIEW (view), GTK_TEXT_BUFFER (priv->buffer));
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), GTK_WRAP_WORD);
+
+ /* Set syntax highlight according to preferences */
+ gtk_source_buffer_set_highlight_syntax (priv->buffer,
+ g_settings_get_boolean (priv->editor_settings,
+ GTR_SETTINGS_HIGHLIGHT_SYNTAX));
+
+ /* Set dot char according to preferences */
+ gtr_view_enable_visible_whitespace (view,
+ g_settings_get_boolean (priv->editor_settings,
+ GTR_SETTINGS_VISIBLE_WHITESPACE));
+
+ font = g_settings_get_string (priv->editor_settings, GTR_SETTINGS_FONT);
+ gtr_view_set_font (view, font);
+
+ /* Set scheme color according to preferences */
+ gtr_view_reload_scheme_color (view);
+ gtk_text_view_set_monospace (GTK_TEXT_VIEW (view), TRUE);
+}
static void
gtr_view_dispose (GObject * object)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]