[aisleriot] themes: Use a packagekit catalogue to install the card themes
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aisleriot] themes: Use a packagekit catalogue to install the card themes
- Date: Mon, 28 Nov 2011 14:54:14 +0000 (UTC)
commit 9805371ede59831b62117358d145ce95e26d7cbe
Author: Christian Persch <chpe gnome org>
Date: Mon Nov 28 15:52:42 2011 +0100
themes: Use a packagekit catalogue to install the card themes
Instead of guessing the distro based on lsb_release and building a
package list from that with data from a key file for the various
distros, just use a packagekit catalogue file and let packagekit
sort it all out.
configure.ac | 33 +++++------------
data/Makefile.am | 6 ++-
data/aisleriot.catalog.in | 44 ++++++++++++++++++++++++
data/theme-install.ini | 51 ----------------------------
src/lib/ar-card-themes.c | 82 ++++++++++++--------------------------------
src/lib/ar-card-themes.h | 4 +-
6 files changed, 83 insertions(+), 137 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 601523e..9099bf0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -34,27 +34,6 @@ AC_PROG_LIBTOOL
GNOME_COMMON_INIT
GNOME_DEBUG_CHECK
-# *****************
-# Distribution info
-# *****************
-
-LSB_DISTRIBUTOR=
-LSB_DISTRIBUTION=
-
-AC_PATH_PROG([LSB_RELEASE],[lsb_release],[false])
-if test "$LSB_RELEASE" != "false"; then
- LSB_DISTRIBUTOR="$($LSB_RELEASE -s -i | sed 's,^\",,;s,\"$,,')"
- LSB_DISTRIBUTION="$($LSB_RELEASE -s -d | sed 's,^\",,;s,\"$,,')"
-fi
-
-AC_MSG_CHECKING([for LSB distributor])
-AC_MSG_RESULT([$LSB_DISTRIBUTOR])
-AC_MSG_CHECKING([for LSB distribution])
-AC_MSG_RESULT([$LSB_DISTRIBUTION])
-
-AC_DEFINE_UNQUOTED([LSB_DISTRIBUTOR],["$LSB_DISTRIBUTOR"],[The distributor ID])
-AC_DEFINE_UNQUOTED([LSB_DISTRIBUTION],["$LSB_DISTRIBUTION"],[The full distribution description])
-
# ************
# Dependencies
# ************
@@ -220,11 +199,18 @@ AM_CONDITIONAL([ENABLE_CARD_THEME_FORMAT_PYSOL],[test "$enable_card_theme_format
# Card theme paths
+AC_PATH_PROG([LSB_RELEASE],[lsb_release],[false])
+if test "$LSB_RELEASE" != "false"; then
+ LSB_DISTRIBUTION="$($LSB_RELEASE -s -d | sed 's,^\",,;s,\"$,,')"
+else
+ LSB_DISTRIBUTION=
+fi
+
if test "$enable_card_theme_format_kde" = "yes"; then
AC_MSG_CHECKING([for KDE card themes base path])
AC_ARG_WITH([kde-card-theme-path],
[AS_HELP_STRING([--with-kde-card-theme-path],[The base path to the KDE card themes])],
- [],[case $LSB_DISTRIBUTION in
+ [],[case "$LSB_DISTRIBUTION" in
*Debian*|*Fedora*|*RedHat*|*SUSE*|*Ubuntu*) with_kde_card_theme_path="/usr/share/kde4/apps/carddecks" ;;
*) AC_MSG_ERROR([When enabling the KDE card theme format, you must specify the KDE card themes base path.]) ;;
esac])
@@ -237,7 +223,7 @@ if test "$enable_card_theme_format_pysol" = "yes"; then
AC_MSG_CHECKING([for PySol card themes base path])
AC_ARG_WITH([pysol-card-theme-path],
[AS_HELP_STRING([--with-pysol-card-theme-path],[The base path to the PySol card themes])],
- [],[case $LSB_DISTRIBUTION in
+ [],[case "$LSB_DISTRIBUTION" in
*Debian*|*Ubuntu*) with_pysol_card_theme_path="/usr/share/games/pysol" ;;
*Fedora*|*RedHat*) with_pysol_card_theme_path="/usr/share/PySolFC" ;;
*SUSE*) with_pysol_card_theme_path="/usr/share/games/pysol/data" ;;
@@ -658,6 +644,7 @@ AC_CONFIG_FILES([
Makefile
cards/Makefile
data/Makefile
+data/aisleriot.catalog
data/icons/Makefile
data/sounds/Makefile
data/sol.desktop.in
diff --git a/data/Makefile.am b/data/Makefile.am
index 128908a..1e18d2e 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -11,8 +11,8 @@ slotdir = $(pkgdatadir)/pixmaps
dist_slot_DATA = slot.svg
endif # HAVE_RSVG
-themeinstalldir = $(pkgdatadir)
-dist_themeinstall_DATA = theme-install.ini
+pkcatalogdir = $(pkgdatadir)
+pkcatalog_DATA = aisleriot.catalog
desktop_in_files = \
sol.desktop.in.in \
@@ -28,10 +28,12 @@ EXTRA_DIST = \
CLEANFILES = \
$(desktop_DATA) \
+ $(pkcatalog_DATA) \
$(NULL)
DISTCLEANFILES = \
$(desktop_DATA) \
+ $(pkcatalog_DATA) \
$(NULL)
@INTLTOOL_DESKTOP_RULE@
diff --git a/data/aisleriot.catalog.in b/data/aisleriot.catalog.in
new file mode 100644
index 0000000..69c653a
--- /dev/null
+++ b/data/aisleriot.catalog.in
@@ -0,0 +1,44 @@
+# Aisleriot card theme catalogue
+#
+# 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, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT 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, see <http://www.gnu.org/licenses/>.
+#
+# *****************************************************************************
+# This is a PackageKit catalogue file for installing Aisleriot card themes.
+# See http://www.packagekit.org/pk-faq.html#catalogs for some hints on the
+# file format, and
+# http://cgit.freedesktop.org/packagekit/tree/lib/packagekit-glib2/pk-common.c
+# in the pk_get_distro_id() function for a list of distribution IDs.
+# *****************************************************************************
+
+[PackageKit Catalog]
+
+# Debian
+ ENABLE_CARD_THEME_FORMAT_SVG_TRUE@InstallPackages(debian)=gnome-games-extra-data;
+ ENABLE_CARD_THEME_FORMAT_KDE_TRUE@InstallPackages(debian)=kdegames-card-data;
+ ENABLE_CARD_THEME_FORMAT_PYSOL_TRUE@InstallPackages(debian)=pysolfc-cardsets;
+
+# Fedora
+ ENABLE_CARD_THEME_FORMAT_SVG_TRUE@InstallPackages(fedora)=
+ ENABLE_CARD_THEME_FORMAT_KDE_TRUE@InstallPackages(fedora)=kdegames-minimal;
+ ENABLE_CARD_THEME_FORMAT_PYSOL_TRUE@InstallPackages(fedora)=PySolFC-cardsets;
+
+# Suse
+ ENABLE_CARD_THEME_FORMAT_SVG_TRUE@InstallPackages(suse)=aisleriot-themes;
+ ENABLE_CARD_THEME_FORMAT_KDE_TRUE@InstallPackages(suse)=kdegames4-carddecks-default;kdegames4-carddecks-other;
+ ENABLE_CARD_THEME_FORMAT_PYSOL_TRUE@InstallPackages(suse)=pysol-cardsets;
+
+# Ubuntu
+ ENABLE_CARD_THEME_FORMAT_SVG_TRUE@InstallPackages(ubuntu)=gnome-cards-data;
+ ENABLE_CARD_THEME_FORMAT_KDE_TRUE@InstallPackages(ubuntu)=kdegames-card-data;kdegames-card-data-extra;
+ ENABLE_CARD_THEME_FORMAT_PYSOL_TRUE@InstallPackages(ubuntu)=pysolfc-cardsets;
diff --git a/src/lib/ar-card-themes.c b/src/lib/ar-card-themes.c
index 58c4b1a..aa45cfb 100644
--- a/src/lib/ar-card-themes.c
+++ b/src/lib/ar-card-themes.c
@@ -374,8 +374,8 @@ theme_install_reply_cb (GDBusConnection *connection,
variant = g_dbus_connection_call_finish (connection, result, &error);
if (variant == NULL) {
ar_debug_print (AR_DEBUG_CARD_THEME,
- "Failed to call InstallPackages: %s\n",
- error->message);
+ "Failed to call InstallCatalogs: %s\n",
+ error->message);
g_error_free (error);
g_object_unref (theme_manager);
return;
@@ -641,85 +641,49 @@ ar_card_themes_get_themes (ArCardThemes *theme_manager)
*/
void
ar_card_themes_install_themes (ArCardThemes *theme_manager,
- GtkWindow *parent_window,
- guint user_time)
+ GtkWidget *parent_window,
+ guint user_time)
{
- static const char *formats[] = {
-#ifdef ENABLE_CARD_THEME_FORMAT_SVG
- "ThemesSVG",
-#endif
-#ifdef ENABLE_CARD_THEME_FORMAT_KDE
- "ThemesKDE",
-#endif
-#ifdef ENABLE_CARD_THEME_FORMAT_PYSOL
- "ThemesPySol",
-#endif
- NULL
- };
char *path;
- GKeyFile *key_file;
GDBusConnection *connection;
GVariantBuilder builder;
- gsize i;
GError *error = NULL;
+ path = ar_runtime_get_file (AR_RUNTIME_PKG_DATA_DIRECTORY, "aisleriot.catalog");
+
+ /* The gnome-packagekit DBUS API is broken */
+ if (!g_utf8_validate (path, -1, NULL)) {
+ g_free (path);
+ g_warning ("Borked! Cannot call InstallCatalogs with non-UTF-8 path!\n");
+ return;
+ }
+
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
if (connection == NULL) {
ar_debug_print (AR_DEBUG_CARD_THEME,
- "Failed to get the session bus: %s\n",
- error->message);
+ "Failed to get the session bus: %s\n",
+ error->message);
g_error_free (error);
- return;
- }
-
- key_file = g_key_file_new ();
- path = ar_runtime_get_file (AR_RUNTIME_PKG_DATA_DIRECTORY, "theme-install.ini");
- if (!g_key_file_load_from_file (key_file, path, 0, NULL)) {
g_free (path);
- g_key_file_free (key_file);
- g_object_unref (connection);
return;
}
- g_free (path);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("(uass)"));
#ifdef GDK_WINDOWING_X11
- if (parent_window) {
+ if (parent_window &&
+ GDK_IS_X11_DISPLAY (gtk_widget_get_display (parent_window))) {
g_variant_builder_add (&builder, "u",
- (guint) GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (parent_window))));
+ (guint) GDK_WINDOW_XID (gtk_widget_get_window (parent_window)));
} else
#endif
g_variant_builder_add (&builder, "u", (guint) 0);
g_variant_builder_open (&builder, G_VARIANT_TYPE ("as"));
-
- /* If there's a group for the specific distribution, use that one, or
- * otherwise the generic one. E.g.:
- * If "Ubuntu 8.10" group exists, use it, else fallback to "Ubuntu" group.
- */
- for (i = 0; formats[i] != NULL; ++i) {
- char **packages;
- gsize n_packages, j;
-
- packages = g_key_file_get_string_list (key_file, LSB_DISTRIBUTION, formats[i], &n_packages, NULL);
- if (packages == NULL)
- packages = g_key_file_get_string_list (key_file, LSB_DISTRIBUTOR, formats[i], &n_packages, NULL);
- if (packages == NULL)
- continue;
-
- for (j = 0; j < n_packages; ++j) {
- g_variant_builder_add (&builder, "s", packages[j]);
- ar_debug_print (AR_DEBUG_CARD_THEME, "Requesting pkg '%s'\n",
- packages[j]);
- }
-
- g_strfreev (packages);
- }
-
- g_key_file_free (key_file);
-
+ g_variant_builder_add (&builder, "s", path);
g_variant_builder_close (&builder);
+ g_free (path);
+
g_variant_builder_add (&builder, "s", "hide-confirm-search" ","
"show-confirm-install" ","
"hide-warning");
@@ -728,12 +692,12 @@ ar_card_themes_install_themes (ArCardThemes *theme_manager,
"org.freedesktop.PackageKit",
"/org/freedesktop/PackageKit",
"org.freedesktop.PackageKit.Modify",
- "InstallPackageNames",
+ "InstallCatalogs",
g_variant_builder_end (&builder),
G_VARIANT_TYPE ("()"),
G_DBUS_CALL_FLAGS_NONE,
G_MAXINT /* no timeout */,
- NULL,
+ NULL /* cancellable */,
(GAsyncReadyCallback) theme_install_reply_cb,
g_object_ref (theme_manager));
}
diff --git a/src/lib/ar-card-themes.h b/src/lib/ar-card-themes.h
index 776f316..b27739c 100644
--- a/src/lib/ar-card-themes.h
+++ b/src/lib/ar-card-themes.h
@@ -58,8 +58,8 @@ ArCardTheme *ar_card_themes_get_theme_by_name (ArCardThemes *theme_manager,
ArCardTheme *ar_card_themes_get_theme_any (ArCardThemes *theme_manager);
void ar_card_themes_install_themes (ArCardThemes *theme_manager,
- GtkWindow *parent_window,
- guint user_time);
+ GtkWidget *parent_window,
+ guint user_time);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]