general: Allow running in separate instance

When hacking on Nautilus, it is very inconvenient to have to close any
running instance before running the built version. This commit enables
running three different instances by changing the application ID.
Beside the default “profile” is one crafted for stable flatpak
releases and one for development. The stable flatpak profile adds an
identifying mark to the about dialog to aid collecting information in
bug reports. The development profile is that plus additional styling to
help visually identify the development instance. It also will be used
when generating Flatpak bundles with the help of CI.

Generally, the implementation is slightly hacky to allow all the
different workflows, spanning from regular installations to GNOME
Builder flatpak builds, as each comes with its own quirks.
This commit is contained in:
Ernestas Kulik 2018-03-16 17:24:11 +02:00
parent 30a76b3033
commit df583c2e4a
21 changed files with 281 additions and 39 deletions

View file

@ -17,14 +17,14 @@ flatpak:master:
script:
# This should be removed once the base image works with git submodules
- dnf install -y git
- flatpak-builder --stop-at=nautilus app build-aux/flatpak/org.gnome.Nautilus.json
- flatpak-builder --run app build-aux/flatpak/org.gnome.Nautilus.json meson --prefix=/app --libdir=/app/lib _build
- flatpak-builder --run app build-aux/flatpak/org.gnome.Nautilus.json ninja -C _build install
- flatpak-builder --finish-only --repo=repo app build-aux/flatpak/org.gnome.Nautilus.json
- flatpak-builder --stop-at=nautilus app build-aux/flatpak/org.gnome.NautilusDevel.json
- flatpak-builder --run app build-aux/flatpak/org.gnome.NautilusDevel.json meson --prefix=/app --libdir=/app/lib -Dprofile=development _build
- flatpak-builder --run app build-aux/flatpak/org.gnome.NautilusDevel.json ninja -C _build install
- flatpak-builder --finish-only --repo=repo app build-aux/flatpak/org.gnome.NautilusDevel.json
# Make a Flatpak Nautilus bundle for people to test
- flatpak build-bundle repo nautilus-dev.flatpak org.gnome.Nautilus
- flatpak build-bundle repo nautilus-dev.flatpak org.gnome.NautilusDevel
# Run automatic tests inside the Flatpak env
- flatpak-builder --run app build-aux/flatpak/org.gnome.Nautilus.json ninja -C _build test
- flatpak-builder --run app build-aux/flatpak/org.gnome.NautilusDevel.json ninja -C _build test
artifacts:
paths:
- nautilus-dev.flatpak

View file

@ -1,5 +1,5 @@
{
"app-id": "org.gnome.Nautilus",
"app-id": "org.gnome.NautilusDevel",
"runtime": "org.gnome.Platform",
"runtime-version": "3.28",
"sdk": "org.gnome.Sdk",
@ -82,7 +82,8 @@
"builddir": true,
"name": "nautilus",
"config-opts": [
"--libdir=/app/lib"
"--libdir=/app/lib",
"-Dprofile=development"
],
"sources": [
{

View file

@ -1,7 +1,36 @@
install_subdir(
join_paths('icons', 'hicolor'),
install_dir: join_paths(datadir, 'icons')
########## EVIL EVIL EVIL
# See https://github.com/mesonbuild/meson/issues/1487
# and https://github.com/mesonbuild/meson/pull/3223
#
# This is primarily for the “build profiles” feature,
# to be able to have icons even if we change the application ID.
#
# https://gitlab.gnome.org/GNOME/nautilus/merge_requests/144
##########
foreach icon_size: ['16x16', '22x22', '24x24', '32x32', '48x48', '512x512']
configure_file(
command: [
'cp', '@INPUT@', '@OUTPUT@'
],
input: files(
join_paths('icons', 'hicolor', icon_size, 'apps', 'org.gnome.Nautilus.png')
),
install_dir: join_paths(datadir, 'icons', 'hicolor', icon_size, 'apps'),
output: '@0@.png'.format(application_id)
)
endforeach
configure_file(
command: [
'cp', '@INPUT@', '@OUTPUT@'
],
input: files(
join_paths('icons', 'hicolor', 'symbolic', 'apps', 'org.gnome.Nautilus-symbolic.svg')
),
install_dir: join_paths(datadir, 'icons', 'hicolor', 'symbolic', 'apps'),
output: '@0@-symbolic.svg'.format(application_id)
)
##########
po_dir = join_paths(meson.source_root(), 'po')
@ -14,10 +43,18 @@ line_up_parameters = executable(
]
)
desktop_conf = configuration_data()
desktop_conf.set('icon', application_id)
desktop = i18n.merge_file(
'desktop',
input: 'org.gnome.Nautilus.desktop.in',
output: 'org.gnome.Nautilus.desktop',
input: configure_file(
input: files('org.gnome.Nautilus.desktop.in.in'),
output: 'org.gnome.Nautilus.desktop.in',
configuration: desktop_conf
),
output: '@0@.desktop'.format(application_id),
install: true,
install_dir: desktopdir,
po_dir: po_dir,
@ -34,21 +71,30 @@ desktop_autorun_software = i18n.merge_file(
type: 'desktop'
)
appdata_conf = configuration_data()
appdata_conf.set('appid', application_id)
appdata = i18n.merge_file(
'appdata',
input: 'org.gnome.Nautilus.appdata.xml.in',
output: 'org.gnome.Nautilus.appdata.xml',
input: configure_file(
input: files('org.gnome.Nautilus.appdata.xml.in.in'),
output: 'org.gnome.Nautilus.appdata.xml.in',
configuration: appdata_conf
),
output: '@0@.appdata.xml'.format(application_id),
install: true,
install_dir: join_paths(datadir, 'metainfo'),
po_dir: po_dir
)
service_conf = configuration_data()
service_conf.set('appid', application_id)
service_conf.set('bindir', join_paths(prefix, bindir))
configure_file(
input: 'org.gnome.Nautilus.service.in',
output: 'org.gnome.Nautilus.service',
output: '@0@.service'.format(application_id),
configuration: service_conf,
install_dir: servicedir
)
@ -60,9 +106,16 @@ configure_file(
install_dir: servicedir
)
install_data(
'org.gnome.Nautilus.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.Nautilus.search-provider.ini.in'),
install_dir: join_paths(datadir, 'gnome-shell', 'search-providers'),
output: '@0@.search-provider.ini'.format(application_id)
)
install_data(

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<component type="desktop">
<id>org.gnome.Nautilus.desktop</id>
<id>@appid@.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0+</project_license>
<name>Nautilus</name>

View file

@ -5,7 +5,7 @@ Comment=Access and organize files
Keywords=folder;manager;explore;disk;filesystem;
Exec=nautilus --new-window %U
# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
Icon=org.gnome.Nautilus
Icon=@icon@
Terminal=false
Type=Application
DBusActivatable=true

View file

@ -1,5 +0,0 @@
[Shell Search Provider]
DesktopId=org.gnome.Nautilus.desktop
BusName=org.gnome.Nautilus
ObjectPath=/org/gnome/Nautilus/SearchProvider
Version=2

View file

@ -0,0 +1,5 @@
[Shell Search Provider]
DesktopId=@appid@.desktop
BusName=@appid@
ObjectPath=/org/gnome/Nautilus@profile@/SearchProvider
Version=2

View file

@ -1,3 +1,3 @@
[D-BUS Service]
Name=org.gnome.Nautilus
Name=@appid@
Exec=@bindir@/nautilus --gapplication-service

View file

@ -27,6 +27,7 @@ libeel_2_sources = [
]
libeel_2_deps = [
config_h,
gail,
glib,
gtk,

View file

@ -54,6 +54,7 @@ libnautilus_extension_sources = [
]
libnautilus_extension_deps = [
config_h,
glib,
gtk
]

View file

@ -92,12 +92,31 @@ xml = dependency('libxml-2.0', version: '>= 2.7.8')
# Configuration
conf = configuration_data()
conf.set_quoted('VERSION', meson.project_version())
if get_option('profile') == 'development'
version = '@0@-@VCS_TAG@'.format(meson.project_version())
conf.set_quoted('NAME_SUFFIX', ' (Development Snapshot)')
profile = 'Devel'
else
if get_option('profile') == 'stable-flatpak'
version = '@0@-flatpak'.format(meson.project_version())
profile = 'Stable'
else
version = meson.project_version()
profile = ''
endif
conf.set_quoted('NAME_SUFFIX', '')
endif
application_id = 'org.gnome.Nautilus@0@'.format(profile)
conf.set_quoted('VERSION', version)
conf.set_quoted('PACKAGE_VERSION', meson.project_version())
conf.set_quoted('GETTEXT_PACKAGE', 'nautilus')
conf.set_quoted('LOCALEDIR', join_paths(prefix, get_option('localedir')))
conf.set_quoted('NAUTILUS_DATADIR', join_paths(datadir, 'nautilus'))
conf.set_quoted('NAUTILUS_EXTENSIONDIR', join_paths(prefix, extensiondir))
conf.set_quoted('APPLICATION_ID', application_id)
conf.set_quoted('PROFILE', profile)
if get_option('packagekit')
conf.set10('ENABLE_PACKAGEKIT', true)
@ -109,7 +128,25 @@ if get_option('selinux')
conf.set10('HAVE_SELINUX', true)
endif
configure_file(output: 'config.h', configuration: conf)
if get_option('profile') == 'development'
config_h = declare_dependency(
sources: vcs_tag(
command: ['git', 'rev-parse', '--short', 'HEAD'],
fallback: 'devel',
input: configure_file(
output: 'config.h.in',
configuration: conf
),
output: 'config.h'
)
)
else
configure_file(
output: 'config.h',
configuration: conf
)
config_h = dependency('', required: false)
endif
#
nautilus_include_dirs = include_directories(

View file

@ -4,3 +4,13 @@ option('extensions', type: 'boolean', value: true)
option('packagekit', type: 'boolean', value: true)
option('selinux', type: 'boolean', value: false)
option('tests', type: 'combo', choices: ['none', 'headless', 'all'], value: 'headless')
option(
'profile',
type: 'combo',
choices: [
'default',
'stable-flatpak',
'development'
],
value: 'default'
)

View file

@ -266,6 +266,7 @@ libnautilus_sources = [
]
nautilus_deps = [
config_h,
eel_2,
gio_unix,
gmodule,
@ -323,6 +324,9 @@ executable(
'nautilus-autorun-software',
nautilus_autorun_software_sources,
include_directories: nautilus_include_dirs,
dependencies: gtk,
dependencies: [
config_h,
gtk
],
install: true
)

View file

@ -245,6 +245,7 @@ nautilus_application_create_window (NautilusApplication *self,
g_autoptr (GVariant) default_size = NULL;
gint default_width = 0;
gint default_height = 0;
const gchar *application_id;
g_return_val_if_fail (NAUTILUS_IS_APPLICATION (self), NULL);
nautilus_profile_start (NULL);
@ -270,6 +271,16 @@ nautilus_application_create_window (NautilusApplication *self,
MAX (NAUTILUS_WINDOW_MIN_WIDTH, default_width),
MAX (NAUTILUS_WINDOW_MIN_HEIGHT, default_height));
application_id = g_application_get_application_id (G_APPLICATION (self));
if (g_strcmp0 (application_id, "org.gnome.NautilusDevel") == 0)
{
GtkStyleContext *style_context;
style_context = gtk_widget_get_style_context (GTK_WIDGET (window));
gtk_style_context_add_class (style_context, "devel");
}
DEBUG ("Creating a new navigation window");
nautilus_profile_end (NULL);
@ -1253,7 +1264,7 @@ nautilus_application_startup_common (NautilusApplication *self)
*/
G_APPLICATION_CLASS (nautilus_application_parent_class)->startup (G_APPLICATION (self));
gtk_window_set_default_icon_name ("org.gnome.Nautilus");
gtk_window_set_default_icon_name (APPLICATION_ID);
setup_theme_extensions ();
@ -1535,7 +1546,7 @@ NautilusApplication *
nautilus_application_new (void)
{
return g_object_new (NAUTILUS_TYPE_APPLICATION,
"application-id", "org.gnome.Nautilus",
"application-id", APPLICATION_ID,
"flags", G_APPLICATION_HANDLES_COMMAND_LINE | G_APPLICATION_HANDLES_OPEN,
"inactivity-timeout", 12000,
NULL);

View file

@ -171,7 +171,7 @@ nautilus_dbus_manager_register (NautilusDBusManager *self,
GError **error)
{
return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->file_operations),
connection, "/org/gnome/Nautilus", error);
connection, "/org/gnome/Nautilus" PROFILE, error);
}
void

View file

@ -26,7 +26,9 @@
#include <gio/gio.h>
#include <gtk/gtk.h>
#define NAUTILUS_DESKTOP_ID "org.gnome.Nautilus.desktop"
#include <config.h>
#define NAUTILUS_DESKTOP_ID APPLICATION_ID ".desktop"
/* These functions all return something something that needs to be
* freed with g_free, is not NULL, and is guaranteed to exist.

View file

@ -508,7 +508,7 @@ static void nautilus_preferences_window_setup(GtkBuilder *builder,
window = GTK_WIDGET (gtk_builder_get_object (builder, "preferences_window"));
preferences_window = window;
gtk_window_set_icon_name (GTK_WINDOW (preferences_window), "org.gnome.Nautilus");
gtk_window_set_icon_name (GTK_WINDOW (preferences_window), APPLICATION_ID);
g_object_add_weak_pointer (G_OBJECT (window), (gpointer *) &preferences_window);

View file

@ -779,7 +779,7 @@ nautilus_shell_search_provider_register (NautilusShellSearchProvider *self,
{
return g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (self->skeleton),
connection,
"/org/gnome/Nautilus/SearchProvider", error);
"/org/gnome/Nautilus" PROFILE "/SearchProvider", error);
}
void

View file

@ -2987,6 +2987,7 @@ NautilusWindow *
nautilus_window_new (GdkScreen *screen)
{
return g_object_new (NAUTILUS_TYPE_WINDOW,
"icon-name", APPLICATION_ID,
"screen", screen,
NULL);
}
@ -3071,9 +3072,16 @@ nautilus_window_show_about_dialog (NautilusWindow *window)
"Sun Microsystems",
NULL
};
g_autofree gchar *program_name = NULL;
/* “Files” is the generic application name and the suffix is
* an arbitrary and deliberately unlocalized string only shown
* in development builds.
*/
program_name = g_strconcat (_("Files"), NAME_SUFFIX, NULL);
gtk_show_about_dialog (window ? GTK_WINDOW (window) : NULL,
"program-name", _("Files"),
"program-name", program_name,
"version", VERSION,
"comments", _("Access and organize your files."),
"copyright", "Copyright © 19992018 The Files Authors",
@ -3086,7 +3094,7 @@ nautilus_window_show_about_dialog (NautilusWindow *window)
* box to give credit to the translator(s).
*/
"translator-credits", _("translator-credits"),
"logo-icon-name", "org.gnome.Nautilus",
"logo-icon-name", APPLICATION_ID,
NULL);
}

View file

@ -4,6 +4,121 @@
background: @theme_base_color;
}
.nautilus-window.devel headerbar {
background: #cbd2d9 -gtk-icontheme("system-run-symbolic") 70% 0/64px 64px no-repeat, linear-gradient(to top, #a5b1bd, #c5cdd5 2px, #cbd2d9 3px);
box-shadow: inset 0 1px #f1f3f5;
border-color: #909fae;
color: rgba(46, 52, 54, 0.2);
}
.nautilus-window.devel headerbar > * {
color: #2e3436;
}
.nautilus-window.devel headerbar > *:backdrop {
color: #8b8e8f;
}
.nautilus-window.devel headerbar:backdrop {
background-image: -gtk-icontheme("system-run-symbolic"), image(#cbd2d9);
box-shadow: inset 0 1px #f1f3f5;
color: rgba(139, 142, 143, 0.1);
}
.nautilus-window.devel headerbar button {
color: #2e3436;
outline-color: rgba(46, 52, 54, 0.3);
border-color: #909fae;
border-bottom-color: #738698;
background-image: linear-gradient(to bottom, #cbd2d9, #bfc8d0 60%, #aeb9c3);
text-shadow: 0 1px rgba(255, 255, 255, 0.76923);
-gtk-icon-shadow: 0 1px rgba(255, 255, 255, 0.76923);
box-shadow: inset 0 1px rgba(255, 255, 255, 0.6);
}
.nautilus-window.devel headerbar button.flat,
.nautilus-window.devel headerbar button.titlebutton {
border-color: transparent;
background-color: transparent;
background-image: none;
box-shadow: inset 0 1px rgba(255, 255, 255, 0);
text-shadow: none;
-gtk-icon-shadow: none;
}
.nautilus-window.devel headerbar button.titlebutton {
text-shadow: 0 1px rgba(255, 255, 255, 0.76923);
-gtk-icon-shadow: 0 1px rgba(255, 255, 255, 0.76923);
}
.nautilus-window.devel headerbar button:hover {
color: #2e3436;
outline-color: rgba(46, 52, 54, 0.3);
border-color: #909fae;
border-bottom-color: #738698;
text-shadow: 0 1px rgba(255, 255, 255, 0.76923);
-gtk-icon-shadow: 0 1px rgba(255, 255, 255, 0.76923);
box-shadow: inset 0 1px rgba(255, 255, 255, 0.6);
background-image: linear-gradient(to bottom, #dde1e6, #cbd2d9 60%, #bfc8d0);
}
.nautilus-window.devel headerbar button:active,
.nautilus-window.devel headerbar button:checked {
color: #2e3436;
outline-color: rgba(46, 52, 54, 0.3);
border-color: #909fae;
background-image: image(#b9c3cc);
box-shadow: inset 0 1px rgba(255, 255, 255, 0);
text-shadow: none;
-gtk-icon-shadow: none;
}
.nautilus-window.devel headerbar button:disabled {
border-color: #909fae;
background-image: image(#d3d9df);
text-shadow: none;
-gtk-icon-shadow: none;
box-shadow: inset 0 1px rgba(255, 255, 255, 0);
}
.nautilus-window.devel headerbar button:disabled label,
.nautilus-window.devel headerbar button:disabled {
color: #8b8e8f;
}
.nautilus-window.devel headerbar button:backdrop {
border-color: #cbd2d9;
background-image: image(#cbd2d9);
text-shadow: none;
-gtk-icon-shadow: none;
box-shadow: inset 0 1px rgba(255, 255, 255, 0);
border-color: #909fae;
}
.nautilus-window.devel headerbar button:backdrop label,
.nautilus-window.devel headerbar button:backdrop {
color: #8b8e8f;
}
.nautilus-window.devel headerbar button:backdrop:active {
border-color: #bbc5ce;
background-image: image(#bbc5ce);
box-shadow: inset 0 1px rgba(255, 255, 255, 0);
border-color: #909fae;
}
.nautilus-window.devel headerbar button:backdrop:active label,
.nautilus-window.devel headerbar button:backdrop:active {
color: #8b8e8f;
}
.nautilus-window.devel headerbar button:backdrop:disabled {
border-color: #d3d9df;
background-image: image(#d3d9df);
text-shadow: none;
-gtk-icon-shadow: none;
box-shadow: inset 0 1px rgba(255, 255, 255, 0);
border-color: #909fae;
}
.nautilus-window.devel headerbar button:backdrop:disabled label,
.nautilus-window.devel headerbar button:backdrop:disabled {
color: #999fa4;
}
.nautilus-window.devel headerbar button.flat:backdrop,
.nautilus-window.devel headerbar button.titlebutton:backdrop {
border-color: transparent;
background-color: transparent;
background-image: none;
box-shadow: inset 0 1px rgba(255, 255, 255, 0);
text-shadow: none;
-gtk-icon-shadow: none;
}
.nautilus-canvas-item {
border-radius: 5px;
}

View file

@ -3,7 +3,6 @@
<template class="NautilusWindow" parent="GtkApplicationWindow">
<property name="show-menubar">False</property>
<property name="title" translatable="yes">_Files</property>
<property name="icon-name">org.gnome.Nautilus</property>
<child type="titlebar">
<object class="NautilusToolbar" id="toolbar">
<!-- We override the title widget so the GtkHeaderBar stop managing the