Skip to content
This repository was archived by the owner on Nov 5, 2023. It is now read-only.

Commit df44d97

Browse files
New: Refresh action (main menu) and improvements
1 parent 8af0be4 commit df44d97

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/Common.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -860,23 +860,23 @@ def current_tab_refresh(action, parameter, main_window_object):
860860
# if refresh button is pressed for a long time.
861861
if Config.current_main_tab == 0:
862862
if Config.performance_tab_current_sub_tab in [0, 1, 2, 3, 4]:
863-
time_difference = 0.25
863+
tab_refresh_time_difference = 0.2
864864
elif Config.performance_tab_current_sub_tab in [5, 6]:
865-
time_difference = 0.35
865+
tab_refresh_time_difference = 0.35
866866
elif Config.current_main_tab in [1, 2]:
867-
time_difference = 0.35
867+
tab_refresh_time_difference = 0.35
868868
elif Config.current_main_tab in [3, 4]:
869-
time_difference = 1
869+
tab_refresh_time_difference = 1
870870

871871
import time
872-
current_time = time.time()
873-
global previous_time
872+
tab_refresh_time_current = time.time()
873+
global tab_refresh_time_prev
874874
try:
875-
if current_time - previous_time < time_difference:
875+
if tab_refresh_time_current - tab_refresh_time_prev < tab_refresh_time_difference:
876876
return
877877
except NameError:
878878
pass
879-
previous_time = current_time
879+
tab_refresh_time_prev = tab_refresh_time_current
880880

881881
# Reset "loop_already_run" values of Services and System tab for refreshing them.
882882
# These tabs are not refreshed on every main loop of the application if these values are "1".

src/MainWindow.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,10 @@ def main_menu_gui(self, val=None):
429429
return
430430

431431
# Menu actions
432+
# "Refresh" action
433+
action = Gio.SimpleAction.new("refresh", None)
434+
action.connect("activate", Common.current_tab_refresh, self)
435+
self.main_window.add_action(action)
432436
# "General Settings" action
433437
action = Gio.SimpleAction.new("settings", None)
434438
action.connect("activate", self.on_main_menu_settings_button_clicked)
@@ -440,6 +444,7 @@ def main_menu_gui(self, val=None):
440444

441445
# Menu model
442446
main_menu_model = Gio.Menu.new()
447+
main_menu_model.append(_tr("Refresh"), "win.refresh")
443448
main_menu_model.append(_tr("General Settings"), "win.settings")
444449
main_menu_model.append(_tr("About"), "win.about")
445450

0 commit comments

Comments
 (0)