[gnome-builder] plugins/editorui: move GtkSourceLanguages tweaks to plugin



commit 07c3725c3177d20a13bc9f644e7f64d35d78e354
Author: Christian Hergert <chergert redhat com>
Date:   Fri Aug 12 16:07:00 2022 -0700

    plugins/editorui: move GtkSourceLanguages tweaks to plugin
    
    Want to get this out of IdeApplication as it's specific to the editor.

 src/libide/gui/ide-application-actions.c         | 18 -----------
 src/libide/gui/tweaks.ui                         | 33 -------------------
 src/plugins/editorui/gbp-editorui-tweaks-addin.c | 41 +++++++++++++++++++++---
 src/plugins/editorui/tweaks.ui                   | 37 +++++++++++++++++++++
 4 files changed, 73 insertions(+), 56 deletions(-)
---
diff --git a/src/libide/gui/ide-application-actions.c b/src/libide/gui/ide-application-actions.c
index c5e18a934..0d6c97111 100644
--- a/src/libide/gui/ide-application-actions.c
+++ b/src/libide/gui/ide-application-actions.c
@@ -75,24 +75,6 @@ ide_application_actions_tweaks (GSimpleAction *action,
 
   tweaks = ide_tweaks_new ();
 
-  /* Setup access to sourceview languages */
-  {
-    GtkSourceLanguageManager *lm = gtk_source_language_manager_get_default ();
-    const char * const *ids = gtk_source_language_manager_get_language_ids (lm);
-
-    languages = g_list_store_new (GTK_SOURCE_TYPE_LANGUAGE);
-
-    for (guint i = 0; ids[i]; i++)
-      {
-        GtkSourceLanguage *l = gtk_source_language_manager_get_language (lm, ids[i]);
-
-        if (!gtk_source_language_get_hidden (l))
-          g_list_store_append (languages, l);
-      }
-
-    ide_tweaks_expose_object (tweaks, "GtkSourceLanguages", G_OBJECT (languages));
-  }
-
   /* Load our base tweaks scaffolding */
   tweaks_file = g_file_new_for_uri ("resource:///org/gnome/libide-gui/tweaks.ui");
   ide_tweaks_load_from_file (tweaks, tweaks_file, NULL, &error);
diff --git a/src/libide/gui/tweaks.ui b/src/libide/gui/tweaks.ui
index e9f479f48..897e7c148 100644
--- a/src/libide/gui/tweaks.ui
+++ b/src/libide/gui/tweaks.ui
@@ -25,39 +25,6 @@
     </child>
     <child>
       <object class="IdeTweaksSection" id="code_section">
-        <child>
-          <object class="IdeTweaksPage" id="languages_page">
-            <property name="icon-name">text-x-javascript-symbolic</property>
-            <property name="title" translatable="yes">Programming Languages</property>
-            <child>
-              <object class="IdeTweaksFactory" id="language_page_factory">
-                <property name="model">GtkSourceLanguages</property>
-                <child>
-                  <object class="IdeTweaksPage" id="language_page">
-                    <binding name="title">
-                      <lookup name="name" type="GtkSourceLanguage">
-                        <lookup name="item">language_page_factory</lookup>
-                      </lookup>
-                    </binding>
-                    <child>
-                      <object class="IdeTweaksSettings" id="language_page_settings">
-                        <property name="schema-id">org.gnome.builder.editor.language</property>
-                        <binding name="schema-path">
-                          <closure type="gchararray" function="format">
-                            <constant type="gchararray">/org/gnome/builder/editor/languages/%s/</constant>
-                            <lookup name="id" type="GtkSourceLanguage">
-                              <lookup name="item">language_page_factory</lookup>
-                            </lookup>
-                          </closure>
-                        </binding>
-                      </object>
-                    </child>
-                  </object>
-                </child>
-              </object>
-            </child>
-          </object>
-        </child>
       </object>
     </child>
     <child>
diff --git a/src/plugins/editorui/gbp-editorui-tweaks-addin.c 
b/src/plugins/editorui/gbp-editorui-tweaks-addin.c
index b74cd3ea0..3787a7bd9 100644
--- a/src/plugins/editorui/gbp-editorui-tweaks-addin.c
+++ b/src/plugins/editorui/gbp-editorui-tweaks-addin.c
@@ -67,17 +67,48 @@ editorui_create_style_scheme_selector (GbpEditoruiTweaksAddin *self,
 }
 
 static void
-gbp_editorui_tweaks_addin_class_init (GbpEditoruiTweaksAddinClass *klass)
+gbp_editorui_tweaks_addin_load (IdeTweaksAddin *addin,
+                                IdeTweaks      *tweaks)
 {
-}
+  GbpEditoruiTweaksAddin *self = (GbpEditoruiTweaksAddin *)addin;
+  g_autoptr(GListStore) store = NULL;
+  GtkSourceLanguageManager *lm;
+  const char * const *ids;
+
+  g_assert (GBP_IS_EDITORUI_TWEAKS_ADDIN (self));
+
+  lm = gtk_source_language_manager_get_default ();
+  ids = gtk_source_language_manager_get_language_ids (lm);
+  store = g_list_store_new (GTK_SOURCE_TYPE_LANGUAGE);
+
+  for (guint i = 0; ids[i]; i++)
+    {
+      GtkSourceLanguage *l = gtk_source_language_manager_get_language (lm, ids[i]);
+
+      if (!gtk_source_language_get_hidden (l))
+        g_list_store_append (store, l);
+    }
 
-static void
-gbp_editorui_tweaks_addin_init (GbpEditoruiTweaksAddin *self)
-{
   ide_tweaks_addin_set_resource_path (IDE_TWEAKS_ADDIN (self),
                                       "/plugins/editorui/tweaks.ui");
   ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self),
                                   editorui_create_style_scheme_preview);
   ide_tweaks_addin_bind_callback (IDE_TWEAKS_ADDIN (self),
                                   editorui_create_style_scheme_selector);
+  ide_tweaks_expose_object (tweaks, "GtkSourceLanguages", G_OBJECT (store));
+
+  IDE_TWEAKS_ADDIN_CLASS (gbp_editorui_tweaks_addin_parent_class)->load (addin, tweaks);
+}
+
+static void
+gbp_editorui_tweaks_addin_class_init (GbpEditoruiTweaksAddinClass *klass)
+{
+  IdeTweaksAddinClass *addin_class = IDE_TWEAKS_ADDIN_CLASS (klass);
+
+  addin_class->load = gbp_editorui_tweaks_addin_load;
+}
+
+static void
+gbp_editorui_tweaks_addin_init (GbpEditoruiTweaksAddin *self)
+{
 }
diff --git a/src/plugins/editorui/tweaks.ui b/src/plugins/editorui/tweaks.ui
index e0d6d1127..9c338b13a 100644
--- a/src/plugins/editorui/tweaks.ui
+++ b/src/plugins/editorui/tweaks.ui
@@ -43,5 +43,42 @@
         </child>
       </object>
     </child>
+    <child internal-child="code_section">
+      <object class="IdeTweaksSection">
+        <child>
+          <object class="IdeTweaksPage" id="languages_page">
+            <property name="icon-name">text-x-javascript-symbolic</property>
+            <property name="title" translatable="yes">Programming Languages</property>
+            <child>
+              <object class="IdeTweaksFactory" id="language_page_factory">
+                <property name="model">GtkSourceLanguages</property>
+                <child>
+                  <object class="IdeTweaksPage" id="language_page">
+                    <binding name="title">
+                      <lookup name="name" type="GtkSourceLanguage">
+                        <lookup name="item">language_page_factory</lookup>
+                      </lookup>
+                    </binding>
+                    <child>
+                      <object class="IdeTweaksSettings" id="language_page_settings">
+                        <property name="schema-id">org.gnome.builder.editor.language</property>
+                        <binding name="schema-path">
+                          <closure type="gchararray" function="format">
+                            <constant type="gchararray">/org/gnome/builder/editor/languages/%s/</constant>
+                            <lookup name="id" type="GtkSourceLanguage">
+                              <lookup name="item">language_page_factory</lookup>
+                            </lookup>
+                          </closure>
+                        </binding>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
   </template>
 </interface>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]