[gnome-builder: 132/139] valgrind: port to libide-foundry



commit 0125a87134886b9e9d84dbec3cf122c756a1608d
Author: Christian Hergert <chergert redhat com>
Date:   Wed Jan 9 17:43:40 2019 -0800

    valgrind: port to libide-foundry

 src/plugins/valgrind/gtk/menus.ui                  | 10 ++++++++
 src/plugins/valgrind/meson.build                   | 11 ++++----
 ...plugin.gresource.xml => valgrind.gresource.xml} |  2 +-
 src/plugins/valgrind/valgrind.plugin               | 13 ++++++----
 src/plugins/valgrind/valgrind_plugin.py            | 29 +++++++++++-----------
 5 files changed, 39 insertions(+), 26 deletions(-)
---
diff --git a/src/plugins/valgrind/gtk/menus.ui b/src/plugins/valgrind/gtk/menus.ui
index 598a29e41..4a2e8122a 100644
--- a/src/plugins/valgrind/gtk/menus.ui
+++ b/src/plugins/valgrind/gtk/menus.ui
@@ -13,4 +13,14 @@
       </item>
     </section>
   </menu>
+  <menu id="project-tree-run-with-submenu">
+    <section id="project-tree-menu-run-with-section">
+      <item>
+        <attribute name="id">project-tree-menu-valgrind</attribute>
+        <attribute name="label" translatable="yes">Run with Valgrind</attribute>
+        <attribute name="action">buildui.run-with-handler</attribute>
+        <attribute name="target" type="s">'valgrind'</attribute>
+      </item>
+    </section>
+  </menu>
 </interface>
diff --git a/src/plugins/valgrind/meson.build b/src/plugins/valgrind/meson.build
index 7684f9f0c..240671f1f 100644
--- a/src/plugins/valgrind/meson.build
+++ b/src/plugins/valgrind/meson.build
@@ -1,20 +1,19 @@
-if get_option('with_valgrind')
-
-install_data('valgrind_plugin.py', install_dir: plugindir)
+if get_option('plugin_valgrind')
 
 valgrind_resources = gnome.compile_resources(
   'valgrind_plugin',
-  'valgrind-plugin.gresource.xml',
-
+  'valgrind.gresource.xml',
   gresource_bundle: true,
            install: true,
        install_dir: plugindir,
 )
 
+install_data('valgrind_plugin.py', install_dir: plugindir)
+
 configure_file(
           input: 'valgrind.plugin',
          output: 'valgrind.plugin',
-           copy: true,
+  configuration: config_h,
         install: true,
     install_dir: plugindir,
 )
diff --git a/src/plugins/valgrind/valgrind-plugin.gresource.xml b/src/plugins/valgrind/valgrind.gresource.xml
similarity index 62%
rename from src/plugins/valgrind/valgrind-plugin.gresource.xml
rename to src/plugins/valgrind/valgrind.gresource.xml
index 2c0ad6ec7..7fc84b65d 100644
--- a/src/plugins/valgrind/valgrind-plugin.gresource.xml
+++ b/src/plugins/valgrind/valgrind.gresource.xml
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
-  <gresource prefix="/org/gnome/builder/plugins/valgrind_plugin">
+  <gresource prefix="/plugins/valgrind_plugin">
     <file>gtk/menus.ui</file>
   </gresource>
 </gresources>
diff --git a/src/plugins/valgrind/valgrind.plugin b/src/plugins/valgrind/valgrind.plugin
index 0cf8c8c6a..e8b8cc63b 100644
--- a/src/plugins/valgrind/valgrind.plugin
+++ b/src/plugins/valgrind/valgrind.plugin
@@ -1,8 +1,11 @@
 [Plugin]
-Module=valgrind_plugin
-Loader=python3
-Name=Valgrind
-Description=Provides integration with valgrind
 Authors=Christian Hergert <christian hergert me>
-Copyright=Copyright © 2017 Christian Hergert
 Builtin=true
+Copyright=Copyright © 2017-2018 Christian Hergert
+Depends=buildui;editor;
+Description=Provides integration with valgrind
+Loader=python3
+Module=valgrind_plugin
+Name=Valgrind
+X-Builder-ABI=@PACKAGE_ABI@
+X-Has-Resources=true
diff --git a/src/plugins/valgrind/valgrind_plugin.py b/src/plugins/valgrind/valgrind_plugin.py
index 29a5ff89e..d067c4d44 100644
--- a/src/plugins/valgrind/valgrind_plugin.py
+++ b/src/plugins/valgrind/valgrind_plugin.py
@@ -1,7 +1,7 @@
 #
-# __init__.py
+# valgrind_plugin.py
 #
-# Copyright 2017-2019 Christian Hergert <chergert redhat com>
+# Copyright 2017-2018 Christian Hergert <chergert redhat com>
 #
 # This program is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -20,8 +20,6 @@
 import gi
 import os
 
-gi.require_version('Ide', '1.0')
-
 from gi.repository import Ide
 from gi.repository import GLib
 from gi.repository import GObject
@@ -29,6 +27,7 @@ from gi.repository import GObject
 _ = Ide.gettext
 
 class ValgrindWorkbenchAddin(GObject.Object, Ide.WorkbenchAddin):
+    build_manager = None
     workbench = None
     has_handler = False
     notify_handler = None
@@ -36,12 +35,13 @@ class ValgrindWorkbenchAddin(GObject.Object, Ide.WorkbenchAddin):
     def do_load(self, workbench):
         self.workbench = workbench
 
-        build_manager = workbench.get_context().get_build_manager()
-        self.notify_handler = build_manager.connect('notify::pipeline', self.notify_pipeline)
-        self.notify_pipeline(build_manager, None)
+    def do_project_loaded(self, project_info):
+        self.build_manager = Ide.BuildManager.from_context(self.workbench.get_context())
+        self.notify_handler = self.build_manager.connect('notify::pipeline', self.notify_pipeline)
+        self.notify_pipeline(self.build_manager, None)
 
     def notify_pipeline(self, build_manager, pspec):
-        run_manager = self.workbench.get_context().get_run_manager()
+        run_manager = Ide.RunManager.from_context(self.workbench.get_context())
 
         # When the pipeline changes, we need to check to see if we can find
         # valgrind inside the runtime environment.
@@ -58,12 +58,13 @@ class ValgrindWorkbenchAddin(GObject.Object, Ide.WorkbenchAddin):
             run_manager.remove_handler('valgrind')
 
     def do_unload(self, workbench):
-        build_manager = workbench.get_context().get_build_manager()
-        build_manager.disconnect(self.notify_handler)
-        self.notify_handler = None
+        if self.build_manager is not None:
+            if self.notify_handler is not None:
+                self.build_manager.disconnect(self.notify_handler)
+                self.notify_handler = None
 
         if self.has_handler:
-            run_manager = workbench.get_context().get_run_manager()
+            run_manager = Ide.RunManager.from_context(workbench.get_context())
             run_manager.remove_handler('valgrind')
 
         self.workbench = None
@@ -83,5 +84,5 @@ class ValgrindWorkbenchAddin(GObject.Object, Ide.WorkbenchAddin):
         # If we weren't unloaded in the meantime, we can open the file using
         # the "editor" hint to ensure the editor opens the file.
         if self.workbench:
-            uri = Ide.Uri.new('file://'+name, 0)
-            self.workbench.open_uri_async(uri, 'editor', 0, None, None, None)
+            gfile = Gio.File.new_for_path(name)
+            self.workbench.open_async(gfile, 'editor', 0, None, None, None)


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