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

Removed: Startup tab

üst 9d1ee7c5
......@@ -5,8 +5,10 @@ include database/*
include src/*.py
include src/__version__
include locale/cs/LC_MESSAGES/*
include locale/hu/LC_MESSAGES/*
include locale/pl/LC_MESSAGES/*
include locale/pt_BR/LC_MESSAGES/*
include locale/ru_RU/LC_MESSAGES/*
include locale/tr/LC_MESSAGES/*
include ui/*.ui
include setup.py
......
......@@ -45,7 +45,7 @@ Multi-featured system monitor.
### Features:
- Detailed system performance and usage usage monitoring/managing features:
- Monitoring CPU, RAM, Disk, Network, GPU hardware information/performance/usage
- Monitoring and managing processes, startup applications and services (systemd)
- Monitoring and managing processes and services (systemd)
- Monitoring users, sensors and general system information
- Supports PolicyKit. No need to run the application with "sudo"
- Hardware selection options (selecting different CPU cores, disks, network cards, GPUs)
......
......@@ -20,9 +20,9 @@ Terminal=false
Type=Application
Categories=System;
StartupNotify=true
Keywords=system monitor;task manager;performance;cpu;ram;swap;memory;disk;network;processes;users;startup;services;
Keywords[hu]=rendszerfigyelő;feladatkezelő;teljesítmény;cpu;ram;cserehely;memória;lemez;hálózat;folyamatok;felhasználók;indítás;szolgáltatások;
Keywords[pt_BR]=monitor do sistema;gerenciador de tarefas;desempenho;uso de CPU;uso de ram;memória swap;uso de memória;armazenamento;uso de rede;processos;usuários;programas de inicialização;serviços;
Keywords[tr]=sistem gözlemcisi;görev yöneticisi;performans;cpu;mib;ram;takas;bellek;disk;işlemler;kullanıcılar;başlangıç;servisler;
Keywords[ru_RU]=системный монитор;менеджер задач;производительность;cpu;ram;подкачка;память;диск;сеть;процессы;пользователи;автозагрузка;сервисы;
Keywords=system monitor;task manager;performance;cpu;ram;swap;memory;disk;network;processes;users;services;
Keywords[hu]=rendszerfigyelő;feladatkezelő;teljesítmény;cpu;ram;cserehely;memória;lemez;hálózat;folyamatok;felhasználók;szolgáltatások;
Keywords[pt_BR]=monitor do sistema;gerenciador de tarefas;desempenho;uso de CPU;uso de ram;memória swap;uso de memória;armazenamento;uso de rede;processos;usuários;serviços;
Keywords[tr]=sistem gözlemcisi;görev yöneticisi;performans;cpu;mib;ram;takas;bellek;disk;işlemler;kullanıcılar;servisler;
Keywords[ru_RU]=системный монитор;менеджер задач;производительность;cpu;ram;подкачка;память;диск;сеть;процессы;пользователи;сервисы;
......@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-06-12 11:25+0300\n"
"POT-Creation-Date: 2022-06-14 13:12+0300\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
......@@ -26,7 +26,7 @@ msgid "CPU Usage (Per Core)"
msgstr ""
#: src/Cpu.py:348 src/Disk.py:294 src/Disk.py:296 src/Gpu.py:290 src/Gpu.py:292
#: src/Network.py:122 src/Network.py:124
#: src/Network.py:198 src/Network.py:200
msgid "Unknown"
msgstr ""
......@@ -42,17 +42,17 @@ msgstr ""
msgid "Disk"
msgstr ""
#: src/Disk.py:302 src/Disk.py:412 src/Performance.py:1007
#: src/Disk.py:302 src/Disk.py:412 src/Performance.py:1108
msgid "Swap"
msgstr ""
#: src/Disk.py:387 src/Gpu.py:243 src/Gpu.py:246 src/Network.py:215
#: src/Network.py:243 src/Services.py:171 src/ServicesDetails.py:128
#: src/Disk.py:387 src/Gpu.py:243 src/Gpu.py:246 src/Network.py:260
#: src/Network.py:300 src/Services.py:171 src/ServicesDetails.py:128
#: src/UsersDetails.py:213
msgid "Yes"
msgstr ""
#: src/Disk.py:389 src/Gpu.py:248 src/Network.py:217 src/Services.py:171
#: src/Disk.py:389 src/Gpu.py:248 src/Network.py:262 src/Services.py:171
#: src/ServicesDetails.py:128 src/UsersDetails.py:215
msgid "No"
msgstr ""
......@@ -66,33 +66,33 @@ msgstr ""
msgid "Disk Details"
msgstr ""
#: src/MainGUI.py:173
#: src/MainGUI.py:171
msgid ""
"Warning! The application has been run with root privileges, you may harm "
"your system."
msgstr ""
#: src/MainGUI.py:224
#: src/MainGUI.py:222
msgid "There is a newer version on PyPI."
msgstr ""
#: src/MainGUI.py:538 src/SettingsGUI.py:51 ui/MainWindow.ui:182
#: src/MainGUI.py:516 src/SettingsGUI.py:51 ui/MainWindow.ui:182
#: ui/ProcessesDetailsWindow.ui:709 ui/ServicesDetailsWindow.ui:613
#: ui/SummaryTab.ui:21
msgid "Summary"
msgstr ""
#: src/MainGUI.py:548
#: src/MainGUI.py:526
msgid "CPU core selection affects only frequency and cache memory information."
msgstr ""
#: src/MainGUI.py:552 src/Memory.py:180 src/Performance.py:989
#: src/Performance.py:1292 ui/MemoryMenus.ui:131 ui/MemoryTab.ui:28
#: src/MainGUI.py:530 src/Memory.py:180 src/Performance.py:1090
#: src/Performance.py:1406 ui/MemoryMenus.ui:131 ui/MemoryTab.ui:28
#: ui/PerformanceSummaryHeaderBarGrid.ui:52
msgid "RAM"
msgstr ""
#: src/MainGUI.py:552 src/Memory.py:207 src/Performance.py:1292
#: src/MainGUI.py:530 src/Memory.py:207 src/Performance.py:1406
#: ui/MemoryTab.ui:504 ui/ProcessesDetailsWindow.ui:902
msgid "Swap Memory"
msgstr ""
......@@ -116,7 +116,7 @@ msgid "Number Of Devices"
msgstr ""
#: src/MemoryRamHardware.py:124 src/MemoryRamHardware.py:144
#: src/MemorySwapDetails.py:96 src/Startup.py:114 ui/DiskDetailsWindow.ui:84
#: src/MemorySwapDetails.py:96 ui/DiskDetailsWindow.ui:84
#: ui/ServicesDetailsWindow.ui:225
msgid "Type"
msgstr ""
......@@ -141,14 +141,14 @@ msgstr ""
msgid "Bank Locator"
msgstr ""
#: src/MemorySwapDetails.py:66 src/StartupNewItem.py:137
#: src/MemorySwapDetails.py:66
msgid "File"
msgstr ""
#: src/MemorySwapDetails.py:95 src/Processes.py:185 src/Sensors.py:83
#: src/Services.py:139 src/Startup.py:112 ui/ProcessesDetailsWindow.ui:48
#: src/Services.py:139 ui/ProcessesDetailsWindow.ui:48
#: ui/ProcessesMenuCustomizations.ui:177 ui/ServicesDetailsWindow.ui:49
#: ui/ServicesMenuCustomizations.ui:107 ui/StartupNewItemWindow.ui:193
#: ui/ServicesMenuCustomizations.ui:107
msgid "Name"
msgstr ""
......@@ -162,19 +162,19 @@ msgstr ""
msgid "Priority"
msgstr ""
#: src/Network.py:132
#: src/Network.py:208
msgid "Virtual Network Interface"
msgstr ""
#: src/Network.py:136
#: src/Network.py:217
msgid "Ethernet"
msgstr ""
#: src/Network.py:138
#: src/Network.py:219
msgid "Wi-Fi"
msgstr ""
#: src/Performance.py:980 src/Processes.py:189 src/SettingsGUI.py:51
#: src/Performance.py:1081 src/Processes.py:189 src/SettingsGUI.py:51
#: src/Users.py:142 ui/CpuMenus.ui:23 ui/CpuMenus.ui:155 ui/CpuTab.ui:453
#: ui/MainWindow.ui:229 ui/PerformanceSummaryHeaderBarGrid.ui:17
#: ui/ProcessesDetailsWindow.ui:113 ui/ProcessesDetailsWindow.ui:741
......@@ -184,30 +184,30 @@ msgstr ""
msgid "CPU"
msgstr ""
#: src/Performance.py:998 src/Processes.py:626 src/SettingsGUI.py:50
#: src/Performance.py:1099 src/Processes.py:626 src/SettingsGUI.py:50
#: src/Users.py:137 ui/MainWindow.ui:675 ui/ProcessesMenuCustomizations.ui:23
#: ui/ProcessesTab.ui:48 ui/UsersDetailsWindow.ui:110
#: ui/UsersMenuCustomizations.ui:179
msgid "Processes"
msgstr ""
#: src/Performance.py:1143 src/Processes.py:195 ui/DiskMenus.ui:121
#: src/Performance.py:1257 src/Processes.py:195 ui/DiskMenus.ui:121
#: ui/DiskTab.ui:69 ui/ProcessesDetailsWindow.ui:139
#: ui/ProcessesDetailsWindow.ui:1281 ui/ProcessesMenuCustomizations.ui:347
msgid "Read Speed"
msgstr ""
#: src/Performance.py:1150 src/Processes.py:196 ui/DiskMenus.ui:134
#: src/Performance.py:1264 src/Processes.py:196 ui/DiskMenus.ui:134
#: ui/DiskTab.ui:81 ui/ProcessesDetailsWindow.ui:664
#: ui/ProcessesDetailsWindow.ui:1294 ui/ProcessesMenuCustomizations.ui:361
msgid "Write Speed"
msgstr ""
#: src/Performance.py:1157 ui/NetworkMenus.ui:121 ui/NetworkTab.ui:113
#: src/Performance.py:1271 ui/NetworkMenus.ui:121 ui/NetworkTab.ui:113
msgid "Download Speed"
msgstr ""
#: src/Performance.py:1164 ui/NetworkMenus.ui:134 ui/NetworkTab.ui:101
#: src/Performance.py:1278 ui/NetworkMenus.ui:134 ui/NetworkTab.ui:101
msgid "Upload Speed"
msgstr ""
......@@ -317,9 +317,8 @@ msgstr ""
msgid "Dead"
msgstr ""
#: src/Processes.py:626 src/Sensors.py:341 src/Services.py:455
#: src/Startup.py:411 src/Users.py:501 ui/ProcessesTab.ui:66
#: ui/SensorsTab.ui:66 ui/ServicesTab.ui:99 ui/StartupTab.ui:66
#: src/Processes.py:626 src/Sensors.py:341 src/Services.py:455 src/Users.py:501
#: ui/ProcessesTab.ui:66 ui/SensorsTab.ui:66 ui/ServicesTab.ui:99
#: ui/UsersTab.ui:66
msgid "Search..."
msgstr ""
......@@ -438,7 +437,7 @@ msgstr ""
msgid "Exited"
msgstr ""
#: src/Services.py:455 src/SettingsGUI.py:50 ui/MainWindow.ui:816
#: src/Services.py:455 src/SettingsGUI.py:50 ui/MainWindow.ui:769
#: ui/ServicesMenuCustomizations.ui:23 ui/ServicesTab.ui:61
msgid "Services"
msgstr ""
......@@ -456,11 +455,7 @@ msgstr ""
msgid "Users"
msgstr ""
#: src/SettingsGUI.py:50 ui/MainWindow.ui:769 ui/StartupTab.ui:48
msgid "Startup"
msgstr ""
#: src/SettingsGUI.py:50 ui/MainWindow.ui:863 ui/SystemTab.ui:26
#: src/SettingsGUI.py:50 ui/MainWindow.ui:816 ui/SystemTab.ui:26
msgid "System"
msgstr ""
......@@ -480,38 +475,10 @@ msgstr ""
msgid "GPU"
msgstr ""
#: src/SettingsGUI.py:546
#: src/SettingsGUI.py:538
msgid "Do you want to reset all settings to defaults?"
msgstr ""
#: src/Startup.py:113 ui/StartupNewItemWindow.ui:105
msgid "Comment"
msgstr ""
#: src/Startup.py:411
msgid "Startup Items"
msgstr ""
#: src/StartupMenuRightClick.py:65
msgid "Do you want to delete this startup item?"
msgstr ""
#: src/StartupMenuRightClick.py:120 src/StartupNewItem.py:136
msgid "Startup Item"
msgstr ""
#: src/StartupMenuRightClick.py:121 ui/StartupNewItemWindow.ui:117
msgid "Command"
msgstr ""
#: src/StartupNewItem.py:134
msgid "Do you want to overwrite the existing file?"
msgstr ""
#: src/StartupNewItem.py:135
msgid "There is already a '.desktop' file with the same name."
msgstr ""
#: src/Users.py:133 ui/UsersDetailsWindow.ui:58
#: ui/UsersMenuCustomizations.ui:123
msgid "Full Name"
......@@ -532,7 +499,7 @@ msgstr ""
msgid "Group"
msgstr ""
#: src/Users.py:140 ui/StartupNewItemWindow.ui:163 ui/UsersDetailsWindow.ui:149
#: src/Users.py:140 ui/UsersDetailsWindow.ui:149
#: ui/UsersMenuCustomizations.ui:249
msgid "Terminal"
msgstr ""
......@@ -750,19 +717,19 @@ msgstr ""
msgid "Multi-featured system monitor."
msgstr ""
#: ui/MainMenusDialogs.ui:86
#: ui/MainMenusDialogs.ui:87
msgid "Settings"
msgstr ""
#: ui/MainMenusDialogs.ui:130
#: ui/MainMenusDialogs.ui:131
msgid "About"
msgstr ""
#: ui/MainWindow.ui:894
#: ui/MainWindow.ui:847
msgid "System Monitoring Center"
msgstr ""
#: ui/MainWindow.ui:902
#: ui/MainWindow.ui:855
msgid "Main Menu"
msgstr ""
......@@ -832,11 +799,11 @@ msgid ""
"(Smaller value means higher process priority)"
msgstr ""
#: ui/ProcessesCustomPriorityWindow.ui:84 ui/StartupNewItemWindow.ui:49
#: ui/ProcessesCustomPriorityWindow.ui:84
msgid "Save"
msgstr ""
#: ui/ProcessesCustomPriorityWindow.ui:96 ui/StartupNewItemWindow.ui:61
#: ui/ProcessesCustomPriorityWindow.ui:96
msgid "Cancel"
msgstr ""
......@@ -1104,41 +1071,6 @@ msgstr ""
msgid "Default main tab and sub-tab:"
msgstr ""
#: ui/StartupMenuRightClick.ui:12
msgid "Add"
msgstr ""
#: ui/StartupMenuRightClick.ui:19
msgid "Delete"
msgstr ""
#: ui/StartupMenuRightClick.ui:32
msgid "Open '.desktop' File..."
msgstr ""
#: ui/StartupNewItemWindow.ui:7
msgid "Add New Startup Item"
msgstr ""
#: ui/StartupNewItemWindow.ui:129
msgid "Icon"
msgstr ""
#: ui/StartupNewItemWindow.ui:149
msgid "Startup Notify"
msgstr ""
#: ui/StartupNewItemWindow.ui:180
msgid "Note: Name and Command fields cannot be left blank."
msgstr ""
#: ui/StartupTab.ui:84
msgid ""
"Note: Only user-specific startup items can be added/deleted. Auto-start of "
"an startup item depend on some values in its '.desktop' files and desktop "
"environment."
msgstr ""
#: ui/SystemTab.ui:64 ui/SystemTab.ui:310
msgid "Computer"
msgstr ""
......
......@@ -86,8 +86,6 @@ class Config:
self.config_default_processes_row_sort_column_order_func()
self.config_default_users_func()
self.config_default_users_row_sort_column_order_func()
self.config_default_startup_func()
self.config_default_startup_row_sort_column_order_func()
self.config_default_services_func()
self.config_default_services_row_sort_column_order_func()
......@@ -217,25 +215,6 @@ class Config:
self.users_data_column_widths = [-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
# ----------------------- Called for default Startup Tab settings -----------------------
def config_default_startup_func(self):
self.startup_treeview_columns_shown = [0, 1, 2]
self.startup_data_row_sorting_column = 0
self.startup_data_row_sorting_order = 0
self.startup_data_column_order = [0, 1, 2]
self.startup_data_column_widths = [-1, -1, -1]
# ----------------------- Called for default Startup Tab Row Sort Column Order Width settings -----------------------
def config_default_startup_row_sort_column_order_func(self):
self.startup_data_row_sorting_column = 0
self.startup_data_row_sorting_order = 0
self.startup_data_column_order = [0, 1, 2]
self.startup_data_column_widths = [-1, -1, -1]
# ----------------------- Called for default Services Tab settings -----------------------
def config_default_services_func(self):
......
......@@ -45,7 +45,6 @@ class MainGUI:
self.radiobutton1 = builder.get_object('radiobutton1')
self.radiobutton2 = builder.get_object('radiobutton2')
self.radiobutton3 = builder.get_object('radiobutton3')
self.radiobutton5 = builder.get_object('radiobutton5')
self.radiobutton6 = builder.get_object('radiobutton6')
self.radiobutton8 = builder.get_object('radiobutton8')
self.grid1 = builder.get_object('grid1')
......@@ -88,7 +87,6 @@ class MainGUI:
self.radiobutton1.connect("toggled", self.on_main_gui_tab_radiobuttons_toggled)
self.radiobutton2.connect("toggled", self.on_main_gui_tab_radiobuttons_toggled)
self.radiobutton3.connect("toggled", self.on_main_gui_tab_radiobuttons_toggled)
self.radiobutton5.connect("toggled", self.on_main_gui_tab_radiobuttons_toggled)
self.radiobutton6.connect("toggled", self.on_main_gui_tab_radiobuttons_toggled)
self.radiobutton8.connect("toggled", self.on_main_gui_tab_radiobuttons_toggled)
# Connect Main GUI - Performance tab GUI signals
......@@ -241,7 +239,7 @@ class MainGUI:
MainMenusDialogs.popover1001p.popup()
# ----------------------- "Performance, Processes, Users, Startup, Services, System, CPU, Memory, Disk, Network, GPU, Sensors" Radiobuttons -----------------------
# ----------------------- "Performance, Processes, Users, Services, System, CPU, Memory, Disk, Network, GPU, Sensors" Radiobuttons -----------------------
def on_main_gui_tab_radiobuttons_toggled(self, widget):
if widget.get_active() == True:
......@@ -259,10 +257,8 @@ class MainGUI:
elif default_main_tab == 2:
self.radiobutton3.set_active(True)
elif default_main_tab == 3:
self.radiobutton5.set_active(True)
elif default_main_tab == 4:
self.radiobutton6.set_active(True)
elif default_main_tab == 5:
elif default_main_tab == 4:
self.radiobutton8.set_active(True)
performance_tab_default_sub_tab = Config.performance_tab_default_sub_tab
......@@ -467,31 +463,13 @@ class MainGUI:
Users.users_loop_func()
return
# Switch to "Startup" tab
elif self.radiobutton5.get_active() == True:
self.stack1.set_visible_child(self.grid5)
if remember_last_opened_tabs_on_application_start == 1:
Config.default_main_tab = 3
Config.config_save_func()
Config.current_main_tab = 3
if 'Startup' not in globals():
global Startup
import Startup
Startup.startup_import_func()
Startup.startup_gui_func()
self.grid5.attach(Startup.grid5101, 0, 0, 1, 1)
if Startup.initial_already_run == 0:
Startup.startup_initial_func()
Startup.startup_loop_func()
return
# Switch to "Services" tab
elif self.radiobutton6.get_active() == True:
self.stack1.set_visible_child(self.grid6)
if remember_last_opened_tabs_on_application_start == 1:
Config.default_main_tab = 4
Config.default_main_tab = 3
Config.config_save_func()
Config.current_main_tab = 4
Config.current_main_tab = 3
if 'Services' not in globals():
global Services
import Services
......@@ -506,9 +484,9 @@ class MainGUI:
elif self.radiobutton8.get_active() == True:
self.stack1.set_visible_child(self.grid8)
if remember_last_opened_tabs_on_application_start == 1:
Config.default_main_tab = 5
Config.default_main_tab = 4
Config.config_save_func()
Config.current_main_tab = 5
Config.current_main_tab = 4
if self.grid8.get_child_at(0,0) == None:
global System
from System import System
......@@ -733,8 +711,6 @@ class MainGUI:
GLib.idle_add(Processes.processes_loop_func)
if current_main_tab == 2:
GLib.idle_add(Users.users_loop_func)
if current_main_tab == 3:
GLib.idle_add(Startup.startup_loop_func)
self.main_glib_source.set_callback(self.main_gui_tab_loop_func)
# Attach GLib.Source to MainContext. Therefore it will be part of the main loop until it is destroyed. A function may be attached to the MainContext multiple times.
......
......@@ -1115,7 +1115,7 @@ class Performance:
# Draw "%" labels below the CPU and RAM percentages on the inner circle of the circular gauge.
percentage_text = _tr("%")
percentage_text = "%"
ctx.set_font_size(gauge_percentage_label_text_below_cpu_ram_size)
text_extends = ctx.text_extents(percentage_text)
text_start_x = text_extends.width
......
......@@ -47,7 +47,7 @@ class SettingsGUI:
# Define data lists in order to add them into comboboxes.
self.update_interval_list = [0.5, 0.75, 1.0, 1.25, 1.5, 2.0, 3.0, 5.0, 10.0]
self.chart_data_history_list = [30, 60, 90, 120, 150, 180, 300, 600, 1200]
self.default_main_tab_list = [_tr("Performance"), _tr("Processes"), _tr("Users"), _tr("Startup"), _tr("Services"), _tr("System")]
self.default_main_tab_list = [_tr("Performance"), _tr("Processes"), _tr("Users"), _tr("Services"), _tr("System")]
self.performance_tab_default_sub_tab_list = [_tr("Summary"), _tr("CPU"), _tr("Memory"), _tr("Disk"), _tr("Network"), _tr("GPU"), _tr("Sensors")]
......@@ -486,12 +486,6 @@ class SettingsGUI:
except ImportError:
pass
try:
from MainGUI import Startup
Startup.initial_already_run = 0
except ImportError:
pass
try:
from MainGUI import Services
Services.initial_already_run = 0
......@@ -516,12 +510,10 @@ class SettingsGUI:
Config.default_main_tab = 1
elif MainGUI.radiobutton3.get_active() == True:
Config.default_main_tab = 2
elif MainGUI.radiobutton5.get_active() == True:
Config.default_main_tab = 3
elif MainGUI.radiobutton6.get_active() == True:
Config.default_main_tab = 4
Config.default_main_tab = 3
elif MainGUI.radiobutton8.get_active() == True:
Config.default_main_tab = 5
Config.default_main_tab = 4
if MainGUI.radiobutton1007.get_active() == True:
Config.performance_tab_default_sub_tab = 0
......
This diff is collapsed.
#!/usr/bin/env python3
# Import modules
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gio', '2.0')
from gi.repository import Gtk, Gio
import os
import subprocess
from threading import Thread
from locale import gettext as _tr
from Config import Config
import Startup
# Define class
class StartupMenuRightClick:
# ----------------------- Always called when object is generated -----------------------
def __init__(self):
# Get GUI objects from file
builder = Gtk.Builder()
builder.add_from_file(os.path.dirname(os.path.realpath(__file__)) + "/../ui/StartupMenuRightClick.ui")
# Get GUI objects
self.menu5101m = builder.get_object('menu5101m')
self.menuitem5102m = builder.get_object('menuitem5102m')
self.menuitem5103m = builder.get_object('menuitem5103m')
self.menuitem5105m = builder.get_object('menuitem5105m')
self.sub_menuitem5101m = builder.get_object('sub_menuitem5101m')
# Connect GUI signals
self.menuitem5102m.connect("activate", self.on_menuitem5102m_activate)
self.menuitem5103m.connect("activate", self.on_menuitem5103m_activate)
self.sub_menuitem5101m.connect("activate", self.on_sub_menuitem5101m_activate)
# ----------------------- "Add" item -----------------------
def on_menuitem5102m_activate(self, widget):
from StartupNewItem import StartupNewItem
StartupNewItem.window5101w.show()
# ----------------------- "Delete" item -----------------------
def on_menuitem5103m_activate(self, widget):
# Get startup application file name and application name.
selected_startup_application_file_name = Startup.selected_startup_application_file_name
selected_startup_application_name = Startup.selected_startup_application_name
# Get startup application exec value
# Initial value of "selected_startup_application_exec_value". This value will be used if it can not be get.
selected_startup_application_exec_value = ""
with open(selected_startup_application_file_name) as reader:
desktop_file_lines = reader.read().strip("").split("\n")
for line in desktop_file_lines:
if "Exec=" in line:
selected_startup_application_exec_value = line.split("=")[1]
# Show a warning dialog before deleting the startup item.
message_text = _tr("Do you want to delete this startup item?")
self.startup_warning_dialog(message_text, selected_startup_application_name, selected_startup_application_exec_value)
if self.warning_dialog5101_response == Gtk.ResponseType.YES:
try:
(subprocess.check_output(["rm", selected_startup_application_file_name], stderr=subprocess.STDOUT, shell=False)).decode()
except Exception:
pass
# ----------------------- "Open .desktop File" item -----------------------
def on_sub_menuitem5101m_activate(self, widget):
# Get startup application file name.
selected_startup_application_file_name = Startup.selected_startup_application_file_name
# Get applications which support "text/plain" MIME type. This is MIME type of ".desktop" files. This code gives "default application list" in the order of "open with ..." applications list. Last used application is the first application.
default_app_list_for_content_type = Gio.app_info_get_all_for_type('text/plain')
# Default application for the MIME type could be get. But it may give an application other than desired application for viewing/editing ".desktop" files if a text editor is not set default for this file.
# default_app_list_for_content_type = Gio.app_info_get_all_for_type('text/plain')
# Running action is performed in a separate thread for without waiting closing the new opened application.
def open_file():
# Open the file with "0th" appliation in the list.
subprocess.call([default_app_list_for_content_type[0].get_executable(), selected_startup_application_file_name])
# Define a thread and run it
try:
open_file_thread = Thread(target=open_file, daemon=True).start()
except FileNotFoundError:
pass
# ----------------------------------- Startup - Set Menu Labels Function (sets widget sensitivity of "Remove" menuitem and widget sensitivity and labels (system-wide and user-specific .desktop file names) of sub-menu items of "Browse '.desktop' File..." menu item when right click operation is performed on startup item row on the treeview) -----------------------------------
def startup_set_menu_labels_func(self):
# Get startup application file name and directory.
selected_startup_application_file_name = Startup.selected_startup_application_file_name
selected_startup_application_directory = selected_startup_application_file_name.rsplit("/", 1)[0] + "/"
# Check if this is a user-specific startup item and set "Run" menu item as sensitive/insensitive.
if selected_startup_application_directory == "/etc/xdg/autostart/":
self.menuitem5103m.set_sensitive(False)
else:
self.menuitem5103m.set_sensitive(True)
# Set menu item label by using startup item file path.
self.sub_menuitem5101m.set_label(selected_startup_application_file_name)
# ----------------------------------- Startup - Startup Run Startup Item Warning Dialog Function -----------------------------------
def startup_warning_dialog(self, message_text, selected_startup_application_name, selected_startup_application_exec_value):
warning_dialog5101 = Gtk.MessageDialog(transient_for=Startup.grid5101.get_toplevel(), title="", flags=0, message_type=Gtk.MessageType.WARNING,
buttons=Gtk.ButtonsType.YES_NO, text=message_text)
warning_dialog5101.format_secondary_text(_tr("Startup Item") + ": " + selected_startup_application_name +
"\n" + _tr("Command") + ": " + selected_startup_application_exec_value)
self.warning_dialog5101_response = warning_dialog5101.run()
warning_dialog5101.destroy()
# Generate object
StartupMenuRightClick = StartupMenuRightClick()
#!/usr/bin/env python3
# Import modules
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
import os
from locale import gettext as _tr
from Config import Config
import Startup
# Define class
class StartupNewItem:
# ----------------------- Always called when object is generated -----------------------
def __init__(self):
# Get GUI objects from file
builder5101w = Gtk.Builder()
builder5101w.add_from_file(os.path.dirname(os.path.realpath(__file__)) + "/../ui/StartupNewItemWindow.ui")
# Get GUI objects
self.window5101w = builder5101w.get_object('window5101w')
self.entry5101w = builder5101w.get_object('entry5101w')
self.entry5102w = builder5101w.get_object('entry5102w')
self.entry5103w = builder5101w.get_object('entry5103w')
self.entry5104w = builder5101w.get_object('entry5104w')
self.checkbutton5101w = builder5101w.get_object('checkbutton5101w')
self.checkbutton5102w = builder5101w.get_object('checkbutton5102w')
self.button5101w = builder5101w.get_object('button5101w')
self.button5102w = builder5101w.get_object('button5102w')
# Connect GUI signals
self.window5101w.connect("delete-event", self.on_window5101w_delete_event)
self.window5101w.connect("show", self.on_window5101w_show)
self.entry5101w.connect("changed", self.on_name_command_entries_changed)
self.entry5103w.connect("changed", self.on_name_command_entries_changed)
self.button5101w.connect("clicked", self.on_button5101w_clicked)
self.button5102w.connect("clicked", self.on_button5102w_clicked)
# ----------------------- Called for running code/functions when window is closed -----------------------
def on_window5101w_delete_event(self, widget, event):
self.window5101w.hide()
return True
# ----------------------- Called for running code/functions when GUI is shown -----------------------
def on_window5101w_show(self, widget):
# Reset GUI
self.entry5101w.set_text("")
self.entry5102w.set_text("")
self.entry5103w.set_text("")
self.entry5104w.set_text("")
self.checkbutton5101w.set_active(False)
self.checkbutton5102w.set_active(False)
self.button5102w.set_sensitive(False)
# ----------------------- Called for setting sensitivity of the "Save" button as "False" if "Name" and "Command" entries are empty. -----------------------
def on_name_command_entries_changed(self, widget):
if self.entry5101w.get_text() == "" or self.entry5103w.get_text() == "":
self.button5102w.set_sensitive(False)
if self.entry5101w.get_text() != "" and self.entry5103w.get_text() != "":
self.button5102w.set_sensitive(True)
# ----------------------- "Cancel" Button -----------------------
def on_button5101w_clicked(self, widget):
self.window5101w.hide()
# ----------------------- "Save" Button -----------------------
def on_button5102w_clicked(self, widget):
# Get user-specific autostart application directory.
current_user_home_directory = os.environ.get('HOME')
current_user_autostart_directory = current_user_home_directory + "/.config/autostart/"
# Get startup item infomation from the GUI.
new_startup_application_name = self.entry5101w.get_text()
new_startup_application_file_name = self.entry5101w.get_text() + ".desktop"
new_startup_application_comment = self.entry5102w.get_text()
new_startup_application_command = self.entry5103w.get_text()
new_startup_application_icon = self.entry5104w.get_text()
if self.checkbutton5101w.get_active() == True:
new_startup_application_startup_notify = "True"
else:
new_startup_application_startup_notify = "False"
if self.checkbutton5102w.get_active() == True:
new_startup_application_terminal = "True"
else:
new_startup_application_terminal = "False"
# Show a warning dialog if there is already a .desktop file with the same name.
if os.path.isfile(current_user_autostart_directory + new_startup_application_file_name) == True:
self.startup_overwrite_existing_startup_item_warning_dialog(new_startup_application_name, new_startup_application_file_name)
if warning_dialog5102_response != Gtk.ResponseType.YES:
return
# Save ".desktop" file in order to add the new startup item
with open(current_user_autostart_directory + new_startup_application_name + ".desktop", "w") as writer:
writer.write("[Desktop Entry]" + "\n")
writer.write("Type=Application" + "\n")
writer.write("Name=" + new_startup_application_name + "\n")
if new_startup_application_comment != "":
writer.write("Comment=" + new_startup_application_comment + "\n")
writer.write("Exec=" + new_startup_application_command + "\n")
if new_startup_application_icon != "":
writer.write("Icon=" + new_startup_application_icon + "\n")
if new_startup_application_startup_notify == "True":
writer.write("StartupNotify=true" + "\n")
if new_startup_application_startup_notify == "False":
writer.write("StartupNotify=false" + "\n")
if new_startup_application_terminal == "True":
writer.write("Terminal=true" + "\n")
if new_startup_application_terminal == "False":
writer.write("Terminal=false" + "\n")
self.window5101w.hide()
# ----------------------------------- Startup - Startup Overwrite Existing Startup Item Warning Dialog Function (shows a warning dialog when a new startup item file is tried to be generated with the same name of an existing one) -----------------------------------
def startup_overwrite_existing_startup_item_warning_dialog(self, new_startup_application_name, new_startup_application_file_name):
warning_dialog5102 = Gtk.MessageDialog(transient_for=Startup.grid5101.get_toplevel(), title="", flags=0, message_type=Gtk.MessageType.WARNING,
buttons=Gtk.ButtonsType.YES_NO, text=_tr("Do you want to overwrite the existing file?"))
warning_dialog5102.format_secondary_text(_tr("There is already a '.desktop' file with the same name.") +
"\n\n " + _tr("Startup Item") + ": " + new_startup_application_name +
"\n " + _tr("File") + ": " + new_startup_application_file_name)
self.warning_dialog5102_response = warning_dialog5102.run()
warning_dialog5102.destroy()
# Generate object
StartupNewItem = StartupNewItem()
......@@ -587,7 +587,7 @@
</packing>
</child>
<child>
<!-- n-columns=6 n-rows=1 -->
<!-- n-columns=5 n-rows=1 -->
<object class="GtkGrid">
<property name="width-request">660</property>
<property name="visible">True</property>
......@@ -735,53 +735,6 @@
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radiobutton5">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">False</property>
<property name="group">radiobutton1</property>
<child>
<!-- n-columns=1 n-rows=2 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="row-homogeneous">True</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="pixel-size">24</property>
<property name="icon-name">system-monitoring-center-startup-symbolic</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Startup</property>
<property name="ellipsize">end</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkRadioButton" id="radiobutton6">
<property name="visible">True</property>
......@@ -825,7 +778,7 @@
</child>
</object>
<packing>
<property name="left-attach">4</property>
<property name="left-attach">3</property>
<property name="top-attach">0</property>
</packing>
</child>
......@@ -872,7 +825,7 @@
</child>
</object>
<packing>
<property name="left-attach">5</property>
<property name="left-attach">4</property>
<property name="top-attach">0</property>
</packing>
</child>
......
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="3.22"/>
<object class="GtkMenu" id="menu5101m">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkMenuItem" id="menuitem5102m">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Add</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem5103m">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Delete</property>
</object>
</child>
<child>
<object class="GtkSeparatorMenuItem">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
</child>
<child>
<object class="GtkMenuItem" id="menuitem5105m">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Open '.desktop' File...</property>
<child type="submenu">
<object class="GtkMenu">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkMenuItem" id="sub_menuitem5101m">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label">--</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
This diff is collapsed.
This diff is collapsed.
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