gnome-games r8490 - in trunk: . aisleriot libgames-support
- From: chpe svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8490 - in trunk: . aisleriot libgames-support
- Date: Tue, 6 Jan 2009 18:20:17 +0000 (UTC)
Author: chpe
Date: Tue Jan 6 18:20:17 2009
New Revision: 8490
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8490&view=rev
Log:
Add start of PackageKit magic to install new card themes. Based on
nautilus code for interaction with PackageKit via DBus.
Modified:
trunk/aisleriot/window.c
trunk/configure.in
trunk/libgames-support/Makefile.am
trunk/libgames-support/games-card-themes.c
trunk/libgames-support/games-card-themes.h
Modified: trunk/aisleriot/window.c
==============================================================================
--- trunk/aisleriot/window.c (original)
+++ trunk/aisleriot/window.c Tue Jan 6 18:20:17 2009
@@ -63,7 +63,11 @@
#define MAIN_MENU_UI_PATH "/MainMenu"
#define RECENT_GAMES_MENU_PATH MAIN_MENU_UI_PATH "/GameMenu/RecentMenu"
#define OPTIONS_MENU_PATH MAIN_MENU_UI_PATH "/OptionsMenu"
+#ifdef HAVE_HILDON
#define CARD_THEMES_MENU_PATH MAIN_MENU_UI_PATH "/ViewMenu/ThemeMenu"
+#else
+#define CARD_THEMES_MENU_PATH MAIN_MENU_UI_PATH "/ViewMenu/ThemeMenu/ThemesPH"
+#endif
#define TOOLBAR_UI_PATH "/Toolbar"
/* The maximum number of recent games saved */
@@ -684,6 +688,21 @@
gtk_window_present (GTK_WINDOW (priv->stats_dialog));
}
+#ifdef ENABLE_CARD_THEMES_INSTALLER
+
+static void
+install_themes_cb (GtkAction *action,
+ AisleriotWindow *window)
+{
+ AisleriotWindowPrivate *priv = window->priv;
+
+ games_card_themes_install_themes (priv->theme_manager,
+ GTK_WINDOW (window),
+ gtk_get_current_event_time ());
+}
+
+#endif /* ENABLE_CARD_THEMES_INSTALLER */
+
#ifdef ENABLE_DEBUG_UI
#ifndef HAVE_HILDON
@@ -2130,6 +2149,11 @@
{ "About", GTK_STOCK_ABOUT, NULL, NULL,
ACTION_TOOLTIP (N_("About this game")),
G_CALLBACK (help_about_cb) },
+#ifdef ENABLE_CARD_THEMES_INSTALLER
+ { "InstallThemes", NULL, N_("Install card themesâ"), NULL,
+ ACTION_TOOLTIP (N_("Install new card themes from the distribution packages repositories")),
+ G_CALLBACK (install_themes_cb) },
+#endif /* ENABLE_CARD_THEMES_INSTALLER */
/* Toolbar-only actions */
#ifndef HAVE_MAEMO
@@ -2282,7 +2306,13 @@
"<menuitem action='Toolbar'/>"
"<menuitem action='Statusbar'/>"
"<separator/>"
- "<menu action='ThemeMenu'/>"
+ "<menu action='ThemeMenu'>"
+ "<placeholder name='ThemesPH'/>"
+#ifdef ENABLE_CARD_THEMES_INSTALLER
+ "<separator/>"
+ "<menuitem action='InstallThemes'/>"
+#endif
+ "</menu>"
"</menu>"
"<menu action='ControlMenu'>"
"<menuitem action='UndoMove'/>"
@@ -2533,6 +2563,11 @@
action = gtk_action_group_get_action (priv->action_group, "RecentMenu");
g_object_set (action, "hide-if-empty", FALSE, NULL);
+#ifdef ENABLE_CARD_THEMES_INSTALLER
+ action = gtk_action_group_get_action (priv->action_group, "InstallThemes");
+ gtk_action_set_sensitive (action, games_card_themes_can_install_themes (priv->theme_manager));
+#endif /* ENABLE_CARD_THEMES_INSTALLER */
+
set_fullscreen_actions (window, FALSE);
#ifdef HAVE_CLUTTER
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Tue Jan 6 18:20:17 2009
@@ -110,6 +110,7 @@
need_python=no
need_libxml=no
need_clutter=no
+need_dbus_glib=no
want_gstreamer=no
allow_gnuchess=no
allow_smclient=no
@@ -405,7 +406,25 @@
AC_DEFINE_UNQUOTED([GAMES_CARD_THEME_DEFAULT_FORMAT],[$GAMES_CARD_THEME_DEFAULT_FORMAT],[The default card theme format type])
-# Checks for libraries.
+# Card theme installer
+
+AC_MSG_CHECKING([whether card themes installer support is requested])
+AC_ARG_ENABLE([card-themes-installer],
+ [AS_HELP_STRING([--enable-card-themes-installer],[Enable card theme installer with PackageKit (default: disabled)])],
+ [],[enable_card_themes_installer=no])
+AC_MSG_RESULT([$enable_card_themes_installer])
+
+if test "$enable_card_themes_installer" = "yes"; then
+ AC_DEFINE([ENABLE_CARD_THEMES_INSTALLER],[1],[Define if card theme installer support is enabled])
+ need_dbus_glib=yes
+fi
+
+AM_CONDITIONAL([ENABLE_CARD_THEMES_INSTALLER],[test "$enable_card_themes_installer" = "yes"])
+
+# ********************
+# Checks for libraries
+# ********************
+
PYGTK_REQUIRED=2.10.0
GNOME_PYTHON_DESKTOP_REQUIRED=2.17.3
@@ -424,6 +443,7 @@
GSTREAMER_REQUIRED=0.10.11
HILDON_LIBS_REQUIRED=0.14
HILDON_1_REQUIRED=1.00
+DBUS_GLIB_REQUIRED=0.75
# Check for common modules
@@ -549,6 +569,14 @@
AM_CONDITIONAL([HAVE_CLUTTER],[test "$enable_clutter" = "yes"])
+# Check for DBUS/GLIB
+
+if test "$need_dbus_glib" = "yes"; then
+ PKG_CHECK_MODULES([DBUS_GLIB],[dbus-glib-1 >= $DBUS_GLIB_REQUIRED])
+ AC_SUBST([DBUS_GLIB_CFLAGS])
+ AC_SUBST([DBUS_GLIB_LIBS])
+fi
+
# Check for PyGTK
if test "$have_python" = "yes"; then
Modified: trunk/libgames-support/Makefile.am
==============================================================================
--- trunk/libgames-support/Makefile.am (original)
+++ trunk/libgames-support/Makefile.am Tue Jan 6 18:20:17 2009
@@ -186,6 +186,11 @@
libgames_support_la_LIBADD += $(SDL_MIXER_LIBS)
endif
+if ENABLE_CARD_THEMES_INSTALLER
+libgames_support_la_CFLAGS += $(DBUS_GLIB_CFLAGS)
+libgames_support_la_LIBADD += $(DBUS_GLIB_LIBS)
+endif
+
# Auxiliary programme to prerender card images
if HAVE_RSVG
Modified: trunk/libgames-support/games-card-themes.c
==============================================================================
--- trunk/libgames-support/games-card-themes.c (original)
+++ trunk/libgames-support/games-card-themes.c Tue Jan 6 18:20:17 2009
@@ -25,6 +25,14 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gtk/gtk.h>
+#ifdef ENABLE_CARD_THEMES_INSTALLER
+#include <dbus/dbus-glib.h>
+#endif
+
+#ifdef GDK_WINDOWING_X11
+#include <gdk/gdkx.h>
+#endif
+
#include "games-debug.h"
#include "games-profile.h"
#include "games-runtime.h"
@@ -249,6 +257,41 @@
return data.theme_info;
}
+#ifdef ENABLE_CARD_THEMES_INSTALLER
+
+typedef struct {
+ GamesCardThemes *theme_manager;
+ DBusGProxy *proxy;
+} ThemeInstallData;
+
+static void
+theme_install_data_free (ThemeInstallData *data)
+{
+ g_object_unref (data->theme_manager);
+ g_object_unref (data->proxy);
+ g_free (data);
+}
+
+static void
+theme_install_reply_cb (DBusGProxy *proxy,
+ DBusGProxyCall *call,
+ ThemeInstallData *data)
+{
+ GError *error = NULL;
+
+ if (!dbus_g_proxy_end_call (proxy, call, &error, G_TYPE_INVALID)) {
+ _games_debug_print (GAMES_DEBUG_CARD_THEME,
+ "Failed to call InstallPackages: %s\n",
+ error->message);
+ g_error_free (error);
+ return;
+ }
+
+ /* FIXME: re-scan theme directories, and emit "changed" signal */
+}
+
+#endif /* ENABLE_CARD_THEMES_INSTALLER */
+
/* Class implementation */
G_DEFINE_TYPE (GamesCardThemes, games_card_themes, G_TYPE_OBJECT);
@@ -529,3 +572,91 @@
return g_list_sort (list, (GCompareFunc) _games_card_theme_info_collate);
}
+
+
+/**
+ * games_card_themes_can_install_themes:
+ * @theme_manager:
+ *
+ * Returns: whether the new theme installer is supported
+ */
+gboolean
+games_card_themes_can_install_themes (GamesCardThemes *theme_manager)
+{
+#ifdef ENABLE_CARD_THEMES_INSTALLER
+ return TRUE;
+#else
+ return FALSE;
+#endif
+}
+
+/**
+ * games_card_themes_install_themes:
+ * @theme_manager:
+ * @parent_window:
+ * @user_time:
+ *
+ * Try to install more card themes.
+ */
+void
+games_card_themes_install_themes (GamesCardThemes *theme_manager,
+ GtkWindow *parent_window,
+ 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",
+ NULL
+ };
+
+ DBusGConnection *connection;
+ ThemeInstallData *data;
+ guint xid = 0;
+ GError *error = NULL;
+
+ connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (!connection) {
+ _games_debug_print (GAMES_DEBUG_CARD_THEME,
+ "Failed to get the session bus: %s\n",
+ error->message);
+ g_error_free (error);
+ return;
+ }
+
+ data = g_new (ThemeInstallData, 1);
+ data->theme_manager = g_object_ref (theme_manager);
+
+ /* PackageKit-GNOME interface */
+ data->proxy = dbus_g_proxy_new_for_name (connection,
+ "org.freedesktop.PackageKit",
+ "/org/freedesktop/PackageKit",
+ "org.freedesktop.PackageKit");
+ g_assert (data->proxy != NULL); /* the call above never fails */
+
+#ifdef GDK_WINDOWING_X11
+ if (parent_window) {
+ xid = GDK_WINDOW_XID (GTK_WIDGET (parent_window)->window);
+ }
+#endif
+
+ /* Installing can take a long time; don't do the automatic timeout */
+ dbus_g_proxy_set_default_timeout (data->proxy, G_MAXINT);
+
+ if (!dbus_g_proxy_begin_call (data->proxy,
+ "InstallPackageNames",
+ (DBusGProxyCallNotify) theme_install_reply_cb,
+ data,
+ (GDestroyNotify) theme_install_data_free,
+ G_TYPE_UINT, xid,
+ G_TYPE_UINT, user_time,
+ G_TYPE_STRV, packages,
+ G_TYPE_INVALID)) {
+ /* Failed; cleanup. FIXME: can this happen at all? */
+ _games_debug_print (GAMES_DEBUG_CARD_THEME,
+ "Failed to call the InstallPackages method\n");
+
+ theme_install_data_free (data);
+ }
+#endif
+}
Modified: trunk/libgames-support/games-card-themes.h
==============================================================================
--- trunk/libgames-support/games-card-themes.h (original)
+++ trunk/libgames-support/games-card-themes.h Tue Jan 6 18:20:17 2009
@@ -53,6 +53,12 @@
GList *games_card_themes_get_themes (GamesCardThemes *theme_manager);
+gboolean games_card_themes_can_install_themes (GamesCardThemes *theme_manager);
+
+void games_card_themes_install_themes (GamesCardThemes *theme_manager,
+ GtkWindow *parent_window,
+ guint user_time);
+
G_END_DECLS
#endif /* GAMES_CARD_THEMES_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]