gnome-games r8112 - in trunk: . gnotski



Author: thomashpa
Date: Sun Oct 19 17:36:26 2008
New Revision: 8112
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8112&view=rev

Log:
remove libgnome dependency in gnotski

Modified:
   trunk/configure.in
   trunk/gnotski/Makefile.am
   trunk/gnotski/gnotski.c

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Sun Oct 19 17:36:26 2008
@@ -156,7 +156,7 @@
     *) need_rsvg=yes ;;
   esac
   case $game in
-    aisleriot|glines|gnobots2|gnomine|gnotravex) allow_smclient=yes ;;
+    aisleriot|glines|gnobots2|gnomine|gnotravex|gnotski) allow_smclient=yes ;;
     *) ;;
   esac
 done

Modified: trunk/gnotski/Makefile.am
==============================================================================
--- trunk/gnotski/Makefile.am	(original)
+++ trunk/gnotski/Makefile.am	Sun Oct 19 17:36:26 2008
@@ -14,7 +14,7 @@
 	-I$(top_srcdir)/libgames-support		\
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"	\
 	-DDATADIR="\"$(datadir)\""			\
-	-DPIXMAPDIR="\"$(pkgdatadir)/gnotski\""		\
+	-DPIXMAPDIR="\"$(pkgdatadir)/gnotski/pixmaps\""		\
 	$(AM_CPPFLAGS)
 
 gnotski_CFLAGS = \
@@ -42,7 +42,7 @@
 gnotski_LDADD += $(GTHREAD_LIBS)
 endif
 
-pixmapdir = $(pkgdatadir)/gnotski
+pixmapdir = $(pkgdatadir)/gnotski/pixmaps
 pixmap_DATA = \
 	gnotski.svg	\
 	$(NULL)

Modified: trunk/gnotski/gnotski.c
==============================================================================
--- trunk/gnotski/gnotski.c	(original)
+++ trunk/gnotski/gnotski.c	Sun Oct 19 17:36:26 2008
@@ -25,20 +25,20 @@
 #include <stdlib.h>
 
 #include <glib/gi18n.h>
-#include <gdk-pixbuf/gdk-pixbuf.h>
 #include <gtk/gtk.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
 
-#include <games-preimage.h>
-#include <games-gridframe.h>
-#include <games-stock.h>
-#include <games-scores.h>
-#include <games-scores-dialog.h>
-#include <games-conf.h>
-#include <games-runtime.h>
-
-#ifdef HAVE_GNOME
-#include <gnome.h>
-#endif
+#include <libgames-support/games-conf.h>
+#include <libgames-support/games-gridframe.h>
+#include <libgames-support/games-preimage.h>
+#include <libgames-support/games-runtime.h>
+#include <libgames-support/games-scores.h>
+#include <libgames-support/games-scores-dialog.h>
+#include <libgames-support/games-stock.h>
+
+#ifdef WITH_SMCLIENT
+#include <libgames-support/eggsmclient.h>
+#endif /* WITH_SMCLIENT */
 
 #include "pieces.h"
 
@@ -152,10 +152,10 @@
 gint move_piece (gint, gint, gint, gint, gint);
 void copymap (char *, char *);
 gint mapcmp (char *, char *);
-#ifdef HAVE_GNOME
-gint save_state (GnomeClient *, gint, GnomeRestartStyle, gint,
-		 GnomeInteractStyle, gint fast, gpointer);
-#endif /* HAVE_GNOME */              
+#ifdef WITH_SMCLIENT
+static int save_state_cb (EggSMClient *client, GKeyFile *keyfile, gpointer client_data);
+static int quit_cb (EggSMClient *client, gpointer client_data);
+#endif /* WITH_SMCLIENT */     
 void new_move (void);
 void game_score (void);
 gint game_over (void);
@@ -484,13 +484,11 @@
   GtkWidget *vbox;
   GtkWidget *menubar;
   gint startup_level;
-#ifdef HAVE_GNOME
-  GnomeClient *client;
-  GnomeProgram *program;
-#else
   gboolean retval;
   GError *error = NULL;
-#endif
+#ifdef WITH_SMCLIENT
+  EggSMClient *sm_client;
+#endif /* WITH_SMCLIENT */
 
 #if defined(HAVE_GNOME) || defined(HAVE_RSVG_GNOMEVFS)
   /* If we're going to use gnome-vfs, we need to init threads before
@@ -504,7 +502,7 @@
 
   setgid_io_init ();
 
-  bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
+  bindtextdomain (GETTEXT_PACKAGE, games_runtime_get_directory (GAMES_RUNTIME_LOCALE_DIRECTORY));
   bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
   textdomain (GETTEXT_PACKAGE);
 
@@ -512,25 +510,11 @@
 #if GLIB_CHECK_VERSION (2, 12, 0)
   g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
 #endif
-
-  g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
-
-#ifdef HAVE_GNOME
-  program = gnome_program_init (APPNAME, VERSION,
-				LIBGNOMEUI_MODULE,
-				argc, argv,
-				GNOME_PARAM_GOPTION_CONTEXT, context,
-				GNOME_PARAM_APP_DATADIR, DATADIR, NULL);
-
-  client = gnome_master_client ();
-
-  g_signal_connect (client, "save_yourself",
-                    G_CALLBACK (save_state), argv[0]);
-  g_signal_connect (client, "die",
-                    G_CALLBACK (quit_game_cb), argv[0]);
-
-#else
   g_option_context_add_group (context, gtk_get_option_group (TRUE));
+#ifdef WITH_SMCLIENT
+  g_option_context_add_group (context, egg_sm_client_get_option_group ());
+#endif /* WITH_SMCLIENT */
+  g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
 
   retval = g_option_context_parse (context, &argc, &argv, &error);
   g_option_context_free (context);
@@ -539,7 +523,6 @@
     g_error_free (error);
     exit (1);
   }
-#endif /* HAVE_GNOME */
 
   g_set_application_name (_(APPNAME_LONG));
 
@@ -549,6 +532,14 @@
 
   gtk_window_set_default_icon_name ("gnome-klotski");
   
+#ifdef WITH_SMCLIENT
+  sm_client = egg_sm_client_get ();
+  g_signal_connect (sm_client, "save-state",
+		    G_CALLBACK (save_state_cb), NULL);
+  g_signal_connect (sm_client, "quit",
+                    G_CALLBACK (quit_cb), NULL);
+#endif /* WITH_SMCLIENT */
+
   highscores = games_scores_new (&scoredesc);
 
   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -590,10 +581,6 @@
 
   games_conf_shutdown ();
 
-#ifdef HAVE_GNOME
-  g_object_unref (program);
-#endif /* HAVE_GNOME */
-
   games_runtime_shutdown ();
 
   return 0;
@@ -1181,10 +1168,12 @@
 void
 load_image (void)
 {
+  const char *dname;
   char *path;
   GError *error = NULL;
 
-  path = g_build_filename (PIXMAPDIR, "gnotski.svg", NULL);
+  dname = games_runtime_get_directory (GAMES_RUNTIME_GAME_PIXMAP_DIRECTORY);
+  path = g_build_filename (dname, "gnotski.svg", NULL);
   tiles_preimage = games_preimage_new_from_file (path, &error);
   g_free (path);
 
@@ -1481,36 +1470,43 @@
   gtk_main_quit ();
 }
 
-#ifdef HAVE_GNOME
-
-gint
-save_state (GnomeClient * client, gint phase,
-	    GnomeRestartStyle save_style, gint shutdown,
-	    GnomeInteractStyle interact_style, gint fast,
+#ifdef WITH_SMCLIENT
+static int
+save_state_cb (EggSMClient *client,
+	    GKeyFile* keyfile,
 	    gpointer client_data)
 {
   gchar *argv[20];
-  gint i;
+  gint argc;
   gint xpos, ypos;
 
   gdk_window_get_origin (window->window, &xpos, &ypos);
 
-  i = 0;
-  argv[i++] = (gchar *) client_data;
-  argv[i++] = "-x";
-  argv[i++] = g_strdup_printf ("%d", xpos);
-  argv[i++] = "-y";
-  argv[i++] = g_strdup_printf ("%d", ypos);
+  argc = 0;
+  argv[argc++] = g_get_prgname ();
+  argv[argc++] = "-x";
+  argv[argc++] = g_strdup_printf ("%d", xpos);
+  argv[argc++] = "-y";
+  argv[argc++] = g_strdup_printf ("%d", ypos);
 
-  gnome_client_set_restart_command (client, i, argv);
-  gnome_client_set_clone_command (client, 0, NULL);
+  egg_sm_client_set_restart_command (client, argc, (const char **) argv);
 
   g_free (argv[2]);
   g_free (argv[4]);
+
   return TRUE;
 }
 
-#endif /* HAVE_GNOME */
+static gint
+quit_cb (EggSMClient *client,
+         gpointer client_data)
+{
+  gtk_main_quit ();
+
+  return FALSE;
+}
+
+#endif /* WITH_SMCLIENT */
 
 void
 level_cb (GtkAction * action, GtkRadioAction * current)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]