Merge lp:~3v1n0/unity/migrate-gnome-desktop-files into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Andrea Azzarone
Approved revision: no longer in the source branch.
Merged at revision: 4273
Proposed branch: lp:~3v1n0/unity/migrate-gnome-desktop-files
Merge into: lp:unity
Diff against target: 93 lines (+78/-6)
2 files modified
debian/unity.migrations (+1/-6)
tools/migration-scripts/07_unity_migrate_gnome_favorites (+77/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/migrate-gnome-desktop-files
Reviewer Review Type Date Requested Status
Andrea Azzarone (community) Approve
Review via email: mp+342685@code.launchpad.net

Commit message

unity.migrations: add migration script to rename GNOME desktop files

We were still using legacy names, we should migrate favorites to new
names. Using the values that is also gnome-shell doing.

To post a comment you must log in.
Revision history for this message
Andrea Azzarone (azzar1) wrote :

LGTM.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/unity.migrations'
2--- debian/unity.migrations 2017-11-16 03:13:36 +0000
3+++ debian/unity.migrations 2018-04-06 11:43:07 +0000
4@@ -1,6 +1,1 @@
5-tools/migration-scripts/01_unity_change_dconf_path
6-tools/migration-scripts/02_unity_setup_text_scale_factor
7-tools/migration-scripts/03_unity_first_run_stamp_move
8-tools/migration-scripts/04_unity_update_software_center_desktop_file
9-tools/migration-scripts/05_unity_use_ubuntu_scaling_settings_schemas
10-tools/migration-scripts/06_unity_set_lowgfx_mode_settings_v1
11+tools/migration-scripts/*
12
13=== added file 'tools/migration-scripts/07_unity_migrate_gnome_favorites'
14--- tools/migration-scripts/07_unity_migrate_gnome_favorites 1970-01-01 00:00:00 +0000
15+++ tools/migration-scripts/07_unity_migrate_gnome_favorites 2018-04-06 11:43:07 +0000
16@@ -0,0 +1,77 @@
17+#!/usr/bin/python3
18+# -*- coding: utf-8 -*-
19+# Copyright (C) 2017 Canonical
20+#
21+# Authors:
22+# Marco Trevisan <marco.trevisan@canonical.com>
23+#
24+# This program is free software; you can redistribute it and/or modify it under
25+# the terms of the GNU General Public License as published by the Free Software
26+# Foundation; version 3.
27+#
28+# This program is distributed in the hope that it will be useful, but WITHOUTa
29+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
30+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
31+# details.
32+#
33+# You should have received a copy of the GNU General Public License along with
34+# this program; if not, write to the Free Software Foundation, Inc.,
35+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
36+
37+from gi.repository import Gio
38+import os
39+
40+UNITY_LAUNCHER_SETTINGS = "com.canonical.Unity.Launcher";
41+UNITY_LAUNCHER_FAVORITES = "favorites";
42+
43+# This comes from gnome-shell/js/ui/appFavorites.js
44+GNOME_RENAMED_DESKTOP_IDS = {
45+ 'baobab.desktop': 'org.gnome.baobab.desktop',
46+ 'cheese.desktop': 'org.gnome.Cheese.desktop',
47+ 'dconf-editor.desktop': 'ca.desrt.dconf-editor.desktop',
48+ 'empathy.desktop': 'org.gnome.Empathy.desktop',
49+ 'epiphany.desktop': 'org.gnome.Epiphany.desktop',
50+ 'file-roller.desktop': 'org.gnome.FileRoller.desktop',
51+ 'gcalctool.desktop': 'org.gnome.Calculator.desktop',
52+ 'geary.desktop': 'org.gnome.Geary.desktop',
53+ 'gedit.desktop': 'org.gnome.gedit.desktop',
54+ 'glchess.desktop': 'gnome-chess.desktop',
55+ 'glines.desktop': 'five-or-more.desktop',
56+ 'gnect.desktop': 'four-in-a-row.desktop',
57+ 'gnibbles.desktop': 'org.gnome.Nibbles.desktop',
58+ 'gnobots2.desktop': 'gnome-robots.desktop',
59+ 'gnome-boxes.desktop': 'org.gnome.Boxes.desktop',
60+ 'gnome-calculator.desktop': 'org.gnome.Calculator.desktop',
61+ 'gnome-clocks.desktop': 'org.gnome.clocks.desktop',
62+ 'gnome-contacts.desktop': 'org.gnome.Contacts.desktop',
63+ 'gnome-documents.desktop': 'org.gnome.Documents.desktop',
64+ 'gnome-font-viewer.desktop': 'org.gnome.font-viewer.desktop',
65+ 'gnome-nibbles.desktop': 'org.gnome.Nibbles.desktop',
66+ 'gnome-music.desktop': 'org.gnome.Music.desktop',
67+ 'gnome-photos.desktop': 'org.gnome.Photos.desktop',
68+ 'gnome-screenshot.desktop': 'org.gnome.Screenshot.desktop',
69+ 'gnome-software.desktop': 'org.gnome.Software.desktop',
70+ 'gnome-terminal.desktop': 'org.gnome.Terminal.desktop',
71+ 'gnome-weather.desktop': 'org.gnome.Weather.Application.desktop',
72+ 'gnomine.desktop': 'gnome-mines.desktop',
73+ 'gnotravex.desktop': 'gnome-tetravex.desktop',
74+ 'gnotski.desktop': 'gnome-klotski.desktop',
75+ 'gtali.desktop': 'tali.desktop',
76+ 'nautilus.desktop': 'org.gnome.Nautilus.desktop',
77+ 'polari.desktop': 'org.gnome.Polari.desktop',
78+ 'totem.desktop': 'org.gnome.Totem.desktop',
79+}
80+
81+launcher_settings = Gio.Settings.new(UNITY_LAUNCHER_SETTINGS)
82+favorites = launcher_settings.get_strv(UNITY_LAUNCHER_FAVORITES)
83+replaced = False
84+
85+for i, fav in enumerate(favorites):
86+ desktop_id = os.path.basename(fav)
87+ if desktop_id in GNOME_RENAMED_DESKTOP_IDS.keys():
88+ favorites[i] = fav.replace(desktop_id, GNOME_RENAMED_DESKTOP_IDS[desktop_id])
89+ replaced = True
90+
91+if replaced:
92+ launcher_settings.set_strv(UNITY_LAUNCHER_FAVORITES, favorites)
93+ Gio.Settings.sync()