[four-in-a-row/KaKnife/four-in-a-row-vala: 4/65] added some more impls



commit 7370fb1edf132b17763d9bb2bac8aa50eaf2d1bb
Author: Jacob Humphrey <jacob ryan humphrey gmail com>
Date:   Fri Nov 9 17:06:09 2018 -0600

    added some more impls

 src/Makefile.am |   4 +-
 src/gfx2.vala   |   6 +--
 src/main.c      | 149 +++++---------------------------------------------------
 src/main2.vala  | 131 ++++++++++++++++++++++++++++++++++++++++++++++---
 src/prefs.c     | 126 +++++++++++++++++++++++------------------------
 src/prefs.vala  |   6 +--
 src/temp.vapi   |  35 ++++++++-----
 src/theme.c     | 108 ----------------------------------------
 src/theme.h     |   8 +--
 src/theme.vala  |  73 +++++++++++++++++++++++++++
 10 files changed, 305 insertions(+), 341 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index e8031e0..480e4d8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,7 +7,6 @@ four_in_a_row_SOURCES = main.h     \
                 gfx.h      \
                 gfx.c      \
                 prefs.h    \
-                theme.c    \
                 theme.h    \
                 games-controls.c \
                 games-controls.h \
@@ -17,7 +16,8 @@ four_in_a_row_SOURCES = main.h     \
                 main2.vala \
                 $(ai_HEADER)\
                prefs.vala \
-               gfx2.vala
+               gfx2.vala \
+               theme.vala
 
 four_in_a_row_CPPFLAGS = \
        -I$(top_srcdir)
diff --git a/src/gfx2.vala b/src/gfx2.vala
index 5c6db0f..47bdf90 100644
--- a/src/gfx2.vala
+++ b/src/gfx2.vala
@@ -8,10 +8,8 @@ extern Gdk.Pixbuf? pb_bground;
 extern Gdk.Pixbuf? pb_tileset;
 extern Gdk.Pixbuf? pb_tileset_raw;
 extern Gdk.Pixbuf? pb_bground_raw;
-extern Theme theme[];
-extern int[,] gboard;
-
-int gboard_length2 = 7;
+//extern Theme theme[];
+int[,] gboard;
 
 namespace Gfx{
     public int get_column (int xpos) {
diff --git a/src/main.c b/src/main.c
index 3810de0..5e9dc65 100644
--- a/src/main.c
+++ b/src/main.c
@@ -45,14 +45,14 @@
 extern Prefs p;
 
 GSettings *settings;
-GtkWidget *window;
+extern GtkWidget *window;
 GtkWidget *drawarea;
 GtkWidget *headerbar;
-GtkWidget *scorebox = NULL;
-GtkApplication *application;
+extern GtkWidget *scorebox;
+extern GtkApplication *application;
 
-GtkWidget *label_name[3];
-GtkWidget *label_score[3];
+extern GtkWidget *label_name[3];
+extern GtkWidget *label_score[3];
 
 GAction *new_game_action;
 GAction *undo_action;
@@ -71,12 +71,12 @@ extern gint row;
 extern gint row_dropto;
 extern gint timeout;
 
-gint gboard[7][7];
-gchar vstr[SIZE_VSTR];
+extern gint gboard[7][7];
+extern gchar vstr[SIZE_VSTR];
 gchar vlevel[] = "0abc";
 struct board *vboard;
 
-AnimID anim;
+extern AnimID anim;
 
 extern gint blink_r1, blink_c1;
 extern gint blink_r2, blink_c2;
@@ -100,6 +100,8 @@ gboolean is_player_human ();
 int get_n_human_players();
 void on_game_undo (GSimpleAction *action, GVariant *parameter);
 void on_game_scores (GSimpleAction *action, GVariant *parameter);
+void on_game_new (GSimpleAction *action, GVariant *parameter, gpointer data);
+void on_game_exit (GSimpleAction *action, GVariant *parameter, gpointer data);
 
 gboolean
 on_animate (gint c)
@@ -300,15 +302,7 @@ prompt_player (void)
 
 
 
-void on_game_new (GSimpleAction *action, GVariant *parameter, gpointer data);
-
-void
-on_game_exit (GSimpleAction *action, GVariant *parameter, gpointer data)
-{
 
-  stop_anim ();
-  g_application_quit (G_APPLICATION (application));
-}
 
 
 
@@ -393,21 +387,6 @@ scorebox_update (void)
   g_free (s);
 }
 
-
-
-void
-scorebox_reset (void)
-{
-  score[PLAYER1] = 0;
-  score[PLAYER2] = 0;
-  score[NOBODY] = 0;
-  scorebox_update ();
-}
-
-
-
-
-
 void
 on_help_about (GSimpleAction *action, GVariant *parameter, gpointer data)
 {
@@ -461,87 +440,6 @@ on_settings_preferences (GSimpleAction *action, GVariant *parameter, gpointer us
   prefsbox_open ();
 }
 
-
-
-gboolean
-is_hline_at (PlayerID p, gint r, gint c, gint * r1, gint * c1, gint * r2, gint * c2)
-{
-  *r1 = *r2 = r;
-  *c1 = *c2 = c;
-  while (*c1 > 0 && gboard[r][*c1 - 1] == p)
-    *c1 = *c1 - 1;
-  while (*c2 < 6 && gboard[r][*c2 + 1] == p)
-    *c2 = *c2 + 1;
-  if (*c2 - *c1 >= 3)
-    return TRUE;
-  return FALSE;
-}
-
-
-
-gboolean
-is_vline_at (PlayerID p, gint r, gint c, gint * r1, gint * c1, gint * r2, gint * c2)
-{
-  *r1 = *r2 = r;
-  *c1 = *c2 = c;
-  while (*r1 > 1 && gboard[*r1 - 1][c] == p)
-    *r1 = *r1 - 1;
-  while (*r2 < 6 && gboard[*r2 + 1][c] == p)
-    *r2 = *r2 + 1;
-  if (*r2 - *r1 >= 3)
-    return TRUE;
-  return FALSE;
-}
-
-gboolean
-is_dline1_at (PlayerID p, gint r, gint c, gint * r1, gint * c1, gint * r2, gint * c2)
-{
-  /* upper left to lower right */
-  *r1 = *r2 = r;
-  *c1 = *c2 = c;
-  while (*c1 > 0 && *r1 > 1 && gboard[*r1 - 1][*c1 - 1] == p) {
-    *r1 = *r1 - 1;
-    *c1 = *c1 - 1;
-  }
-  while (*c2 < 6 && *r2 < 6 && gboard[*r2 + 1][*c2 + 1] == p) {
-    *r2 = *r2 + 1;
-    *c2 = *c2 + 1;
-  }
-  if (*r2 - *r1 >= 3)
-    return TRUE;
-  return FALSE;
-}
-
-gboolean
-is_dline2_at (PlayerID p, gint r, gint c, gint * r1, gint * c1, gint * r2, gint * c2)
-{
-  /* upper right to lower left */
-  *r1 = *r2 = r;
-  *c1 = *c2 = c;
-  while (*c1 < 6 && *r1 > 1 && gboard[*r1 - 1][*c1 + 1] == p) {
-    *r1 = *r1 - 1;
-    *c1 = *c1 + 1;
-  }
-  while (*c2 > 0 && *r2 < 6 && gboard[*r2 + 1][*c2 - 1] == p) {
-    *r2 = *r2 + 1;
-    *c2 = *c2 - 1;
-  }
-  if (*r2 - *r1 >= 3)
-    return TRUE;
-  return FALSE;
-}
-
-gboolean
-is_line_at (PlayerID p, gint r, gint c)
-{
-  gint r1, r2, c1, c2;
-
-  return is_hline_at (p, r, c, &r1, &c1, &r2, &c2) ||
-    is_vline_at (p, r, c, &r1, &c1, &r2, &c2) ||
-    is_dline1_at (p, r, c, &r1, &c1, &r2, &c2) ||
-    is_dline2_at (p, r, c, &r1, &c1, &r2, &c2);
-}
-
 void
 blink_winner (gint n)
 {
@@ -613,34 +511,9 @@ check_game_state (void)
 
 
 
-void
-process_move (gint c)
-{
-  if (timeout) {
-    g_timeout_add (SPEED_DROP, (GSourceFunc) next_move, GINT_TO_POINTER (c));
-    return;
-  }
 
-  column_moveto = c;
-  anim = ANIM_MOVE;
-  timeout = g_timeout_add (SPEED_MOVE, (GSourceFunc) on_animate, GINT_TO_POINTER (c));
-}
 
-void
-process_move2 (gint c)
-{
-  gint r;
-
-  r = first_empty_row (c);
-  if (r > 0) {
-    row = 0;
-    row_dropto = r;
-    anim = ANIM_DROP;
-    timeout = g_timeout_add (SPEED_DROP, (GSourceFunc) on_animate, GINT_TO_POINTER (c));
-  } else {
-    play_sound (SOUND_COLUMN_FULL);
-  }
-}
+
 
 void
 process_move3 (gint c)
diff --git a/src/main2.vala b/src/main2.vala
index eaf1925..154dff5 100644
--- a/src/main2.vala
+++ b/src/main2.vala
@@ -4,22 +4,25 @@ using Gtk;
 
 const string jfasolfdas = Config.GETTEXT_PACKAGE;
 extern int main2(int argc, char** argv);
-extern Gtk.Window window;
-extern Gtk.Dialog? scorebox;
-extern Label label_name[3];
-extern Label label_score[3];
+Gtk.Application? application;
+Window window;
+Gtk.Dialog? scorebox = null;
+Label label_name[3];
+Label label_score[3];
 bool gameover;
 bool player_active;
 PlayerID player;
 PlayerID winner;
 PlayerID who_starts;
 int score[3];
-extern AnimID anim;
-extern char vstr[];
+AnimID anim;
+char vstr[SIZE_VSTR];
 extern char vlevel[];
 int moves;
 extern const int SIZE_VSTR;
 const int SPEED_BLINK = 150;
+const int SPEED_MOVE = 35;
+const int SPEED_DROP = 20;
 int column;
 int column_moveto;
 int row;
@@ -353,3 +356,119 @@ void on_game_scores (SimpleAction action, Variant parameter)
 
     scorebox_update ();
 }
+
+void
+on_game_exit (SimpleAction action, Variant parameter)
+{
+  stop_anim ();
+  application.quit();
+}
+
+void
+process_move2 (int c)
+{
+  int r;
+
+  r = first_empty_row (c);
+  if (r > 0) {
+    row = 0;
+    row_dropto = r;
+    anim = AnimID.DROP;
+    timeout = Timeout.add(SPEED_DROP, on_animate, c);
+    //timeout = g_timeout_add (SPEED_DROP, (GSourceFunc) on_animate, GINT_TO_POINTER (c));
+  } else {
+    play_sound (SoundID.COLUMN_FULL);
+  }
+}
+
+bool is_vline_at (PlayerID p, int r, int c, int * r1, int * c1, int * r2, int * c2)
+{
+  *r1 = *r2 = r;
+  *c1 = *c2 = c;
+  while (*r1 > 1 && gboard[*r1 - 1, c] == p)
+    *r1 = *r1 - 1;
+  while (*r2 < 6 && gboard[*r2 + 1, c] == p)
+    *r2 = *r2 + 1;
+  if (*r2 - *r1 >= 3)
+    return true;
+  return false;
+}
+
+bool is_dline1_at (PlayerID p, int r, int c, int * r1, int * c1, int * r2, int * c2) {
+  /* upper left to lower right */
+  *r1 = *r2 = r;
+  *c1 = *c2 = c;
+  while (*c1 > 0 && *r1 > 1 && gboard[*r1 - 1, *c1 - 1] == p) {
+    *r1 = *r1 - 1;
+    *c1 = *c1 - 1;
+  }
+  while (*c2 < 6 && *r2 < 6 && gboard[*r2 + 1, *c2 + 1] == p) {
+    *r2 = *r2 + 1;
+    *c2 = *c2 + 1;
+  }
+  if (*r2 - *r1 >= 3)
+    return true;
+  return false;
+}
+
+bool is_line_at (PlayerID p, int r, int c)
+{
+  int r1, r2, c1, c2;
+
+  return is_hline_at (p, r, c, &r1, &c1, &r2, &c2) ||
+    is_vline_at (p, r, c, &r1, &c1, &r2, &c2) ||
+    is_dline1_at (p, r, c, &r1, &c1, &r2, &c2) ||
+    is_dline2_at (p, r, c, &r1, &c1, &r2, &c2);
+}
+
+bool is_dline2_at (PlayerID p, int r, int c, int * r1, int * c1, int * r2, int * c2) {
+  /* upper right to lower left */
+  *r1 = *r2 = r;
+  *c1 = *c2 = c;
+  while (*c1 < 6 && *r1 > 1 && gboard[*r1 - 1, *c1 + 1] == p) {
+    *r1 = *r1 - 1;
+    *c1 = *c1 + 1;
+  }
+  while (*c2 > 0 && *r2 < 6 && gboard[*r2 + 1, *c2 - 1] == p) {
+    *r2 = *r2 + 1;
+    *c2 = *c2 - 1;
+  }
+  if (*r2 - *r1 >= 3)
+    return true;
+  return false;
+}
+
+bool is_hline_at (PlayerID p, int r, int c, int * r1, int * c1, int * r2, int * c2)
+{
+  *r1 = *r2 = r;
+  *c1 = *c2 = c;
+  while (*c1 > 0 && gboard[r, *c1 - 1] == p)
+    *c1 = *c1 - 1;
+  while (*c2 < 6 && gboard[r, *c2 + 1] == p)
+    *c2 = *c2 + 1;
+  if (*c2 - *c1 >= 3)
+    return true;
+  return false;
+}
+
+void scorebox_reset ()
+{
+  score[PlayerID.PLAYER1] = 0;
+  score[PlayerID.PLAYER2] = 0;
+  score[PlayerID.NOBODY] = 0;
+  scorebox_update ();
+}
+
+void process_move (int c)
+{
+    if (timeout != 0) {
+        //Timeout.add(SPEED_DROP, next_move, c.to_pointer());
+        //g_timeout_add (SPEED_DROP, (GSourceFunc) next_move, GINT_TO_POINTER (c));
+        return;
+    }
+
+    column_moveto = c;
+    anim = AnimID.MOVE;
+    //Timeout.add(SPEED_DROP, on_animate, c.to_pointer());
+    //timeout = g_timeout_add (SPEED_MOVE, (GSourceFunc) on_animate, GINT_TO_POINTER (c));
+}
diff --git a/src/prefs.c b/src/prefs.c
index 7217dd6..90cd74a 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -2,6 +2,7 @@
  * generated from prefs.vala, do not modify */
 
 /*public const int DEFAULT_THEME_ID = 0;*/
+/*extern int n_themes;*/
 
 
 #include <glib.h>
@@ -13,8 +14,9 @@
 #include <config.h>
 #include <prefs.h>
 #include <gdk/gdk.h>
-#include <main.h>
+#include <theme.h>
 #include <glib/gi18n-lib.h>
+#include <main.h>
 #include <float.h>
 #include <math.h>
 
@@ -22,7 +24,6 @@
 #define _g_free0(var) (var = (g_free (var), NULL))
 
 
-extern gint n_themes;
 extern GSettings* settings;
 extern GtkDialog* prefsbox;
 GtkDialog* prefsbox = NULL;
@@ -53,14 +54,17 @@ static void _settings_changed_cb_g_settings_changed (GSettings* _sender,
                                               gpointer self);
 gboolean gfx_change_theme (void);
 void on_select_opponent (GtkComboBox* w);
+void scorebox_reset (void);
 void prefsbox_open (void);
 static void _on_select_opponent_gtk_combo_box_changed (GtkComboBox* _sender,
                                                 gpointer self);
+gchar* theme_get_title (gint id);
 static void _on_select_theme_gtk_combo_box_changed (GtkComboBox* _sender,
                                              gpointer self);
 static void _on_toggle_sound_gtk_toggle_button_toggled (GtkToggleButton* _sender,
                                                  gpointer self);
 
+extern const Theme theme[5];
 
 gint
 sane_theme_id (gint val)
@@ -70,9 +74,7 @@ sane_theme_id (gint val)
        if (val < 0) {
                _tmp0_ = TRUE;
        } else {
-               gint _tmp1_;
-               _tmp1_ = n_themes;
-               _tmp0_ = val >= _tmp1_;
+               _tmp0_ = val >= G_N_ELEMENTS (theme);
        }
        if (_tmp0_) {
                result = DEFAULT_THEME_ID;
@@ -389,23 +391,23 @@ prefsbox_open (void)
        GtkGrid* _tmp71_;
        GtkLabel* _tmp72_;
        GtkComboBoxText* _tmp73_;
-       GtkLabel* _tmp82_;
-       GtkComboBoxText* _tmp83_;
-       GtkGrid* _tmp84_;
-       GtkComboBoxText* _tmp85_;
-       GtkCheckButton* _tmp86_;
-       GtkGrid* _tmp87_;
-       GtkCheckButton* _tmp88_;
-       GtkLabel* _tmp89_;
-       GtkComboBoxText* _tmp90_;
-       Prefs _tmp91_;
-       gint _tmp92_;
-       GtkCheckButton* _tmp93_;
-       Prefs _tmp94_;
-       gboolean _tmp95_;
-       GtkComboBoxText* _tmp96_;
-       GtkCheckButton* _tmp97_;
-       GtkDialog* _tmp98_;
+       GtkLabel* _tmp81_;
+       GtkComboBoxText* _tmp82_;
+       GtkGrid* _tmp83_;
+       GtkComboBoxText* _tmp84_;
+       GtkCheckButton* _tmp85_;
+       GtkGrid* _tmp86_;
+       GtkCheckButton* _tmp87_;
+       GtkLabel* _tmp88_;
+       GtkComboBoxText* _tmp89_;
+       Prefs _tmp90_;
+       gint _tmp91_;
+       GtkCheckButton* _tmp92_;
+       Prefs _tmp93_;
+       gboolean _tmp94_;
+       GtkComboBoxText* _tmp95_;
+       GtkCheckButton* _tmp96_;
+       GtkDialog* _tmp97_;
        _tmp0_ = prefsbox;
        if (_tmp0_ != NULL) {
                GtkDialog* _tmp1_;
@@ -573,11 +575,10 @@ prefsbox_open (void)
                        _tmp74_ = TRUE;
                        while (TRUE) {
                                gint _tmp76_;
-                               gint _tmp77_;
-                               GtkComboBoxText* _tmp78_;
-                               gint _tmp79_;
+                               GtkComboBoxText* _tmp77_;
+                               gint _tmp78_;
+                               gchar* _tmp79_;
                                gchar* _tmp80_;
-                               gchar* _tmp81_;
                                if (!_tmp74_) {
                                        gint _tmp75_;
                                        _tmp75_ = i;
@@ -585,50 +586,49 @@ prefsbox_open (void)
                                }
                                _tmp74_ = FALSE;
                                _tmp76_ = i;
-                               _tmp77_ = n_themes;
-                               if (!(_tmp76_ < _tmp77_)) {
+                               if (!(_tmp76_ < G_N_ELEMENTS (theme))) {
                                        break;
                                }
-                               _tmp78_ = combobox_theme;
-                               _tmp79_ = i;
-                               _tmp80_ = theme_get_title (_tmp79_);
-                               _tmp81_ = _tmp80_;
-                               gtk_combo_box_text_append_text (_tmp78_, _ (_tmp81_));
-                               _g_free0 (_tmp81_);
+                               _tmp77_ = combobox_theme;
+                               _tmp78_ = i;
+                               _tmp79_ = theme_get_title (_tmp78_);
+                               _tmp80_ = _tmp79_;
+                               gtk_combo_box_text_append_text (_tmp77_, _ (_tmp80_));
+                               _g_free0 (_tmp80_);
                        }
                }
        }
-       _tmp82_ = label;
-       _tmp83_ = combobox_theme;
-       gtk_label_set_mnemonic_widget (_tmp82_, (GtkWidget*) _tmp83_);
-       _tmp84_ = grid;
-       _tmp85_ = combobox_theme;
-       gtk_grid_attach (_tmp84_, (GtkWidget*) _tmp85_, 1, 1, 1, 1);
-       _tmp86_ = (GtkCheckButton*) gtk_check_button_new_with_mnemonic (_ ("E_nable sounds"));
-       g_object_ref_sink (_tmp86_);
+       _tmp81_ = label;
+       _tmp82_ = combobox_theme;
+       gtk_label_set_mnemonic_widget (_tmp81_, (GtkWidget*) _tmp82_);
+       _tmp83_ = grid;
+       _tmp84_ = combobox_theme;
+       gtk_grid_attach (_tmp83_, (GtkWidget*) _tmp84_, 1, 1, 1, 1);
+       _tmp85_ = (GtkCheckButton*) gtk_check_button_new_with_mnemonic (_ ("E_nable sounds"));
+       g_object_ref_sink (_tmp85_);
        _g_object_unref0 (checkbutton_sound);
-       checkbutton_sound = _tmp86_;
-       _tmp87_ = grid;
-       _tmp88_ = checkbutton_sound;
-       gtk_grid_attach (_tmp87_, (GtkWidget*) _tmp88_, 0, 2, 2, 1);
-       _tmp89_ = (GtkLabel*) gtk_label_new_with_mnemonic (_ ("Keyboard Controls"));
-       g_object_ref_sink (_tmp89_);
+       checkbutton_sound = _tmp85_;
+       _tmp86_ = grid;
+       _tmp87_ = checkbutton_sound;
+       gtk_grid_attach (_tmp86_, (GtkWidget*) _tmp87_, 0, 2, 2, 1);
+       _tmp88_ = (GtkLabel*) gtk_label_new_with_mnemonic (_ ("Keyboard Controls"));
+       g_object_ref_sink (_tmp88_);
        _g_object_unref0 (label);
-       label = _tmp89_;
-       _tmp90_ = combobox_theme;
-       _tmp91_ = p;
-       _tmp92_ = _tmp91_.theme_id;
-       gtk_combo_box_set_active ((GtkComboBox*) _tmp90_, _tmp92_);
-       _tmp93_ = checkbutton_sound;
-       _tmp94_ = p;
-       _tmp95_ = _tmp94_.do_sound;
-       gtk_toggle_button_set_active ((GtkToggleButton*) _tmp93_, _tmp95_);
-       _tmp96_ = combobox_theme;
-       g_signal_connect ((GtkComboBox*) _tmp96_, "changed", (GCallback) 
_on_select_theme_gtk_combo_box_changed, NULL);
-       _tmp97_ = checkbutton_sound;
-       g_signal_connect ((GtkToggleButton*) _tmp97_, "toggled", (GCallback) 
_on_toggle_sound_gtk_toggle_button_toggled, NULL);
-       _tmp98_ = prefsbox;
-       gtk_widget_show_all ((GtkWidget*) _tmp98_);
+       label = _tmp88_;
+       _tmp89_ = combobox_theme;
+       _tmp90_ = p;
+       _tmp91_ = _tmp90_.theme_id;
+       gtk_combo_box_set_active ((GtkComboBox*) _tmp89_, _tmp91_);
+       _tmp92_ = checkbutton_sound;
+       _tmp93_ = p;
+       _tmp94_ = _tmp93_.do_sound;
+       gtk_toggle_button_set_active ((GtkToggleButton*) _tmp92_, _tmp94_);
+       _tmp95_ = combobox_theme;
+       g_signal_connect ((GtkComboBox*) _tmp95_, "changed", (GCallback) 
_on_select_theme_gtk_combo_box_changed, NULL);
+       _tmp96_ = checkbutton_sound;
+       g_signal_connect ((GtkToggleButton*) _tmp96_, "toggled", (GCallback) 
_on_toggle_sound_gtk_toggle_button_toggled, NULL);
+       _tmp97_ = prefsbox;
+       gtk_widget_show_all ((GtkWidget*) _tmp97_);
        _g_object_unref0 (model);
        _g_object_unref0 (renderer);
        _g_object_unref0 (label);
diff --git a/src/prefs.vala b/src/prefs.vala
index a51f40a..dd5f96d 100644
--- a/src/prefs.vala
+++ b/src/prefs.vala
@@ -1,5 +1,5 @@
 //public const int DEFAULT_THEME_ID = 0;
-extern int n_themes;
+//extern int n_themes;
 extern Settings settings;
 Gtk.Dialog? prefsbox = null;
 Gtk.ComboBox combobox;
@@ -16,7 +16,7 @@ const int DEFAULT_THEME_ID = 0;
 
 static int sane_theme_id (int val)
 {
-  if (val < 0 || val >= n_themes)
+  if (val < 0 || val >= theme.length)
     return DEFAULT_THEME_ID;
   return val;
 }
@@ -178,7 +178,7 @@ public void prefsbox_open ()
     grid.attach(label, 0, 1, 1, 1);
 
     combobox_theme = new Gtk.ComboBoxText();
-    for (int i = 0; i < n_themes; i++) {
+    for (int i = 0; i < theme.length; i++) {
         combobox_theme.append_text(_(theme_get_title(i)));
     }
     label.set_mnemonic_widget(combobox_theme);
diff --git a/src/temp.vapi b/src/temp.vapi
index ba097d0..df7c71a 100644
--- a/src/temp.vapi
+++ b/src/temp.vapi
@@ -8,16 +8,16 @@ struct Prefs {
 
 [CCode (cname = "Theme", cheader_filename="theme.h")]
 struct Theme {
-    const string title;
-    const string fname_tileset;
-    const string fname_bground;
+    public string title;
+    public string fname_tileset;
+    public string fname_bground;
     public string grid_color;
-    const string player1;
-    const string player2;
-    const string player1_win;
-    const string player2_win;
-    const string player1_turn;
-    const string player2_turn;
+    public string player1;
+    public string player2;
+    public string player1_win;
+    public string player2_win;
+    public string player1_turn;
+    public string player2_turn;
 }
 
 [CCode (cname = "AnimID", cprefix = "ANIM_", cheader_filename="main.h")]
@@ -63,8 +63,18 @@ public enum Move {
   DROP
 }
 
+[CCode (cname = "SoundID", cprefix = "SOUND_", cheader_filename="main.h")]
+public enum SoundID{
+  DROP,
+  I_WIN,
+  YOU_WIN,
+  PLAYER_WIN,
+  DRAWN_GAME,
+  COLUMN_FULL
+}
+
 void game_reset ();
-void process_move(int c);
+//void process_move(int c);
 void gfx_refresh_pixmaps();
 bool gfx_load_pixmaps();
 void gfx_paint_tile(Cairo.Context cr, int r, int c);
@@ -73,13 +83,12 @@ void gfx_paint_tile(Cairo.Context cr, int r, int c);
 void gfx_free ();
 void scorebox_update ();       /* update visible player descriptions */
 void prompt_player ();
-void scorebox_reset ();
-string theme_get_title(int i);
 void on_dialog_close(int response_id);
 bool on_animate();
 //static void settings_changed_cb (string key);
+void play_sound(SoundID id);
 
-[CCode (cprefix = "", lower_case_prefix = "", cheader_filename = "config.h")]
+[CCode (cprefix = "", cheader_filename = "config.h")]
 namespace Config {
     [CCode (cname = "GETTEXT_PACKAGE")]
     public const string GETTEXT_PACKAGE;
diff --git a/src/theme.c b/src/theme.c
index bc2e8d4..384ee9a 100644
--- a/src/theme.c
+++ b/src/theme.c
@@ -1,121 +1,13 @@
-/* -*- mode:C; indent-tabs-mode:t; tab-width:8; c-basic-offset:8; -*- */
 
-/* theme.c
- *
- * Four-in-a-row for GNOME
- * (C) 2000 - 2004
- * Authors: Timothy Musson <trmusson ihug co nz>
- *
- * This game is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
- */
 
 
 
-#include <config.h>
 
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
 
-#include "main.h"
-#include "theme.h"
-#include "prefs.h"
 
 
-extern Prefs p;
 
-Theme theme[] = {
-  {
-   N_("High Contrast"),
-   "tileset_50x50_hcontrast.svg",
-   NULL,
-   "#000000",
-   N_("Circle"), N_("Cross"),
-   N_("Circle wins!"), N_("Cross wins!"),
-   N_("Circle’s turn"), N_("Cross’s turn")
-   },
-  {
-   N_("High Contrast Inverse"),
-   "tileset_50x50_hcinverse.svg",
-   NULL,
-   "#FFFFFF",
-   N_("Circle"), N_("Cross"),
-   N_("Circle wins!"), N_("Cross wins!"),
-   N_("Circle’s turn"), N_("Cross’s turn")
-   },
-  {
-   N_("Red and Green Marbles"),
-   "tileset_50x50_faenza-glines-icon1.svg",
-   "bg_toplight.png",
-   "#727F8C",
-   N_("Red"), N_("Green"),
-   N_("Red wins!"), N_("Green wins!"),
-   N_("Red’s turn"), N_("Green’s turn")
-   },
-  {
-   N_("Blue and Red Marbles"),
-   "tileset_50x50_faenza-glines-icon2.svg",
-   "bg_toplight.png",
-   "#727F8C",
-   N_("Blue"), N_("Red"),
-   N_("Blue wins!"), N_("Red wins!"),
-   N_("Blue’s turn"), N_("Red’s turn")
-   },
-  {
-   N_("Stars and Rings"),
-   "tileset_50x50_faenza-gnect-icon.svg",
-   "bg_toplight.png",
-   "#727F8C",
-   N_("Red"), N_("Green"),
-   N_("Red wins!"), N_("Green wins!"),
-   N_("Red’s turn"), N_("Green’s turn")
-   }
-};
 
 
-gint n_themes = G_N_ELEMENTS (theme);
 
 
-const gchar *
-theme_get_player (PlayerID who)
-{
-  if (who == PLAYER1)
-    return theme[p.theme_id].player1;
-  return theme[p.theme_id].player2;
-}
-
-
-const gchar *
-theme_get_player_win (PlayerID who)
-{
-  if (who == PLAYER1)
-    return theme[p.theme_id].player1_win;
-  return theme[p.theme_id].player2_win;
-}
-
-
-
-const gchar *
-theme_get_player_turn (PlayerID who)
-{
-  if (who == PLAYER1)
-    return theme[p.theme_id].player1_turn;
-  return theme[p.theme_id].player2_turn;
-}
-
-const gchar *
-theme_get_title (gint id)
-{
-  return theme[id].title;
-}
diff --git a/src/theme.h b/src/theme.h
index ab449e2..b8c1de4 100644
--- a/src/theme.h
+++ b/src/theme.h
@@ -19,9 +19,9 @@ struct _Theme {
 };
 
 
-const gchar *theme_get_player (PlayerID who);
-const gchar *theme_get_player_win (PlayerID who);
-const gchar *theme_get_player_turn (PlayerID who);
-const gchar *theme_get_title (gint id);
+gchar *theme_get_player (PlayerID who);
+gchar *theme_get_player_win (PlayerID who);
+gchar *theme_get_player_turn (PlayerID who);
+gchar *theme_get_title (gint id);
 
 #endif
diff --git a/src/theme.vala b/src/theme.vala
new file mode 100644
index 0000000..4193f74
--- /dev/null
+++ b/src/theme.vala
@@ -0,0 +1,73 @@
+//extern Theme theme[];
+const string random_shit = Config.GETTEXT_PACKAGE;
+
+string theme_get_title (int id) {
+   return theme[id].title;
+}
+
+string theme_get_player_turn (PlayerID who) {
+  if (who == PlayerID.PLAYER1)
+    return theme[p.theme_id].player1_turn;
+  return theme[p.theme_id].player2_turn;
+}
+
+string theme_get_player_win (PlayerID who) {
+  if (who == PlayerID.PLAYER1)
+    return theme[p.theme_id].player1_win;
+  return theme[p.theme_id].player2_win;
+}
+
+string theme_get_player (PlayerID who) {
+  if (who == PlayerID.PLAYER1)
+    return theme[p.theme_id].player1;
+  return theme[p.theme_id].player2;
+}
+
+
+const Theme theme[] = {
+  {
+   N_("High Contrast"),
+   "tileset_50x50_hcontrast.svg",
+   null,
+   "#000000",
+   N_("Circle"), N_("Cross"),
+   N_("Circle wins!"), N_("Cross wins!"),
+   N_("Circle’s turn"), N_("Cross’s turn")
+   },
+  {
+   N_("High Contrast Inverse"),
+   "tileset_50x50_hcinverse.svg",
+   null,
+   "#FFFFFF",
+   N_("Circle"), N_("Cross"),
+   N_("Circle wins!"), N_("Cross wins!"),
+   N_("Circle’s turn"), N_("Cross’s turn")
+   },
+  {
+   N_("Red and Green Marbles"),
+   "tileset_50x50_faenza-glines-icon1.svg",
+   "bg_toplight.png",
+   "#727F8C",
+   N_("Red"), N_("Green"),
+   N_("Red wins!"), N_("Green wins!"),
+   N_("Red’s turn"), N_("Green’s turn")
+   },
+  {
+   N_("Blue and Red Marbles"),
+   "tileset_50x50_faenza-glines-icon2.svg",
+   "bg_toplight.png",
+   "#727F8C",
+   N_("Blue"), N_("Red"),
+   N_("Blue wins!"), N_("Red wins!"),
+   N_("Blue’s turn"), N_("Red’s turn")
+   },
+  {
+   N_("Stars and Rings"),
+   "tileset_50x50_faenza-gnect-icon.svg",
+   "bg_toplight.png",
+   "#727F8C",
+   N_("Red"), N_("Green"),
+   N_("Red wins!"), N_("Green wins!"),
+   N_("Red’s turn"), N_("Green’s turn")
+   }
+};


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