gnome-games r8567 - in trunk: . libgames-support
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8567 - in trunk: . libgames-support
- Date: Wed, 14 Jan 2009 23:41:57 +0000 (UTC)
Author: chpe
Date: Wed Jan 14 23:41:57 2009
New Revision: 8567
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8567&view=rev
Log:
Split the list of packages with card themes into an external key file.
Use the org.freedesktop.PackageKit.Modify interface.
Added:
trunk/libgames-support/theme-install.ini
Modified:
trunk/configure.in
trunk/libgames-support/Makefile.am
trunk/libgames-support/games-card-themes.c
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Wed Jan 14 23:41:57 2009
@@ -216,6 +216,22 @@
AC_C99_INITIALIZERS
AC_C99_STDINT_H
+# *****************
+# 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)"
+ LSB_DISTRIBUTION="$($LSB_RELEASE -s -d)"
+fi
+
+AC_DEFINE_UNQUOTED([LSB_DISTRIBUTOR],["$LSB_DISTRIBUTOR"],[The distributor ID])
+AC_DEFINE_UNQUOTED([LSB_DISTRIBUTION],["$LSB_DISTRIBUTION"],[The full distribution description])
+
# *************
# Documentation
# *************
@@ -427,6 +443,10 @@
AC_MSG_RESULT([$enable_card_themes_installer])
if test "$enable_card_themes_installer" = "yes"; then
+ if test -z "$LSB_DISTRIBUTOR" -o -z "$LSB_DISTRIBUTION"; then
+ AC_MSG_ERROR([couldn't determine the distribution information using lsb_release])
+ fi
+
AC_DEFINE([ENABLE_CARD_THEMES_INSTALLER],[1],[Define if card theme installer support is enabled])
need_dbus_glib=yes
fi
@@ -1009,6 +1029,8 @@
[GNOME_GAMES_CFLAGS="$GNOME_GAMES_CFLAGS $BUILD_BREAKER_BASIC $MEGA_BUILD_BREAKER"
GNOME_GAMES_CXXFLAGS="$GNOME_GAMES_CXXFLAGS $BUILD_BREAKER_BASIC $MEGA_BUILD_BREAKER"])
+##############################################
+
AC_SUBST([GNOME_GAMES_CFLAGS])
AC_SUBST([GNOME_GAMES_CXXFLAGS])
AC_SUBST([GNOME_GAMES_LIBS])
Modified: trunk/libgames-support/Makefile.am
==============================================================================
--- trunk/libgames-support/Makefile.am (original)
+++ trunk/libgames-support/Makefile.am Wed Jan 14 23:41:57 2009
@@ -1,10 +1,15 @@
NULL =
-carddir = $(datadir)/gnome-games-common/cards
+commondatadir = $(datadir)/gnome-games-common
+
+carddir = $(commondatadir)/cards
card_DATA = \
gnomangelo_bitmap.svg \
$(NULL)
+themeinstalldir = $(commondatadir)
+themeinstall_DATA = theme-install.ini
+
slotdir = $(pkgdatadir)/pixmaps
slot_DATA = slot.svg
@@ -12,6 +17,7 @@
$(schema_in_files) \
$(card_DATA) \
$(slot_DATA) \
+ $(themeinstall_DATA) \
games-marshal.list \
$(NULL)
Modified: trunk/libgames-support/games-card-themes.c
==============================================================================
--- trunk/libgames-support/games-card-themes.c (original)
+++ trunk/libgames-support/games-card-themes.c Wed Jan 14 23:41:57 2009
@@ -680,17 +680,79 @@
guint user_time)
{
#ifdef ENABLE_CARD_THEMES_INSTALLER
- /* FIXME: more packages, and test with other distros beside ubuntu! */
- const char *packages[] = {
- "gnome-games-extra-data",
+ 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
};
-
+ GKeyFile *key_file;
+ char *path;
+ const char *group;
+ GPtrArray *arr;
+ char **packages;
+ gsize n_packages, i, j;
DBusGConnection *connection;
ThemeInstallData *data;
guint xid = 0;
GError *error = NULL;
+ arr = g_ptr_array_new ();
+
+ key_file = g_key_file_new ();
+ path = games_runtime_get_file (GAMES_RUNTIME_COMMON_DATA_DIRECTORY, "theme-install.ini");
+ if (!g_key_file_load_from_file (key_file, path, 0, NULL))
+ goto do_install;
+
+ /* 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.
+ */
+ if (g_key_file_has_group (key_file, LSB_DISTRIBUTION))
+ group = LSB_DISTRIBUTION;
+ else if (g_key_file_has_group (key_file, LSB_DISTRIBUTOR))
+ group = LSB_DISTRIBUTOR;
+ else
+ goto do_install;
+
+ for (i = 0; formats[i] != NULL; ++i) {
+ packages = g_key_file_get_string_list (key_file, group, formats[i], &n_packages, NULL);
+ if (!packages)
+ continue;
+
+ for (j = 0; j < n_packages; ++j) {
+ g_ptr_array_add (arr, packages[j]);
+ }
+ g_free (packages); /* The strings are now owned by the ptr array */
+ }
+ g_ptr_array_add (arr, NULL);
+
+do_install:
+ g_key_file_free (key_file);
+ g_free (path);
+
+ n_packages = arr->len;
+ packages = (char **) g_ptr_array_free (arr, FALSE);
+ if (n_packages == 0) {
+ g_strfreev (packages);
+ return; /* FIXME: show dialogue? */
+ }
+
+#ifdef GNOME_ENABLE_DEBUG
+ _GAMES_DEBUG_IF (GAMES_DEBUG_CARD_THEME) {
+ _games_debug_print (GAMES_DEBUG_CARD_THEME, "Packages to install: ");
+ for (i = 0; packages[i]; ++i)
+ _games_debug_print (GAMES_DEBUG_CARD_THEME, "%s ", packages[i]);
+ _games_debug_print (GAMES_DEBUG_CARD_THEME, "\n");
+ }
+#endif
+
connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
if (!connection) {
_games_debug_print (GAMES_DEBUG_CARD_THEME,
@@ -707,7 +769,7 @@
data->proxy = dbus_g_proxy_new_for_name (connection,
"org.freedesktop.PackageKit",
"/org/freedesktop/PackageKit",
- "org.freedesktop.PackageKit");
+ "org.freedesktop.PackageKit.Modify");
g_assert (data->proxy != NULL); /* the call above never fails */
#ifdef GDK_WINDOWING_X11
@@ -725,8 +787,8 @@
data,
(GDestroyNotify) theme_install_data_free,
G_TYPE_UINT, xid,
- G_TYPE_UINT, user_time,
G_TYPE_STRV, packages,
+ G_TYPE_STRING, "" /* FIXME? interaction type */,
G_TYPE_INVALID)) {
/* Failed; cleanup. FIXME: can this happen at all? */
_games_debug_print (GAMES_DEBUG_CARD_THEME,
@@ -734,5 +796,7 @@
theme_install_data_free (data);
}
+
+ g_strfreev (packages);
#endif
}
Added: trunk/libgames-support/theme-install.ini
==============================================================================
--- (empty file)
+++ trunk/libgames-support/theme-install.ini Wed Jan 14 23:41:57 2009
@@ -0,0 +1,36 @@
+# Aisleriot card theme install
+#
+# This programme 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 2, or (at your option)
+# any later version.
+#
+# This programme 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 library; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
+#
+# *****************************************************************************
+#
+# Format: A group containing keys with lists of packages.
+# The group name is either [Distribution] or [Distributor], e.g.
+# "Ubuntu 8.10" or "Ubuntu". If the [Distribution] group doesn't exist,
+# we fall back to the [Distributor] one.
+# The entries are a semicolon-separated list of packages names to install
+# for the given theme format. Note the trailing semicolon! Only the
+# packages for theme formats enabled at compile time will actually
+# be installed.
+#
+# Distributors:
+# If you add your distribution here, please do send a patch upstream by filing
+# a bug at http://bugzilla.gnome.org/enter_bug.cgi?product=gnome-games&component=general
+#
+
+[Ubuntu]
+ThemesSVG=gnome-games-extra-data;
+ThemesKDE=kdegames-card-data;
+ThemesPySol=pysol-cardsets;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]