From 09b30dc470479ea603802f76a8a1f32d3bef011e Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 14:19:33 +0000 Subject: [PATCH 01/23] First compilable version --- meson.build | 6 +- .../brackets-completion.vala | 4 +- plugins/detect-indent/detect-indent.vala | 4 +- plugins/editorconfig/editorconfig.vala | 4 +- plugins/fuzzy-search/fuzzy-search.vala | 4 +- .../highlight-word-selection.vala | 4 +- .../markdown-actions/markdown-actions.vala | 4 +- plugins/pastebin/pastebin.vala | 4 +- plugins/preserve-indent/preserve-indent.vala | 4 +- plugins/spell/spell.vala | 4 +- plugins/vim-emulation/vim-emulation.vala | 4 +- plugins/word-completion/plugin.vala | 4 +- src/Dialogs/PreferencesDialog.vala | 2 +- src/Services/PluginManager.vala | 66 +++++++-- vapi/libpeas-2.vapi | 136 ++++++++++++++++++ 15 files changed, 214 insertions(+), 40 deletions(-) create mode 100644 vapi/libpeas-2.vapi diff --git a/meson.build b/meson.build index b600a80667..5939e5947f 100644 --- a/meson.build +++ b/meson.build @@ -33,8 +33,8 @@ gtk_dep = dependency('gtk+-3.0', version: '>=3.6.0') granite_dep = dependency('granite', version: '>=6.0.0') handy_dep = dependency('libhandy-1', version: '>=0.90.0') gtksourceview_dep = dependency('gtksourceview-4') -peas_dep = dependency('libpeas-1.0') -peasgtk_dep = dependency('libpeas-gtk-1.0') +peas_dep = dependency('libpeas-2') +# peasgtk_dep = dependency('libpeas-gtk-1.0') git_dep = dependency('libgit2-glib-1.0') fontconfig_dep = dependency('fontconfig') pangofc_dep = dependency('pangoft2') @@ -59,7 +59,7 @@ dependencies = [ handy_dep, gtksourceview_dep, peas_dep, - peasgtk_dep, + # peasgtk_dep, git_dep, fontconfig_dep, pangofc_dep, diff --git a/plugins/brackets-completion/brackets-completion.vala b/plugins/brackets-completion/brackets-completion.vala index bf3f4cf15c..a252df5196 100644 --- a/plugins/brackets-completion/brackets-completion.vala +++ b/plugins/brackets-completion/brackets-completion.vala @@ -18,7 +18,7 @@ END LICENSE ***/ -public class Scratch.Plugins.BracketsCompletion : Peas.ExtensionBase, Peas.Activatable { +public class Scratch.Plugins.BracketsCompletion : Peas.ExtensionBase, Scratch.Services.ActivatablePlugin { Gee.HashMap brackets; Gee.HashMap keys; const string[] VALID_NEXT_CHARS = { @@ -278,6 +278,6 @@ public class Scratch.Plugins.BracketsCompletion : Peas.ExtensionBase, Peas.Activ [ModuleInit] public void peas_register_types (GLib.TypeModule module) { var objmodule = module as Peas.ObjectModule; - objmodule.register_extension_type (typeof (Peas.Activatable), + objmodule.register_extension_type (typeof (Scratch.Services.ActivatablePlugin), typeof (Scratch.Plugins.BracketsCompletion)); } diff --git a/plugins/detect-indent/detect-indent.vala b/plugins/detect-indent/detect-indent.vala index 09fe9c1d24..1e267685e5 100644 --- a/plugins/detect-indent/detect-indent.vala +++ b/plugins/detect-indent/detect-indent.vala @@ -1,4 +1,4 @@ -public class Scratch.Plugins.DetectIndent: Peas.ExtensionBase, Peas.Activatable { +public class Scratch.Plugins.DetectIndent: Peas.ExtensionBase, Scratch.Services.ActivatablePlugin { const int MAX_LINES = 500; Scratch.Services.Interface plugins; @@ -79,7 +79,7 @@ public class Scratch.Plugins.DetectIndent: Peas.ExtensionBase, Peas.Activatable public void peas_register_types (GLib.TypeModule module) { var objmodule = module as Peas.ObjectModule; objmodule.register_extension_type ( - typeof (Peas.Activatable), + typeof (Scratch.Services.ActivatablePlugin), typeof (Scratch.Plugins.DetectIndent) ); } diff --git a/plugins/editorconfig/editorconfig.vala b/plugins/editorconfig/editorconfig.vala index 8a5b8f4285..936257d3d2 100644 --- a/plugins/editorconfig/editorconfig.vala +++ b/plugins/editorconfig/editorconfig.vala @@ -17,7 +17,7 @@ * Boston, MA 02110-1301 USA */ -public class Scratch.Plugins.EditorConfigPlugin: Peas.ExtensionBase, Peas.Activatable { +public class Scratch.Plugins.EditorConfigPlugin: Peas.ExtensionBase, Scratch.Services.ActivatablePlugin { Scratch.Services.Interface plugins; public Object object { owned get; construct; } private Code.FormatBar format_bar; @@ -91,5 +91,5 @@ public class Scratch.Plugins.EditorConfigPlugin: Peas.ExtensionBase, Peas.Activa [ModuleInit] public void peas_register_types (GLib.TypeModule module) { var objmodule = module as Peas.ObjectModule; - objmodule.register_extension_type (typeof (Peas.Activatable), typeof (Scratch.Plugins.EditorConfigPlugin)); + objmodule.register_extension_type (typeof (Scratch.Services.ActivatablePlugin), typeof (Scratch.Plugins.EditorConfigPlugin)); } diff --git a/plugins/fuzzy-search/fuzzy-search.vala b/plugins/fuzzy-search/fuzzy-search.vala index 2cff1cf2b7..f38f62f245 100644 --- a/plugins/fuzzy-search/fuzzy-search.vala +++ b/plugins/fuzzy-search/fuzzy-search.vala @@ -6,7 +6,7 @@ */ -public class Scratch.Plugins.FuzzySearch: Peas.ExtensionBase, Peas.Activatable { +public class Scratch.Plugins.FuzzySearch: Peas.ExtensionBase, Scratch.Services.ActivatablePlugin { public Object object { owned get; construct; } private const uint ACCEL_KEY = Gdk.Key.F; private const Gdk.ModifierType ACCEL_MODTYPE = Gdk.ModifierType.MOD1_MASK; @@ -158,7 +158,7 @@ public class Scratch.Plugins.FuzzySearch: Peas.ExtensionBase, Peas.Activatable { public void peas_register_types (GLib.TypeModule module) { var objmodule = module as Peas.ObjectModule; objmodule.register_extension_type ( - typeof (Peas.Activatable), + typeof (Scratch.Services.ActivatablePlugin), typeof (Scratch.Plugins.FuzzySearch) ); } diff --git a/plugins/highlight-word-selection/highlight-word-selection.vala b/plugins/highlight-word-selection/highlight-word-selection.vala index 5896b5d43e..3f64affec1 100644 --- a/plugins/highlight-word-selection/highlight-word-selection.vala +++ b/plugins/highlight-word-selection/highlight-word-selection.vala @@ -18,7 +18,7 @@ END LICENSE ***/ -public class Scratch.Plugins.HighlightSelectedWords : Peas.ExtensionBase, Peas.Activatable { +public class Scratch.Plugins.HighlightSelectedWords : Peas.ExtensionBase, Scratch.Services.ActivatablePlugin { Scratch.Widgets.SourceView current_source; Scratch.MainWindow? main_window = null; Gtk.SourceSearchContext? current_search_context = null; @@ -151,6 +151,6 @@ public class Scratch.Plugins.HighlightSelectedWords : Peas.ExtensionBase, Peas.A [ModuleInit] public void peas_register_types (TypeModule module) { var objmodule = module as Peas.ObjectModule; - objmodule.register_extension_type (typeof (Peas.Activatable), + objmodule.register_extension_type (typeof (Scratch.Services.ActivatablePlugin), typeof (Scratch.Plugins.HighlightSelectedWords)); } diff --git a/plugins/markdown-actions/markdown-actions.vala b/plugins/markdown-actions/markdown-actions.vala index 024e97c3b6..d53bf4fcd8 100644 --- a/plugins/markdown-actions/markdown-actions.vala +++ b/plugins/markdown-actions/markdown-actions.vala @@ -18,7 +18,7 @@ END LICENSE ***/ -public class Code.Plugins.MarkdownActions : Peas.ExtensionBase, Peas.Activatable { +public class Code.Plugins.MarkdownActions : Peas.ExtensionBase, Scratch.Services.ActivatablePlugin { Scratch.Widgets.SourceView current_source; Scratch.Services.Interface plugins; @@ -243,6 +243,6 @@ public class Code.Plugins.MarkdownActions : Peas.ExtensionBase, Peas.Activatable [ModuleInit] public void peas_register_types (TypeModule module) { var objmodule = module as Peas.ObjectModule; - objmodule.register_extension_type (typeof (Peas.Activatable), + objmodule.register_extension_type (typeof (Scratch.Services.ActivatablePlugin), typeof (Code.Plugins.MarkdownActions)); } diff --git a/plugins/pastebin/pastebin.vala b/plugins/pastebin/pastebin.vala index 3a4471dc21..f2cf090e18 100644 --- a/plugins/pastebin/pastebin.vala +++ b/plugins/pastebin/pastebin.vala @@ -68,7 +68,7 @@ namespace Scratch.Services { } } -public class Scratch.Plugins.Pastebin : Peas.ExtensionBase, Peas.Activatable { +public class Scratch.Plugins.Pastebin : Peas.ExtensionBase, Scratch.Services.ActivatablePlugin { GLib.MenuItem? menuitem = null; GLib.Menu? share_menu = null; public Object object { owned get; construct; } @@ -147,6 +147,6 @@ public class Scratch.Plugins.Pastebin : Peas.ExtensionBase, Peas.Activatable { [ModuleInit] public void peas_register_types (GLib.TypeModule module) { var objmodule = module as Peas.ObjectModule; - objmodule.register_extension_type (typeof (Peas.Activatable), + objmodule.register_extension_type (typeof (Scratch.Services.ActivatablePlugin), typeof (Scratch.Plugins.Pastebin)); } diff --git a/plugins/preserve-indent/preserve-indent.vala b/plugins/preserve-indent/preserve-indent.vala index 6f07e0c3d3..bfb8ff801b 100644 --- a/plugins/preserve-indent/preserve-indent.vala +++ b/plugins/preserve-indent/preserve-indent.vala @@ -18,7 +18,7 @@ END LICENSE ***/ -public class Scratch.Plugins.PreserveIndent : Peas.ExtensionBase, Peas.Activatable { +public class Scratch.Plugins.PreserveIndent : Peas.ExtensionBase, Scratch.Services.ActivatablePlugin { private Scratch.Services.Interface plugins; private Gee.TreeSet documents; @@ -244,6 +244,6 @@ public class Scratch.Plugins.PreserveIndent : Peas.ExtensionBase, Peas.Activatab [ModuleInit] public void peas_register_types (GLib.TypeModule module) { var objmodule = module as Peas.ObjectModule; - objmodule.register_extension_type (typeof (Peas.Activatable), + objmodule.register_extension_type (typeof (Scratch.Services.ActivatablePlugin), typeof (Scratch.Plugins.PreserveIndent)); } diff --git a/plugins/spell/spell.vala b/plugins/spell/spell.vala index 6e90e60e2f..f27bae823f 100644 --- a/plugins/spell/spell.vala +++ b/plugins/spell/spell.vala @@ -13,7 +13,7 @@ * with this program. If not, see */ -public class Scratch.Plugins.Spell: Peas.ExtensionBase, Peas.Activatable { +public class Scratch.Plugins.Spell: Peas.ExtensionBase, Scratch.Services.ActivatablePlugin { Scratch.Services.Interface plugins; @@ -160,7 +160,7 @@ public class Scratch.Plugins.Spell: Peas.ExtensionBase, Peas.Activatable { public void peas_register_types (GLib.TypeModule module) { var objmodule = module as Peas.ObjectModule; objmodule.register_extension_type ( - typeof (Peas.Activatable), + typeof (Scratch.Services.ActivatablePlugin), typeof (Scratch.Plugins.Spell) ); } diff --git a/plugins/vim-emulation/vim-emulation.vala b/plugins/vim-emulation/vim-emulation.vala index 32ec3c397a..426737da21 100644 --- a/plugins/vim-emulation/vim-emulation.vala +++ b/plugins/vim-emulation/vim-emulation.vala @@ -18,7 +18,7 @@ END LICENSE ***/ -public class Scratch.Plugins.VimEmulation : Peas.ExtensionBase, Peas.Activatable { +public class Scratch.Plugins.VimEmulation : Peas.ExtensionBase, Scratch.Services.ActivatablePlugin { public enum Mode { COMMAND, INSERT, @@ -298,6 +298,6 @@ public class Scratch.Plugins.VimEmulation : Peas.ExtensionBase, Peas.Activatable [ModuleInit] public void peas_register_types (GLib.TypeModule module) { var objmodule = module as Peas.ObjectModule; - objmodule.register_extension_type (typeof (Peas.Activatable), + objmodule.register_extension_type (typeof (Scratch.Services.ActivatablePlugin), typeof (Scratch.Plugins.VimEmulation)); } diff --git a/plugins/word-completion/plugin.vala b/plugins/word-completion/plugin.vala index d227d12a6a..0f45c14841 100644 --- a/plugins/word-completion/plugin.vala +++ b/plugins/word-completion/plugin.vala @@ -18,7 +18,7 @@ * */ -public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable { +public class Scratch.Plugins.Completion : Peas.ExtensionBase, Scratch.Services.ActivatablePlugin { public Object object { owned get; construct; } private List text_view_list = new List (); @@ -185,6 +185,6 @@ public class Scratch.Plugins.Completion : Peas.ExtensionBase, Peas.Activatable { [ModuleInit] public void peas_register_types (GLib.TypeModule module) { var objmodule = module as Peas.ObjectModule; - objmodule.register_extension_type (typeof (Peas.Activatable), + objmodule.register_extension_type (typeof (Scratch.Services.ActivatablePlugin), typeof (Scratch.Plugins.Completion)); } diff --git a/src/Dialogs/PreferencesDialog.vala b/src/Dialogs/PreferencesDialog.vala index 96f2de4590..378c246cd1 100644 --- a/src/Dialogs/PreferencesDialog.vala +++ b/src/Dialogs/PreferencesDialog.vala @@ -146,7 +146,7 @@ public class Scratch.Dialogs.Preferences : Granite.Dialog { plugins.hook_preferences_dialog (this); - if (Peas.Engine.get_default ().get_plugin_list ().length () > 0) { + if (plugins.get_n_plugins () > 0) { var pbox = plugins.get_view (); pbox.vexpand = true; diff --git a/src/Services/PluginManager.vala b/src/Services/PluginManager.vala index 26729a2400..40e310f332 100644 --- a/src/Services/PluginManager.vala +++ b/src/Services/PluginManager.vala @@ -19,10 +19,17 @@ ***/ namespace Scratch.Services { - public class Interface : GLib.Object { - - public PluginsManager manager; + // Interface implemented by all plugins + public interface ActivatablePlugin : Object { + // Migrated from Peas.Activatable + public virtual void activate () {} + public virtual void deactivate () {} + public virtual void update_state () {} + public abstract GLib.Object object { owned get; construct; } + } + // Object shared with plugins providing signals and methods to interface with application + public class Interface : GLib.Object { // Signals public signal void hook_window (Scratch.MainWindow window); public signal void hook_share_menu (GLib.MenuModel menu); @@ -32,6 +39,7 @@ namespace Scratch.Services { public signal void hook_folder_item_change (File file, File? other_file, FileMonitorEvent event_type); public Scratch.TemplateManager template_manager { private set; get; } + public Scratch.Services.PluginsManager manager { private set; get; } public Interface (PluginsManager manager) { this.manager = manager; @@ -50,7 +58,6 @@ namespace Scratch.Services { } } - public class PluginsManager : GLib.Object { Peas.Engine engine; Peas.ExtensionSet exts; @@ -86,19 +93,24 @@ namespace Scratch.Services { Scratch.settings.bind ("plugins-enabled", engine, "loaded-plugins", SettingsBindFlags.DEFAULT); /* Our extension set */ - exts = new Peas.ExtensionSet (engine, typeof (Peas.Activatable), "object", plugin_iface, null); + exts = new Peas.ExtensionSet.with_properties ( + engine, + typeof (ActivatablePlugin), + {"object"}, + {plugin_iface} + ); exts.extension_added.connect ((info, ext) => { - ((Peas.Activatable)ext).activate (); + ((ActivatablePlugin)ext).activate (); extension_added (info); }); exts.extension_removed.connect ((info, ext) => { - ((Peas.Activatable)ext).deactivate (); + ((ActivatablePlugin)ext).deactivate (); extension_removed (info); }); - exts.foreach (on_extension_foreach); + exts.@foreach ((Peas.ExtensionSetForeachFunc) on_extension_foreach, null); // Connect managers signals to interface's signals this.hook_window.connect ((w) => { @@ -126,15 +138,41 @@ namespace Scratch.Services { }); } - void on_extension_foreach (Peas.ExtensionSet set, Peas.PluginInfo info, Peas.Extension extension) { - ((Peas.Activatable)extension).activate (); + void on_extension_foreach (Peas.ExtensionSet exts, Peas.PluginInfo info, Object ext, void* data) { + ((ActivatablePlugin)ext).activate (); } public Gtk.Widget get_view () { - var view = new PeasGtk.PluginManager (engine); - var bottom_box = view.get_children ().nth_data (1); - bottom_box.no_show_all = true; - return view; + // var view = new PeasGtk.PluginManager (engine); + // var bottom_box = view.get_children ().nth_data (1); + // bottom_box.no_show_all = true; + // return view; + var list_box = new Gtk.ListBox (); + var index = 0; + while (index < engine.get_n_items ()) { + var info = (Peas.PluginInfo) engine.get_item (index); + var row = new Gtk.ListBoxRow (); + var content = new Gtk.Box (HORIZONTAL, 6); + var checkbox = new Gtk.CheckButton (); + var image = new Gtk.Image.from_icon_name (info.get_icon_name (), MENU); + var description_box = new Gtk.Box (VERTICAL, 0); + var name_label = new Gtk.Label (info.get_name ()); + var description_label = new Gtk.Label (info.get_description ()); + description_box.add (name_label); + description_box.add (description_label); + content.add (checkbox); + content.add (image); + content.add (description_box); + row.child = content; + + index++; + } + + return list_box; + } + + public uint get_n_plugins () { + return engine.get_n_items (); } } } diff --git a/vapi/libpeas-2.vapi b/vapi/libpeas-2.vapi new file mode 100644 index 0000000000..c870b6a04b --- /dev/null +++ b/vapi/libpeas-2.vapi @@ -0,0 +1,136 @@ +/* libpeas-2.vapi generated by vapigen, do not modify. */ + +[CCode (cprefix = "Peas", gir_namespace = "Peas", gir_version = "2", lower_case_cprefix = "peas_")] +namespace Peas { + [CCode (cheader_filename = "libpeas.h", type_id = "peas_engine_get_type ()")] + public sealed class Engine : GLib.Object, GLib.ListModel { + [CCode (has_construct_function = false)] + public Engine (); + public void add_search_path (string module_dir, string? data_dir); + public GLib.Object create_extension_with_properties (Peas.PluginInfo info, GLib.Type extension_type, [CCode (array_length_cname = "n_properties", array_length_pos = 2.5, array_length_type = "guint")] string[] prop_names, [CCode (array_length_cname = "n_properties", array_length_pos = 2.5, array_length_type = "guint")] GLib.Value[] prop_values); + [CCode (array_length = false, array_null_terminated = true)] + public string[] dup_loaded_plugins (); + public void enable_loader (string loader_name); + public void garbage_collect (); + public static unowned Peas.Engine get_default (); + public unowned Peas.PluginInfo get_plugin_info (string plugin_name); + public bool provides_extension (Peas.PluginInfo info, GLib.Type extension_type); + public void rescan_plugins (); + public void set_loaded_plugins ([CCode (array_length = false, array_null_terminated = true)] string[]? plugin_names); + [CCode (has_construct_function = false)] + public Engine.with_nonglobal_loaders (); + [CCode (array_length = false, array_null_terminated = true)] + [NoAccessorMethod] + public string[] loaded_plugins { owned get; set; } + [NoAccessorMethod] + public bool nonglobal_loaders { get; construct; } + [HasEmitter] + public signal void load_plugin (Peas.PluginInfo info); + [HasEmitter] + public signal void unload_plugin (Peas.PluginInfo info); + } + [CCode (cheader_filename = "libpeas.h", type_id = "peas_extension_base_get_type ()")] + public abstract class ExtensionBase : GLib.Object { + [CCode (has_construct_function = false)] + protected ExtensionBase (); + public string get_data_dir (); + public unowned Peas.PluginInfo get_plugin_info (); + public string data_dir { owned get; } + public Peas.PluginInfo plugin_info { get; construct; } + } + [CCode (cheader_filename = "libpeas.h", type_id = "peas_extension_set_get_type ()")] + public sealed class ExtensionSet : GLib.Object, GLib.ListModel { + [CCode (has_construct_function = false)] + protected ExtensionSet (); + public void @foreach (Peas.ExtensionSetForeachFunc func, void* data); + public unowned GLib.Object? get_extension (Peas.PluginInfo info); + [CCode (has_construct_function = false)] + public ExtensionSet.with_properties (Peas.Engine? engine, GLib.Type exten_type, [CCode (array_length_cname = "n_properties", array_length_pos = 2.5, array_length_type = "guint")] string[] prop_names, [CCode (array_length_cname = "n_properties", array_length_pos = 2.5, array_length_type = "guint")] GLib.Value[] prop_values); + [NoAccessorMethod] + public void* construct_properties { construct; } + [NoAccessorMethod] + public Peas.Engine engine { owned get; construct; } + [NoAccessorMethod] + public GLib.Type extension_type { get; construct; } + public signal void extension_added (Peas.PluginInfo info, GLib.Object extension); + public signal void extension_removed (Peas.PluginInfo info, GLib.Object extension); + } + [CCode (cheader_filename = "libpeas.h", type_id = "peas_object_module_get_type ()")] + public class ObjectModule : GLib.TypeModule, GLib.TypePlugin { + [CCode (has_construct_function = false)] + protected ObjectModule (); + public void register_extension_factory (GLib.Type exten_type, owned Peas.FactoryFunc factory_func); + public void register_extension_type (GLib.Type exten_type, GLib.Type impl_type); + [NoAccessorMethod] + public bool local_linkage { get; construct; } + [NoAccessorMethod] + public string module_name { owned get; construct; } + [NoAccessorMethod] + public string path { owned get; construct; } + [NoAccessorMethod] + public bool resident { get; construct; } + [NoAccessorMethod] + public string symbol { owned get; construct; } + } + [CCode (cheader_filename = "libpeas.h", type_id = "peas_plugin_info_get_type ()")] + public sealed class PluginInfo : GLib.Object { + [CCode (has_construct_function = false)] + protected PluginInfo (); + public static GLib.Quark error_quark (); + [CCode (array_length = false, array_null_terminated = true)] + public unowned string[] get_authors (); + public unowned string get_copyright (); + public unowned string get_data_dir (); + [CCode (array_length = false, array_null_terminated = true)] + public unowned string[] get_dependencies (); + public unowned string get_description (); + [Version (since = "1.6")] + public unowned string? get_external_data (string key); + public unowned string get_help_uri (); + public unowned string get_icon_name (); + public unowned string get_module_dir (); + public unowned string get_module_name (); + public unowned string get_name (); + public GLib.Resource get_resource (string? filename) throws GLib.Error; + [Version (since = "1.4")] + public GLib.Settings? get_settings (string? schema_id); + public unowned string get_version (); + public unowned string get_website (); + public bool has_dependency (string module_name); + public bool is_available () throws GLib.Error; + public bool is_builtin (); + public bool is_hidden (); + public bool is_loaded (); + public void load_resource (string? filename) throws GLib.Error; + [CCode (array_length = false, array_null_terminated = true)] + public string[] authors { get; } + [NoAccessorMethod] + public bool builtin { get; } + public string copyright { get; } + [CCode (array_length = false, array_null_terminated = true)] + public string[] dependencies { get; } + public string description { get; } + public string help_uri { get; } + [NoAccessorMethod] + public bool hidden { get; } + public string icon_name { get; } + [NoAccessorMethod] + public bool loaded { get; } + public string module_dir { get; } + public string module_name { get; } + public string name { get; } + public string version { get; } + public string website { get; } + } + [CCode (cheader_filename = "libpeas.h", cprefix = "PEAS_PLUGIN_INFO_ERROR_", has_type_id = false)] + public enum PluginInfoError { + LOADING_FAILED, + LOADER_NOT_FOUND, + DEP_NOT_FOUND, + DEP_LOADING_FAILED + } + [CCode (cheader_filename = "libpeas.h", has_target = false)] + public delegate void ExtensionSetForeachFunc (Peas.ExtensionSet @set, Peas.PluginInfo info, GLib.Object extension, void* data); + [CCode (cheader_filename = "libpeas.h", instance_pos = 1.9)] + public delegate GLib.Object FactoryFunc ([CCode (array_length_cname = "n_parameters", array_length_pos = 0.5, array_length_type = "guint")] GLib.Parameter[] parameters); +} From 8751ab921eadf4576ad0b29be480ff827bba98ce Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 16:05:20 +0000 Subject: [PATCH 02/23] Emulate previous appearance of Plugins view --- src/Services/PluginManager.vala | 46 +++++++++++++++++++++++++-------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/src/Services/PluginManager.vala b/src/Services/PluginManager.vala index 40e310f332..5d79a36171 100644 --- a/src/Services/PluginManager.vala +++ b/src/Services/PluginManager.vala @@ -142,33 +142,57 @@ namespace Scratch.Services { ((ActivatablePlugin)ext).activate (); } + // Return an emulation of the discontinued libpeas-1.0 widget public Gtk.Widget get_view () { - // var view = new PeasGtk.PluginManager (engine); - // var bottom_box = view.get_children ().nth_data (1); - // bottom_box.no_show_all = true; - // return view; var list_box = new Gtk.ListBox (); + var scrolled_window = new Gtk.ScrolledWindow (null, null) { + hscrollbar_policy = NEVER, + vscrollbar_policy = AUTOMATIC, + max_content_height = 300, + child = list_box + }; + var frame = new Gtk.Frame (null) { + child = scrolled_window + }; + var index = 0; while (index < engine.get_n_items ()) { var info = (Peas.PluginInfo) engine.get_item (index); - var row = new Gtk.ListBoxRow (); + var row = new Gtk.ListBoxRow () { + margin_start = 6, + margin_end = 6 + }; var content = new Gtk.Box (HORIZONTAL, 6); - var checkbox = new Gtk.CheckButton (); - var image = new Gtk.Image.from_icon_name (info.get_icon_name (), MENU); + var checkbox = new Gtk.CheckButton () { + valign = Gtk.Align.CENTER + }; + var image = new Gtk.Image.from_icon_name (info.get_icon_name (), MENU) { + valign = Gtk.Align.CENTER + }; var description_box = new Gtk.Box (VERTICAL, 0); - var name_label = new Gtk.Label (info.get_name ()); - var description_label = new Gtk.Label (info.get_description ()); + var name_label = new Granite.HeaderLabel (info.name); + //TODO In Granite-7 we can use secondary text property but emulate for now + var description_label = new Gtk.Label (info.get_description ()) { + use_markup = true, + wrap = true, + xalign = 0, + margin_start = 6 + }; + description_label.get_style_context ().add_class (Granite.STYLE_CLASS_SMALL_LABEL); + description_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); description_box.add (name_label); description_box.add (description_label); + content.add (name_label); content.add (checkbox); content.add (image); content.add (description_box); row.child = content; - + list_box.add (row); index++; } - return list_box; + frame.show_all (); + return frame; } public uint get_n_plugins () { From 31389a8030627075fd309f7e9d5ae3b3f9f38608 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 16:10:12 +0000 Subject: [PATCH 03/23] Update ci.yml --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9090e51f05..d7873804ee 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: - name: Install Dependencies run: | apt update - apt install -y exuberant-ctags libeditorconfig-dev libgail-3-dev libgee-0.8-dev libgit2-glib-1.0-dev libgranite-dev libgtk-3-dev libgtksourceview-4-dev libgtkspell3-3-dev libhandy-1-dev libpeas-dev libsoup2.4-dev libvala-dev libvte-2.91-dev meson valac polkitd libpolkit-gobject-1-dev + apt install -y exuberant-ctags libeditorconfig-dev libgail-3-dev libgee-0.8-dev libgit2-glib-1.0-dev libgranite-dev libgtk-3-dev libgtksourceview-4-dev libgtkspell3-3-dev libhandy-1-dev libpeas-2-dev libsoup2.4-dev libvala-dev libvte-2.91-dev meson valac polkitd libpolkit-gobject-1-dev - name: Build env: DESTDIR: out From ddfafb6321859b7719fc7d336116070f16fed4ac Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 16:12:21 +0000 Subject: [PATCH 04/23] Update io.elementary.code.yml --- io.elementary.code.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io.elementary.code.yml b/io.elementary.code.yml index c0764fbf43..ea5cb06a18 100644 --- a/io.elementary.code.yml +++ b/io.elementary.code.yml @@ -42,7 +42,7 @@ modules: sources: - type: git url: https://gitlab.gnome.org/GNOME/libpeas.git - tag: libpeas-1.34.0 + tag: libpeas-2.0.5 - name: git2-glib buildsystem: meson From d79d046861963ae42596a14e10807825da2a6a94 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 17:09:40 +0000 Subject: [PATCH 05/23] Bump glib dependency for libpeas-2 --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 5939e5947f..6f2f61d926 100644 --- a/meson.build +++ b/meson.build @@ -26,7 +26,7 @@ pluginsdir = get_option('prefix') / get_option('libdir') / meson.project_name() gnome = import('gnome') i18n = import('i18n') -glib_dep = dependency('glib-2.0', version: '>=2.30.0') +glib_dep = dependency('glib-2.0', version: '>=2.74.0') gio_unix_dep = dependency('gio-unix-2.0', version: '>=2.20') gee_dep = dependency('gee-0.8', version: '>=0.8.5') gtk_dep = dependency('gtk+-3.0', version: '>=3.6.0') From 7687d4ef34840b5cbee319e51dca44c71f12f8fe Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 17:10:19 +0000 Subject: [PATCH 06/23] Rename non-functional Flatpak manifest --- io.elementary.code.yml => io.elementary.code.yml.not_working | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename io.elementary.code.yml => io.elementary.code.yml.not_working (100%) diff --git a/io.elementary.code.yml b/io.elementary.code.yml.not_working similarity index 100% rename from io.elementary.code.yml rename to io.elementary.code.yml.not_working From d2e4e3423f9ee852ae51afa2d40725494dfcbfc4 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 17:15:23 +0000 Subject: [PATCH 07/23] Sync checkbutton with plugin loaded on show --- src/Services/PluginManager.vala | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Services/PluginManager.vala b/src/Services/PluginManager.vala index 5d79a36171..1d35b6623a 100644 --- a/src/Services/PluginManager.vala +++ b/src/Services/PluginManager.vala @@ -164,7 +164,8 @@ namespace Scratch.Services { }; var content = new Gtk.Box (HORIZONTAL, 6); var checkbox = new Gtk.CheckButton () { - valign = Gtk.Align.CENTER + valign = Gtk.Align.CENTER, + active = info.is_loaded () }; var image = new Gtk.Image.from_icon_name (info.get_icon_name (), MENU) { valign = Gtk.Align.CENTER From 13f6db7d5c32f3422ecf2b255e7b5e8b12afafe2 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 17:19:10 +0000 Subject: [PATCH 08/23] Action when checkbox toggled --- src/Services/PluginManager.vala | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Services/PluginManager.vala b/src/Services/PluginManager.vala index 1d35b6623a..129f477264 100644 --- a/src/Services/PluginManager.vala +++ b/src/Services/PluginManager.vala @@ -167,6 +167,13 @@ namespace Scratch.Services { valign = Gtk.Align.CENTER, active = info.is_loaded () }; + checkbox.toggled.connect (() => { + if (checkbox.active) { + engine.load_plugin (info); + } else { + engine.unload_plugin (info); + } + }); var image = new Gtk.Image.from_icon_name (info.get_icon_name (), MENU) { valign = Gtk.Align.CENTER }; From d882fabb93792b40ba0fe428241a2b08610c7daa Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 17:20:51 +0000 Subject: [PATCH 09/23] Fix double parenting --- src/Services/PluginManager.vala | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Services/PluginManager.vala b/src/Services/PluginManager.vala index 129f477264..7708f4e26e 100644 --- a/src/Services/PluginManager.vala +++ b/src/Services/PluginManager.vala @@ -190,7 +190,6 @@ namespace Scratch.Services { description_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); description_box.add (name_label); description_box.add (description_label); - content.add (name_label); content.add (checkbox); content.add (image); content.add (description_box); From 0071f7da337c3641039d90326836dc3f5be6b13d Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 17:39:29 +0000 Subject: [PATCH 10/23] Sort plugins by name --- src/Services/PluginManager.vala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Services/PluginManager.vala b/src/Services/PluginManager.vala index 7708f4e26e..b6d6feff3c 100644 --- a/src/Services/PluginManager.vala +++ b/src/Services/PluginManager.vala @@ -194,10 +194,15 @@ namespace Scratch.Services { content.add (image); content.add (description_box); row.child = content; + row.set_data ("name", info.name); list_box.add (row); index++; } + list_box.set_sort_func ((row1, row2) => { + return strcmp (row1.get_data ("name"), row2.get_data ("name")); + }); + frame.show_all (); return frame; } From 37f607db76738b439298e6eb1cb78c8883359e00 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 17:59:51 +0000 Subject: [PATCH 11/23] Use bind_model and factory --- src/Services/PluginManager.vala | 94 +++++++++++++++++---------------- 1 file changed, 48 insertions(+), 46 deletions(-) diff --git a/src/Services/PluginManager.vala b/src/Services/PluginManager.vala index b6d6feff3c..4996593e92 100644 --- a/src/Services/PluginManager.vala +++ b/src/Services/PluginManager.vala @@ -156,57 +156,59 @@ namespace Scratch.Services { }; var index = 0; - while (index < engine.get_n_items ()) { - var info = (Peas.PluginInfo) engine.get_item (index); - var row = new Gtk.ListBoxRow () { - margin_start = 6, - margin_end = 6 - }; - var content = new Gtk.Box (HORIZONTAL, 6); - var checkbox = new Gtk.CheckButton () { - valign = Gtk.Align.CENTER, - active = info.is_loaded () - }; - checkbox.toggled.connect (() => { - if (checkbox.active) { - engine.load_plugin (info); - } else { - engine.unload_plugin (info); - } - }); - var image = new Gtk.Image.from_icon_name (info.get_icon_name (), MENU) { - valign = Gtk.Align.CENTER - }; - var description_box = new Gtk.Box (VERTICAL, 0); - var name_label = new Granite.HeaderLabel (info.name); - //TODO In Granite-7 we can use secondary text property but emulate for now - var description_label = new Gtk.Label (info.get_description ()) { - use_markup = true, - wrap = true, - xalign = 0, - margin_start = 6 - }; - description_label.get_style_context ().add_class (Granite.STYLE_CLASS_SMALL_LABEL); - description_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); - description_box.add (name_label); - description_box.add (description_label); - content.add (checkbox); - content.add (image); - content.add (description_box); - row.child = content; - row.set_data ("name", info.name); - list_box.add (row); - index++; - } - - list_box.set_sort_func ((row1, row2) => { - return strcmp (row1.get_data ("name"), row2.get_data ("name")); + // Bind the engine ListModel and use a row factory + list_box.bind_model (engine, get_widget_for_plugin_info); + //Cannot sort a ListModel so sort the ListBox (is there a better way?) + list_box.set_sort_func ((r1, r2) => { + return strcmp ( + r1.get_child ().get_data ("name"), + r2.get_child ().get_data ("name") + ); }); - frame.show_all (); return frame; } + private Gtk.Widget get_widget_for_plugin_info (Object obj) { + var info = (Peas.PluginInfo)obj; + var content = new Gtk.Box (HORIZONTAL, 6); + var checkbox = new Gtk.CheckButton () { + valign = Gtk.Align.CENTER, + active = info.is_loaded (), + margin_start = 6 + }; + checkbox.toggled.connect (() => { + if (checkbox.active) { + engine.load_plugin (info); + } else { + engine.unload_plugin (info); + } + }); + var image = new Gtk.Image.from_icon_name (info.get_icon_name (), LARGE_TOOLBAR) { + valign = Gtk.Align.CENTER + }; + var description_box = new Gtk.Box (VERTICAL, 0); + var name_label = new Granite.HeaderLabel (info.name); + //TODO In Granite-7 we can use secondary text property but emulate for now + var description_label = new Gtk.Label (info.get_description ()) { + use_markup = true, + wrap = true, + xalign = 0, + margin_start = 6, + margin_bottom = 6 + }; + description_label.get_style_context ().add_class (Granite.STYLE_CLASS_SMALL_LABEL); + description_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + description_box.add (name_label); + description_box.add (description_label); + content.add (checkbox); + content.add (image); + content.add (description_box); + content.set_data ("name", info.get_name ()); + + return content; + } + public uint get_n_plugins () { return engine.get_n_items (); } From 07f83a258df1bb75ccff709c7a2da014f69ae5db Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 18:03:04 +0000 Subject: [PATCH 12/23] Lose unused entities --- src/Services/PluginManager.vala | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Services/PluginManager.vala b/src/Services/PluginManager.vala index 4996593e92..bab7886f0e 100644 --- a/src/Services/PluginManager.vala +++ b/src/Services/PluginManager.vala @@ -62,8 +62,6 @@ namespace Scratch.Services { Peas.Engine engine; Peas.ExtensionSet exts; - string settings_field; - public Interface plugin_iface { private set; public get; } public weak MainWindow window; @@ -82,7 +80,6 @@ namespace Scratch.Services { public PluginsManager (MainWindow window) { this.window = window; - settings_field = "plugins-enabled"; plugin_iface = new Interface (this); @@ -155,7 +152,6 @@ namespace Scratch.Services { child = scrolled_window }; - var index = 0; // Bind the engine ListModel and use a row factory list_box.bind_model (engine, get_widget_for_plugin_info); //Cannot sort a ListModel so sort the ListBox (is there a better way?) From d2d44aad8dfe863397467a0276b59920e02764a8 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 18:14:56 +0000 Subject: [PATCH 13/23] Cleanup and code style --- src/Services/PluginManager.vala | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Services/PluginManager.vala b/src/Services/PluginManager.vala index bab7886f0e..e0051eb7bb 100644 --- a/src/Services/PluginManager.vala +++ b/src/Services/PluginManager.vala @@ -2,7 +2,9 @@ /*** BEGIN LICENSE - Copyright (C) 2013 Mario Guerriero + Copyright (C) 2019–2024 elementary, Inc. + 2013 Mario Guerriero + This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 3, as published by the Free Software Foundation. @@ -38,12 +40,16 @@ namespace Scratch.Services { public signal void hook_preferences_dialog (Scratch.Dialogs.Preferences dialog); public signal void hook_folder_item_change (File file, File? other_file, FileMonitorEvent event_type); - public Scratch.TemplateManager template_manager { private set; get; } - public Scratch.Services.PluginsManager manager { private set; get; } + public Scratch.TemplateManager template_manager { get; construct; } + public Scratch.Services.PluginsManager manager { get; construct; } - public Interface (PluginsManager manager) { - this.manager = manager; + public Interface (PluginsManager _manager) { + Object ( + manager: _manager + ); + } + construct { template_manager = new Scratch.TemplateManager (); } @@ -63,8 +69,7 @@ namespace Scratch.Services { Peas.ExtensionSet exts; public Interface plugin_iface { private set; public get; } - - public weak MainWindow window; + public weak MainWindow window {get; construct; } // Signals public signal void hook_window (Scratch.MainWindow window); @@ -77,10 +82,13 @@ namespace Scratch.Services { public signal void extension_added (Peas.PluginInfo info); public signal void extension_removed (Peas.PluginInfo info); - public PluginsManager (MainWindow window) { - this.window = window; - + public PluginsManager (MainWindow _window) { + Object ( + window: _window + ); + } + construct { plugin_iface = new Interface (this); /* Let's init the engine */ From cc2f607f89c89843b70da0321937ddf340a672c0 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 18:45:36 +0000 Subject: [PATCH 14/23] Fix initial appearance of preferences dialog --- src/Dialogs/PreferencesDialog.vala | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Dialogs/PreferencesDialog.vala b/src/Dialogs/PreferencesDialog.vala index 378c246cd1..278886998e 100644 --- a/src/Dialogs/PreferencesDialog.vala +++ b/src/Dialogs/PreferencesDialog.vala @@ -160,6 +160,11 @@ public class Scratch.Dialogs.Preferences : Granite.Dialog { close_button.clicked.connect (() => { destroy (); }); + + //Ensure appearance correct after using libpeas-2 + realize.connect (() => { + stack.set_visible_child_name ("behavior"); + }); } private class SettingSwitch : Gtk.Grid { From 5939f5690cb07660a33e23424699450104516ce8 Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 18:45:49 +0000 Subject: [PATCH 15/23] Add some comments --- src/Dialogs/PreferencesDialog.vala | 2 +- src/Services/PluginManager.vala | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Dialogs/PreferencesDialog.vala b/src/Dialogs/PreferencesDialog.vala index 278886998e..53288c3985 100644 --- a/src/Dialogs/PreferencesDialog.vala +++ b/src/Dialogs/PreferencesDialog.vala @@ -144,7 +144,7 @@ public class Scratch.Dialogs.Preferences : Granite.Dialog { main_box.add (stackswitcher); main_box.add (stack); - plugins.hook_preferences_dialog (this); + plugins.hook_preferences_dialog (this); // Unused? if (plugins.get_n_plugins () > 0) { var pbox = plugins.get_view (); diff --git a/src/Services/PluginManager.vala b/src/Services/PluginManager.vala index e0051eb7bb..b4659d3a2b 100644 --- a/src/Services/PluginManager.vala +++ b/src/Services/PluginManager.vala @@ -162,7 +162,10 @@ namespace Scratch.Services { // Bind the engine ListModel and use a row factory list_box.bind_model (engine, get_widget_for_plugin_info); - //Cannot sort a ListModel so sort the ListBox (is there a better way?) + // Cannot sort a ListModel so sort the ListBox (is there a better way?) + // Gtk warns the function will be ignored but it does in fact work, at least + // on initial display. We know the model will not change while the view is used + // In Gtk4 could use SortListModel list_box.set_sort_func ((r1, r2) => { return strcmp ( r1.get_child ().get_data ("name"), From b8ef69ab893aaace73715339260d43f7ffef2e1f Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 18:50:05 +0000 Subject: [PATCH 16/23] Lose commented out code --- meson.build | 2 -- 1 file changed, 2 deletions(-) diff --git a/meson.build b/meson.build index 6f2f61d926..70b4375222 100644 --- a/meson.build +++ b/meson.build @@ -34,7 +34,6 @@ granite_dep = dependency('granite', version: '>=6.0.0') handy_dep = dependency('libhandy-1', version: '>=0.90.0') gtksourceview_dep = dependency('gtksourceview-4') peas_dep = dependency('libpeas-2') -# peasgtk_dep = dependency('libpeas-gtk-1.0') git_dep = dependency('libgit2-glib-1.0') fontconfig_dep = dependency('fontconfig') pangofc_dep = dependency('pangoft2') @@ -59,7 +58,6 @@ dependencies = [ handy_dep, gtksourceview_dep, peas_dep, - # peasgtk_dep, git_dep, fontconfig_dep, pangofc_dep, From feb933b71f969ecbad18d7f2db70fb72e8cbf8df Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Wed, 25 Dec 2024 18:52:59 +0000 Subject: [PATCH 17/23] Make activate and deactivate methods mandatory to implement --- src/Services/PluginManager.vala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Services/PluginManager.vala b/src/Services/PluginManager.vala index b4659d3a2b..56fa429845 100644 --- a/src/Services/PluginManager.vala +++ b/src/Services/PluginManager.vala @@ -24,8 +24,8 @@ namespace Scratch.Services { // Interface implemented by all plugins public interface ActivatablePlugin : Object { // Migrated from Peas.Activatable - public virtual void activate () {} - public virtual void deactivate () {} + public abstract void activate (); + public abstract void deactivate (); public virtual void update_state () {} public abstract GLib.Object object { owned get; construct; } } From cd945db8ebd44dfcdb5374f4b41241056683926c Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Mon, 30 Dec 2024 15:35:52 +0000 Subject: [PATCH 18/23] Fix Flatpak build for OS8 --- ....yml.not_working => io.elementary.code.yml | 20 +++++++++++-------- plugins/pastebin/meson.build | 2 +- plugins/pastebin/pastebin.vala | 17 +++++++++++----- 3 files changed, 25 insertions(+), 14 deletions(-) rename io.elementary.code.yml.not_working => io.elementary.code.yml (89%) diff --git a/io.elementary.code.yml.not_working b/io.elementary.code.yml similarity index 89% rename from io.elementary.code.yml.not_working rename to io.elementary.code.yml index ea5cb06a18..e3ff3a4eb8 100644 --- a/io.elementary.code.yml.not_working +++ b/io.elementary.code.yml @@ -1,6 +1,6 @@ app-id: io.elementary.code runtime: io.elementary.Sdk # The outline plugin requires libvala which is only in the SDK, not the runtime -runtime-version: '7.1' +runtime-version: 'daily' sdk: io.elementary.Sdk command: io.elementary.code finish-args: @@ -33,16 +33,20 @@ modules: url: https://gitlab.gnome.org/GNOME/gtksourceview.git tag: '4.8.4' - - name: peas + - name: libpeas buildsystem: meson config-opts: - - '-Dgtk_doc=false' - - '-Ddemos=false' - - '-Dvapi=true' + - -Dlua51=false + - -Dgjs=false sources: - - type: git - url: https://gitlab.gnome.org/GNOME/libpeas.git - tag: libpeas-2.0.5 + - type: archive + url: https://download.gnome.org/sources/libpeas/2.0/libpeas-2.0.5.tar.xz + sha256: 376f2f73d731b54e13ddbab1d91b6382cf6a980524def44df62add15489de6dd + x-checker-data: + type: gnome + versions: + <: '2.0.6' + name: libpeas - name: git2-glib buildsystem: meson diff --git a/plugins/pastebin/meson.build b/plugins/pastebin/meson.build index f18e644d41..b426acff0e 100644 --- a/plugins/pastebin/meson.build +++ b/plugins/pastebin/meson.build @@ -5,7 +5,7 @@ module_files = [ 'pastebin.vala' ] -soup_dep = dependency('libsoup-2.4') +soup_dep = dependency('libsoup-3.0') module_deps = [ codecore_dep, diff --git a/plugins/pastebin/pastebin.vala b/plugins/pastebin/pastebin.vala index f2cf090e18..2d32634904 100644 --- a/plugins/pastebin/pastebin.vala +++ b/plugins/pastebin/pastebin.vala @@ -34,6 +34,7 @@ namespace Scratch.Services { string paste_private, string paste_expire_date, string paste_format) { + link = null; if (paste_code.length == 0) { link = "No text to paste"; return false; } string api_url = "https://pastebin.com/api/api_post.php"; @@ -50,15 +51,21 @@ namespace Scratch.Services { "api_paste_expire_date", paste_expire_date, "api_paste_format", paste_format); - message.set_request ("application/x-www-form-urlencoded", Soup.MemoryUse.COPY, request.data); + message.set_request_body_from_bytes ("application/x-www-form-urlencoded", new Bytes (request.data)); message.set_flags (Soup.MessageFlags.NO_REDIRECT); - session.send_message (message); + Bytes output; + try { + output = session.send_and_read (message); + } catch (Error e) { + return false; + } + - var output = (string) message.response_body.data; - link = output; + var output_s = (string) output.get_data (); + link = output_s; - if (Uri.parse_scheme (output) == null || message.status_code != 200) { + if (Uri.parse_scheme (output_s) == null || message.status_code != 200) { // A URI was not returned return false; } From 45f4225b488e2a199ae496caf2dc4d2c2d6dec44 Mon Sep 17 00:00:00 2001 From: Leonardo Lemos Date: Mon, 30 Dec 2024 16:07:43 +0000 Subject: [PATCH 19/23] Fix libsoup3.0-dev dependency --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d7873804ee..95edfc51b7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: - name: Install Dependencies run: | apt update - apt install -y exuberant-ctags libeditorconfig-dev libgail-3-dev libgee-0.8-dev libgit2-glib-1.0-dev libgranite-dev libgtk-3-dev libgtksourceview-4-dev libgtkspell3-3-dev libhandy-1-dev libpeas-2-dev libsoup2.4-dev libvala-dev libvte-2.91-dev meson valac polkitd libpolkit-gobject-1-dev + apt install -y exuberant-ctags libeditorconfig-dev libgail-3-dev libgee-0.8-dev libgit2-glib-1.0-dev libgranite-dev libgtk-3-dev libgtksourceview-4-dev libgtkspell3-3-dev libhandy-1-dev libpeas-2-dev libsoup3.0-dev libvala-dev libvte-2.91-dev meson valac polkitd libpolkit-gobject-1-dev - name: Build env: DESTDIR: out From da385663a8c3dbabea5521230e55ed0e703de4d9 Mon Sep 17 00:00:00 2001 From: Leonardo Lemos Date: Mon, 30 Dec 2024 16:09:32 +0000 Subject: [PATCH 20/23] Fix libsoup name --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 95edfc51b7..a00473b6a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,13 +22,13 @@ jobs: - name: Install Dependencies run: | apt update - apt install -y exuberant-ctags libeditorconfig-dev libgail-3-dev libgee-0.8-dev libgit2-glib-1.0-dev libgranite-dev libgtk-3-dev libgtksourceview-4-dev libgtkspell3-3-dev libhandy-1-dev libpeas-2-dev libsoup3.0-dev libvala-dev libvte-2.91-dev meson valac polkitd libpolkit-gobject-1-dev + apt install -y exuberant-ctags libeditorconfig-dev libgail-3-dev libgee-0.8-dev libgit2-glib-1.0-dev libgranite-dev libgtk-3-dev libgtksourceview-4-dev libgtkspell3-3-dev libhandy-1-dev libpeas-2-dev libsoup-3.0-dev libvala-dev libvte-2.91-dev meson valac polkitd libpolkit-gobject-1-dev - name: Build env: DESTDIR: out run: | meson build - ninja -C build install + ninja -C build install. flatpak: name: Flatpak From 9ef37c1dfe938a479b716ed764d7640479c87dab Mon Sep 17 00:00:00 2001 From: Leonardo Lemos Date: Mon, 30 Dec 2024 16:11:08 +0000 Subject: [PATCH 21/23] Fix ninja build install command --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a00473b6a9..60128499b8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: DESTDIR: out run: | meson build - ninja -C build install. + ninja -C build install flatpak: name: Flatpak From 21051645d01026c19003a212df62e54675d1030f Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Sat, 17 May 2025 17:00:20 +0100 Subject: [PATCH 22/23] Revert to '7.1' Sdk --- io.elementary.code.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/io.elementary.code.yml b/io.elementary.code.yml index e3ff3a4eb8..fc654e9cfa 100644 --- a/io.elementary.code.yml +++ b/io.elementary.code.yml @@ -1,6 +1,6 @@ app-id: io.elementary.code runtime: io.elementary.Sdk # The outline plugin requires libvala which is only in the SDK, not the runtime -runtime-version: 'daily' +runtime-version: '7.1' sdk: io.elementary.Sdk command: io.elementary.code finish-args: From f157a1b8fd20bf8195d1fb15b2c1132de5af4f4b Mon Sep 17 00:00:00 2001 From: Jeremy Wootten Date: Sat, 17 May 2025 17:03:46 +0100 Subject: [PATCH 23/23] Update libpeas dependency in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9f440e8b3e..9682f0b07b 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ You'll need the following dependencies: * libgtkspell3-3-dev * libgranite-dev >= 6.0.0 * libhandy-1-dev >= 0.90.0 -* libpeas-dev +* libpeas-2-dev * libsoup2.4-dev * libvala-0.48-dev (or higher) * libvte-2.91-dev