@@ -151,10 +151,8 @@ def __create_break_item(self, break_config, is_short):
151151 ),
152152 )
153153
154- gbox = box .box
155-
156- gbox .set_visible (True )
157- parent_box .append (gbox )
154+ box .set_visible (True )
155+ parent_box .append (box )
158156
159157 @Gtk .Template .Callback ()
160158 def on_reset_menu_clicked (self , button ):
@@ -224,10 +222,8 @@ def __create_plugin_item(self, plugin_config):
224222 if plugin_config .get ("break_override_allowed" , False ):
225223 self .plugin_map [plugin_config ["id" ]] = plugin_config ["meta" ]["name" ]
226224
227- gbox = box .box
228-
229- gbox .set_visible (True )
230- return gbox
225+ box .set_visible (True )
226+ return box
231227
232228 def __show_plugins_properties_dialog (self , plugin_config ):
233229 """Show the PluginProperties dialog."""
@@ -347,52 +343,57 @@ def on_window_delete(self, *args):
347343 self .destroy ()
348344
349345
350- class BreakItem :
346+ @Gtk .Template (filename = SETTINGS_BREAK_ITEM_GLADE )
347+ class BreakItem (Gtk .Box ):
348+ __gtype_name__ = "BreakItem"
349+
350+ lbl_name = Gtk .Template .Child ()
351+
351352 def __init__ (self , break_name , on_properties , on_delete ):
352353 super ().__init__ ()
353354
354355 self .on_properties = on_properties
355356 self .on_delete = on_delete
356357
357- builder = utility .create_gtk_builder (SETTINGS_BREAK_ITEM_GLADE )
358- self .box = builder .get_object ("box" )
359- self .lbl_name = builder .get_object ("lbl_name" )
360358 self .lbl_name .set_label (_ (break_name ))
361- self .btn_properties = builder .get_object ("btn_properties" )
362- self .btn_properties .connect ("clicked" , self .on_properties_clicked )
363- self .btn_delete = builder .get_object ("btn_delete" )
364- self .btn_delete .connect ("clicked" , self .on_delete_clicked )
365359
366360 def set_break_name (self , break_name ):
367361 self .lbl_name .set_label (_ (break_name ))
368362
363+ @Gtk .Template .Callback ()
369364 def on_properties_clicked (self , button ):
370365 self .on_properties ()
371366
367+ @Gtk .Template .Callback ()
372368 def on_delete_clicked (self , button ):
373369 self .on_delete ()
374370
375371
376- class PluginItem :
372+ @Gtk .Template (filename = SETTINGS_PLUGIN_ITEM_GLADE )
373+ class PluginItem (Gtk .Box ):
374+ __gtype_name__ = "PluginItem"
375+
376+ lbl_plugin_name = Gtk .Template .Child ()
377+ lbl_plugin_description = Gtk .Template .Child ()
378+ switch_enable = Gtk .Template .Child ()
379+ btn_properties = Gtk .Template .Child ()
380+ btn_disable_errored = Gtk .Template .Child ()
381+ btn_plugin_extra_link = Gtk .Template .Child ()
382+ img_plugin_icon = Gtk .Template .Child ()
383+
377384 def __init__ (self , plugin_config , on_properties ):
378385 super ().__init__ ()
379386
380387 self .on_properties = on_properties
381388 self .plugin_config = plugin_config
382389
383- builder = utility .create_gtk_builder (SETTINGS_PLUGIN_ITEM_GLADE )
384- self .lbl_plugin_name = builder .get_object ("lbl_plugin_name" )
385- self .lbl_plugin_description = builder .get_object ("lbl_plugin_description" )
386- self .switch_enable = builder .get_object ("switch_enable" )
387- self .btn_properties = builder .get_object ("btn_properties" )
388390 self .lbl_plugin_name .set_label (_ (plugin_config ["meta" ]["name" ]))
389391 self .switch_enable .set_active (plugin_config ["enabled" ])
390392
391393 if plugin_config ["error" ]:
392394 message = plugin_config ["meta" ]["dependency_description" ]
393395 if isinstance (message , PluginDependency ):
394396 self .lbl_plugin_description .set_label (_ (message .message ))
395- self .btn_plugin_extra_link = builder .get_object ("btn_plugin_extra_link" )
396397 self .btn_plugin_extra_link .set_uri (message .link )
397398 self .btn_plugin_extra_link .set_visible (True )
398399 else :
@@ -402,32 +403,29 @@ def __init__(self, plugin_config, on_properties):
402403 self .switch_enable .set_sensitive (False )
403404 self .btn_properties .set_sensitive (False )
404405 if plugin_config ["enabled" ]:
405- self .btn_disable_errored = builder .get_object ("btn_disable_errored" )
406406 self .btn_disable_errored .set_visible (True )
407- self .btn_disable_errored .connect ("clicked" , self .on_disable_errored )
408407 else :
409408 self .lbl_plugin_description .set_label (
410409 _ (plugin_config ["meta" ]["description" ])
411410 )
412411 if plugin_config ["settings" ]:
413412 self .btn_properties .set_sensitive (True )
414- self .btn_properties .connect ("clicked" , self .on_properties_clicked )
415413 else :
416414 self .btn_properties .set_sensitive (False )
417415
418416 if plugin_config ["icon" ]:
419- builder .get_object ("img_plugin_icon" ).set_from_file (plugin_config ["icon" ])
420-
421- self .box = builder .get_object ("box" )
417+ self .img_plugin_icon .set_from_file (plugin_config ["icon" ])
422418
423419 def is_enabled (self ):
424420 return self .switch_enable .get_active ()
425421
422+ @Gtk .Template .Callback ()
426423 def on_disable_errored (self , button ):
427424 """Permanently disable errored plugin."""
428425 self .btn_disable_errored .set_sensitive (False )
429426 self .switch_enable .set_active (False )
430427
428+ @Gtk .Template .Callback ()
431429 def on_properties_clicked (self , button ):
432430 if not self .plugin_config ["error" ] and self .plugin_config ["settings" ]:
433431 self .on_properties ()
0 commit comments