@@ -150,18 +150,20 @@ namespace Scratch.Services {
150150 // Return an emulation of the discontinued libpeas-1.0 widget
151151 public Gtk .Widget get_view () {
152152 var list_box = new Gtk .ListBox ();
153+ list_box. get_accessible (). accessible_name = _(" Extensions" );
154+
153155 var scrolled_window = new Gtk .ScrolledWindow (null , null ) {
154156 hscrollbar_policy = NEVER ,
155- vscrollbar_policy = AUTOMATIC ,
156- max_content_height = 300 ,
157157 child = list_box
158158 };
159+
159160 var frame = new Gtk .Frame (null ) {
160161 child = scrolled_window
161162 };
162163
163164 // Bind the engine ListModel and use a row factory
164165 list_box. bind_model (engine, get_widget_for_plugin_info);
166+
165167 // Cannot sort a ListModel so sort the ListBox (is there a better way?)
166168 // Gtk warns the function will be ignored but it does in fact work, at least
167169 // on initial display. We know the model will not change while the view is used
@@ -172,47 +174,62 @@ namespace Scratch.Services {
172174 r2. get_child (). get_data< string > (" name" )
173175 );
174176 });
177+
175178 frame. show_all ();
176179 return frame;
177180 }
178181
179182 private Gtk .Widget get_widget_for_plugin_info (Object obj ) {
180183 var info = (Peas . PluginInfo )obj;
181- var content = new Gtk . Box ( HORIZONTAL , 6 );
184+
182185 var checkbox = new Gtk .CheckButton () {
183- valign = Gtk . Align . CENTER ,
184- active = info.is_loaded (),
185- margin_start = 6
186+ valign = CENTER ,
187+ active = info.is_loaded ()
186188 };
187- checkbox.toggled.connect (() => {
188- if (checkbox. active) {
189- engine. load_plugin (info);
190- } else {
191- engine. unload_plugin (info);
192- }
193- });
189+
194190 var image = new Gtk .Image .from_icon_name (info. get_icon_name (), LARGE_TOOLBAR ) {
195- valign = Gtk . Align . CENTER
191+ valign = START
192+ };
193+
194+ var name_label = new Gtk .Label (info. name) {
195+ ellipsize = MIDDLE ,
196+ xalign = 0
196197 };
197- var description_box = new Gtk .Box (VERTICAL , 0 );
198- var name_label = new Granite .HeaderLabel (info. name);
199- // TODO In Granite-7 we can use secondary text property but emulate for now
198+
200199 var description_label = new Gtk .Label (info. get_description ()) {
201- use_markup = true ,
200+ ellipsize = END ,
201+ lines = 2 ,
202202 wrap = true ,
203- xalign = 0 ,
204- margin_start = 6 ,
205- margin_bottom = 6
203+ xalign = 0
206204 };
207205 description_label.get_style_context ().add_class (Granite .STYLE_CLASS_SMALL_LABEL );
208206 description_label.get_style_context ().add_class (Gtk .STYLE_CLASS_DIM_LABEL );
207+
208+ var description_box = new Gtk .Box (VERTICAL , 0 ) {
209+ hexpand = true
210+ };
209211 description_box.add (name_label );
210212 description_box.add (description_label );
211- content.add (checkbox );
213+
214+ var content = new Gtk .Box (HORIZONTAL , 6 ) {
215+ margin_top = 6 ,
216+ margin_end = 12 ,
217+ margin_bottom = 6 ,
218+ margin_start = 6
219+ };
212220 content.add (image );
213221 content.add (description_box );
222+ content.add (checkbox );
214223 content.set_data<string> ("name", info.get_name ());
215224
225+ checkbox.toggled.connect (() => {
226+ if (checkbox. active) {
227+ engine. load_plugin (info);
228+ } else {
229+ engine. unload_plugin (info);
230+ }
231+ });
232+
216233 return content;
217234 }
218235
0 commit comments