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