[gnome-chess/chess-telepathy-networking-support-664946-rebase: 18/64] Make gnome-chess include config.h for preprocessor definitions



commit 5f2682da07b8be2f74e7a82550a2a4271f2c008e
Author: Chandni Verma <chandniverma2112 gmail com>
Date:   Fri Dec 21 16:39:34 2012 +0530

    Make gnome-chess include config.h for preprocessor definitions

 src/chess-view-2d.vala |    2 +-
 src/chess-view-3d.vala |   16 ++++++++--------
 src/config.vapi        |   14 +++++++++-----
 src/gnome-chess.vala   |   30 +++++++++++++++---------------
 4 files changed, 33 insertions(+), 29 deletions(-)
---
diff --git a/src/chess-view-2d.vala b/src/chess-view-2d.vala
index f6ea88d..17efada 100644
--- a/src/chess-view-2d.vala
+++ b/src/chess-view-2d.vala
@@ -35,7 +35,7 @@ private class ChessView2D : ChessView
         Rsvg.Handle handle;
         try
         {
-            handle = new Rsvg.Handle.from_file (Path.build_filename (PKGDATADIR, "pieces", scene.theme_name, name + ".svg", null));
+            handle = new Rsvg.Handle.from_file (Path.build_filename (Config.PKGDATADIR, "pieces", scene.theme_name, name + ".svg", null));
         }
         catch (Error e)
         {
diff --git a/src/chess-view-3d.vala b/src/chess-view-3d.vala
index 14bf9c1..ae1df16 100644
--- a/src/chess-view-3d.vala
+++ b/src/chess-view-3d.vala
@@ -36,7 +36,7 @@ private class ChessView3D : ChessView
     private GLuint _board_texture = 0;
     private GLuint board_texture
     {
-        get { if (_board_texture == 0) _board_texture = load_texture (Path.build_filename (PKGDATADIR, "textures", "board.png", null)); return _board_texture; }
+        get { if (_board_texture == 0) _board_texture = load_texture (Path.build_filename (Config.PKGDATADIR, "textures", "board.png", null)); return _board_texture; }
     }
 
     private GLuint _numbering_texture = 0;
@@ -48,7 +48,7 @@ private class ChessView3D : ChessView
     private GLuint _piece_texture = 0;
     private GLuint piece_texture
     {
-        get { if (_piece_texture == 0) _piece_texture = load_texture (Path.build_filename (PKGDATADIR, "textures", "piece.png", null)); return _piece_texture; }
+        get { if (_piece_texture == 0) _piece_texture = load_texture (Path.build_filename (Config.PKGDATADIR, "textures", "piece.png", null)); return _piece_texture; }
     }
 
     public ChessView3D ()
@@ -73,12 +73,12 @@ private class ChessView3D : ChessView
         double_buffered = false;
         try
         {
-            pawn_model = new TDSModel (File.new_for_path (Path.build_filename (PKGDATADIR, "pieces", "3d", "pawn.3ds", null)));
-            knight_model = new TDSModel (File.new_for_path (Path.build_filename (PKGDATADIR, "pieces", "3d", "knight.3ds", null)));
-            bishop_model = new TDSModel (File.new_for_path (Path.build_filename (PKGDATADIR, "pieces", "3d", "bishop.3ds", null)));
-            rook_model = new TDSModel (File.new_for_path (Path.build_filename (PKGDATADIR, "pieces", "3d", "rook.3ds", null)));
-            queen_model = new TDSModel (File.new_for_path (Path.build_filename (PKGDATADIR, "pieces", "3d", "queen.3ds", null)));
-            king_model = new TDSModel (File.new_for_path (Path.build_filename (PKGDATADIR, "pieces", "3d", "king.3ds", null)));
+            pawn_model = new TDSModel (File.new_for_path (Path.build_filename (Config.PKGDATADIR, "pieces", "3d", "pawn.3ds", null)));
+            knight_model = new TDSModel (File.new_for_path (Path.build_filename (Config.PKGDATADIR, "pieces", "3d", "knight.3ds", null)));
+            bishop_model = new TDSModel (File.new_for_path (Path.build_filename (Config.PKGDATADIR, "pieces", "3d", "bishop.3ds", null)));
+            rook_model = new TDSModel (File.new_for_path (Path.build_filename (Config.PKGDATADIR, "pieces", "3d", "rook.3ds", null)));
+            queen_model = new TDSModel (File.new_for_path (Path.build_filename (Config.PKGDATADIR, "pieces", "3d", "queen.3ds", null)));
+            king_model = new TDSModel (File.new_for_path (Path.build_filename (Config.PKGDATADIR, "pieces", "3d", "king.3ds", null)));
         }
         catch (Error e)
         {
diff --git a/src/config.vapi b/src/config.vapi
index 7f2503d..2feca8c 100644
--- a/src/config.vapi
+++ b/src/config.vapi
@@ -1,5 +1,9 @@
-public const string PKGDATADIR;
-public const string LOCALEDIR;
-public const string GETTEXT_PACKAGE;
-public const string VERSION;
-public const bool ENABLE_NETWORKING;
+[CCode (cprefix = "", lower_case_cprefix = "", cheader_filename = "config.h")]
+namespace Config
+{
+  public const string PKGDATADIR;
+  public const string LOCALEDIR;
+  public const string GETTEXT_PACKAGE;
+  public const string VERSION;
+  public const bool ENABLE_NETWORKING;
+}
diff --git a/src/gnome-chess.vala b/src/gnome-chess.vala
index a7e1907..8896a62 100644
--- a/src/gnome-chess.vala
+++ b/src/gnome-chess.vala
@@ -144,7 +144,7 @@ public class Application : Gtk.Application
         builder = new Gtk.Builder ();
         try
         {
-            builder.add_from_file (Path.build_filename (PKGDATADIR, "gnome-chess.ui", null));
+            builder.add_from_file (Path.build_filename (Config.PKGDATADIR, "gnome-chess.ui", null));
         }
         catch (Error e)
         {
@@ -244,7 +244,7 @@ public class Application : Gtk.Application
         settings.changed.connect (settings_changed_cb);
         settings_changed_cb (settings, "show-3d");
 
-        string engines_file = Path.build_filename (PKGDATADIR, "engines.conf", null);
+        string engines_file = Path.build_filename (Config.PKGDATADIR, "engines.conf", null);
         ai_profiles = load_ai_profiles (engines_file);
 
         foreach (var profile in ai_profiles)
@@ -286,7 +286,7 @@ public class Application : Gtk.Application
 
         }
 
-        if (!ENABLE_NETWORKING)
+        if (!Config.ENABLE_NETWORKING)
           togglebutton_remote_player.hide ();
 
         if (game_file == null)
@@ -333,7 +333,7 @@ public class Application : Gtk.Application
         promotion_type_selector_builder = new Gtk.Builder ();
         try
         {
-            promotion_type_selector_builder.add_from_file (Path.build_filename (PKGDATADIR, "promotion-type-selector.ui", null));
+            promotion_type_selector_builder.add_from_file (Path.build_filename (Config.PKGDATADIR, "promotion-type-selector.ui", null));
         }
         catch (Error e)
         {
@@ -348,16 +348,16 @@ public class Application : Gtk.Application
         else
             color = "black";
 
-        var filename = Path.build_filename (PKGDATADIR, "pieces", scene.theme_name, "%sQueen.svg".printf (color));
+        var filename = Path.build_filename (Config.PKGDATADIR, "pieces", scene.theme_name, "%sQueen.svg".printf (color));
         set_piece_image (promotion_type_selector_builder.get_object ("image_queen") as Gtk.Image, filename);
 
-        filename = Path.build_filename (PKGDATADIR, "pieces", scene.theme_name, "%sKnight.svg".printf (color));
+        filename = Path.build_filename (Config.PKGDATADIR, "pieces", scene.theme_name, "%sKnight.svg".printf (color));
         set_piece_image (promotion_type_selector_builder.get_object ("image_knight") as Gtk.Image, filename);
 
-        filename = Path.build_filename (PKGDATADIR, "pieces", scene.theme_name, "%sRook.svg".printf (color));
+        filename = Path.build_filename (Config.PKGDATADIR, "pieces", scene.theme_name, "%sRook.svg".printf (color));
         set_piece_image (promotion_type_selector_builder.get_object ("image_rook") as Gtk.Image, filename);
 
-        filename = Path.build_filename (PKGDATADIR, "pieces", scene.theme_name, "%sBishop.svg".printf (color));
+        filename = Path.build_filename (Config.PKGDATADIR, "pieces", scene.theme_name, "%sBishop.svg".printf (color));
         set_piece_image (promotion_type_selector_builder.get_object ("image_bishop") as Gtk.Image, filename);
 
         promotion_type_selector_builder.connect_signals (this);
@@ -1607,7 +1607,7 @@ public class Application : Gtk.Application
         preferences_builder = new Gtk.Builder ();
         try
         {
-            preferences_builder.add_from_file (Path.build_filename (PKGDATADIR, "preferences.ui", null));
+            preferences_builder.add_from_file (Path.build_filename (Config.PKGDATADIR, "preferences.ui", null));
         }
         catch (Error e)
         {
@@ -1881,7 +1881,7 @@ public class Application : Gtk.Application
         about_dialog.transient_for = window;
         about_dialog.modal = true;
         about_dialog.program_name = "Chess";
-        about_dialog.version = VERSION;
+        about_dialog.version = Config.VERSION;
         about_dialog.copyright = "Copyright 2010 Robert Ancell <robert ancell gmail com>";
         about_dialog.license_type = Gtk.License.GPL_2_0;
         about_dialog.comments = _("The 2D/3D chess game for GNOME. \n\nGNOME Chess is a part of GNOME Games.");
@@ -2125,15 +2125,15 @@ class GnomeChess
     public static int main (string[] args)
     {
         Intl.setlocale (LocaleCategory.ALL, "");
-        Intl.bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
-        Intl.bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-        Intl.textdomain (GETTEXT_PACKAGE);
+        Intl.bindtextdomain (Config.GETTEXT_PACKAGE, Config.LOCALEDIR);
+        Intl.bind_textdomain_codeset (Config.GETTEXT_PACKAGE, "UTF-8");
+        Intl.textdomain (Config.GETTEXT_PACKAGE);
 
         Gtk.init (ref args);
 
         var c = new OptionContext (/* Arguments and description for --help text */
                                    _("[FILE] - Play Chess"));
-        c.add_main_entries (options, GETTEXT_PACKAGE);
+        c.add_main_entries (options, Config.GETTEXT_PACKAGE);
         c.add_group (Gtk.get_option_group (true));
         try
         {
@@ -2150,7 +2150,7 @@ class GnomeChess
         if (show_version)
         {
             /* Note, not translated so can be easily parsed */
-            stderr.printf ("gnome-chess %s\n", VERSION);
+            stderr.printf ("gnome-chess %s\n", Config.VERSION);
             return Posix.EXIT_SUCCESS;
         }
 



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