[epiphany] Enable co-existing of Epiphany Tech Preview with stable version



commit 8061c1929caf99bce9a5f13df5d6d644baa01abd
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Sat Jan 5 13:19:26 2019 +0100

    Enable co-existing of Epiphany Tech Preview with stable version
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/20

 .gitlab-ci.yml                                     |   6 +-
 data/meson.build                                   | 110 ++++++++++++++-------
 data/org.gnome.Epiphany.SearchProvider.ini.in      |   5 +
 data/org.gnome.Epiphany.SearchProvider.service.in  |   2 +-
 ...xml.in => org.gnome.Epiphany.appdata.xml.in.in} |   4 +-
 ...desktop.in => org.gnome.Epiphany.desktop.in.in} |   2 +-
 data/org.gnome.Epiphany.search-provider.ini        |   5 -
 embed/ephy-about-handler.c                         |   8 +-
 ephy-vcs-version.h.in                              |   1 -
 meson.build                                        |  53 +++++-----
 meson_options.txt                                  |   6 ++
 org.gnome.Epiphany.json                            |   5 +-
 src/ephy-main.c                                    |   5 +-
 src/ephy-shell.c                                   |   8 +-
 src/ephy-window.c                                  |   2 +-
 src/meson.build                                    |   1 +
 src/prefs-dialog.c                                 |   2 +
 src/search-provider/ephy-search-provider.c         |   6 +-
 src/window-commands.c                              |   5 +-
 19 files changed, 140 insertions(+), 96 deletions(-)
---
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index ab33890c8..ae91587b0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -9,10 +9,8 @@ flatpak:
     MANIFEST_PATH: 'org.gnome.Epiphany.json'
     RUNTIME_REPO: 'https://sdk.gnome.org/gnome-nightly.flatpakrepo'
     FLATPAK_MODULE: 'epiphany'
-    # Make sure to keep this in sync with the Flatpak manifest, all arguments
-    # are passed except the config-args because we build it ourselves
-    MESON_ARGS: '-Dunit_tests=enabled --werror'
-    APP_ID: 'org.gnome.Epiphany'
+    MESON_ARGS: '-Dprofile=Devel -Dunit_tests=enabled --werror'
+    APP_ID: 'org.gnome.Epiphany.Devel'
 
 review:
   dependencies:
diff --git a/data/meson.build b/data/meson.build
index 912484fe8..2dad9a4ec 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,42 +1,50 @@
-install_subdir('icons/hicolor',
-  install_dir: join_paths(datadir, 'icons')
+po_dir = join_paths(meson.source_root(), 'po')
+
+icondir = join_paths('icons', 'hicolor', 'scalable', 'apps')
+install_data(
+  join_paths(icondir, 'org.gnome.Epiphany.svg'),
+  install_dir: join_paths(datadir, icondir),
+  rename: '@0@.svg'.format(application_id)
+)
+
+icondir = join_paths('icons', 'hicolor', 'symbolic', 'apps')
+install_data(
+  join_paths(icondir, 'org.gnome.Epiphany-symbolic.svg'),
+  install_dir: join_paths(datadir, icondir),
+  rename: '@0 -symbolic svg'.format(application_id)
 )
 
-desktop_file = i18n.merge_file('desktop-file',
-  input: 'org.gnome.Epiphany.desktop.in',
-  output: 'org.gnome.Epiphany.desktop',
+desktop_conf = configuration_data()
+desktop_conf.set('icon', application_id)
+desktop = i18n.merge_file(
+  'desktop',
+  input: configure_file(
+    input: files('org.gnome.Epiphany.desktop.in.in'),
+    output: 'org.gnome.Epiphany.desktop.in',
+    configuration: desktop_conf
+  ),
+  output: '@0@.desktop'.format(application_id),
   install: true,
-  install_dir: join_paths(datadir, 'applications'),
-  po_dir: '../po',
+  install_dir: desktopdir,
+  po_dir: po_dir,
   type: 'desktop'
 )
-desktop_file_validate = find_program ('desktop-file-validate', required: false)
-if desktop_file_validate.found()
-  test(
-    'validate-desktop',
-    desktop_file_validate,
-    args: [
-      desktop_file.full_path()
-    ]
-  )
-endif
 
-appdata_file = i18n.merge_file('appdata-file',
-  input: 'org.gnome.Epiphany.appdata.xml.in',
-  output: 'org.gnome.Epiphany.appdata.xml',
+appdata_conf = configuration_data()
+appdata_conf.set('appid', application_id)
+appdata = i18n.merge_file(
+  'appdata',
+  input: configure_file(
+    input: files('org.gnome.Epiphany.appdata.xml.in.in'),
+    output: 'org.gnome.Epiphany.appdata.xml.in',
+    configuration: appdata_conf
+  ),
+  output: '@0  appdata xml'.format(application_id),
   install: true,
   install_dir: join_paths(datadir, 'metainfo'),
-  po_dir: '../po'
+  po_dir: po_dir
 )
 appstream_util = find_program('appstream-util', required: false)
-if appstream_util.found()
-  test(
-    'validate-appdata', appstream_util,
-    args: [
-      'validate-relax', '--nonet', appdata_file.full_path()
-    ]
-  )
-endif
 
 # We need three custom_target() calls because Meson doesn't have very
 # good support for GSettings yet. First, generate our GSettings enums
@@ -81,17 +89,24 @@ install_data('org.gnome.epiphany.gschema.xml',
   install_dir: join_paths(datadir, 'glib-2.0', 'schemas')
 )
 
-serviceconf = configuration_data()
-serviceconf.set('libexecdir', libexecdir)
+service_conf = configuration_data()
+service_conf.set('appid', application_id)
+service_conf.set('libexecdir', libexecdir)
 configure_file(
   input: 'org.gnome.Epiphany.SearchProvider.service.in',
-  output: 'org.gnome.Epiphany.SearchProvider.service',
-  configuration: serviceconf,
-  install: true,
-  install_dir: join_paths(datadir, 'dbus-1', 'services')
+  output: '@0@.SearchProvider.service'.format(application_id),
+  configuration: service_conf,
+  install_dir: servicedir
 )
-install_data('org.gnome.Epiphany.search-provider.ini',
-  install_dir: join_paths(datadir, 'gnome-shell', 'search-providers')
+
+search_provider_conf = configuration_data()
+search_provider_conf.set('appid', application_id)
+search_provider_conf.set('profile', profile)
+configure_file(
+  configuration: search_provider_conf,
+  input: files('org.gnome.Epiphany.SearchProvider.ini.in'),
+  install_dir: join_paths(datadir, 'gnome-shell', 'search-providers'),
+  output: '@0  SearchProvider ini'.format(application_id)
 )
 
 bookmarksconf = configuration_data()
@@ -105,3 +120,24 @@ configure_file(
 )
 
 install_man('epiphany.1')
+
+desktop_file_validate = find_program('desktop-file-validate', required: false)
+if desktop_file_validate.found()
+  test(
+    'validate-desktop',
+    desktop_file_validate,
+    args: [
+      desktop.full_path()
+    ]
+  )
+endif
+
+appstream_util = find_program('appstream-util', required: false)
+if appstream_util.found()
+  test(
+    'validate-appdata', appstream_util,
+    args: [
+      'validate-relax', appdata.full_path()
+    ]
+  )
+endif
diff --git a/data/org.gnome.Epiphany.SearchProvider.ini.in b/data/org.gnome.Epiphany.SearchProvider.ini.in
new file mode 100644
index 000000000..5f68d3a2f
--- /dev/null
+++ b/data/org.gnome.Epiphany.SearchProvider.ini.in
@@ -0,0 +1,5 @@
+[Shell Search Provider]
+DesktopId=@appid@.desktop
+BusName=@appid@.SearchProvider
+ObjectPath=/org/gnome/Epiphany@profile@/SearchProvider
+Version=2
diff --git a/data/org.gnome.Epiphany.SearchProvider.service.in 
b/data/org.gnome.Epiphany.SearchProvider.service.in
index e501c58fd..e2054ed8a 100644
--- a/data/org.gnome.Epiphany.SearchProvider.service.in
+++ b/data/org.gnome.Epiphany.SearchProvider.service.in
@@ -1,3 +1,3 @@
 [D-BUS Service]
-Name=org.gnome.Epiphany.SearchProvider
+Name=@appid@.SearchProvider
 Exec=@libexecdir@/epiphany-search-provider
diff --git a/data/org.gnome.Epiphany.appdata.xml.in b/data/org.gnome.Epiphany.appdata.xml.in.in
similarity index 94%
rename from data/org.gnome.Epiphany.appdata.xml.in
rename to data/org.gnome.Epiphany.appdata.xml.in.in
index b8c373ef6..4354ba98a 100644
--- a/data/org.gnome.Epiphany.appdata.xml.in
+++ b/data/org.gnome.Epiphany.appdata.xml.in.in
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright 2013, 2015 Epiphany contributors -->
+<!-- Copyright 2013, 2015, 2019 Epiphany contributors -->
 <component type="desktop">
-  <id>org.gnome.Epiphany.desktop</id>
+  <id>@appid@.desktop</id>
   <metadata_license>CC0-1.0</metadata_license>
   <name>GNOME Web</name>
   <summary>Web browser for GNOME</summary>
diff --git a/data/org.gnome.Epiphany.desktop.in b/data/org.gnome.Epiphany.desktop.in.in
similarity index 97%
rename from data/org.gnome.Epiphany.desktop.in
rename to data/org.gnome.Epiphany.desktop.in.in
index c02164e1e..a0f272322 100644
--- a/data/org.gnome.Epiphany.desktop.in
+++ b/data/org.gnome.Epiphany.desktop.in.in
@@ -9,7 +9,7 @@ StartupNotify=true
 Terminal=false
 Type=Application
 # Translators: Do NOT translate or transliterate this text (this is an icon file name)!
-Icon=org.gnome.Epiphany
+Icon=@icon@
 Categories=Network;GNOME;GTK;WebBrowser;
 
MimeType=text/html;text/xml;application/xhtml+xml;x-scheme-handler/http;x-scheme-handler/https;multipart/related;application/x-mimearchive;message/rfc822;
 Actions=new-window;Incognito;
diff --git a/embed/ephy-about-handler.c b/embed/ephy-about-handler.c
index 693f8b1ec..437a57a21 100644
--- a/embed/ephy-about-handler.c
+++ b/embed/ephy-about-handler.c
@@ -31,7 +31,6 @@
 #include "ephy-settings.h"
 #include "ephy-smaps.h"
 #include "ephy-snapshot-service.h"
-#include "ephy-vcs-version.h"
 #include "ephy-web-app-utils.h"
 
 #include <gio/gio.h>
@@ -163,10 +162,10 @@ ephy_about_handler_handle_about (EphyAboutHandler       *handler,
   char *version;
   GtkIconInfo *icon_info;
 
-  version = g_strdup_printf (_("Version %s"), VCSVERSION);
+  version = g_strdup_printf (_("Version %s"), VERSION);
 
   icon_info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
-                                          "org.gnome.Epiphany",
+                                          APPLICATION_ID,
                                           256,
                                           GTK_ICON_LOOKUP_FORCE_SVG);
 
@@ -343,9 +342,10 @@ history_service_query_urls_cb (EphyHistoryService     *history,
 
   if (g_list_length (urls) == 0 || !success) {
     GtkIconInfo *icon_info;
+    g_autofree gchar *icon = g_strconcat (APPLICATION_ID, "-symbolic", NULL);
 
     icon_info = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
-                                            "org.gnome.Epiphany-symbolic",
+                                            icon,
                                             128,
                                             0);
     g_string_append_printf (data_str,
diff --git a/meson.build b/meson.build
index 3eb061829..d8b7128ab 100644
--- a/meson.build
+++ b/meson.build
@@ -1,7 +1,7 @@
 project('epiphany', 'c',
   license: 'GPL3+',
   version: '3.31.90',
-  meson_version: '>= 0.42.0',
+  meson_version: '>= 0.46.0',
   default_options: ['c_std=gnu11']
 )
 
@@ -17,6 +17,7 @@ endif
 
 prefix = get_option('prefix')
 datadir = join_paths(prefix, get_option('datadir'))
+desktopdir = join_paths(datadir, 'applications')
 libdir = join_paths(prefix, get_option('libdir'))
 libexecdir = join_paths(prefix, get_option('libexecdir'))
 liblocaledir = join_paths(prefix, libdir, 'locale')
@@ -24,13 +25,24 @@ localedir = join_paths(prefix, get_option('localedir'))
 pkgdatadir = join_paths(datadir, 'epiphany')
 pkglibdir = join_paths(libdir, 'epiphany')
 pkglibexecdir = join_paths(libexecdir, 'epiphany')
+servicedir = join_paths(datadir, 'dbus-1', 'services')
 webextensionsdir = join_paths(pkglibdir, 'web-extensions')
 
 iso_codes = dependency('iso-codes')
 iso_codes_prefix = iso_codes.get_pkgconfig_variable('prefix')
 
+profile = get_option('profile')
+application_id = 'org.gnome.Epiphany'
+
+if profile != ''
+  application_id = 'org.gnome.Epiphany.' + profile
+endif
+
 conf = configuration_data()
+conf.set_quoted('APPLICATION_ID', application_id)
 conf.set_quoted('BUILD_ROOT', meson.build_root())
+developer_mode = get_option('developer_mode')
+conf.set10('DEVELOPER_MODE', developer_mode)
 conf.set_quoted('DISTRIBUTOR_NAME', distributor_name)
 conf.set_quoted('EPHY_WEB_EXTENSIONS_DIR', webextensionsdir)
 conf.set_quoted('GETTEXT_PACKAGE', meson.project_name())
@@ -39,42 +51,29 @@ conf.set_quoted('LIBLOCALEDIR', liblocaledir)
 conf.set_quoted('LOCALEDIR', localedir)
 conf.set_quoted('PKGDATADIR', pkgdatadir)
 conf.set_quoted('PKGLIBEXECDIR', pkglibexecdir)
+conf.set_quoted('PROFILE', profile)
 conf.set_quoted('SOURCE_ROOT', meson.source_root())
-
-developer_mode = get_option('developer_mode')
-conf.set10('DEVELOPER_MODE', developer_mode)
-
 tech_preview = get_option('tech_preview')
 conf.set10('TECH_PREVIEW', tech_preview)
 
-conf.set_quoted('VERSION', meson.project_version())
-
 version_array = meson.project_version().split('.')
 conf.set('EPHY_MAJOR_VERSION', version_array[0].to_int())
 conf.set('EPHY_MINOR_VERSION', version_array[1].to_int())
 conf.set('EPHY_MICRO_VERSION', version_array[2].to_int())
 
-configure_file(
-  output: 'config.h',
-  configuration: conf
-)
-
-if tech_preview or developer_mode
-  vcs_tag(
-    input: 'ephy-vcs-version.h.in',
-    output: 'ephy-vcs-version.h',
-    replace_string: '@VCSVERSION@'
-  )
-else
-  version_conf = configuration_data()
-  version_conf.set('VCSVERSION', meson.project_version())
-
-  configure_file(
-    input: 'ephy-vcs-version.h.in',
-    output: 'ephy-vcs-version.h',
-    configuration: version_conf
+conf.set_quoted('VERSION', '@0@-@VCS_TAG@'.format(meson.project_version()))
+
+config_h = declare_dependency(
+  sources: vcs_tag(
+    command: ['git', 'rev-parse', '--short', 'HEAD'],
+    fallback: get_option('profile') != 'default' ? 'devel' : 'stable',
+    input: configure_file(
+      output: 'config.h.in',
+      configuration: conf
+    ),
+    output: 'config.h'
   )
-endif
+)
 
 glib_requirement = '>= 2.56.0'
 gtk_requirement = '>= 3.24.0'
diff --git a/meson_options.txt b/meson_options.txt
index 007c56393..512ef4079 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -16,6 +16,12 @@ option('tech_preview',
   description: 'Enable Epiphany Tech Preview branding'
 )
 
+option('profile',
+  type: 'string',
+  value: '',
+  description: 'Build with appended profile to application ID'
+)
+
 option('unit_tests',
   type: 'feature',
   value: 'enabled',
diff --git a/org.gnome.Epiphany.json b/org.gnome.Epiphany.json
index 901d08ae6..c37534b6a 100644
--- a/org.gnome.Epiphany.json
+++ b/org.gnome.Epiphany.json
@@ -1,5 +1,5 @@
 {
-    "app-id" : "org.gnome.Epiphany",
+    "app-id" : "org.gnome.Epiphany.Devel",
     "runtime" : "org.gnome.Platform",
     "runtime-version" : "master",
     "sdk" : "org.gnome.Sdk",
@@ -68,7 +68,8 @@
         {
             "name" : "epiphany",
             "config-opts" : [
-                "-Dtech_preview=true"
+                "-Dtech_preview=true",
+                "-Dprofile=Devel"
             ],
             "buildsystem" : "meson",
             "builddir" : true,
diff --git a/src/ephy-main.c b/src/ephy-main.c
index 04ed3fe12..ec895b574 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -29,7 +29,6 @@
 #include "ephy-settings.h"
 #include "ephy-shell.h"
 #include "ephy-string.h"
-#include "ephy-vcs-version.h"
 #include "ephy-web-app-utils.h"
 
 #include <errno.h>
@@ -100,7 +99,7 @@ option_version_cb (const gchar *option_name,
                    gpointer     data,
                    GError     **error)
 {
-  g_print ("%s %s\n", _("Web"), VCSVERSION);
+  g_print ("%s %s\n", _("Web"), VERSION);
 
   exit (EXIT_SUCCESS);
   return FALSE;
@@ -404,7 +403,7 @@ main (int   argc,
     g_set_prgname ("epiphany");
     g_set_application_name (_("Web"));
 
-    gtk_window_set_default_icon_name ("org.gnome.Epiphany");
+    gtk_window_set_default_icon_name (APPLICATION_ID);
   }
 
   hdy_init (&argc, &argv);
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 5cd490791..f7dcd15b3 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -988,12 +988,14 @@ ephy_shell_get_prefs_dialog (EphyShell *shell)
 void
 _ephy_shell_create_instance (EphyEmbedShellMode mode)
 {
-  const char *id;
+  g_autofree gchar *id = NULL;
 
   g_assert (ephy_shell == NULL);
 
-  id = (mode == EPHY_EMBED_SHELL_MODE_APPLICATION ? "org.gnome.Epiphany.WebApp"
-                                                  : "org.gnome.Epiphany");
+  if (mode == EPHY_EMBED_SHELL_MODE_APPLICATION)
+    id = g_strconcat (APPLICATION_ID, ".WebApp", NULL);
+  else
+    id = g_strdup (APPLICATION_ID);
 
   ephy_shell = EPHY_SHELL (g_object_new (EPHY_TYPE_SHELL,
                                          "application-id", id,
diff --git a/src/ephy-window.c b/src/ephy-window.c
index ef675b973..dafa41bd1 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -3573,7 +3573,7 @@ ephy_window_new (void)
                        "application", GTK_APPLICATION (ephy_shell_get_default ()),
                        "default-height", 768,
                        "default-width", 1024,
-                       "icon-name", "org.gnome.Epiphany",
+                       "icon-name", APPLICATION_ID,
                        NULL);
 }
 
diff --git a/src/meson.build b/src/meson.build
index 40d003daf..40cb73a04 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -52,6 +52,7 @@ libephymain_sources = [
 ]
 
 libephymain_deps = [
+  config_h,
   ephyembed_dep,
   ephymisc_dep,
   ephysync_dep,
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 1e0932020..9f6125770 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -2401,6 +2401,8 @@ prefs_dialog_init (PrefsDialog *dialog)
   gtk_widget_set_visible (dialog->reader_mode_box,
                           mode != EPHY_EMBED_SHELL_MODE_APPLICATION);
 
+  gtk_window_set_icon_name (GTK_WINDOW (dialog), APPLICATION_ID);
+
   setup_general_page (dialog);
   setup_fonts_page (dialog);
   setup_stored_data_page (dialog);
diff --git a/src/search-provider/ephy-search-provider.c b/src/search-provider/ephy-search-provider.c
index e7422e640..18512fae0 100644
--- a/src/search-provider/ephy-search-provider.c
+++ b/src/search-provider/ephy-search-provider.c
@@ -196,7 +196,7 @@ handle_get_result_metas (EphyShellSearchProvider2 *skeleton,
                              "name", g_variant_new_take_string (g_strdup_printf (_("Search the web for 
“%s”"),
                                                                                  results[i] + strlen 
("special:search:"))));
       g_variant_builder_add (&builder, "{sv}",
-                             "gicon", g_variant_new_string ("org.gnome.Epiphany"));
+                             "gicon", g_variant_new_string (APPLICATION_ID));
       g_variant_builder_close (&builder);
     } else {
       EphySuggestion *suggestion;
@@ -421,7 +421,9 @@ ephy_search_provider_class_init (EphySearchProviderClass *klass)
 EphySearchProvider *
 ephy_search_provider_new (void)
 {
+  g_autofree gchar *app_id = g_strconcat (APPLICATION_ID, ".SearchProvider", NULL);
+
   return g_object_new (EPHY_TYPE_SEARCH_PROVIDER,
-                       "application-id", "org.gnome.Epiphany.SearchProvider",
+                       "application-id", app_id,
                        NULL);
 }
diff --git a/src/window-commands.c b/src/window-commands.c
index ef981835b..3383cffca 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -52,7 +52,6 @@
 #include "ephy-settings.h"
 #include "ephy-shell.h"
 #include "ephy-string.h"
-#include "ephy-vcs-version.h"
 #include "ephy-view-source-handler.h"
 #include "ephy-web-app-utils.h"
 #include "ephy-zoom.h"
@@ -603,14 +602,14 @@ window_cmd_show_about (GSimpleAction *action,
   gtk_about_dialog_set_program_name (dialog, _("Epiphany Technology Preview"));
 #endif
 
-  gtk_about_dialog_set_version (dialog, VCSVERSION);
+  gtk_about_dialog_set_version (dialog, VERSION);
   gtk_about_dialog_set_copyright (dialog, "Copyright © 2002–2004 Marco Pesenti Gritti\n"
                                           "Copyright © 2003–2019 The GNOME Web Developers");
   gtk_about_dialog_set_comments (dialog, comments);
   gtk_about_dialog_set_license_type (dialog, GTK_LICENSE_GPL_3_0);
   gtk_about_dialog_set_website (dialog, "https://wiki.gnome.org/Apps/Web";);
   gtk_about_dialog_set_website_label (dialog, _("Website"));
-  gtk_about_dialog_set_logo_icon_name (dialog, "org.gnome.Epiphany");
+  gtk_about_dialog_set_logo_icon_name (dialog, APPLICATION_ID);
 
   /* We have to use add_credit_section() for documenters and artists to
    * ensure maintainers get sorted first. */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]