From bcd7713a299cbec13471dd4c520192ef7345c6fe Mon Sep 17 00:00:00 2001 From: Timothy Feierabend Date: Thu, 20 Feb 2025 07:33:11 -0600 Subject: [PATCH 1/2] added webapp description entry field --- usr/lib/webapp-manager/common.py | 21 +- usr/lib/webapp-manager/webapp-manager.py | 7 +- usr/share/webapp-manager/webapp-manager.ui | 346 +++++++++++---------- 3 files changed, 209 insertions(+), 165 deletions(-) diff --git a/usr/lib/webapp-manager/common.py b/usr/lib/webapp-manager/common.py index 96025ea..b5a73c6 100644 --- a/usr/lib/webapp-manager/common.py +++ b/usr/lib/webapp-manager/common.py @@ -80,6 +80,7 @@ def __init__(self, path, codename): self.codename = codename self.web_browser = None self.name = None + self.desc = None self.icon = None self.is_valid = False self.exec = None @@ -104,6 +105,12 @@ def __init__(self, path, codename): self.name = line.replace("Name=", "") continue + if "Comment=" in line: + self.desc = line.replace("Comment=", "") + if self.desc == _("Web App"): + self.desc = "" + continue + if "Icon=" in line: self.icon = line.replace("Icon=", "") continue @@ -250,17 +257,20 @@ def delete_webbapp(self, webapp): os.remove(falkon_orig_prof_dir) shutil.rmtree(os.path.join(FALKON_PROFILES_DIR, webapp.codename), ignore_errors=True) - def create_webapp(self, name, url, icon, category, browser, custom_parameters, isolate_profile=True, navbar=False, privatewindow=False): + def create_webapp(self, name, desc, url, icon, category, browser, custom_parameters, isolate_profile=True, navbar=False, privatewindow=False): # Generate a 4 digit random code (to prevent name collisions, so we can define multiple launchers with the same name) random_code = ''.join(choice(string.digits) for _ in range(4)) codename = "".join(filter(str.isalpha, name)) + random_code path = os.path.join(APPS_DIR, "WebApp-%s.desktop" % codename) + if not desc: + desc = _("Web App") + with open(path, 'w') as desktop_file: desktop_file.write("[Desktop Entry]\n") desktop_file.write("Version=1.0\n") desktop_file.write("Name=%s\n" % name) - desktop_file.write("Comment=%s\n" % _("Web App")) + desktop_file.write("Comment=%s\n" % desc) exec_string = self.get_exec_string(browser, codename, custom_parameters, icon, isolate_profile, navbar, privatewindow, url) @@ -421,13 +431,16 @@ def get_exec_string(self, browser, codename, custom_parameters, icon, isolate_pr return exec_string - def edit_webapp(self, path, name, browser, url, icon, category, custom_parameters, codename, isolate_profile, navbar, privatewindow): + def edit_webapp(self, path, name, desc, browser, url, icon, category, custom_parameters, codename, isolate_profile, navbar, privatewindow): + if not desc: + desc = _("Web App") + config = configparser.RawConfigParser() config.optionxform = str config.read(path) config.set("Desktop Entry", "Name", name) config.set("Desktop Entry", "Icon", icon) - config.set("Desktop Entry", "Comment", _("Web App")) + config.set("Desktop Entry", "Comment", desc) config.set("Desktop Entry", "Categories", "GTK;%s;" % category) try: diff --git a/usr/lib/webapp-manager/webapp-manager.py b/usr/lib/webapp-manager/webapp-manager.py index fa403bf..ced00c0 100755 --- a/usr/lib/webapp-manager/webapp-manager.py +++ b/usr/lib/webapp-manager/webapp-manager.py @@ -89,6 +89,7 @@ def __init__(self, application): self.run_button = self.builder.get_object("run_button") self.ok_button = self.builder.get_object("ok_button") self.name_entry = self.builder.get_object("name_entry") + self.desc_entry = self.builder.get_object("desc_entry") self.url_entry = self.builder.get_object("url_entry") self.url_label = self.builder.get_object("url_label") self.customparameters_entry = self.builder.get_object("customparameters_entry") @@ -313,6 +314,7 @@ def on_ok_button(self, widget): category = self.category_combo.get_model()[self.category_combo.get_active()][CATEGORY_ID] browser = self.browser_combo.get_model()[self.browser_combo.get_active()][BROWSER_OBJ] name = self.name_entry.get_text() + desc = self.desc_entry.get_text() url = self.get_url() isolate_profile = self.isolated_switch.get_active() navbar = self.navbar_switch.get_active() @@ -326,10 +328,10 @@ def on_ok_button(self, widget): shutil.copyfile(icon, new_path) icon = new_path if self.edit_mode: - self.manager.edit_webapp(self.selected_webapp.path, name, browser, url, icon, category, custom_parameters, self.selected_webapp.codename, isolate_profile, navbar, privatewindow) + self.manager.edit_webapp(self.selected_webapp.path, name, desc, browser, url, icon, category, custom_parameters, self.selected_webapp.codename, isolate_profile, navbar, privatewindow) self.load_webapps() else: - self.manager.create_webapp(name, url, icon, category, browser, custom_parameters, isolate_profile, navbar, + self.manager.create_webapp(name, desc, url, icon, category, browser, custom_parameters, isolate_profile, navbar, privatewindow) self.load_webapps() @@ -355,6 +357,7 @@ def on_add_button(self, widget): def on_edit_button(self, widget): if self.selected_webapp is not None: self.name_entry.set_text(self.selected_webapp.name) + self.desc_entry.set_text(self.selected_webapp.desc) self.icon_chooser.set_icon(self.selected_webapp.icon) self.url_entry.set_text(self.selected_webapp.url) self.customparameters_entry.set_text(self.selected_webapp.custom_parameters) diff --git a/usr/share/webapp-manager/webapp-manager.ui b/usr/share/webapp-manager/webapp-manager.ui index b2b44a1..e71335a 100644 --- a/usr/share/webapp-manager/webapp-manager.ui +++ b/usr/share/webapp-manager/webapp-manager.ui @@ -1,66 +1,41 @@ - + True - False + False - False - 12 - 600 - 400 - webapp-manager - - - True - False - Web Apps - Manage your Web Apps - True - - - True - True - False - True - main_menu - - - True - False - open-menu-symbolic - - - - - - + False + 12 + 600 + 400 + webapp-manager True - False - slide-left-right + False + slide-left-right True - False + False vertical True - True - in + True + in True - False + False True - True - False + True + False @@ -78,31 +53,31 @@ True - False - icons - False + False + icons + False 1 True - False + False center True True - False + False True - False - False - Add + False + False + Add True - False - list-add-symbolic + False + list-add-symbolic @@ -116,14 +91,14 @@ True False - False - False - Remove + False + False + Remove True - False - list-remove-symbolic + False + list-remove-symbolic @@ -137,14 +112,14 @@ True False - False - False - Edit + False + False + Edit True - False - document-edit-symbolic + False + document-edit-symbolic @@ -158,14 +133,14 @@ True False - False - False - Launch + False + False + Launch True - False - web-browser-symbolic + False + web-browser-symbolic @@ -201,92 +176,93 @@ True - False + False center center vertical 12 + True - False - 12 - 12 + False + 12 + 12 True - False + False end Name: - 0 - 0 + 0 + 0 True - False + False end Address: - 0 - 1 + 0 + 2 True - False + False end Icon: - 0 - 2 + 0 + 3 True - True - 40 - Website name + True + 40 + Website name - 1 - 0 + 1 + 0 True - True - https://www.website.com - url + True + https://www.website.com + url - 1 - 1 + 1 + 2 True - False + False center center - 12 + 12 True - expand + expand Cancel True - True - True + True + True True @@ -299,8 +275,8 @@ OK True False - True - True + True + True True @@ -310,8 +286,8 @@ - 0 - 9 + 0 + 10 3 @@ -319,18 +295,18 @@ True False - True - True - Find icons online + True + True + Find icons online True - False + False True - False - insert-image-symbolic + False + insert-image-symbolic page_image @@ -338,7 +314,7 @@ - False + False page_spinner @@ -349,165 +325,189 @@ - 2 - 1 + 2 + 2 True - False + False vertical - 1 - 2 + 1 + 3 True - False + False end Category: - 0 - 3 + 0 + 4 True - False + False - 1 - 3 + 1 + 4 True - False + False - 1 - 4 + 1 + 5 True - False + False end Browser: - 0 - 4 + 0 + 5 True - True - If this option is enabled the website will run with its own browser profile. + True + If this option is enabled the website will run with its own browser profile. center True - 1 - 6 + 1 + 7 True - False + False end Isolated profile: - 0 - 6 + 0 + 7 True - True + True center - 1 - 7 + 1 + 8 True - False + False end Navigation bar: True - 20 + 20 - 0 - 7 + 0 + 8 True - True + True center - 1 - 8 + 1 + 9 True - False + False end Private/Incognito Window: True - 30 + 30 - 0 - 8 + 0 + 9 True - False + False end Custom parameters: - 0 - 5 + 0 + 6 True - True - 40 - Custom browser parameters + True + 40 + Custom browser parameters + + + 1 + 6 + + + + + True + False + end + Description: + + + 0 + 1 + + + + + True + True + 40 + Web App - 1 - 5 + 1 + 1 @@ -534,6 +534,9 @@ + + + False @@ -550,22 +553,22 @@ True - False + False vertical 6 True - True - in + True + in True - False + False True - False + False @@ -580,15 +583,15 @@ True - False + False vertical - start + start Cancel True - True - True + True + True True @@ -611,5 +614,30 @@ + + + True + False + Web Apps + Manage your Web Apps + True + + + True + True + False + True + main_menu + + + True + False + open-menu-symbolic + + + + + + From 52f292efb47cafc958edd5a31724f6d53c4b2986 Mon Sep 17 00:00:00 2001 From: Timothy Feierabend Date: Thu, 20 Feb 2025 07:58:52 -0600 Subject: [PATCH 2/2] strip whitespace from webapp description entry --- usr/lib/webapp-manager/webapp-manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr/lib/webapp-manager/webapp-manager.py b/usr/lib/webapp-manager/webapp-manager.py index ced00c0..375b49a 100755 --- a/usr/lib/webapp-manager/webapp-manager.py +++ b/usr/lib/webapp-manager/webapp-manager.py @@ -314,7 +314,7 @@ def on_ok_button(self, widget): category = self.category_combo.get_model()[self.category_combo.get_active()][CATEGORY_ID] browser = self.browser_combo.get_model()[self.browser_combo.get_active()][BROWSER_OBJ] name = self.name_entry.get_text() - desc = self.desc_entry.get_text() + desc = self.desc_entry.get_text().strip() url = self.get_url() isolate_profile = self.isolated_switch.get_active() navbar = self.navbar_switch.get_active()