[gnome-builder: 84/139] gettext: port to libide-code



commit 4d1b6b484c720637b6d3876fe907f24f842d3852
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 9 17:21:26 2019 -0800

    gettext: port to libide-code

 src/plugins/gettext/gettext-plugin.c               |  8 +++--
 src/plugins/gettext/gettext.gresource.xml          |  2 +-
 src/plugins/gettext/gettext.plugin                 | 13 +++++----
 .../gettext/ide-gettext-diagnostic-provider.c      | 34 ++++++++++------------
 .../gettext/ide-gettext-diagnostic-provider.h      |  2 +-
 src/plugins/gettext/meson.build                    | 20 ++++++-------
 6 files changed, 38 insertions(+), 41 deletions(-)
---
diff --git a/src/plugins/gettext/gettext-plugin.c b/src/plugins/gettext/gettext-plugin.c
index 64fcb7978..2a20dc6f8 100644
--- a/src/plugins/gettext/gettext-plugin.c
+++ b/src/plugins/gettext/gettext-plugin.c
@@ -18,13 +18,15 @@
  * SPDX-License-Identifier: GPL-3.0-or-later
  */
 
+#include "config.h"
+
 #include <libpeas/peas.h>
-#include <ide.h>
+#include <libide-code.h>
 
 #include "ide-gettext-diagnostic-provider.h"
 
-void
-ide_gettext_register_types (PeasObjectModule *module)
+_IDE_EXTERN void
+_ide_gettext_register_types (PeasObjectModule *module)
 {
   peas_object_module_register_extension_type (module,
                                               IDE_TYPE_DIAGNOSTIC_PROVIDER,
diff --git a/src/plugins/gettext/gettext.gresource.xml b/src/plugins/gettext/gettext.gresource.xml
index a4326d629..24e3173ba 100644
--- a/src/plugins/gettext/gettext.gresource.xml
+++ b/src/plugins/gettext/gettext.gresource.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
-  <gresource prefix="/org/gnome/builder/plugins">
+  <gresource prefix="/plugins/gettext">
     <file>gettext.plugin</file>
   </gresource>
 </gresources>
diff --git a/src/plugins/gettext/gettext.plugin b/src/plugins/gettext/gettext.plugin
index b84ab8479..9204cf242 100644
--- a/src/plugins/gettext/gettext.plugin
+++ b/src/plugins/gettext/gettext.plugin
@@ -1,10 +1,11 @@
 [Plugin]
-Module=gettext-plugin
-Name=Gettext
-Description=Provides integration with Gettext
 Authors=Daiki Ueno
-Copyright=Copyright © 2016 Daiki Ueno
 Builtin=true
-Embedded=ide_gettext_register_types
-X-Diagnostic-Provider-Languages=c,chdr,cpp,js,python,vala
+Copyright=Copyright © 2016 Daiki Ueno
+Depends=editor;
+Description=Provides integration with Gettext
+Embedded=_ide_gettext_register_types
+Module=gettext
+Name=Gettext
 X-Diagnostic-Provider-Languages-Priority=100
+X-Diagnostic-Provider-Languages=c,chdr,cpp,js,python,vala
diff --git a/src/plugins/gettext/ide-gettext-diagnostic-provider.c 
b/src/plugins/gettext/ide-gettext-diagnostic-provider.c
index ad2faf7e4..373162b69 100644
--- a/src/plugins/gettext/ide-gettext-diagnostic-provider.c
+++ b/src/plugins/gettext/ide-gettext-diagnostic-provider.c
@@ -80,7 +80,7 @@ ide_gettext_diagnostic_provider_communicate_cb (GObject      *object,
   g_autofree gchar *stderr_buf = NULL;
   g_autofree gchar *stdout_buf = NULL;
   IdeLineReader reader;
-  IdeFile *file;
+  GFile *file;
   gchar *line;
   gsize len;
 
@@ -96,16 +96,16 @@ ide_gettext_diagnostic_provider_communicate_cb (GObject      *object,
 
   file = ide_task_get_task_data (task);
   g_assert (file != NULL);
-  g_assert (IDE_IS_FILE (file));
+  g_assert (G_IS_FILE (file));
 
-  ret = ide_diagnostics_new (NULL);
+  ret = ide_diagnostics_new ();
 
   ide_line_reader_init (&reader, stderr_buf, -1);
 
   while (NULL != (line = ide_line_reader_next (&reader, &len)))
     {
       g_autoptr(IdeDiagnostic) diag = NULL;
-      g_autoptr(IdeSourceLocation) loc = NULL;
+      g_autoptr(IdeLocation) loc = NULL;
       guint64 lineno;
 
       line[len] = '\0';
@@ -132,20 +132,21 @@ ide_gettext_diagnostic_provider_communicate_cb (GObject      *object,
 
       line += strlen (": ");
 
-      loc = ide_source_location_new (file, lineno, 0, 0);
+      loc = ide_location_new (file, lineno, -1);
       diag = ide_diagnostic_new (IDE_DIAGNOSTIC_WARNING, line, loc);
       ide_diagnostics_add (ret, diag);
     }
 
   ide_task_return_pointer (task,
                            g_steal_pointer (&ret),
-                           (GDestroyNotify)ide_diagnostics_unref);
+                           g_object_unref);
 }
 
 static void
 ide_gettext_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider,
-                                                IdeFile               *file,
-                                                IdeBuffer             *buffer,
+                                                GFile                 *file,
+                                                GBytes                *contents,
+                                                const gchar           *lang_id,
                                                 GCancellable          *cancellable,
                                                 GAsyncReadyCallback    callback,
                                                 gpointer               user_data)
@@ -153,16 +154,13 @@ ide_gettext_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider,
   IdeGettextDiagnosticProvider *self = (IdeGettextDiagnosticProvider *)provider;
   g_autoptr(IdeSubprocessLauncher) launcher = NULL;
   g_autoptr(IdeSubprocess) subprocess = NULL;
-  g_autoptr(GBytes) contents = NULL;
   g_autoptr(IdeTask) task = NULL;
   g_autoptr(GError) error = NULL;
-  GtkSourceLanguage *language;
-  const gchar *lang_id = NULL;
   const gchar *xgettext_id;
 
   g_assert (IDE_IS_GETTEXT_DIAGNOSTIC_PROVIDER (self));
-  g_assert (IDE_IS_FILE (file));
-  g_assert (IDE_IS_BUFFER (buffer));
+  g_assert (G_IS_FILE (file));
+  g_assert (contents != NULL);
   g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
 
   task = ide_task_new (self, cancellable, callback, user_data);
@@ -171,9 +169,7 @@ ide_gettext_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider,
   ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
 
   /* Figure out what language xgettext should use */
-  if (!(language = gtk_source_buffer_get_language (GTK_SOURCE_BUFFER (buffer))) ||
-      !(lang_id = gtk_source_language_get_id (language)) ||
-      !(xgettext_id = id_to_xgettext_language (lang_id)))
+  if (!(xgettext_id = id_to_xgettext_language (lang_id)))
     {
       ide_task_return_new_error (task,
                                  G_IO_ERROR,
@@ -184,11 +180,11 @@ ide_gettext_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider,
     }
 
   /* Return an empty set if we failed to locate any buffer contents */
-  if (!(contents = ide_buffer_get_content (buffer)) || g_bytes_get_size (contents) == 0)
+  if (g_bytes_get_size (contents) == 0)
     {
       ide_task_return_pointer (task,
-                               ide_diagnostics_new (NULL),
-                               (GDestroyNotify)ide_diagnostics_unref);
+                               ide_diagnostics_new (),
+                               g_object_unref);
       return;
     }
 
diff --git a/src/plugins/gettext/ide-gettext-diagnostic-provider.h 
b/src/plugins/gettext/ide-gettext-diagnostic-provider.h
index 2556868a0..83321ea0b 100644
--- a/src/plugins/gettext/ide-gettext-diagnostic-provider.h
+++ b/src/plugins/gettext/ide-gettext-diagnostic-provider.h
@@ -21,7 +21,7 @@
 
 #pragma once
 
-#include <ide.h>
+#include <libide-code.h>
 
 G_BEGIN_DECLS
 
diff --git a/src/plugins/gettext/meson.build b/src/plugins/gettext/meson.build
index 6bcf45ea1..24ccf09b4 100644
--- a/src/plugins/gettext/meson.build
+++ b/src/plugins/gettext/meson.build
@@ -1,18 +1,16 @@
-if get_option('with_gettext')
+if get_option('plugin_gettext')
 
-gettext_resources = gnome.compile_resources(
+plugins_sources += files([
+  'gettext-plugin.c',
+  'ide-gettext-diagnostic-provider.c',
+])
+
+plugin_gettext_resources = gnome.compile_resources(
   'gettext-resources',
   'gettext.gresource.xml',
-  c_name: 'ide_gettext',
+  c_name: 'gbp_gettext',
 )
 
-gettext_sources = [
-  'ide-gettext-diagnostic-provider.c',
-  'ide-gettext-diagnostic-provider.h',
-  'gettext-plugin.c',
-]
-
-gnome_builder_plugins_sources += files(gettext_sources)
-gnome_builder_plugins_sources += gettext_resources[0]
+plugins_sources += plugin_gettext_resources[0]
 
 endif


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