@@ -23,31 +23,39 @@ def __init__(self, *args, **kwds):
2323 foreground = CONF_FG ,
2424 background = CONF_BG ,
2525 )
26+
27+ def run_command (self , cmd ):
28+ _cmd = str .encode (f"{ cmd } \n " )
29+ self .feed_child (_cmd )
30+
31+ def run_command_btn (self , btn , cmd ):
32+ self .run_command (cmd )
2633
2734
2835class HeaderBar (Handy .HeaderBar ):
2936 actions_box = Gtk .Box (orientation = Gtk .Orientation .HORIZONTAL , spacing = 6 )
3037
31- def __init__ (self , * args , ** kwds ):
38+ def __init__ (self , terminal , * args , ** kwds ):
3239 super (HeaderBar , self ).__init__ (* args , ** kwds )
3340 self .set_show_close_button (True )
3441 self .set_title (CONF_NAME )
3542 self .pack_start (self .actions_box )
43+ self .terminal = terminal
3644
3745 def build_actions (self , actions :dict ):
3846 for action in actions :
3947 button = Gtk .Button ()
4048 button .set_tooltip_text (action ["tooltip" ])
4149 button .set_image (Gtk .Image .new_from_icon_name (action ["icon" ], Gtk .IconSize .BUTTON ))
42- button .connect ("clicked" , action ["callback " ])
50+ button .connect ("clicked" , self . terminal . run_command_btn , action ["command " ])
4351 self .actions_box .pack_start (button , False , False , 0 )
4452
4553
4654class MainWindow (Handy .ApplicationWindow ):
4755 Handy .init ()
4856 box = Gtk .Box (orientation = Gtk .Orientation .VERTICAL )
49- headerbar = HeaderBar ()
5057 terminal = Terminal ()
58+ headerbar = HeaderBar (terminal )
5159
5260 def __init__ (self , cwd :str = "" , command :list = [], env :list = [], actions :list = [], * args , ** kwds ):
5361 super ().__init__ ()
0 commit comments