diff --git a/src/Services/PluginManager.vala b/src/Services/PluginManager.vala index b460041e4..8e97214d3 100644 --- a/src/Services/PluginManager.vala +++ b/src/Services/PluginManager.vala @@ -150,18 +150,20 @@ namespace Scratch.Services { // Return an emulation of the discontinued libpeas-1.0 widget public Gtk.Widget get_view () { var list_box = new Gtk.ListBox (); + list_box.get_accessible ().accessible_name = _("Extensions"); + 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 }; // 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?) // 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 @@ -172,47 +174,62 @@ namespace Scratch.Services { 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 + valign = 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 (), LARGE_TOOLBAR) { - valign = Gtk.Align.CENTER + valign = START + }; + + var name_label = new Gtk.Label (info.name) { + ellipsize = MIDDLE, + xalign = 0 }; - 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, + ellipsize = END, + lines = 2, wrap = true, - xalign = 0, - margin_start = 6, - margin_bottom = 6 + xalign = 0 }; description_label.get_style_context ().add_class (Granite.STYLE_CLASS_SMALL_LABEL); description_label.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); + + var description_box = new Gtk.Box (VERTICAL, 0) { + hexpand = true + }; description_box.add (name_label); description_box.add (description_label); - content.add (checkbox); + + var content = new Gtk.Box (HORIZONTAL, 6) { + margin_top = 6, + margin_end = 12, + margin_bottom = 6, + margin_start = 6 + }; content.add (image); content.add (description_box); + content.add (checkbox); content.set_data ("name", info.get_name ()); + checkbox.toggled.connect (() => { + if (checkbox.active) { + engine.load_plugin (info); + } else { + engine.unload_plugin (info); + } + }); + return content; }