summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Mikhaylenko <exalm7659@gmail.com>2020-09-25 15:31:11 +0500
committerAlexander Mikhaylenko <alexm@gnome.org>2020-09-25 17:20:22 +0500
commite6b7c0cc8410068ea9542f7ad6ea1f4ac608a9d3 (patch)
treed83036b834aa306fc96d439a71539a0698a854ec
parent6c849b7e801a98cb59131404671469e7d9a67e69 (diff)
downloadepiphany-e6b7c0cc8410068ea9542f7ad6ea1f4ac608a9d3.tar.gz
Hide web app preferences for system apps
Since system web apps have desktop file in /usr, they cannot be edited and the preferences do nothing. Introduce EPHY_WEB_APPLICATION_SYSTEM option, set it for any applications created via ephy_web_application_ensure_for_app_info(). Hide preferences for those apps.
-rw-r--r--data/org.gnome.epiphany.gschema.xml5
-rw-r--r--lib/ephy-prefs.h1
-rw-r--r--lib/ephy-web-app-utils.c11
-rw-r--r--lib/ephy-web-app-utils.h1
-rw-r--r--src/preferences/prefs-general-page.c17
5 files changed, 26 insertions, 9 deletions
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index be60ff9e5..d1341d4bf 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -257,6 +257,11 @@
<summary>Run in background</summary>
<description>If enabled, application continues running in the background after closing the window.</description>
</key>
+ <key type="b" name="system">
+ <default>false</default>
+ <summary>WebApp is system-wide</summary>
+ <description>If enabled, application cannot be edited or removed.</description>
+ </key>
</schema>
<schema id="org.gnome.Epiphany.state">
<key type="s" name="download-dir">
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index d42344190..6158df1e0 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -198,6 +198,7 @@ static const char * const ephy_prefs_web_schema[] = {
#define EPHY_PREFS_WEB_APP_ADDITIONAL_URLS "additional-urls"
#define EPHY_PREFS_WEB_APP_MOBILE_CAPABLE "mobile-capable"
#define EPHY_PREFS_WEB_APP_RUN_IN_BACKGROUND "run-in-background"
+#define EPHY_PREFS_WEB_APP_SYSTEM "system"
static struct {
const char *schema;
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c
index aff0bc29f..086d794b7 100644
--- a/lib/ephy-web-app-utils.c
+++ b/lib/ephy-web-app-utils.c
@@ -467,7 +467,7 @@ ephy_web_application_ensure_for_app_info (GAppInfo *app_info)
if (error)
g_warning ("Couldn't copy desktop file: %s", error->message);
- ephy_web_application_initialize_settings (profile_dir, EPHY_WEB_APPLICATION_NONE);
+ ephy_web_application_initialize_settings (profile_dir, EPHY_WEB_APPLICATION_SYSTEM);
}
return g_steal_pointer (&profile_dir);
@@ -793,12 +793,17 @@ ephy_web_application_initialize_settings (const char *profile_dir
g_object_unref (settings);
g_object_unref (web_app_settings);
- if (options & EPHY_WEB_APPLICATION_MOBILE_CAPABLE) {
+ if (options) {
path = g_build_path ("/", "/org/gnome/epiphany/web-apps/", name, "webapp/", NULL);
web_app_settings = g_settings_new_with_path (EPHY_PREFS_WEB_APP_SCHEMA, path);
g_free (path);
- g_settings_set_boolean (web_app_settings, EPHY_PREFS_WEB_APP_MOBILE_CAPABLE, TRUE);
+ if (options & EPHY_WEB_APPLICATION_MOBILE_CAPABLE)
+ g_settings_set_boolean (web_app_settings, EPHY_PREFS_WEB_APP_MOBILE_CAPABLE, TRUE);
+
+ if (options & EPHY_WEB_APPLICATION_SYSTEM)
+ g_settings_set_boolean (web_app_settings, EPHY_PREFS_WEB_APP_SYSTEM, TRUE);
+
g_object_unref (web_app_settings);
}
diff --git a/lib/ephy-web-app-utils.h b/lib/ephy-web-app-utils.h
index b51fdaf41..0044abf94 100644
--- a/lib/ephy-web-app-utils.h
+++ b/lib/ephy-web-app-utils.h
@@ -38,6 +38,7 @@ typedef struct {
typedef enum {
EPHY_WEB_APPLICATION_NONE,
EPHY_WEB_APPLICATION_MOBILE_CAPABLE,
+ EPHY_WEB_APPLICATION_SYSTEM,
} EphyWebApplicationOptions;
#define EPHY_WEB_APP_ICON_NAME "app-icon.png"
diff --git a/src/preferences/prefs-general-page.c b/src/preferences/prefs-general-page.c
index 42f5ada03..9bbe6bffe 100644
--- a/src/preferences/prefs-general-page.c
+++ b/src/preferences/prefs-general-page.c
@@ -1153,9 +1153,12 @@ setup_general_page (PrefsGeneralPage *general_page)
if (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ()) == EPHY_EMBED_SHELL_MODE_APPLICATION) {
general_page->webapp = ephy_web_application_for_profile_directory (ephy_profile_dir ());
g_assert (general_page->webapp);
- prefs_general_page_update_webapp_icon (general_page, general_page->webapp->icon_url);
- gtk_entry_set_text (GTK_ENTRY (general_page->webapp_url), general_page->webapp->url);
- gtk_entry_set_text (GTK_ENTRY (general_page->webapp_title), general_page->webapp->name);
+
+ if (!g_settings_get_boolean (EPHY_SETTINGS_WEB_APP, EPHY_PREFS_WEB_APP_SYSTEM)) {
+ prefs_general_page_update_webapp_icon (general_page, general_page->webapp->icon_url);
+ gtk_entry_set_text (GTK_ENTRY (general_page->webapp_url), general_page->webapp->url);
+ gtk_entry_set_text (GTK_ENTRY (general_page->webapp_title), general_page->webapp->name);
+ }
}
/* ======================================================================== */
@@ -1300,8 +1303,12 @@ prefs_general_page_init (PrefsGeneralPage *general_page)
gtk_widget_init_template (GTK_WIDGET (general_page));
+ setup_general_page (general_page);
+
gtk_widget_set_visible (general_page->webapp_box,
- mode == EPHY_EMBED_SHELL_MODE_APPLICATION);
+ mode == EPHY_EMBED_SHELL_MODE_APPLICATION &&
+ !g_settings_get_boolean (EPHY_SETTINGS_WEB_APP,
+ EPHY_PREFS_WEB_APP_SYSTEM));
gtk_widget_set_visible (general_page->homepage_box,
mode != EPHY_EMBED_SHELL_MODE_APPLICATION);
gtk_widget_set_visible (general_page->search_box,
@@ -1310,6 +1317,4 @@ prefs_general_page_init (PrefsGeneralPage *general_page)
mode != EPHY_EMBED_SHELL_MODE_APPLICATION);
gtk_widget_set_visible (general_page->browsing_box,
mode != EPHY_EMBED_SHELL_MODE_APPLICATION);
-
- setup_general_page (general_page);
}