@@ -150,36 +150,30 @@ def __create_break_item(self, break_config, is_short):
150150 parent_box = self .box_long_breaks
151151 if is_short :
152152 parent_box = self .box_short_breaks
153- builder = utility .create_gtk_builder (SETTINGS_BREAK_ITEM_GLADE )
154- box = builder .get_object ("box" )
155- lbl_name = builder .get_object ("lbl_name" )
156- lbl_name .set_label (_ (break_config ["name" ]))
157- btn_properties = builder .get_object ("btn_properties" )
158- btn_properties .connect (
159- "clicked" ,
160- lambda button : self .__show_break_properties_dialog (
153+
154+ box = BreakItem (
155+ break_name = break_config ["name" ],
156+ on_properties = lambda : self .__show_break_properties_dialog (
161157 break_config ,
162158 is_short ,
163159 self .config ,
164- lambda cfg : lbl_name . set_label ( _ ( cfg ["name" ]) ),
160+ lambda cfg : box . set_break_name ( cfg ["name" ]),
165161 lambda is_short , break_config : self .__create_break_item (
166162 break_config , is_short
167163 ),
168164 lambda : parent_box .remove (box ),
169165 ),
170- )
171- btn_delete = builder .get_object ("btn_delete" )
172- btn_delete .connect (
173- "clicked" ,
174- lambda button : self .__delete_break (
166+ on_delete = lambda : self .__delete_break (
175167 break_config ,
176168 is_short ,
177169 lambda : parent_box .remove (box ),
178170 ),
179171 )
180- box .set_visible (True )
181- parent_box .append (box )
182- return box
172+
173+ gbox = box .box
174+
175+ gbox .set_visible (True )
176+ parent_box .append (gbox )
183177
184178 def on_reset_menu_clicked (self , button ):
185179 self .popover .hide ()
@@ -365,6 +359,32 @@ def on_window_delete(self, *args):
365359 self .window .destroy ()
366360
367361
362+ class BreakItem :
363+ def __init__ (self , break_name , on_properties , on_delete ):
364+ super ().__init__ ()
365+
366+ self .on_properties = on_properties
367+ self .on_delete = on_delete
368+
369+ builder = utility .create_gtk_builder (SETTINGS_BREAK_ITEM_GLADE )
370+ self .box = builder .get_object ("box" )
371+ self .lbl_name = builder .get_object ("lbl_name" )
372+ self .lbl_name .set_label (_ (break_name ))
373+ self .btn_properties = builder .get_object ("btn_properties" )
374+ self .btn_properties .connect ("clicked" , self .on_properties_clicked )
375+ self .btn_delete = builder .get_object ("btn_delete" )
376+ self .btn_delete .connect ("clicked" , self .on_delete_clicked )
377+
378+ def set_break_name (self , break_name ):
379+ self .lbl_name .set_label (_ (break_name ))
380+
381+ def on_properties_clicked (self , button ):
382+ self .on_properties ()
383+
384+ def on_delete_clicked (self , button ):
385+ self .on_delete ()
386+
387+
368388class PluginItem :
369389 def __init__ (self , plugin_config , on_properties ):
370390 super ().__init__ ()
0 commit comments