Merge lp:~3v1n0/unity/migrate-to-sc-favorite into lp:unity

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 4075
Proposed branch: lp:~3v1n0/unity/migrate-to-sc-favorite
Merge into: lp:unity
Diff against target: 68 lines (+40/-2)
3 files modified
debian/unity.migrations (+1/-0)
tools/migration-scripts/02_unity_setup_text_scale_factor (+3/-2)
tools/migration-scripts/04_unity_update_software_center_desktop_file (+36/-0)
To merge this branch: bzr merge lp:~3v1n0/unity/migrate-to-sc-favorite
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Robert Ancell Approve
Review via email: mp+286839@code.launchpad.net

Commit message

unity.migrations: add 04_unity_update_software_center_desktop_file

Update favorite to use gnome software

To post a comment you must log in.
Revision history for this message
Robert Ancell (robert-ancell) wrote :

The tools/migration-scripts/02_unity_setup_text_scale_factor changes really should be a separate commit.

Please split:

favorites = [i.replace('ubuntu-software-center', 'org.gnome.Software') if 'ubuntu-software-center.desktop' in i else i for i in favorites]

into multiple lines. It's really hard to understand.

Otherwise, it seems to do the right thing - migrate users from u-s-c to g-s.

Revision history for this message
Robert Ancell (robert-ancell) wrote :

LGTM

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

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 2014-08-26 23:17:51 +0000
3+++ debian/unity.migrations 2016-02-22 20:51:17 +0000
4@@ -1,3 +1,4 @@
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
10=== modified file 'tools/migration-scripts/02_unity_setup_text_scale_factor'
11--- tools/migration-scripts/02_unity_setup_text_scale_factor 2015-04-06 13:37:54 +0000
12+++ tools/migration-scripts/02_unity_setup_text_scale_factor 2016-02-22 20:51:17 +0000
13@@ -28,11 +28,12 @@
14 UNITY_UI_SETTINGS_PATH = "/com/canonical/unity/interface/"
15 UNITY_TEXT_SCALE_FACTOR = "text-scale-factor";
16
17-if GNOME_UI_SETTINGS not in Gio.Settings.list_schemas():
18+gnome_ui_schema = Gio.SettingsSchemaSource.get_default().lookup(GNOME_UI_SETTINGS, recursive=False)
19+if not gnome_ui_schema:
20 print("No gnome desktop interface schemas found, no migration needed")
21 sys.exit(0)
22
23-text_scale_factor = Gio.Settings(schema=GNOME_UI_SETTINGS).get_double(GNOME_TEXT_SCALE_FACTOR)
24+text_scale_factor = Gio.Settings(settings_schema=gnome_ui_schema).get_double(GNOME_TEXT_SCALE_FACTOR)
25
26 # gsettings doesn't work directly, the key is somewhat reverted. Work one level under then: dconf!
27 # Gio.Settings(schema=UNITY_UI_SETTINGS).set_int(UNITY_TEXT_SCALE_FACTOR, text_scale_factor)
28
29=== added file 'tools/migration-scripts/04_unity_update_software_center_desktop_file'
30--- tools/migration-scripts/04_unity_update_software_center_desktop_file 1970-01-01 00:00:00 +0000
31+++ tools/migration-scripts/04_unity_update_software_center_desktop_file 2016-02-22 20:51:17 +0000
32@@ -0,0 +1,36 @@
33+#!/usr/bin/python3
34+# -*- coding: utf-8 -*-
35+# Copyright (C) 2016 Canonical
36+#
37+# Authors:
38+# Marco Trevisan <marco.trevisan@canonical.com>
39+#
40+# This program is free software; you can redistribute it and/or modify it under
41+# the terms of the GNU General Public License as published by the Free Software
42+# Foundation; version 3.
43+#
44+# This program is distributed in the hope that it will be useful, but WITHOUTa
45+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
46+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
47+# details.
48+#
49+# You should have received a copy of the GNU General Public License along with
50+# this program; if not, write to the Free Software Foundation, Inc.,
51+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
52+
53+from gi.repository import Gio
54+
55+UNITY_LAUNCHER_SETTINGS = "com.canonical.Unity.Launcher";
56+UNITY_LAUNCHER_SETTINGS_PATH = "/com/canonical/unity/launcher/"
57+UNITY_LAUNCER_FAVORITES = "favorites";
58+
59+favorites = Gio.Settings(schema=UNITY_LAUNCHER_SETTINGS).get_strv(UNITY_LAUNCER_FAVORITES)
60+
61+for i in range(len(favorites)):
62+ if 'ubuntu-software-center.desktop' in favorites[i]:
63+ favorites[i] = favorites[i].replace('ubuntu-software-center', 'org.gnome.Software')
64+
65+# gsettings doesn't work directly, the key is somewhat reverted. Work one level under then: dconf!
66+from subprocess import Popen, PIPE, STDOUT
67+p = Popen(("dconf load "+UNITY_LAUNCHER_SETTINGS_PATH).split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT)
68+p.communicate(input=bytes("[/]\n"+UNITY_LAUNCER_FAVORITES+"={}".format(favorites), 'utf-8'))