@@ -58,13 +58,23 @@ class RecentSearchManager:
58
58
SEARCH_VALUES_TO_KEEP = 10
59
59
60
60
def __init__ (
61
- self , recent_list : Gtk .ListBox , search_box : Gtk .SearchEntry , enabled : bool
61
+ self ,
62
+ recent_list : Gtk .ListBox ,
63
+ search_box : Gtk .SearchEntry ,
64
+ enabled : bool ,
65
+ other_widgets : list [Gtk .ListBox ],
62
66
):
63
67
self .recent_enabled = enabled
64
68
self .recent_list_box = recent_list
65
69
self .search_box = search_box
66
70
self .recent_searches : Dict [str , RecentSearchRow ] = {}
71
+ self .other_widgets = other_widgets
67
72
self .recent_list_box .connect ("row-activated" , self ._row_clicked )
73
+ self .recent_list_box .connect ("row-selected" , self ._deselect_others )
74
+
75
+ def _deselect_others (self , * _args ):
76
+ for widget in self .other_widgets :
77
+ widget .select_row (None )
68
78
69
79
def set_recent_enabled (self , state ):
70
80
"""Set whether recent searches should be stored or not."""
@@ -112,6 +122,7 @@ def add_new_recent_search(self, text: str):
112
122
self .recent_searches [text ] = row
113
123
114
124
def _row_clicked (self , _widget , row : RecentSearchRow ):
125
+ self ._deselect_others ()
115
126
self .search_box .set_text (row .search_text )
116
127
117
128
@@ -126,16 +137,25 @@ def __init__(
126
137
desktop_file_manager : DesktopFileManager ,
127
138
vm_manager : VMManager ,
128
139
enabled : bool ,
140
+ other_widgets : list [Gtk .ListBox ],
129
141
):
130
142
self .recent_enabled = enabled
131
143
self .recent_list_box = recent_list
132
144
self .desktop_file_manager = desktop_file_manager
133
145
self .vm_manager = vm_manager
134
146
self .recent_apps : list [SearchAppEntry ] = []
135
147
self .recent_list_box .connect ("row-activated" , self ._row_clicked )
136
- self .recent_list_box .get_toplevel ().get_application ().connect (
137
- "app-started" , self .add_new_recent_app
138
- )
148
+ application = self .recent_list_box .get_toplevel ().get_application ()
149
+ if application :
150
+ # this is a workaround for tests: without Gtk.Application.run,
151
+ # this object does not exist
152
+ application .connect ("app-started" , self .add_new_recent_app )
153
+ self .other_widgets = other_widgets
154
+ self .recent_list_box .connect ("row-selected" , self ._deselect_others )
155
+
156
+ def _deselect_others (self , * _args ):
157
+ for widget in self .other_widgets :
158
+ widget .select_row (None )
139
159
140
160
def set_recent_enabled (self , state ):
141
161
"""Set whether recent apps should be stored or not."""
@@ -183,8 +203,8 @@ def add_new_recent_app(self, _widget, app_path: str):
183
203
del self .recent_apps [last_row ]
184
204
self .recent_list_box .remove (last_row )
185
205
186
- @ staticmethod
187
- def _row_clicked ( _widget , row : SearchAppEntry ):
206
+ def _row_clicked ( self , _widget , row : SearchAppEntry ):
207
+ self . _deselect_others ()
188
208
if hasattr (row , "app_info" ):
189
209
row .run_app (row .app_info .vm )
190
210
@@ -250,13 +270,17 @@ def __init__(
250
270
self .recent_box : Gtk .Box = builder .get_object ("search_no_box" )
251
271
252
272
self .recent_search_manager = RecentSearchManager (
253
- self .recent_list , self .search_entry , self .recent_enabled
273
+ self .recent_list ,
274
+ self .search_entry ,
275
+ self .recent_enabled ,
276
+ [self .recent_app_list ],
254
277
)
255
278
self .recent_apps_manager = RecentAppsManager (
256
279
self .recent_app_list ,
257
280
self .desktop_file_manager ,
258
281
self .vm_manager ,
259
282
self .recent_enabled ,
283
+ [self .recent_list ],
260
284
)
261
285
262
286
self .vm_list .connect ("row-selected" , self ._selection_changed )
@@ -436,8 +460,13 @@ def enable_recent(self, state: bool):
436
460
search_label .set_visible (True )
437
461
438
462
if state :
439
- app_label .set_text ("No recent applications" )
440
- search_label .set_text ("No recent searches" )
463
+ app_label .set_text (
464
+ "No recent applications. \n Use Menu Settings to "
465
+ "disable recent applications."
466
+ )
467
+ search_label .set_text (
468
+ "No recent searches. \n Use Menu Settings to disable recent applications."
469
+ )
441
470
else :
442
471
app_label .set_text (
443
472
"Recent application saving disabled.\n Use Menu Settings to enable."
0 commit comments