@@ -16,81 +16,84 @@ class ConnectionListWindow:
16
16
VERTICAL_MARGIN = 5
17
17
HORIZONTAL_MARGIN = 2
18
18
19
- __command_ssh = None
20
- __command_edit = None
21
-
22
- _listbox = None
23
- _frame = None
24
- _scrollable = None
25
- _list_store = Gtk .ListStore (str )
26
-
27
19
def __init__ (
28
20
self , manager : Manager ,
29
21
window_config : Window ,
30
22
command_ssh : AbstractCommand ,
31
23
command_edit : AbstractCommand
32
24
):
25
+ self ._listbox = None
26
+ self ._frame = None
27
+ self ._scrollable = None
28
+ self ._btn_reload = None
29
+ self ._btn_settings = None
30
+ self ._list_store = Gtk .ListStore (str )
31
+
33
32
self .__command_ssh = command_ssh
34
33
self .__command_edit = command_edit
35
34
self ._manager = manager
36
35
self ._window_config = window_config
37
36
38
37
def show (self ):
39
- win = Gtk . Window ()
40
- win . set_size_request ( self . _window_config . width , self . _window_config . height )
41
- win . move ( self ._window_config . x , self . _window_config . y )
42
- win . set_resizable ( False )
38
+ win = self . __create_window ()
39
+
40
+ self .__setup_ui ( win )
41
+ self . __setup_ui_listeners ( win )
43
42
43
+ win .show_all ()
44
+ Gtk .main ()
45
+
46
+ def __setup_ui_listeners (self , win ):
47
+ self ._btn_settings .connect ("clicked" , self .__btn_settings_click )
48
+ self ._btn_reload .connect ("clicked" , self .__btn_reload_click )
49
+ win .connect ("delete-event" , Gtk .main_quit )
50
+
51
+ def __setup_ui (self , win ):
44
52
btn_setting = Gtk .Button ("Settings" )
45
53
btn_setting .set_margin_right (self .HORIZONTAL_MARGIN )
46
54
btn_reload = Gtk .Button ("Reload" )
47
-
48
55
btn_box = Gtk .HBox ()
49
56
btn_box .add (btn_setting )
50
57
btn_box .add (btn_reload )
51
-
52
58
self ._listbox = Gtk .TreeView (self ._list_store )
53
59
self ._listbox .set_headers_visible (False )
54
- self ._listbox .connect ("row-activated" , self .row_activated )
55
-
60
+ self ._listbox .connect ("row-activated" , self .__row_activated )
56
61
self ._scrollable = Gtk .ScrolledWindow ()
57
62
self ._scrollable .add (self ._listbox )
58
- self ._fill_listbox ()
59
-
63
+ self .__fill_listbox ()
60
64
self ._frame = Gtk .Frame ()
61
65
self ._frame .add (self ._scrollable )
62
66
self ._frame .set_border_width (1 )
63
67
self ._frame .set_margin_bottom (self .VERTICAL_MARGIN )
64
-
65
68
vbox = Gtk .VBox ()
66
69
vbox .pack_start (self ._frame , 1 , 1 , 1 )
67
70
vbox .pack_end (btn_box , 0 , 0 , 0 )
68
-
69
71
vbox .set_margin_top (self .VERTICAL_MARGIN )
70
72
vbox .set_margin_bottom (self .VERTICAL_MARGIN )
71
73
vbox .set_margin_left (self .VERTICAL_MARGIN )
72
74
vbox .set_margin_right (self .VERTICAL_MARGIN )
73
-
74
- btn_setting .connect ("clicked" , self .btn_settings_click )
75
- btn_reload .connect ("clicked" , self .btn_reload_click )
76
-
77
75
win .add (vbox )
76
+ return btn_reload , btn_setting
78
77
78
+ def __create_window (self ):
79
+ win = Gtk .Window ()
80
+ win .set_size_request (self ._window_config .width , self ._window_config .height )
81
+ win .move (self ._window_config .x , self ._window_config .y )
82
+ win .set_resizable (False )
79
83
win .set_title ("SshManager GTK" )
80
- win .connect ("delete-event" , Gtk .main_quit )
81
- win .show_all ()
82
- Gtk .main ()
84
+
85
+ return win
83
86
84
87
# noinspection PyUnusedLocal
85
- def btn_settings_click (self , target ):
88
+ def __btn_settings_click (self , target ):
86
89
self .__command_edit .run (application .GtkApplication .get_config_file_path ())
87
90
88
91
# noinspection PyUnusedLocal
89
- def btn_reload_click (self , target ):
92
+ def __btn_reload_click (self , target ):
90
93
self ._manager = application .GtkApplication .create_default_manager ()
91
- self ._fill_listbox ()
94
+ self .__fill_listbox ()
92
95
93
- def _fill_listbox (self ):
96
+ def __fill_listbox (self ):
94
97
self ._list_store .clear ()
95
98
connections = self ._manager .get_connections ()
96
99
for connection in connections :
@@ -104,7 +107,7 @@ def _fill_listbox(self):
104
107
self ._listbox .show_all ()
105
108
106
109
# noinspection PyUnusedLocal
107
- def row_activated (self , target : Gtk .TreeView , path : Gtk .TreePath , column : Gtk .TreeViewColumn ):
110
+ def __row_activated (self , target : Gtk .TreeView , path : Gtk .TreePath , column : Gtk .TreeViewColumn ):
108
111
i = path .get_indices ()[0 ]
109
112
connection = self ._manager .get_connection (i )
110
113
self .__command_ssh .run (connection , connection .args )
0 commit comments