gnome-games r8049 - trunk/gnect/src



Author: thomashpa
Date: Wed Oct 15 16:19:07 2008
New Revision: 8049
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8049&view=rev

Log:
No more libgnome for you my friend.

Modified:
   trunk/gnect/src/connect4.c
   trunk/gnect/src/gfx.c
   trunk/gnect/src/ggz-network.c
   trunk/gnect/src/main.c
   trunk/gnect/src/main.h
   trunk/gnect/src/prefs.c
   trunk/gnect/src/server.c
   trunk/gnect/src/theme.c

Modified: trunk/gnect/src/connect4.c
==============================================================================
--- trunk/gnect/src/connect4.c	(original)
+++ trunk/gnect/src/connect4.c	Wed Oct 15 16:19:07 2008
@@ -111,10 +111,8 @@
   long ob_size, len;
   FILE *h1;
   short x;
-  char *tmp = games_runtime_get_directory (GAMES_RUNTIME_GAME_DATA_DIRECTORY);
-  char *bookdata = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", tmp, WHITE_BOOK);
-
-  g_free (tmp);
+  const char *tmp = games_runtime_get_directory (GAMES_RUNTIME_GAME_DATA_DIRECTORY);
+  char *bookdata = g_build_filename (tmp, WHITE_BOOK, NULL);
 
   if (!g_file_test (bookdata, G_FILE_TEST_EXISTS)) {
     g_printerr ("velena: required file not found (%s)\n", bookdata);

Modified: trunk/gnect/src/gfx.c
==============================================================================
--- trunk/gnect/src/gfx.c	(original)
+++ trunk/gnect/src/gfx.c	Wed Oct 15 16:19:07 2008
@@ -26,8 +26,10 @@
 
 #include <config.h>
 
+#include <glib.h>
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
+
 #include <libgames-support/games-runtime.h>
 
 #include "main.h"
@@ -271,11 +273,10 @@
 }
 
 
-
 gboolean
 gfx_load_pixmaps (void)
 {
-  gchar *dname;
+  const char *dname;
   gchar *fname;
   GdkPixbuf *pb_tileset_tmp;
   GdkPixbuf *pb_bground_tmp = NULL;
@@ -283,9 +284,7 @@
   dname = games_runtime_get_directory (GAMES_RUNTIME_GAME_PIXMAP_DIRECTORY);
   /* Try the theme pixmaps, fallback to the default and then give up */
   while (TRUE) {
-    fname = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", dname,
-			     theme[p.theme_id].fname_tileset);
-
+    fname = g_build_filename (dname, theme[p.theme_id].fname_tileset, NULL);
     pb_tileset_tmp = gdk_pixbuf_new_from_file (fname, NULL);
     if (pb_tileset_tmp == NULL) {
       if (p.theme_id != 0) {
@@ -294,7 +293,6 @@
 	continue;
       } else {
 	gfx_load_error (fname);
-	g_free (dname);
 	g_free (fname);
 	return FALSE;
       }
@@ -310,19 +308,16 @@
   pb_tileset_raw = pb_tileset_tmp;
 
   if (theme[p.theme_id].fname_bground != NULL) {
-    fname = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%s", dname,
-			     theme[p.theme_id].fname_bground);
+    fname = g_build_filename (dname, theme[p.theme_id].fname_bground, NULL);
     pb_bground_tmp = gdk_pixbuf_new_from_file (fname, NULL);
     if (pb_bground_tmp == NULL) {
       gfx_load_error (fname);
       g_object_unref (pb_tileset_tmp);
-      g_free (dname);
       g_free (fname);
       return FALSE;
     }
     g_free (fname);
   }
-  g_free (dname);
 
   if (pb_bground_raw)
     g_object_unref (pb_bground_raw);

Modified: trunk/gnect/src/ggz-network.c
==============================================================================
--- trunk/gnect/src/ggz-network.c	(original)
+++ trunk/gnect/src/ggz-network.c	Wed Oct 15 16:19:07 2008
@@ -25,10 +25,12 @@
 
 
 
-#include "config.h"
-#include <gnome.h>
-#include <pwd.h>
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
 
+#include <pwd.h>
 #include <ggzmod.h>
 #include <ggz-embed.h>
 #include <ggz-gtk.h>

Modified: trunk/gnect/src/main.c
==============================================================================
--- trunk/gnect/src/main.c	(original)
+++ trunk/gnect/src/main.c	Wed Oct 15 16:19:07 2008
@@ -22,14 +22,16 @@
  * USA
  */
 
-#include "config.h"
-#include <gnome.h>
+#include <config.h>
 
-#include <games-gridframe.h>
-#include <games-stock.h>
-#include <games-sound.h>
-#include <games-conf.h>
-#include <games-runtime.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#include <libgames-support/games-conf.h>
+#include <libgames-support/games-gridframe.h>
+#include <libgames-support/games-runtime.h>
+#include <libgames-support/games-sound.h>
+#include <libgames-support/games-stock.h>
 
 #include "connect4.h"
 #include "main.h"
@@ -38,8 +40,8 @@
 #include "gfx.h"
 
 #ifdef GGZ_CLIENT
-#include <games-dlg-chat.h>
-#include <games-dlg-players.h>
+#include <libgames-support/games-dlg-chat.h>
+#include <libgames-support/games-dlg-players.h>
 #include "connectx_client.h"
 #include "ggz-network.h"
 #include <ggz-embed.h>
@@ -886,7 +888,7 @@
 static void
 on_help_about (GtkAction * action, gpointer data)
 {
-  const gchar *authors[] = { "Four-in-a-Row:",
+  const gchar *authors[] = { "Four-in-a-row:",
     "  Tim Musson <trmusson ihug co nz>",
     "  David Neary <bolsh gimp org>",
     "",
@@ -906,10 +908,10 @@
   const gchar *documenters[] = { "Timothy Musson",
     NULL
   };
-  gchar *license = games_get_license (_("Four-in-a-Row"));
+  gchar *license = games_get_license (_(APPNAME_LONG));
 
   gtk_show_about_dialog (GTK_WINDOW (app),
-			 "name", _("Four-in-a-Row"),
+			 "name", _(APPNAME_LONG),
 			 "version", VERSION,
 			 "copyright",
 			 "Copyright \xc2\xa9 1999-2008, Tim Musson and David Neary",
@@ -1412,7 +1414,9 @@
   GtkWidget *vpaned;
   GtkUIManager *ui_manager;
 
-  app = gnome_app_new (APPNAME, _("Four-in-a-Row"));
+  app = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_title (GTK_WINDOW (app), _(APPNAME_LONG));
+
   gtk_window_set_default_size (GTK_WINDOW (app), DEFAULT_WIDTH, DEFAULT_HEIGHT);
   games_conf_add_window (GTK_WINDOW (app), NULL);
 
@@ -1447,7 +1451,7 @@
   gtk_box_pack_start (GTK_BOX (vbox), vpaned, TRUE, TRUE, 0);
   gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0);
 
-  gnome_app_set_contents (GNOME_APP (app), notebook);
+  gtk_container_add (GTK_CONTAINER (app), notebook);
   gtk_notebook_append_page (GTK_NOTEBOOK (notebook), vbox, NULL);
   gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), MAIN_PAGE);
 
@@ -1498,26 +1502,31 @@
 int
 main (int argc, char *argv[])
 {
-  GnomeProgram *program;
   GOptionContext *context;
-
-  bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
-  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-  textdomain (GETTEXT_PACKAGE);
+  gboolean retval;
+  GError *error = NULL;
 
   g_thread_init (NULL);
   
   if (!games_runtime_init ("gnect"))
     return 1;
 
+  bindtextdomain (GETTEXT_PACKAGE, games_runtime_get_directory (GAMES_RUNTIME_LOCALE_DIRECTORY));
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+  textdomain (GETTEXT_PACKAGE);
+
   context = g_option_context_new (NULL);
+  g_option_context_add_group (context, gtk_get_option_group (TRUE));
   games_sound_add_option_group (context);
+  retval = g_option_context_parse (context, &argc, &argv, &error);
+  g_option_context_free (context);
+  if (!retval) {
+    g_print ("%s", error->message);
+    g_error_free (error);
+    exit (1);
+  }
 
-  program = gnome_program_init (APPNAME, VERSION, LIBGNOMEUI_MODULE,
-				argc, argv,
-                                GNOME_PARAM_GOPTION_CONTEXT, context,
-                                GNOME_PARAM_APP_DATADIR, DATADIR,
-				NULL);
+  g_set_application_name (_(APPNAME_LONG));
 
   games_conf_initialise (APPNAME);
 
@@ -1527,10 +1536,8 @@
   /* init gfx */
   if (!gfx_load_pixmaps ()) {
     games_conf_shutdown ();
-    g_object_unref (program);
     exit (1);
   }
-    
 
 #ifdef GGZ_CLIENT
   network_init ();
@@ -1545,8 +1552,6 @@
 
   games_conf_shutdown ();
 
-  g_object_unref (program);
-
   games_runtime_shutdown ();
 
   return 0;

Modified: trunk/gnect/src/main.h
==============================================================================
--- trunk/gnect/src/main.h	(original)
+++ trunk/gnect/src/main.h	Wed Oct 15 16:19:07 2008
@@ -2,6 +2,7 @@
 
 
 #define APPNAME "gnect"
+#define APPNAME_LONG N_("Four-in-a-row")
 
 #define TILE_PLAYER1           0
 #define TILE_PLAYER2           1

Modified: trunk/gnect/src/prefs.c
==============================================================================
--- trunk/gnect/src/prefs.c	(original)
+++ trunk/gnect/src/prefs.c	Wed Oct 15 16:19:07 2008
@@ -24,14 +24,17 @@
 
 
 
-#include "config.h"
+#include <config.h>
 
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
 #include <gdk/gdkkeysyms.h>
-#include <gnome.h>
+
 #include <games-conf.h>
 #include <games-frame.h>
 #include <games-controls.h>
 #include <games-sound.h>
+
 #include "main.h"
 #include "theme.h"
 #include "prefs.h"

Modified: trunk/gnect/src/server.c
==============================================================================
--- trunk/gnect/src/server.c	(original)
+++ trunk/gnect/src/server.c	Wed Oct 15 16:19:07 2008
@@ -15,9 +15,8 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
-#include "config.h"
-#include <gnome.h>
-#include <ggzdmod.h>
+#include <config.h>
+
 #include <sys/types.h>
 #include <errno.h>
 #include <stdio.h>
@@ -25,6 +24,10 @@
 #include <time.h>
 #include <unistd.h>
 
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <ggzdmod.h>
+
 #include "connect4.h"
 #include "main.h"
 #include "server.h"

Modified: trunk/gnect/src/theme.c
==============================================================================
--- trunk/gnect/src/theme.c	(original)
+++ trunk/gnect/src/theme.c	Wed Oct 15 16:19:07 2008
@@ -24,8 +24,11 @@
 
 
 
-#include "config.h"
-#include <gnome.h>
+#include <config.h>
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
 #include "main.h"
 #include "theme.h"
 #include "prefs.h"



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