Hildonized Blackjack Proof of Concept
- From: James Liggett <jrliggett cox net>
- To: GNOME Games List <games-list gnome org>
- Subject: Hildonized Blackjack Proof of Concept
- Date: Sat, 23 Aug 2008 15:48:40 -0700
Hi everyone,
Over the past two weeks I've been experimenting with getting Blackjack
to work on my Nokia n810. The fruits of my labor can be found in the
attached patch. For the most part it works pretty well, except that it
doesn't remember the player's balance (looks like a gconf problem) and
that the rules selection tree view in the preferences dialog is only
about 4 pixels high.
To get this to work, I had to make a number of modifications to
Makefiles in Blackjack's source and to libgames-support. You'll notice
that I redid a lot of Blackjack's Makefile.am to be a little more like
AisleRiot's. Without these changes, various flags would be repeated when
given to the compiler, and Blackjack wouldn't build as a result. Also, I
noticed that in libgames-support's Makefile.am, there are a number of
files that are excluded from Hildon builds. I was able to enable the
files needed for Blackjack without any obvious side effects. But I
wonder if there's a reason these files were excluded in the first place.
Was it a conscious design decision, or was it just like that to speed up
building AisleRiot on this platform?
The attached patch should work against SVN trunk. As of yet I've only
got it running under Scratchbox using the x86 target with Diablo. I
tried ARMEL but it only segfaults there. I've had a lot of programs do
that and then work fine on the actual device so I'm not really
concerned.
I'm also working on making an installable package for it, but being a
Debian packaging newbie it seems I've still got a ways to go before I
figure it out... ;) I did get a package built, but it doesn't install if
you have AisleRiot installed on your tablet, because of the way
gnome-games deals with po files. The problem is that we assume that
users will always install all of the games as one package, so we just
have one big set of po files, which will be provided by the AisleRiot
package if you install it. But, this causes a problem if you try to do
the same thing with Blackjack, as the resultant package will try to
install the files in the exact same place, which will elicit complaints
from the package manager. I'm not really sure about what to do about
that. Personally, I prefer being able to pick and choose which games to
install with individual packages. But, I'm not too familiar with how
you'd rearrange the translations files and other stuff to do that, so I
don't know how hard it would be.
Please feel free to comment on the patch. And sorry for the very long
e-mail. :)
Thanks,
James Liggett
Index: /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/libgames-support/Makefile.am
===================================================================
--- /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/libgames-support/Makefile.am (revision 7821)
+++ /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/libgames-support/Makefile.am (working copy)
@@ -31,12 +31,20 @@
games-card-images.h \
games-card-theme.c \
games-card-theme.h \
+ games-card-selector.c \
+ games-card-selector.h \
games-conf.c \
games-conf.h \
games-files.c \
games-files.h \
+ games-find-file.c \
+ games-find-file.h \
+ games-frame.c \
+ games-frame.h \
games-pixbuf-utils.c \
games-pixbuf-utils.h \
+ games-preimage.c \
+ games-preimage.h \
games-sound.c \
games-sound.h \
games-stock.c \
@@ -47,16 +55,8 @@
libgames_support_la_SOURCES += \
games-clock.c \
games-clock.h \
- games-frame.c \
- games-frame.h \
- games-find-file.c \
- games-find-file.h \
games-gridframe.c \
games-gridframe.h \
- games-card-selector.c \
- games-card-selector.h \
- games-preimage.c \
- games-preimage.h \
games-score.h \
games-score.c \
games-scores.c \
Index: /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/blackjack/src/blackjack.cpp
===================================================================
--- /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/blackjack/src/blackjack.cpp (revision 7821)
+++ /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/blackjack/src/blackjack.cpp (working copy)
@@ -32,6 +32,19 @@
#include <gnome.h>
#endif
+#ifdef HAVE_HILDON
+#include <libosso.h>
+#include <string.h> /* Needed for strcmp */
+
+#ifdef HAVE_MAEMO_3
+#include <osso-browser-interface.h>
+#include <hildon-widgets/hildon-program.h>
+#else
+#include <hildon/hildon-program.h>
+#include <tablet-browser-interface.h>
+#endif /* HAVE_MAEMO_3 */
+#endif
+
#include "blackjack.h"
#include "events.h"
#include "draw.h"
@@ -287,7 +300,11 @@
static const char ui_definition[] =
"<ui>"
+#ifndef HAVE_HILDON
" <menubar name='MenuBar'>"
+#else
+ " <popup name='MenuBar'>"
+#endif
" <menu name='GameMenu' action='game-menu'>"
" <menuitem name='New' action='new-game' />"
" <menuitem name='Restart' action='restart-game' />"
@@ -318,7 +335,11 @@
" <menuitem name='Contents' action='show-help-contents'/>"
" <menuitem name='About' action='show-about'/>"
" </menu>"
+#ifndef HAVE_HILDON
" </menubar>"
+#else
+ " </popup>"
+#endif
" <toolbar name='ToolBar' action='toolbar'>"
" <placeholder name='GameToolItems'>"
" <toolitem name='New' action='new-game'/>"
@@ -356,7 +377,11 @@
{ "show-toolbar", NULL, N_("_Toolbar"), "<Control>T", N_("Show toolbar"), G_CALLBACK (on_toolbar_activate), show_toolbar },
};
+#ifndef HAVE_HILDON
toplevel_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+#else
+ toplevel_window = hildon_window_new ();
+#endif
games_conf_add_window (GTK_WINDOW (toplevel_window), NULL);
@@ -364,7 +389,10 @@
ui = gtk_ui_manager_new ();
gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (status_bar), FALSE);
+
+#ifndef HAVE_HILDON
games_stock_prepare_for_statusbar_tooltips (ui, status_bar);
+#endif
gtk_ui_manager_add_ui_from_string (ui, ui_definition, -1, &error);
@@ -378,9 +406,21 @@
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (toplevel_window), vbox);
+#ifndef HAVE_HILDON
gtk_box_pack_start (GTK_BOX (vbox), gtk_ui_manager_get_widget (ui, "/MenuBar"), FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), gtk_ui_manager_get_widget (ui, "/ToolBar"), FALSE, FALSE, 0);
-
+#else
+ HildonProgram *program;
+
+ program = HILDON_PROGRAM (hildon_program_get_instance ());
+
+ hildon_program_add_window (program, HILDON_WINDOW (toplevel_window));
+ hildon_window_set_menu (HILDON_WINDOW (toplevel_window),
+ GTK_MENU (gtk_ui_manager_get_widget (ui, "/MenuBar")));
+ hildon_window_add_toolbar (HILDON_WINDOW (toplevel_window),
+ GTK_TOOLBAR (gtk_ui_manager_get_widget (ui, "/ToolBar")));
+#endif
+
playing_area = gtk_drawing_area_new ();
gtk_box_pack_start (GTK_BOX (vbox), playing_area, TRUE, TRUE, 0);
@@ -419,7 +459,9 @@
g_free (label_string);
gtk_box_pack_start (GTK_BOX (group_box), balance_value_label, FALSE, FALSE, 0);
+#ifndef HAVE_HILDON
gtk_box_pack_start (GTK_BOX (hbox), status_bar, TRUE, TRUE, 0);
+#endif
fullscreen_action = gtk_action_group_get_action (actions, "Fullscreen");
@@ -677,7 +719,6 @@
#endif
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
-
#ifdef HAVE_GNOME
GnomeProgram *program;
program = gnome_program_init ("Blackjack", VERSION,
@@ -719,9 +760,5 @@
games_conf_shutdown ();
-#ifdef HAVE_GNOME
- g_object_unref (program);
-#endif
-
return 0;
}
Index: /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/blackjack/src/Makefile.am
===================================================================
--- /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/blackjack/src/Makefile.am (revision 7821)
+++ /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/blackjack/src/Makefile.am (working copy)
@@ -1,11 +1,3 @@
-INCLUDES = \
- -I$(top_srcdir)/libgames-support \
- -DPIXMAPDIR=\""$(pkgdatadir)/blackjack/pixmaps"\" \
- -DDATADIR=\""$(pkgdatadir)"\" \
- -DHAVE_GNOME \
- $(GNOME_GAMES_CXXFLAGS) \
- -DGNOMELOCALEDIR=\""$(datadir)/locale"\"
-
bin_PROGRAMS = blackjack
blackjack_SOURCES = \
@@ -38,7 +30,29 @@
chips.h \
chips.cpp
+blackjack_CPPFLAGS = \
+ -I$(top_srcdir)/libgames-support \
+ -DPIXMAPDIR=\""$(pkgdatadir)/blackjack/pixmaps"\" \
+ -DDATADIR=\""$(pkgdatadir)"\" \
+ -DGNOMELOCALEDIR="\"$(datadir)/locale\"" \
+ $(AM_CPPFLAGS)
+
+blackjack_CXXFLAGS =
+ $(GTK_CFLAGS) \
+ $(RSVG_CFLAGS \
+ $(AM_CXXFLAGS)
+
blackjack_LDADD = \
../../libgames-support/libgames-support.la \
- $(GNOME_GAMES_LIBS)
+ $(GTK_LIBS) \
+ $(RSVG_LIBS)
+
+if HAVE_GNOME
+blackjack_CXXFLAGS += $(GNOME_CFLAGS)
+blackjack_LDADD += $(GNOME_LIBS)
+endif
+if HAVE_HILDON
+blackjack_CXXFLAGS += $(HILDON_CFLAGS)
+blackjack_LDADD += $(HILDON_LIBS)
+endif
\ No newline at end of file
Index: /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/blackjack/data/Makefile.am
===================================================================
--- /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/blackjack/data/Makefile.am (revision 7821)
+++ /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/blackjack/data/Makefile.am (working copy)
@@ -4,7 +4,12 @@
Vegas_Downtown.rules \
Vegas_Strip.rules
+if HAVE_MAEMO
+sysdir = $(shell $(PKG_CONFIG) osso-af-settings --variable=desktopentrydir)
+else
sysdir = $(datadir)/applications
+endif
+
sys_in_files = blackjack.desktop.in.in
sys_DATA = $(sys_in_files:.desktop.in.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
Index: /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/blackjack/Makefile.am
===================================================================
--- /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/blackjack/Makefile.am (revision 7821)
+++ /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/blackjack/Makefile.am (working copy)
@@ -1 +1,5 @@
-SUBDIRS = src data pixmaps help
+SUBDIRS = src data pixmaps
+
+if HAVE_GNOME
+SUBDIRS += help
+endif
Index: /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/configure.in
===================================================================
--- /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/configure.in (revision 7821)
+++ /media/storage/scratchbox/users/jim/home/jim/blackjack-2.23.5/configure.in (working copy)
@@ -131,7 +131,7 @@
;;
esac
case $game in
- aisleriot) ;;
+ aisleriot|blackjack) ;;
*) disallow_hildon=yes ;;
esac
case $game in
@@ -277,10 +277,7 @@
AC_MSG_CHECKING([whether to enable scalable graphics])
AC_ARG_ENABLE([scalable],
[AS_HELP_STRING([--enable-scalable],[Enable scalable graphics])],
- [],[case "$with_platform" in
- gnome|gtk-only) enable_scalable=yes ;;
- hildon) enable_scalable=no ;;
- esac])
+ [],[enable_scalable=yes])
AC_MSG_RESULT([$enable_scalable])
# Checks for libraries.
@@ -353,12 +350,14 @@
if test "$with_platform_variant" = "maemo3"; then
PKG_CHECK_MODULES([HILDON],[
libosso
- hildon-libs >= $HILDON_LIBS_REQUIRED])
+ hildon-libs >= $HILDON_LIBS_REQUIRED
+ libxml-2.0 >= $LIBXML_REQUIRED])
else
PKG_CHECK_MODULES([HILDON],[
libosso
dbus-1
- hildon-1 >= $HILDON_1_REQUIRED])
+ hildon-1 >= $HILDON_1_REQUIRED
+ libxml-2.0 >= $LIBXML_REQUIRED])
fi
AC_SUBST([HILDON_CFLAGS])
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]