Kaydet (Commit) f2cd0b36 authored tarafından Hakan Dündar's avatar Hakan Dündar

Improvements for easier maintenance

üst 68f6503c
......@@ -207,13 +207,12 @@ def processes_open_process_details_window_func(event):
except ValueError: # It gives error such as "ValueError: [True, 'system-monitoring-center-process-symbolic', 'python3', 2411, 'asush', 'Running', 1.6633495783351964, 98824192, 548507648, 45764608, 0, 16384, 0, 5461, 0, 4, 1727, 1000, 1000, '/usr/bin/python3.9'] is not in list" rarely. It is handled in this situation.
return
# Open Process Details window
if 'ProcessesDetailsGUI' not in globals(): # Check if "ProcessesDetailsGUI" module is imported. Therefore it is not reimported for every double click on any process on the treeview if "ProcessesDetailsGUI" name is in globals().
global ProcessesDetailsGUI, ProcessesDetails
import ProcessesDetailsGUI, ProcessesDetails
ProcessesDetailsGUI.processes_details_gui_import_function()
ProcessesDetailsGUI.processes_details_gui_function()
if 'ProcessesDetails' not in globals(): # Check if "ProcessesDetails" module is imported. Therefore it is not reimported for every double click on any process on the treeview if "ProcessesDetails" name is in globals().
global ProcessesDetails
import ProcessesDetails
ProcessesDetails.processes_details_import_func()
ProcessesDetailsGUI.window2101w.show()
ProcessesDetails.processes_details_gui_function()
ProcessesDetails.window2101w.show()
ProcessesDetails.process_details_foreground_thread_run_func()
......
This diff is collapsed.
#!/usr/bin/env python3
# ----------------------------------- Processes - Processes Details Window GUI Import Function (contains import code of this module in order to avoid running them during module import) -----------------------------------
def processes_details_gui_import_function():
global Gtk, GLib, os
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk, GLib
import os
global ProcessesDetails
import ProcessesDetails
# ----------------------------------- Processes - Processes Details Window GUI Function (the code of this module in order to avoid running them during module import and defines "Processes Details" window GUI objects and functions/signals) -----------------------------------
def processes_details_gui_function():
# Processes Details window GUI objects
global builder2101w, window2101w, notebook2101w
global label2101w, label2102w, label2103w, label2104w, label2105w, label2106w, label2107w, label2108w, label2109w, label2110w
global label2111w, label2112w, label2113w, label2114w, label2115w, label2116w, label2117w, label2118w, label2119w, label2120w
global label2121w, label2122w, label2123w, label2124w, label2125w, label2126w, label2127w, label2128w, label2129w, label2130w
global label2131w, label2132w, label2133w, label2134w, label2135w, label2136w, label2137w
# Processes Details window GUI objects - get
builder2101w = Gtk.Builder()
builder2101w.add_from_file(os.path.dirname(os.path.realpath(__file__)) + "/../ui/ProcessesDetailsWindow.ui")
window2101w = builder2101w.get_object('window2101w')
notebook2101w = builder2101w.get_object('notebook2101w')
# Process Details window "Summary" tab GUI objects
label2101w = builder2101w.get_object('label2101w')
label2102w = builder2101w.get_object('label2102w')
label2103w = builder2101w.get_object('label2103w')
label2104w = builder2101w.get_object('label2104w')
label2105w = builder2101w.get_object('label2105w')
label2106w = builder2101w.get_object('label2106w')
label2107w = builder2101w.get_object('label2107w')
label2108w = builder2101w.get_object('label2108w')
label2109w = builder2101w.get_object('label2109w')
label2110w = builder2101w.get_object('label2110w')
label2111w = builder2101w.get_object('label2111w')
label2112w = builder2101w.get_object('label2112w')
label2113w = builder2101w.get_object('label2113w')
label2114w = builder2101w.get_object('label2114w')
label2115w = builder2101w.get_object('label2115w')
# Process Details window "CPU and RAM" tab GUI objects
label2116w = builder2101w.get_object('label2116w')
label2117w = builder2101w.get_object('label2117w')
label2118w = builder2101w.get_object('label2118w')
label2119w = builder2101w.get_object('label2119w')
label2120w = builder2101w.get_object('label2120w')
label2121w = builder2101w.get_object('label2121w')
label2122w = builder2101w.get_object('label2122w')
label2123w = builder2101w.get_object('label2123w')
label2124w = builder2101w.get_object('label2124w')
label2125w = builder2101w.get_object('label2125w')
label2126w = builder2101w.get_object('label2126w')
label2127w = builder2101w.get_object('label2127w')
# Process Details window "Disk and Path" tab GUI objects
label2128w = builder2101w.get_object('label2128w')
label2129w = builder2101w.get_object('label2129w')
label2130w = builder2101w.get_object('label2130w')
label2131w = builder2101w.get_object('label2131w')
label2132w = builder2101w.get_object('label2132w')
label2133w = builder2101w.get_object('label2133w')
label2134w = builder2101w.get_object('label2134w')
label2135w = builder2101w.get_object('label2135w')
label2136w = builder2101w.get_object('label2136w')
label2137w = builder2101w.get_object('label2137w')
# Processes Details window GUI functions
def on_window2101w_delete_event(widget, event):
window2101w.hide()
return True
def on_window2101w_show(widget):
processes_details_gui_reset_function() # Call this function in order to reset Processes Details window. Data from previous process remains visible (for a short time) until getting and showing new process data if window is closed and opened for an another process. Also last selected tab remains same because window is made hidden when close button is clicked.
processes_details_tab_switch_control_func()
# Processes Details window GUI functions - connect
window2101w.connect("delete-event", on_window2101w_delete_event)
window2101w.connect("show", on_window2101w_show)
# ----------------------------------- Processes - Processes Details Window GUI Reset Function (resets Processes Details window) -----------------------------------
def processes_details_gui_reset_function():
notebook2101w.set_current_page(0) # Set fist page (Summary tab) of the notebook
label2101w.set_text("--")
label2102w.set_text("--")
label2103w.set_text("--")
label2104w.set_text("--")
label2105w.set_text("--")
label2106w.set_text("--")
label2107w.set_text("--")
label2108w.set_text("--")
label2109w.set_text("--")
label2110w.set_text("--")
label2111w.set_text("--")
label2112w.set_text("--")
label2113w.set_text("--")
label2114w.set_text("--")
label2115w.set_text("--")
label2116w.set_text("--")
label2117w.set_text("--")
label2118w.set_text("--")
label2119w.set_text("--")
label2120w.set_text("--")
label2121w.set_text("--")
label2122w.set_text("--")
label2123w.set_text("--")
label2124w.set_text("--")
label2125w.set_text("--")
label2126w.set_text("--")
label2127w.set_text("--")
label2128w.set_text("--")
label2129w.set_text("--")
label2130w.set_text("--")
label2131w.set_text("--")
label2132w.set_text("--")
label2133w.set_text("--")
label2134w.set_text("--")
label2135w.set_text("--")
label2136w.set_text("--")
label2137w.set_text("--")
# ----------------------------------- Processes - Processes Details Tab Switch Control Function (controls if tab is switched and updates data on the last opened tab immediately without waiting end of the update interval. Signals of notebook for tab switching is not useful because it performs the action and after that it switches the tab. Data updating function does not recognizes tab switch due to this reason.) -----------------------------------
def processes_details_tab_switch_control_func():
global previous_page
if 'previous_page' not in globals(): # For avoiding errors in the first loop of the control
previous_page = None
current_page = None
current_page = notebook2101w.get_current_page()
if current_page != previous_page and previous_page != None: # Check if tab is switched
ProcessesDetails.process_details_foreground_func() # Update the data on the tab
previous_page = current_page
if window2101w.get_visible() == True:
GLib.timeout_add(200, processes_details_tab_switch_control_func) # Check is performed in every 200 ms which is small enough for immediate update and not very frequent for avoiding high CPU usages.
......@@ -135,13 +135,12 @@ def processes_menu_right_click_gui_func():
os.system('xdg-open "%s"' % path_only)
def on_menuitem2108m_activate(widget): # "Details" item on the right click menu
if 'ProcessesDetailsGUI' not in globals(): # Check if "ProcessesDetailsGUI" module is imported. Therefore it is not reimported for every click on "Details" menu item on the right click menu if "ProcessesDetailsGUI" name is in globals().
global ProcessesDetailsGUI, ProcessesDetails
import ProcessesDetailsGUI, ProcessesDetails
ProcessesDetailsGUI.processes_details_gui_import_function()
ProcessesDetailsGUI.processes_details_gui_function()
if 'ProcessesDetails' not in globals(): # Check if "ProcessesDetails" module is imported. Therefore it is not reimported for every click on "Details" menu item on the right click menu if "ProcessesDetails" name is in globals().
global ProcessesDetails
import ProcessesDetails
ProcessesDetails.processes_details_import_func()
ProcessesDetailsGUI.window2101w.show()
ProcessesDetails.processes_details_gui_function()
ProcessesDetails.window2101w.show()
ProcessesDetails.process_details_foreground_thread_run_func()
def on_radiomenuitem2101m_activate(widget): # "Very High" item on the right click menu under "Change Priorty (Nice)" item
......
......@@ -160,13 +160,12 @@ def services_open_service_details_window_func(event):
global selected_service_name
selected_service_name = service_list[services_data_rows.index(model[treeiter][:])] # "[:]" is used in order to copy entire list to be able to use it for getting index in the "services_data_rows" list to use it getting name of the service.
# Open Service Details window
if 'ServicesDetailsGUI' not in globals(): # Check if "ServicesDetailsGUI" module is imported. Therefore it is not reimported for every double click on any user on the treeview if "ServicesDetailsGUI" name is in globals().
global ServicesDetailsGUI, ServicesDetails
import ServicesDetailsGUI, ServicesDetails
ServicesDetailsGUI.services_details_gui_import_function()
ServicesDetailsGUI.services_details_gui_function()
if 'ServicesDetails' not in globals(): # Check if "ServicesDetails" module is imported. Therefore it is not reimported for every double click on any user on the treeview if "ServicesDetails" name is in globals().
global ServicesDetails
import ServicesDetails
ServicesDetails.services_details_import_func()
ServicesDetailsGUI.window6101w.show()
ServicesDetails.services_details_gui_function()
ServicesDetails.window6101w.show()
ServicesDetails.services_details_foreground_thread_run_func()
......
This diff is collapsed.
#!/usr/bin/env python3
# ----------------------------------- Services - Services Details Window GUI Import Function (contains import code of this module in order to avoid running them during module import) -----------------------------------
def services_details_gui_import_function():
global Gtk, os
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import os
# ----------------------------------- Services - Services Details Window GUI Function (the code of this module in order to avoid running them during module import and defines "Services Details" window GUI objects and functions/signals) -----------------------------------
def services_details_gui_function():
# Services Details window GUI objects
global builder6101w, window6101w, notebook6101w
global label6101w, label6102w, label6103w, label6104w, label6105w, label6106w, label6107w, label6108w, label6109w, label6110w
global label6111w, label6112w, label6113w, label6114w, label6115w, label6116w, label6117w, label6118w, label6119w, label6120w
global label6121w, label6122w
# Services Details window GUI objects - get
builder6101w = Gtk.Builder()
builder6101w.add_from_file(os.path.dirname(os.path.realpath(__file__)) + "/../ui/ServicesDetailsWindow.ui")
window6101w = builder6101w.get_object('window6101w')
notebook6101w = builder6101w.get_object('notebook6101w')
# Service Details window "General" tab GUI objects
label6101w = builder6101w.get_object('label6101w')
label6102w = builder6101w.get_object('label6102w')
label6103w = builder6101w.get_object('label6103w')
label6104w = builder6101w.get_object('label6104w')
label6105w = builder6101w.get_object('label6105w')
label6106w = builder6101w.get_object('label6106w')
label6107w = builder6101w.get_object('label6107w')
label6108w = builder6101w.get_object('label6108w')
label6109w = builder6101w.get_object('label6109w')
label6110w = builder6101w.get_object('label6110w')
label6111w = builder6101w.get_object('label6111w')
label6112w = builder6101w.get_object('label6112w')
label6113w = builder6101w.get_object('label6113w')
label6114w = builder6101w.get_object('label6114w')
label6115w = builder6101w.get_object('label6115w')
label6116w = builder6101w.get_object('label6116w')
label6117w = builder6101w.get_object('label6117w')
label6118w = builder6101w.get_object('label6118w')
# Service Details window "Dependencies" tab GUI objects
label6119w = builder6101w.get_object('label6119w')
label6120w = builder6101w.get_object('label6120w')
label6121w = builder6101w.get_object('label6121w')
label6122w = builder6101w.get_object('label6122w')
# Services Details window GUI functions
def on_window6101w_delete_event(widget, event):
window6101w.hide()
return True
def on_window6101w_show(widget):
services_details_gui_reset_function() # Call this function in order to reset Services Details window. Data from previous service remains visible (for a short time) until getting and showing new service data if window is closed and opened for an another service. Also last selected tab remains same because window is made hidden when close button is clicked.
# Services Details window GUI functions - connect
window6101w.connect("delete-event", on_window6101w_delete_event)
window6101w.connect("show", on_window6101w_show)
# ----------------------------------- Services - Services Details Window GUI Reset Function (resets Services Details window) -----------------------------------
def services_details_gui_reset_function():
notebook6101w.set_current_page(0) # Set fist page (Summary tab) of the notebook
label6101w.set_text("--")
label6102w.set_text("--")
label6103w.set_text("--")
label6104w.set_text("--")
label6105w.set_text("--")
label6106w.set_text("--")
label6107w.set_text("--")
label6108w.set_text("--")
label6109w.set_text("--")
label6110w.set_text("--")
label6111w.set_text("--")
label6112w.set_text("--")
label6113w.set_text("--")
label6114w.set_text("--")
label6115w.set_text("--")
label6116w.set_text("--")
label6117w.set_text("--")
label6118w.set_text("--")
label6119w.set_text("--")
label6120w.set_text("--")
label6121w.set_text("--")
label6122w.set_text("--")
# # ----------------------------------- Services - Services Details Tab Switch Control Function (controls if tab is switched and updates data on the last opened tab immediately without waiting end of the update interval. Signals of notebook for tab switching is not useful because it performs the action and after that it switches the tab. Data updating function does not recognizes tab switch due to this reason.) -----------------------------------
# def services_details_tab_switch_control_func():
#
# global previous_page
# if 'previous_page' not in globals(): # For avoiding errors in the first loop of the control
# previous_page = None
# current_page = None
# current_page = notebook6101w.get_current_page()
# if current_page != previous_page and previous_page != None: # Check if tab is switched
# ServicesDetails.service_details_foreground_func() # Update the data on the tab
# previous_page = current_page
# if window6101w.get_visible() == True:
# GLib.timeout_add(200, services_details_tab_switch_control_func) # Check is performed in every 200 ms which is small enough for immediate update and not very frequent for avoiding high CPU usages.
......@@ -104,13 +104,12 @@ def services_menu_right_click_gui_func():
clipboard.store() # Stores copied text in the clipboard. Therefore text stays in the clipboard after application has quit.
def on_menuitem6109m_activate(widget): # "Details" item on the right click menu
if 'ServicesDetailsGUI' not in globals(): # Check if "ServicesDetailsGUI" module is imported. Therefore it is not reimported for every click on "Details" menu item on the right click menu if "ServicesDetailsGUI" name is in globals().
global ServicesDetailsGUI, ServicesDetails
import ServicesDetailsGUI, ServicesDetails
ServicesDetailsGUI.services_details_gui_import_function()
ServicesDetailsGUI.services_details_gui_function()
if 'ServicesDetails' not in globals(): # Check if "ServicesDetails" module is imported. Therefore it is not reimported for every click on "Details" menu item on the right click menu if "ServicesDetails" name is in globals().
global ServicesDetails
import ServicesDetails
ServicesDetails.services_details_import_func()
ServicesDetailsGUI.window6101w.show()
ServicesDetails.services_details_gui_function()
ServicesDetails.window6101w.show()
ServicesDetails.services_details_foreground_thread_run_func()
# ********************** Connect signals to GUI objects for Services tab right click menu **********************
......
......@@ -185,13 +185,12 @@ def storage_open_storage_details_window_func(event):
global selected_storage_kernel_name
selected_storage_kernel_name = disk_list[storage_data_rows.index(model[treeiter][:])] # "[:]" is used in order to copy entire list to be able to use it for getting index in the "storage_data_rows" list to use it getting name of the disk.
# Open Storage Details window
if 'StorageDetailsGUI' not in globals(): # Check if "StorageDetailsGUI" module is imported. Therefore it is not reimported for every double click on any user on the treeview if "StorageDetailsGUI" name is in globals().
global StorageDetailsGUI, StorageDetails
import StorageDetailsGUI, StorageDetails
StorageDetailsGUI.storage_details_gui_import_function()
StorageDetailsGUI.storage_details_gui_function()
if 'StorageDetails' not in globals(): # Check if "StorageDetails" module is imported. Therefore it is not reimported for every double click on any user on the treeview if "StorageDetails" name is in globals().
global StorageDetails
import StorageDetails
StorageDetails.storage_details_import_func()
StorageDetailsGUI.window4101w.show()
StorageDetails.storage_details_gui_function()
StorageDetails.window4101w.show()
StorageDetails.storage_details_foreground_thread_run_func()
......
This diff is collapsed.
#!/usr/bin/env python3
# ----------------------------------- Storage - Storage Details Window GUI Import Function (contains import code of this module in order to avoid running them during module import) -----------------------------------
def storage_details_gui_import_function():
global Gtk, os
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import os
# ----------------------------------- Storage - Storage Details Window GUI Function (the code of this module in order to avoid running them during module import and defines "Storage Details" window GUI objects and functions/signals) -----------------------------------
def storage_details_gui_function():
# Storage Details window GUI objects
global builder4101w, window4101w
global label4101w, label4102w, label4103w, label4104w, label4105w, label4106w, label4107w, label4108w, label4109w, label4110w
global label4111w, label4112w, label4113w, label4114w, label4115w, label4116w, label4117w, label4118w, label4119w, label4120w
global label4121w, label4122w, label4123w, label4124w
# Storage Details window GUI objects - get
builder4101w = Gtk.Builder()
builder4101w.add_from_file(os.path.dirname(os.path.realpath(__file__)) + "/../ui/StorageDetailsWindow.ui")
window4101w = builder4101w.get_object('window4101w')
# Storage Details window GUI objects
label4101w = builder4101w.get_object('label4101w')
label4102w = builder4101w.get_object('label4102w')
label4103w = builder4101w.get_object('label4103w')
label4104w = builder4101w.get_object('label4104w')
label4105w = builder4101w.get_object('label4105w')
label4106w = builder4101w.get_object('label4106w')
label4107w = builder4101w.get_object('label4107w')
label4108w = builder4101w.get_object('label4108w')
label4109w = builder4101w.get_object('label4109w')
label4110w = builder4101w.get_object('label4110w')
label4111w = builder4101w.get_object('label4111w')
label4112w = builder4101w.get_object('label4112w')
label4113w = builder4101w.get_object('label4113w')
label4114w = builder4101w.get_object('label4114w')
label4115w = builder4101w.get_object('label4115w')
label4116w = builder4101w.get_object('label4116w')
label4117w = builder4101w.get_object('label4117w')
label4118w = builder4101w.get_object('label4118w')
label4119w = builder4101w.get_object('label4119w')
label4120w = builder4101w.get_object('label4120w')
label4121w = builder4101w.get_object('label4121w')
label4122w = builder4101w.get_object('label4122w')
label4123w = builder4101w.get_object('label4123w')
label4124w = builder4101w.get_object('label4124w')
# Storage Details window GUI functions
def on_window4101w_delete_event(widget, event):
window4101w.hide()
return True
def on_window4101w_show(widget):
storage_details_gui_reset_function() # Call this function in order to reset Storage Details window. Data from previous storage/disk remains visible (for a short time) until getting and showing new storage/disk data if window is closed and opened for an another storage/disk because window is made hidden when close button is clicked.
# Storage Details window GUI functions - connect
window4101w.connect("delete-event", on_window4101w_delete_event)
window4101w.connect("show", on_window4101w_show)
# ----------------------------------- Storage - Storage Details Window GUI Reset Function (resets Storage Details window) -----------------------------------
def storage_details_gui_reset_function():
label4101w.set_text("--")
label4102w.set_text("--")
label4103w.set_text("--")
label4104w.set_text("--")
label4105w.set_text("--")
label4106w.set_text("--")
label4107w.set_text("--")
label4108w.set_text("--")
label4109w.set_text("--")
label4110w.set_text("--")
label4111w.set_text("--")
label4112w.set_text("--")
label4113w.set_text("--")
label4114w.set_text("--")
label4115w.set_text("--")
label4116w.set_text("--")
label4117w.set_text("--")
label4118w.set_text("--")
label4119w.set_text("--")
label4120w.set_text("--")
label4121w.set_text("--")
label4122w.set_text("--")
label4123w.set_text("--")
label4124w.set_text("--")
# # ----------------------------------- Storage - Storage Details Tab Switch Control Function (controls if tab is switched and updates data on the last opened tab immediately without waiting end of the update interval. Signals of notebook for tab switching is not useful because it performs the action and after that it switches the tab. Data updating function does not recognizes tab switch due to this reason.) -----------------------------------
# def storage_details_tab_switch_control_func():
#
# global previous_page
# if 'previous_page' not in globals(): # For avoiding errors in the first loop of the control
# previous_page = None
# current_page = None
# current_page = notebook4101w.get_current_page()
# if current_page != previous_page and previous_page != None: # Check if tab is switched
# StorageDetails.storage_details_foreground_func() # Update the data on the tab
# previous_page = current_page
# if window4101w.get_visible() == True:
# GLib.timeout_add(200, storage_details_tab_switch_control_func) # Check is performed in every 200 ms which is small enough for immediate update and not very frequent for avoiding high CPU usages.
......@@ -179,13 +179,12 @@ def storage_menu_right_click_gui_func():
StorageRenameGUI.window4101w2.show()
def on_menuitem4108m_activate(widget): # "Details" item on the right click menu
if 'StorageDetailsGUI' not in globals(): # Check if "StorageDetailsGUI" module is imported. Therefore it is not reimported for double click on "Details" menu item on the right click menu if "StorageDetailsGUI" name is in globals().
global StorageDetailsGUI, StorageDetails
import StorageDetailsGUI, StorageDetails
StorageDetailsGUI.storage_details_gui_import_function()
StorageDetailsGUI.storage_details_gui_function()
if 'StorageDetails' not in globals(): # Check if "StorageDetails" module is imported. Therefore it is not reimported for double click on "Details" menu item on the right click menu if "StorageDetails" name is in globals().
global StorageDetails
import StorageDetails
StorageDetails.storage_details_import_func()
StorageDetailsGUI.window4101w.show()
StorageDetails.storage_details_gui_function()
StorageDetails.window4101w.show()
StorageDetails.storage_details_foreground_thread_run_func()
# ********************** Connect signals to GUI objects for Storage tab right click menu **********************
......
......@@ -155,13 +155,12 @@ def users_open_user_details_window_func(event):
global selected_user_uid
selected_user_uid = uid_username_list[users_data_rows.index(model[treeiter][:])][0] # "[:]" is used in order to copy entire list to be able to use it for getting index in the "users_data_rows" list to use it getting UID of the user.
# Open Users Details window
if 'UsersDetailsGUI' not in globals(): # Check if "UsersDetailsGUI" module is imported. Therefore it is not reimported for every double click on any user on the treeview if "UsersDetailsGUI" name is in globals().
global UsersDetails, UsersDetailsGUI
import UsersDetails, UsersDetailsGUI
UsersDetailsGUI.users_details_gui_import_function()
UsersDetailsGUI.users_details_gui_function()
if 'UsersDetails' not in globals(): # Check if "UsersDetails" module is imported. Therefore it is not reimported for every double click on any user on the treeview if "UsersDetails" name is in globals().
global UsersDetails
import UsersDetails
UsersDetails.users_details_import_func()
UsersDetailsGUI.window3101w.show()
UsersDetails.users_details_gui_function()
UsersDetails.window3101w.show()
UsersDetails.users_details_foreground_thread_run_func()
......
......@@ -15,8 +15,8 @@ def users_details_import_func():
import time
global Config, Users, UsersDetailsGUI, MainGUI
import Config, Users, UsersDetailsGUI, MainGUI
global Config, Users, MainGUI
import Config, Users, MainGUI
# Import locale and gettext modules for defining translation texts which will be recognized by gettext application (will be run by programmer externally) and exported into a ".pot" file.
......@@ -36,6 +36,88 @@ def users_details_import_func():
locale.setlocale(locale.LC_ALL, system_current_language)
# ----------------------------------- Users - Users Details Window GUI Function (the code of this module in order to avoid running them during module import and defines "Users Details" window GUI objects and functions/signals) -----------------------------------
def users_details_gui_function():
# Users Details window GUI objects
global builder3101w, window3101w
global label3101w, label3102w, label3103w, label3104w, label3105w, label3106w, label3107w, label3108w, label3109w, label3110w
global label3111w, label3112w, label3113w, label3114w
# Users Details window GUI objects - get
builder3101w = Gtk.Builder()
builder3101w.add_from_file(os.path.dirname(os.path.realpath(__file__)) + "/../ui/UsersDetailsWindow.ui")
window3101w = builder3101w.get_object('window3101w')
# Users Details window GUI objects
label3101w = builder3101w.get_object('label3101w')
label3102w = builder3101w.get_object('label3102w')
label3103w = builder3101w.get_object('label3103w')
label3104w = builder3101w.get_object('label3104w')
label3105w = builder3101w.get_object('label3105w')
label3106w = builder3101w.get_object('label3106w')
label3107w = builder3101w.get_object('label3107w')
label3108w = builder3101w.get_object('label3108w')
label3109w = builder3101w.get_object('label3109w')
label3110w = builder3101w.get_object('label3110w')
label3111w = builder3101w.get_object('label3111w')
label3112w = builder3101w.get_object('label3112w')
label3113w = builder3101w.get_object('label3113w')
label3114w = builder3101w.get_object('label3114w')
# Users Details window GUI functions
def on_window3101w_delete_event(widget, event):
window3101w.hide()
return True
def on_window3101w_show(widget):
users_details_gui_reset_function() # Call this function in order to reset Users Details window. Data from previous user remains visible (for a short time) until getting and showing new user data if window is closed and opened for an another user because window is made hidden when close button is clicked.
# Users Details window GUI functions - connect
window3101w.connect("delete-event", on_window3101w_delete_event)
window3101w.connect("show", on_window3101w_show)
# ----------------------------------- Users - Users Details Window GUI Reset Function (resets Users Details window) -----------------------------------
def users_details_gui_reset_function():
window3101w.set_title(_tr("User Details")) # Reset window title
window3101w.set_icon_name("system-monitoring-center-user-symbolic") # Reset window icon
label3101w.set_text("--")
label3102w.set_text("--")
label3103w.set_text("--")
label3104w.set_text("--")
label3105w.set_text("--")
label3106w.set_text("--")
label3107w.set_text("--")
label3108w.set_text("--")
label3109w.set_text("--")
label3110w.set_text("--")
label3111w.set_text("--")
label3112w.set_text("--")
label3113w.set_text("--")
label3114w.set_text("--")
# # ----------------------------------- Users - Users Details Tab Switch Control Function (controls if tab is switched and updates data on the last opened tab immediately without waiting end of the update interval. Signals of notebook for tab switching is not useful because it performs the action and after that it switches the tab. Data updating function does not recognizes tab switch due to this reason.) -----------------------------------
# def users_details_tab_switch_control_func():
#
# global previous_page
# if 'previous_page' not in globals(): # For avoiding errors in the first loop of the control
# previous_page = None
# current_page = None
# current_page = notebook3101w.get_current_page()
# if current_page != previous_page and previous_page != None: # Check if tab is switched
# UsersDetails.user_details_foreground_func() # Update the data on the tab
# previous_page = current_page
# if window3101w.get_visible() == True:
# GLib.timeout_add(200, users_details_tab_switch_control_func) # Check is performed in every 200 ms which is small enough for immediate update and not very frequent for avoiding high CPU usages.
# ----------------------------------- Users - Users Details Function (the code of this module in order to avoid running them during module import and defines "Users" tab GUI objects and functions/signals) -----------------------------------
def users_details_initial_func():
......@@ -67,7 +149,7 @@ def users_details_initial_func():
def users_details_foreground_func():
global selected_user_uid
selected_user_uid = str(Users.selected_user_uid) # Get right clicked disk name
selected_user_uid = str(Users.selected_user_uid) # Get right clicked disk name
# Get configrations one time per floop instead of getting them multiple times in every loop which causes high CPU usage.
global users_cpu_usage_percent_precision
......@@ -228,34 +310,34 @@ def users_details_foreground_func():
# Set Users Details window title and window icon image
UsersDetailsGUI.window3101w.set_title(_tr("User Details: ") + selected_user_username) # Set window title
UsersDetailsGUI.window3101w.set_icon(selected_user_account_image) # Set UsersDetails window icon
window3101w.set_title(_tr("User Details: ") + selected_user_username) # Set window title
window3101w.set_icon(selected_user_account_image) # Set UsersDetails window icon
# Set label text by using storage/disk data
UsersDetailsGUI.label3101w.set_text(selected_user_username)
UsersDetailsGUI.label3102w.set_text(selected_user_full_name)
UsersDetailsGUI.label3103w.set_text(selected_user_logged_in)
UsersDetailsGUI.label3104w.set_text(selected_user_uid)
UsersDetailsGUI.label3105w.set_text(selected_user_gid)
UsersDetailsGUI.label3106w.set_text(f'{selected_user_process_count}')
UsersDetailsGUI.label3107w.set_text(selected_user_home_dir)
UsersDetailsGUI.label3108w.set_text(selected_user_group_name)
UsersDetailsGUI.label3109w.set_text(selected_user_terminal)
UsersDetailsGUI.label3110w.set_text(selected_user_last_log_in_time)
UsersDetailsGUI.label3111w.set_text(selected_user_last_failed_log_in_time)
label3101w.set_text(selected_user_username)
label3102w.set_text(selected_user_full_name)
label3103w.set_text(selected_user_logged_in)
label3104w.set_text(selected_user_uid)
label3105w.set_text(selected_user_gid)
label3106w.set_text(f'{selected_user_process_count}')
label3107w.set_text(selected_user_home_dir)
label3108w.set_text(selected_user_group_name)
label3109w.set_text(selected_user_terminal)
label3110w.set_text(selected_user_last_log_in_time)
label3111w.set_text(selected_user_last_failed_log_in_time)
if selected_user_process_start_time != 0:
UsersDetailsGUI.label3112w.set_text(datetime.fromtimestamp(selected_user_process_start_time).strftime("%H:%M:%S %d.%m.%Y"))
label3112w.set_text(datetime.fromtimestamp(selected_user_process_start_time).strftime("%H:%M:%S %d.%m.%Y"))
if selected_user_process_start_time == 0:
UsersDetailsGUI.label3112w.set_text("-")
UsersDetailsGUI.label3113w.set_text(f'{selected_user_cpu_percent:.{users_cpu_usage_percent_precision}f} %')
UsersDetailsGUI.label3114w.set_text(f'{users_data_unit_converter_func(selected_user_ram_percent, users_ram_swap_data_unit, users_ram_swap_data_precision)}')
label3112w.set_text("-")
label3113w.set_text(f'{selected_user_cpu_percent:.{users_cpu_usage_percent_precision}f} %')
label3114w.set_text(f'{users_data_unit_converter_func(selected_user_ram_percent, users_ram_swap_data_unit, users_ram_swap_data_precision)}')
# ----------------------------------- Users - Users Details Loop Thread Function (runs the code in the function as threaded in order to avoid blocking/slowing down GUI operations and other operations) -----------------------------------
def users_details_loop_func():
if UsersDetailsGUI.window3101w.get_visible() is True:
if window3101w.get_visible() is True:
GLib.idle_add(users_details_foreground_func)
GLib.timeout_add(Config.update_interval * 1000, users_details_loop_func)
......
#!/usr/bin/env python3
# ----------------------------------- Users - Users Details Window GUI Import Function (contains import code of this module in order to avoid running them during module import) -----------------------------------
def users_details_gui_import_function():
global Gtk, os
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import os
# Import locale and gettext modules for defining translation texts which will be recognized by gettext application (will be run by programmer externally) and exported into a ".pot" file.
global _tr # This arbitrary variable will be recognized by gettext application for extracting texts to be translated
import locale
from locale import gettext as _tr
# Define contstants for language translation support
global application_name
application_name = "system-monitoring-center"
translation_files_path = "/usr/share/locale"
system_current_language = os.environ.get("LANG")
# Define functions for language translation support
locale.bindtextdomain(application_name, translation_files_path)
locale.textdomain(application_name)
locale.setlocale(locale.LC_ALL, system_current_language)
# ----------------------------------- Users - Users Details Window GUI Function (the code of this module in order to avoid running them during module import and defines "Users Details" window GUI objects and functions/signals) -----------------------------------
def users_details_gui_function():
# Users Details window GUI objects
global builder3101w, window3101w
global label3101w, label3102w, label3103w, label3104w, label3105w, label3106w, label3107w, label3108w, label3109w, label3110w
global label3111w, label3112w, label3113w, label3114w
# Users Details window GUI objects - get
builder3101w = Gtk.Builder()
builder3101w.add_from_file(os.path.dirname(os.path.realpath(__file__)) + "/../ui/UsersDetailsWindow.ui")
window3101w = builder3101w.get_object('window3101w')
# Users Details window GUI objects
label3101w = builder3101w.get_object('label3101w')
label3102w = builder3101w.get_object('label3102w')
label3103w = builder3101w.get_object('label3103w')
label3104w = builder3101w.get_object('label3104w')
label3105w = builder3101w.get_object('label3105w')
label3106w = builder3101w.get_object('label3106w')
label3107w = builder3101w.get_object('label3107w')
label3108w = builder3101w.get_object('label3108w')
label3109w = builder3101w.get_object('label3109w')
label3110w = builder3101w.get_object('label3110w')
label3111w = builder3101w.get_object('label3111w')
label3112w = builder3101w.get_object('label3112w')
label3113w = builder3101w.get_object('label3113w')
label3114w = builder3101w.get_object('label3114w')
# Users Details window GUI functions
def on_window3101w_delete_event(widget, event):
window3101w.hide()
return True
def on_window3101w_show(widget):
users_details_gui_reset_function() # Call this function in order to reset Users Details window. Data from previous user remains visible (for a short time) until getting and showing new user data if window is closed and opened for an another user because window is made hidden when close button is clicked.
# Users Details window GUI functions - connect
window3101w.connect("delete-event", on_window3101w_delete_event)
window3101w.connect("show", on_window3101w_show)
# ----------------------------------- Users - Users Details Window GUI Reset Function (resets Users Details window) -----------------------------------
def users_details_gui_reset_function():
window3101w.set_title(_tr("User Details")) # Reset window title
window3101w.set_icon_name("system-monitoring-center-user-symbolic") # Reset window icon
label3101w.set_text("--")
label3102w.set_text("--")
label3103w.set_text("--")
label3104w.set_text("--")
label3105w.set_text("--")
label3106w.set_text("--")
label3107w.set_text("--")
label3108w.set_text("--")
label3109w.set_text("--")
label3110w.set_text("--")
label3111w.set_text("--")
label3112w.set_text("--")
label3113w.set_text("--")
label3114w.set_text("--")
# # ----------------------------------- Users - Users Details Tab Switch Control Function (controls if tab is switched and updates data on the last opened tab immediately without waiting end of the update interval. Signals of notebook for tab switching is not useful because it performs the action and after that it switches the tab. Data updating function does not recognizes tab switch due to this reason.) -----------------------------------
# def users_details_tab_switch_control_func():
#
# global previous_page
# if 'previous_page' not in globals(): # For avoiding errors in the first loop of the control
# previous_page = None
# current_page = None
# current_page = notebook3101w.get_current_page()
# if current_page != previous_page and previous_page != None: # Check if tab is switched
# UsersDetails.user_details_foreground_func() # Update the data on the tab
# previous_page = current_page
# if window3101w.get_visible() == True:
# GLib.timeout_add(200, users_details_tab_switch_control_func) # Check is performed in every 200 ms which is small enough for immediate update and not very frequent for avoiding high CPU usages.
......@@ -28,13 +28,12 @@ def users_menu_right_click_gui_func():
# ********************** Define object functions for Users tab right click menu **********************
def on_menuitem3101m_activate(widget): # "Details" item on the right click menu
if 'UsersDetailsGUI' not in globals(): # Check if "UsersDetailsGUI" module is imported. Therefore it is not reimported for every click on "Details" menu item on right click menu if "UsersDetailsGUI" name is in globals().
global UsersDetails, UsersDetailsGUI
import UsersDetails, UsersDetailsGUI
UsersDetailsGUI.users_details_gui_import_function()
UsersDetailsGUI.users_details_gui_function()
if 'UsersDetails' not in globals(): # Check if "UsersDetails" module is imported. Therefore it is not reimported for every click on "Details" menu item on right click menu if "UsersDetails" name is in globals().
global UsersDetails
import UsersDetails
UsersDetails.users_details_import_func()
UsersDetailsGUI.window3101w.show()
UsersDetails.users_details_gui_function()
UsersDetails.window3101w.show()
UsersDetails.users_details_foreground_thread_run_func()
# ********************** Connect signals to GUI objects for Users tab right click menu **********************
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment