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

Commit

Permalink
Visual improvements for Summary tab graphics
Browse files Browse the repository at this point in the history
  • Loading branch information
hakandundar34coding committed Nov 30, 2022
1 parent 3f1cc2d commit deb23df
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 101 deletions.
6 changes: 6 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# System Monitoring Center

### v2.1.0 (28.11.2022)
* New: Cell colors for process CPU,memory,disk data
* Improvements for system integration
* Updated: Portuguese (Portugal) translations
* Minor GUI improvements for menus

### v1.34.0 (25.11.2022)
* Fix: Resetting all settings when GPU tab is open
* Several improvements (code, setup files, etc.)
Expand Down
10 changes: 1 addition & 9 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,7 @@ include integration/io.github.hakandundar34coding.system-monitoring-center.deskt
include database/*
include src/*.py
include src/__version__
include locale/de/LC_MESSAGES/*
include locale/cs/LC_MESSAGES/*
include locale/fa/LC_MESSAGES/*
include locale/hu/LC_MESSAGES/*
include locale/pl/LC_MESSAGES/*
include locale/pt_BR/LC_MESSAGES/*
include locale/pt_PT/LC_MESSAGES/*
include locale/ru_RU/LC_MESSAGES/*
include locale/tr/LC_MESSAGES/*
include ui/*.ui
include locale/*/LC_MESSAGES/*
include setup.py
recursive-include icons *
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<strong>
Translations:
</strong>
Czech | German | English | Persian | Hungarian | Polish | Portuguese (Brazilian) | Portuguese(European) | Russian | Turkish | <a href="docs/notes_for_translators.md">Notes for translators</a>
Czech | German | English | Persian | Hungarian | Polish | Portuguese (Brazilian) | Portuguese (Portugal) | Russian | Turkish | <a href="docs/notes_for_translators.md">Notes for translators</a>
</p>


Expand Down
51 changes: 21 additions & 30 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ def files_in_folder(folder):
return file_paths


def files_in_locale_folder(folder):
file_paths = []
for file in [filename for filename in os.listdir(folder) if filename.split(".")[-1] not in ["pot", "sh"]]:
file_paths.append(folder + file + "/LC_MESSAGES/system-monitoring-center.mo")
return file_paths


def data_files_in_locale_folder(target_folder, folder):
data_files_in_locale_folder = []
for file in [filename for filename in os.listdir(folder) if filename.split(".")[-1] not in ["pot", "sh"]]:
data_files_in_locale_folder.append((target_folder + file + "/LC_MESSAGES/", [folder + file + "/LC_MESSAGES/system-monitoring-center.mo"]))
return data_files_in_locale_folder


# Python package
if "egg_info" in sys.argv or "sdist" in sys.argv or "bdist_wheel" in sys.argv:
for argv in sys.argv:
Expand All @@ -36,15 +50,8 @@ def files_in_folder(folder):
entry_points={}

os.chmod("integration/io.github.hakandundar34coding.system-monitoring-center.desktop", 0o644)
os.chmod("locale/de/LC_MESSAGES/system-monitoring-center.mo", 0o644)
os.chmod("locale/cs/LC_MESSAGES/system-monitoring-center.mo", 0o644)
os.chmod("locale/fa/LC_MESSAGES/system-monitoring-center.mo", 0o644)
os.chmod("locale/hu/LC_MESSAGES/system-monitoring-center.mo", 0o644)
os.chmod("locale/pl/LC_MESSAGES/system-monitoring-center.mo", 0o644)
os.chmod("locale/pt_BR/LC_MESSAGES/system-monitoring-center.mo", 0o644)
os.chmod("locale/pt_PT/LC_MESSAGES/system-monitoring-center.mo", 0o644)
os.chmod("locale/ru_RU/LC_MESSAGES/system-monitoring-center.mo", 0o644)
os.chmod("locale/tr/LC_MESSAGES/system-monitoring-center.mo", 0o644)
for file in files_in_locale_folder("locale/"):
os.chmod(file, 0o644)
for file in files_in_folder("database/"):
os.chmod(file, 0o644)
for file in files_in_folder("src/"):
Expand All @@ -58,23 +65,15 @@ def files_in_folder(folder):
data_files = [
("/usr/share/applications/", ["integration/io.github.hakandundar34coding.system-monitoring-center.desktop"]),
("/usr/share/polkit-1/actions/", ["integration/io.github.hakandundar34coding.system-monitoring-center.policy"]),
("/usr/share/system-monitoring-center/locale/de/LC_MESSAGES/", ["locale/de/LC_MESSAGES/system-monitoring-center.mo"]),
("/usr/share/system-monitoring-center/locale/cs/LC_MESSAGES/", ["locale/cs/LC_MESSAGES/system-monitoring-center.mo"]),
("/usr/share/system-monitoring-center/locale/fa/LC_MESSAGES/", ["locale/fa/LC_MESSAGES/system-monitoring-center.mo"]),
("/usr/share/system-monitoring-center/locale/hu/LC_MESSAGES/", ["locale/hu/LC_MESSAGES/system-monitoring-center.mo"]),
("/usr/share/system-monitoring-center/locale/pl/LC_MESSAGES/", ["locale/pl/LC_MESSAGES/system-monitoring-center.mo"]),
("/usr/share/system-monitoring-center/locale/pt_BR/LC_MESSAGES/", ["locale/pt_BR/LC_MESSAGES/system-monitoring-center.mo"]),
("/usr/share/system-monitoring-center/locale/pt_PT/LC_MESSAGES/", ["locale/pt_PT/LC_MESSAGES/system-monitoring-center.mo"]),
("/usr/share/system-monitoring-center/locale/ru_RU/LC_MESSAGES/", ["locale/ru_RU/LC_MESSAGES/system-monitoring-center.mo"]),
("/usr/share/system-monitoring-center/locale/tr/LC_MESSAGES/", ["locale/tr/LC_MESSAGES/system-monitoring-center.mo"]),
("/usr/share/system-monitoring-center/database/", files_in_folder("database/")),
("/usr/share/system-monitoring-center/src/", files_in_folder("src/")),
("/usr/share/system-monitoring-center/ui/", files_in_folder("ui/")),
("/usr/share/icons/hicolor/scalable/actions/", files_in_folder("icons/hicolor/scalable/actions/")),
("/usr/share/system-monitoring-center/icons/hicolor/scalable/actions/", files_in_folder("icons/hicolor/scalable/actions/")),
("/usr/share/system-monitoring-center/icons/hicolor/scalable/apps/", ["icons/hicolor/scalable/apps/system-monitoring-center.svg"]),
("/usr/share/icons/hicolor/scalable/apps/", ["icons/hicolor/scalable/apps/system-monitoring-center.svg"]),
("/usr/share/man/man1/", ["man/system-monitoring-center.1.gz"]),
("/usr/bin/", ["integration/system-monitoring-center"])
]
] + data_files_in_locale_folder("/usr/share/system-monitoring-center/locale/", "locale/")


if package_type_var == "python_package":
Expand All @@ -84,21 +83,12 @@ def files_in_folder(folder):

data_files = [
("/systemmonitoringcenter/integration/", ["integration/io.github.hakandundar34coding.system-monitoring-center.desktop"]),
("/systemmonitoringcenter/locale/de/LC_MESSAGES/", ["locale/de/LC_MESSAGES/system-monitoring-center.mo"]),
("/systemmonitoringcenter/locale/cs/LC_MESSAGES/", ["locale/cs/LC_MESSAGES/system-monitoring-center.mo"]),
("/systemmonitoringcenter/locale/fa/LC_MESSAGES/", ["locale/fa/LC_MESSAGES/system-monitoring-center.mo"]),
("/systemmonitoringcenter/locale/hu/LC_MESSAGES/", ["locale/hu/LC_MESSAGES/system-monitoring-center.mo"]),
("/systemmonitoringcenter/locale/pl/LC_MESSAGES/", ["locale/pl/LC_MESSAGES/system-monitoring-center.mo"]),
("/systemmonitoringcenter/locale/pt_BR/LC_MESSAGES/", ["locale/pt_BR/LC_MESSAGES/system-monitoring-center.mo"]),
("/systemmonitoringcenter/locale/pt_PT/LC_MESSAGES/", ["locale/pt_PT/LC_MESSAGES/system-monitoring-center.mo"]),
("/systemmonitoringcenter/locale/ru_RU/LC_MESSAGES/", ["locale/ru_RU/LC_MESSAGES/system-monitoring-center.mo"]),
("/systemmonitoringcenter/locale/tr/LC_MESSAGES/", ["locale/tr/LC_MESSAGES/system-monitoring-center.mo"]),
("/systemmonitoringcenter/database/", files_in_folder("database/")),
("/systemmonitoringcenter/src/", files_in_folder("src/")),
("/systemmonitoringcenter/ui/", files_in_folder("ui/")),
("/systemmonitoringcenter/icons/hicolor/scalable/actions/", files_in_folder("icons/hicolor/scalable/actions/")),
("/systemmonitoringcenter/icons/hicolor/scalable/apps/", ["icons/hicolor/scalable/apps/system-monitoring-center.svg"]),
]
] + data_files_in_locale_folder("/systemmonitoringcenter/locale/", "locale/")


setup(
Expand Down Expand Up @@ -131,3 +121,4 @@ def files_in_folder(folder):
"Topic :: System :: Monitoring",
],
)

91 changes: 36 additions & 55 deletions src/MainGUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from gi.repository import Gtk, GLib
import os

# "_tr" arbitrary variable will be recognized by gettext application for extracting texts to be translated
import locale
from locale import gettext as _tr

Expand Down Expand Up @@ -37,6 +36,10 @@ def __init__(self):
# Detect environment type (Flatpak or native). This information will be used for accessing host OS commands if the application is run in Flatpak environment.
self.main_gui_environment_type_detection_func()

# Add images to the image theme. These images are used for application GUI.
image_theme = Gtk.IconTheme. get_default()
image_theme.append_search_path(os.path.dirname(os.path.realpath(__file__)) + "/../icons")

# Generate symbolic links for GUI icons and application shortcut (.desktop file) in user folders if they are not generated.
self.main_gui_application_system_integration_func()

Expand Down Expand Up @@ -828,31 +831,38 @@ def main_gui_tab_loop_func(self, *args):
self.main_glib_source.attach(GLib.MainContext.default())


# ----------------------- Called for detecting environment type (Flatpak or native). This information will be used for accessing host OS commands if the application is run in Flatpak environment. -----------------------
# ----------------------- Called for detecting environment type (Flatpak or native). -----------------------
def main_gui_environment_type_detection_func(self):
"""
Detect environment type (Flatpak, Python package or native).
This information will be used for accessing host OS commands if the application is run in Flatpak
environment or for showing new version information, etc. if the application is a Python package.
"""

# Get OS version information.
os_version = "-"
with open("/etc/os-release") as reader:
os_release_output_lines = reader.read().strip().split("\n")

for line in os_release_output_lines:
if line.startswith("VERSION="):
os_version = line.split("VERSION=")[1].strip(' "')
break
current_dir = os.path.dirname(os.path.realpath(__file__))
current_user_homedir = os.environ.get('HOME')
application_flatpak_id = os.getenv('FLATPAK_ID')

if "flatpak runtime" in os_version.lower():
if application_flatpak_id != None:
environment_type = "flatpak"

elif current_dir.startswith("/usr/local/lib/python") == True or current_dir.startswith(current_user_homedir + "/.local/lib/python") == True:
environment_type = "python_package"

else:
environment_type = "native"

Config.environment_type = environment_type


# ----------------------- Called for copying files for GUI icons and application shortcut (.desktop file) in user folders if they are not copied before. -----------------------
# ----------------------- Called for copying application image and shortcut (.desktop file) in user folders if they are not copied before. -----------------------
def main_gui_application_system_integration_func(self):
"""
Copy files for application shortcut (.desktop file) in user folders if they are not copied before.
Because these files are not copied if the application is installed as a Python package.
"""

if Config.environment_type == "flatpak":
if Config.environment_type != "python_package":
return

# Called for removing files.
Expand All @@ -876,52 +886,23 @@ def copy_file(source, target):
except Exception:
pass

# Get current directory (which code of this application is in) and current user home directory (files will be copied in).
# Get current directory (which the code is in) and current user home directory (files will be copied in).
current_dir = os.path.dirname(os.path.realpath(__file__))
current_user_homedir = os.environ.get('HOME')

# Define folder list in the home directory for copying files in it.
home_dir_folder_list = [current_user_homedir + "/.local/share/applications/",
current_user_homedir + "/.local/share/icons/hicolor/scalable/actions/",
current_user_homedir + "/.local/share/icons/hicolor/scalable/apps/"]

# Generate folders to copy files in them if they are not generated before.
for folder in home_dir_folder_list:
if os.path.isdir(folder) == False:
generate_folder(folder)

# Get icon file paths in the home directory.
icon_list_actions = [current_user_homedir + "/.local/share/icons/hicolor/scalable/actions/" + file for file in os.listdir(current_user_homedir + "/.local/share/icons/hicolor/scalable/actions/") if file.startswith("system-monitoring-center-")]
icon_list_apps = [current_user_homedir + "/.local/share/icons/hicolor/scalable/apps/" + file for file in os.listdir(current_user_homedir + "/.local/share/icons/hicolor/scalable/apps/") if file.startswith("system-monitoring-center.svg")]
icon_list_home = sorted(icon_list_actions + icon_list_apps)

# Get icon file paths in the installation directory. These files are copied under this statement in order to avoid copying them if this is a system package which copies GUI images into "/usr/share/icons/..." folder during installation.
try:
icon_list_actions = [current_dir + "/../icons/hicolor/scalable/actions/" + file for file in os.listdir(current_dir + "/../icons/hicolor/scalable/actions/") if file.startswith("system-monitoring-center-")]
icon_list_apps = [current_dir + "/../icons/hicolor/scalable/apps/" + file for file in os.listdir(current_dir + "/../icons/hicolor/scalable/apps/") if file.startswith("system-monitoring-center.svg")]
icon_list_current = sorted(icon_list_actions + icon_list_apps)

# Copy .desktop file if it is not copied before.
if os.path.isfile(current_user_homedir + "/.local/share/applications/io.github.hakandundar34coding.system-monitoring-center.desktop") == False:
# Try to remove if there is a broken symlink of the file (symlink was generated in previous versions of the application).
remove_file(current_user_homedir + "/.local/share/applications/io.github.hakandundar34coding.system-monitoring-center.desktop")
# Import module for copying files
import shutil
copy_file(current_dir + "/../integration/io.github.hakandundar34coding.system-monitoring-center.desktop", current_user_homedir + "/.local/share/applications/")
except Exception:
icon_list_current = []

# Check if number of icon files are different. Remove the files in the home directory and copy the files in the installation directory if they are different.
if len(icon_list_home) != len(icon_list_current):

# Import module for copying files
# Copy .desktop file
file_name = "io.github.hakandundar34coding.system-monitoring-center.desktop"
sub_folder_name = "/.local/share/applications/"
if os.path.isfile(current_user_homedir + sub_folder_name + file_name) == False:
import shutil
copy_file(current_dir + "/../integration/" + file_name, current_user_homedir + sub_folder_name)

for file in icon_list_home:
remove_file(file)

for file in icon_list_current:
copy_file(file, current_user_homedir + "/.local/share/icons/hicolor/scalable/" + file.split("/")[-2] + "/")
# Copy application image
file_name = "system-monitoring-center.svg"
sub_folder_name = "/.local/share/icons/hicolor/scalable/apps/"
if os.path.isfile(current_user_homedir + sub_folder_name + file_name) == False:
import shutil
copy_file(current_dir + "/../icons/hicolor/scalable/apps/" + file_name, current_user_homedir + sub_folder_name)


# Generate object
Expand Down
31 changes: 31 additions & 0 deletions src/MainMenusDialogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,43 @@ def on_button1001p_clicked(self, widget):
# ----------------------- "About" menu item -----------------------
def on_button1002p_clicked(self, widget):

# Get software version
self.popover1001p.hide()
try:
software_version = open(os.path.dirname(os.path.abspath(__file__)) + "/__version__").readline()
except Exception:
pass

# Define translators dictionary
translators_dic = {"cs": "panmourovaty",
"de": "Baumfinder",
"fa": "MasterKia",
"hu": "Kálmán Szalai",
"pl": "ski007, K0RR, sdorpl",
"pt_BR": "Bruno do Nascimento",
"pt_PT": "Ricardo Simões",
"ru_RU": "akorny",
"tr": "Hakan Dündar"
}

# Get GUI language for getting translator name
application_language = Config.language
if application_language == "system":
application_language = os.environ.get("LANG")
application_language_code = application_language.split(".")[0]
application_language_code_split = application_language_code.split("_")[0]

# Define translators list
try:
translators = '\n'.join(translators_dic[application_language_code].split(", "))
except Exception:
try:
translators = '\n'.join(translators_dic[application_language_code_split].split(", "))
except Exception:
translators = "-"

self.aboutdialog1001d.set_version(software_version)
self.aboutdialog1001d.set_translator_credits(translators)
self.aboutdialog1001d.set_transient_for(MainGUI.window1)
self.aboutdialog1001d.run()
self.aboutdialog1001d.hide()
Expand Down
Loading

0 comments on commit deb23df

Please sign in to comment.