summaryrefslogtreecommitdiff
diff options
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2016-02-22 21:34:21 +0100
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2016-02-22 21:34:21 +0100
commitc24c087860abe81313800c9e546f850a655045cd (patch)
tree49167a92b8d8b93853d10031141c19c15d732842
parent0973cb0c1e889358e155f2ad4241264a50231606 (diff)
unity.migrations: add 04_unity_update_software_center_desktop_file
Update favorite to use gnome software (bzr r4068.3.1)
-rw-r--r--debian/unity.migrations1
-rwxr-xr-xtools/migration-scripts/02_unity_setup_text_scale_factor5
-rw-r--r--tools/migration-scripts/04_unity_update_software_center_desktop_file33
3 files changed, 37 insertions, 2 deletions
diff --git a/debian/unity.migrations b/debian/unity.migrations
index 1d94ec01b..58bd12d59 100644
--- a/debian/unity.migrations
+++ b/debian/unity.migrations
@@ -1,3 +1,4 @@
tools/migration-scripts/01_unity_change_dconf_path
tools/migration-scripts/02_unity_setup_text_scale_factor
tools/migration-scripts/03_unity_first_run_stamp_move
+tools/migration-scripts/04_unity_update_software_center_desktop_file
diff --git a/tools/migration-scripts/02_unity_setup_text_scale_factor b/tools/migration-scripts/02_unity_setup_text_scale_factor
index 4b6fec3db..b4d42557d 100755
--- a/tools/migration-scripts/02_unity_setup_text_scale_factor
+++ b/tools/migration-scripts/02_unity_setup_text_scale_factor
@@ -28,11 +28,12 @@ UNITY_UI_SETTINGS = "com.canonical.Unity.Interface";
UNITY_UI_SETTINGS_PATH = "/com/canonical/unity/interface/"
UNITY_TEXT_SCALE_FACTOR = "text-scale-factor";
-if GNOME_UI_SETTINGS not in Gio.Settings.list_schemas():
+gnome_ui_schema = Gio.SettingsSchemaSource.get_default().lookup(GNOME_UI_SETTINGS, recursive=False)
+if not gnome_ui_schema:
print("No gnome desktop interface schemas found, no migration needed")
sys.exit(0)
-text_scale_factor = Gio.Settings(schema=GNOME_UI_SETTINGS).get_double(GNOME_TEXT_SCALE_FACTOR)
+text_scale_factor = Gio.Settings(settings_schema=gnome_ui_schema).get_double(GNOME_TEXT_SCALE_FACTOR)
# gsettings doesn't work directly, the key is somewhat reverted. Work one level under then: dconf!
# Gio.Settings(schema=UNITY_UI_SETTINGS).set_int(UNITY_TEXT_SCALE_FACTOR, text_scale_factor)
diff --git a/tools/migration-scripts/04_unity_update_software_center_desktop_file b/tools/migration-scripts/04_unity_update_software_center_desktop_file
new file mode 100644
index 000000000..ac5725626
--- /dev/null
+++ b/tools/migration-scripts/04_unity_update_software_center_desktop_file
@@ -0,0 +1,33 @@
+#!/usr/bin/python3
+# -*- coding: utf-8 -*-
+# Copyright (C) 2016 Canonical
+#
+# Authors:
+# Marco Trevisan <marco.trevisan@canonical.com>
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; version 3.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUTa
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+from gi.repository import Gio
+
+UNITY_LAUNCHER_SETTINGS = "com.canonical.Unity.Launcher";
+UNITY_LAUNCHER_SETTINGS_PATH = "/com/canonical/unity/launcher/"
+UNITY_LAUNCER_FAVORITES = "favorites";
+
+favorites = Gio.Settings(schema=UNITY_LAUNCHER_SETTINGS).get_strv(UNITY_LAUNCER_FAVORITES)
+favorites = [i.replace('ubuntu-software-center', 'org.gnome.Software') if 'ubuntu-software-center.desktop' in i else i for i in favorites]
+
+# gsettings doesn't work directly, the key is somewhat reverted. Work one level under then: dconf!
+from subprocess import Popen, PIPE, STDOUT
+p = Popen(("dconf load "+UNITY_LAUNCHER_SETTINGS_PATH).split(), stdout=PIPE, stdin=PIPE, stderr=STDOUT)
+p.communicate(input=bytes("[/]\n"+UNITY_LAUNCER_FAVORITES+"={}".format(favorites), 'utf-8'))