From 1b29b6284f6288bfd48505664f147dfb077d8e70 Mon Sep 17 00:00:00 2001 From: gyboth Date: Thu, 27 Oct 2005 21:14:14 +0000 Subject: [PATCH] Betting, first draft. --- bygfoot_misc3.glade | 192 ++++++++++++++++++++++++++++++++ bygfoot_misc3.gladep | 17 +++ src/bet.c | 250 ++++++++++++++++++++++++++++++++++++++++++ src/bet.h | 55 ++++++++++ src/bet_struct.h | 51 +++++++++ src/misc3_callbacks.c | 150 +++++++++++++++++++++++++ src/misc3_callbacks.h | 60 ++++++++++ src/misc3_interface.c | 142 ++++++++++++++++++++++++ src/misc3_interface.h | 5 + 9 files changed, 922 insertions(+) create mode 100644 bygfoot_misc3.glade create mode 100644 bygfoot_misc3.gladep create mode 100644 src/bet.c create mode 100644 src/bet.h create mode 100644 src/bet_struct.h create mode 100644 src/misc3_callbacks.c create mode 100644 src/misc3_callbacks.h create mode 100644 src/misc3_interface.c create mode 100644 src/misc3_interface.h diff --git a/bygfoot_misc3.glade b/bygfoot_misc3.glade new file mode 100644 index 00000000..5a912e96 --- /dev/null +++ b/bygfoot_misc3.glade @@ -0,0 +1,192 @@ + + + + + + + 5 + True + + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + True + 600 + 700 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_NORMAL + GDK_GRAVITY_NORTH_WEST + + + + + True + False + 3 + + + + True + Betting -- Left click on odd to place or remove bet + False + False + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + 1 + 10 + True + + + 0 + False + False + + + + + + True + False + 0 + + + + True + Whether to show matches of all leagues. Use the options window to toggle permanently. + True + Show matches from all leagues + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + True + True + + + + + + True + Whether to show cup matches. Use the options window to toggle permanently. + True + Show matches from cups + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + False + False + + + + + + True + Whether to show only your bets in the recent bets list + True + Show only my recent bets + True + GTK_RELIEF_NORMAL + True + False + False + True + + + + 0 + True + True + + + + + 0 + False + False + + + + + + 1 + 10 + True + + + 0 + False + False + + + + + + True + True + True + False + False + True + + + + 0 + True + True + + + + + + True + Esc + True + gtk-close + True + GTK_RELIEF_NORMAL + True + + + + + 0 + False + False + + + + + + + diff --git a/bygfoot_misc3.gladep b/bygfoot_misc3.gladep new file mode 100644 index 00000000..ce2a7f34 --- /dev/null +++ b/bygfoot_misc3.gladep @@ -0,0 +1,17 @@ + + + + + bygfoot_misc3 + bygfoot_misc3 + support_files/pixmaps + FALSE + FALSE + FALSE + FALSE + FALSE + misc3_interface.c + misc3_interface.h + misc3_callbacks.c + misc3_callbacks.h + diff --git a/src/bet.c b/src/bet.c new file mode 100644 index 00000000..a254844c --- /dev/null +++ b/src/bet.c @@ -0,0 +1,250 @@ +/* + Bygfoot Football Manager -- a small and simple GTK2-based + football management game. + + http://bygfoot.sourceforge.net + + Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) + + This program 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 + of the License, 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 "bet.h" +#include "finance.h" +#include "fixture.h" +#include "game_gui.h" +#include "league.h" +#include "main.h" +#include "maths.h" +#include "option.h" +#include "player.h" +#include "treeview2.h" +#include "user.h" + +/** Round a betting odd to a multiple of 0.05. */ +gfloat +bet_round_odd(gfloat odd) +{ + gint local_odd = (gint)rint(odd * 100); + + if(local_odd % 5 == 0) + return odd; + + if(local_odd % 5 >= 3) + return (gfloat)(local_odd + (5 - local_odd % 5)) / 100; + + return (gfloat)(local_odd - local_odd % 5) / 100; +} + +/** Find the bet containing the fixture. */ +BetMatch* +bet_from_fixture(const Fixture *fix) +{ + gint i, j; + + for(i=1;i>=0;i--) + for(j=0;jlen;j++) + if(g_array_index(bets[i], BetMatch, j).fix == fix) + return &g_array_index(bets[i], BetMatch, j); + + main_exit_program(EXIT_BET_ERROR, + "bet_from_fixture: bet going with fixture %s %s - %s not found", + league_cup_get_name_string(fix->clid), + fix->teams[0]->name, fix->teams[0]->name); + + return NULL; +} + +/** Manage the bets made by the users. */ +void +bet_update_user_bets(void) +{ + gint i, j, outcome; + const BetMatch *bet; + + for(i=0;ilen;i++) + { + g_array_free(usr(i).bets[0], TRUE); + usr(i).bets[0] = g_array_new(FALSE, FALSE, sizeof(BetUser)); + + for(j=0;jlen;j++) + { + bet = bet_from_fixture(g_array_index(usr(i).bets[1], BetUser, j).fix); + + if(bet->fix->result[0][0] < bet->fix->result[1][0]) + outcome = 2; + else + outcome = (bet->fix->result[0][0] == bet->fix->result[1][0]); + + if(outcome == g_array_index(usr(i).bets[1], BetUser, j).outcome) + { + usr(i).money += + (gint)rint((gfloat)g_array_index(usr(i).bets[1], BetUser, j).wager * + bet->odds[outcome]); + usr(i).money_in[1][MON_IN_BETS] += + (gint)rint((gfloat)g_array_index(usr(i).bets[1], BetUser, j).wager * + bet->odds[outcome]); + g_array_index(usr(i).bets[1], BetUser, j).wager = + (gint)rint((gfloat)g_array_index(usr(i).bets[1], BetUser, j).wager * + bet->odds[outcome]); + } + else + { + usr(i).money -= + g_array_index(usr(i).bets[1], BetUser, j).wager; + usr(i).money_out[1][MON_OUT_BETS] -= + g_array_index(usr(i).bets[1], BetUser, j).wager; + g_array_index(usr(i).bets[1], BetUser, j).wager *= -1; + } + + g_array_append_val(usr(i).bets[0], + g_array_index(usr(i).bets[1], BetUser, j)); + } + + g_array_free(usr(i).bets[1], TRUE); + usr(i).bets[1] = g_array_new(FALSE, FALSE, sizeof(BetUser)); + } +} + +/** Calculate the odds for the bet. */ +void +bet_get_odds(BetMatch *bet) +{ + gfloat home_advantage = (bet->fix->home_advantage) ? + (const_float("float_game_home_advantage_lower") + + const_float("float_game_home_advantage_upper")) / 2 : 0; + gfloat av_skill[2] = {0, 0}, skilldiff; + gint i, j, better_idx; + + for(i=0;i<2;i++) + { + for(j=0;j<11;j++) + av_skill[i] += + player_get_game_skill(player_of_idx_team(bet->fix->teams[i], j), + FALSE); + + av_skill[i] /= 11; + } + + av_skill[0] *= (1 + home_advantage); + + skilldiff = ABS(av_skill[0] - av_skill[1]); + + better_idx = 2 * (av_skill[0] < av_skill[1]); + + bet->odds[better_idx] = + 0.33 + skilldiff * const_float("float_bet_better_factor"); + bet->odds[2 - better_idx] = + 0.33 + skilldiff * const_float("float_bet_worse_factor"); + + for(i=0;i<2;i++) + bet->odds[i * 2] = CLAMP(bet->odds[i * 2], + const_float("float_bet_lower_limit"), + 1 - const_float("float_bet_lower_limit")); + + bet->odds[1] = (1 - bet->odds[0] - bet->odds[2]); + bet->odds[1] = CLAMP(bet->odds[1], + const_float("float_bet_lower_limit"), + 1 - const_float("float_bet_lower_limit")); + + for(i=0;i<3;i++) + bet->odds[i] = + bet_round_odd((1 / bet->odds[i]) * + (1 - const_float("float_bet_commission_decrease"))); +} + +/** Write the bets for the current week round. */ +void +bet_update(void) +{ + gint i; + GPtrArray *fixtures = fixture_get_week_list(week, week_round); + BetMatch new_bet; + + bet_update_user_bets(); + + g_array_free(bets[0], TRUE); + bets[0] = g_array_new(FALSE, FALSE, sizeof(BetMatch)); + + for(i=0;ilen;i++) + g_array_append_val(bets[0], + g_array_index(bets[1], BetMatch, i)); + + g_array_free(bets[1], TRUE); + bets[1] = g_array_new(FALSE, FALSE, sizeof(BetMatch)); + + for(i=0;ilen;i++) + if(fixture_user_team_involved((Fixture*)g_ptr_array_index(fixtures, i)) == -1) + { + new_bet.fix = (Fixture*)g_ptr_array_index(fixtures, i); + bet_get_odds(&new_bet); + g_array_append_val(bets[1], new_bet); + } + + g_ptr_array_free(fixtures, TRUE); +} + +/** Return the user bet if the user betted on the bet or NULL. */ +BetUser* +bet_is_user(const BetMatch *bet) +{ + gint i, j; + + for(i=1;i>=0;i--) + for(j=0;jlen;j++) + if(bet->fix == g_array_index(current_user.bets[i], BetUser, j).fix) + return &g_array_index(current_user.bets[i], BetUser, j); + + return NULL; +} + +/** Place a new bet. */ +void +bet_place(const Fixture *fix, gint outcome, gint wager) +{ + BetUser new_bet; + + if(wager <= 0) + return; + + if(wager > BUDGET(cur_user)) + { + game_gui_show_warning(_("You don't have the money.")); + return; + } + + new_bet.fix = fix; + new_bet.outcome = outcome; + new_bet.wager = wager; + + g_array_append_val(current_user.bets[1], new_bet); + + if(window.bets != NULL) + treeview2_show_bets(); +} + +/** Remove the bet on the given fixture. */ +void +bet_remove(const Fixture *fix) +{ + gint i; + + for(i=0;ilen;i++) + if(g_array_index(current_user.bets[1], BetUser, i).fix == fix) + { + g_array_remove_index(current_user.bets[1], i); + return; + } +} diff --git a/src/bet.h b/src/bet.h new file mode 100644 index 00000000..54844aa6 --- /dev/null +++ b/src/bet.h @@ -0,0 +1,55 @@ +/* + Bygfoot Football Manager -- a small and simple GTK2-based + football management game. + + http://bygfoot.sourceforge.net + + Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) + + This program 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 + of the License, 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. +*/ + +#ifndef BET_H +#define BET_H + +#include "bet_struct.h" +#include "bygfoot.h" +#include "fixture_struct.h" + +BetMatch* +bet_from_fixture(const Fixture *fix); + +void +bet_update_user_bets(void); + +void +bet_get_odds(BetMatch *bet); + +void +bet_update(void); + +gfloat +bet_round_odd(gfloat odd); + +BetUser* +bet_is_user(const BetMatch *bet); + +void +bet_place(const Fixture *fix, gint outcome, gint wager); + +void +bet_remove(const Fixture *fix); + +#endif diff --git a/src/bet_struct.h b/src/bet_struct.h new file mode 100644 index 00000000..cb69ab94 --- /dev/null +++ b/src/bet_struct.h @@ -0,0 +1,51 @@ +/* + Bygfoot Football Manager -- a small and simple GTK2-based + football management game. + + http://bygfoot.sourceforge.net + + Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) + + This program 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 + of the License, 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. +*/ + +#ifndef BET_STRUCT_H +#define BET_STRUCT_H + +#include "bygfoot.h" +#include "fixture_struct.h" + +/** A struct representing a betting possibility: a fixture plus odds. */ +typedef struct +{ + /** The match the bet is about. */ + const Fixture *fix; + /** The odds for a win, draw or loss of the first team. */ + gfloat odds[3]; + +} BetMatch; + +/** A struct representing a bet by a user. */ +typedef struct +{ + /** Match the user betted on. */ + const Fixture *fix; + /** Which outcome he picked. */ + gint outcome; + /** How much he wagered. */ + gint wager; +} BetUser; + +#endif diff --git a/src/misc3_callbacks.c b/src/misc3_callbacks.c new file mode 100644 index 00000000..259e08c5 --- /dev/null +++ b/src/misc3_callbacks.c @@ -0,0 +1,150 @@ +/* + Bygfoot Football Manager -- a small and simple GTK2-based + football management game. + + http://bygfoot.sourceforge.net + + Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) + + This program 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 + of the License, 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 "bet.h" +#include "misc3_callbacks.h" +#include "misc3_interface.h" +#include "option.h" +#include "support.h" +#include "treeview2.h" +#include "treeview_helper.h" +#include "user.h" +#include "variables.h" +#include "window.h" + +gboolean +on_window_bets_delete_event (GtkWidget *widget, + GdkEvent *event, + gpointer user_data) +{ + on_button_bet_close_clicked(NULL, NULL); + + return TRUE; +} + +void +on_button_bet_close_clicked (GtkButton *button, + gpointer user_data) +{ + window_destroy(&window.bets, FALSE); +} + +gboolean +on_checkbutton_bet_all_leagues_button_press_event + (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) +{ + opt_user_set_int("int_opt_user_bet_show_all_leagues", + !opt_user_int("int_opt_user_bet_show_all_leagues")); + + treeview2_show_bets(); + + return FALSE; +} + + +gboolean +on_checkbutton_bet_cups_button_press_event + (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) +{ + opt_user_set_int("int_opt_user_bet_show_cups", + !opt_user_int("int_opt_user_bet_show_cups")); + + treeview2_show_bets(); + + return FALSE; +} + + +gboolean +on_treeview_bets_button_press_event (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) +{ + GtkTreePath *path = NULL; + GtkTreeViewColumn *col = NULL; + GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(widget)); + GtkTreeIter iter; + const BetMatch *bet = NULL; + gint col_num = -1; + gchar buf[SMALL]; + + if(!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget), + event->x, event->y, + &path, &col, NULL, NULL)) + return TRUE; + + if(!gtk_tree_model_get_iter(model, &iter, path)) + { + gtk_tree_path_free(path); + return TRUE; + } + + gtk_tree_path_free(path); + col_num = treeview_helper_get_col_number_column(col); + + if(col_num == 0 || col_num > 3) + return TRUE; + + gtk_tree_model_get(model, &iter, col_num, &bet, -1); + + if(bet == NULL || bet->fix->attendance != -1) + return TRUE; + + if(bet_is_user(bet)) + { + bet_remove(bet->fix); + treeview2_show_bets(); + return FALSE; + } + + sprintf(buf, _("You bet on outcome %d with an odd of %.2f. How much do you wager?"), + col_num - 1, bet->odds[col_num - 1]); + + statp = (gpointer)bet->fix; + stat1 = STATUS_PLACE_BET; + stat2 = col_num - 1; + + window_show_digits(buf, _("Wager"), 0, NULL, -1); + + return TRUE; +} + + +gboolean +on_checkbutton_bet_user_recent_button_press_event + (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data) +{ + opt_user_set_int("int_opt_user_bet_show_my_recent", + !opt_user_int("int_opt_user_bet_show_my_recent")); + + treeview2_show_bets(); + + return FALSE; +} + diff --git a/src/misc3_callbacks.h b/src/misc3_callbacks.h new file mode 100644 index 00000000..e5c8dfa0 --- /dev/null +++ b/src/misc3_callbacks.h @@ -0,0 +1,60 @@ +/* + Bygfoot Football Manager -- a small and simple GTK2-based + football management game. + + http://bygfoot.sourceforge.net + + Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com) + + This program 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 + of the License, 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. +*/ + +#ifndef MISC2_CALLBACKS_H +#define MISC2_CALLBACKS_H + +#include + + +gboolean +on_window_bets_delete_event (GtkWidget *widget, + GdkEvent *event, + gpointer user_data); + +void +on_button_bet_close_clicked (GtkButton *button, + gpointer user_data); +gboolean +on_checkbutton_bet_all_leagues_button_press_event + (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); + +gboolean +on_checkbutton_bet_cups_button_press_event + (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); + +gboolean +on_treeview_bets_button_press_event (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); + +gboolean +on_checkbutton_bet_user_recent_button_press_event + (GtkWidget *widget, + GdkEventButton *event, + gpointer user_data); +#endif diff --git a/src/misc3_interface.c b/src/misc3_interface.c new file mode 100644 index 00000000..15754721 --- /dev/null +++ b/src/misc3_interface.c @@ -0,0 +1,142 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +#ifdef HAVE_CONFIG_H +# include +#endif + +#include +#include +#include +#include +#include + +#include +#include + +#include "misc3_callbacks.h" +#include "misc3_interface.h" +#include "support.h" + +#define GLADE_HOOKUP_OBJECT(component,widget,name) \ + g_object_set_data_full (G_OBJECT (component), name, \ + gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref) + +#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \ + g_object_set_data (G_OBJECT (component), name, widget) + +GtkWidget* +create_window_bets (void) +{ + GtkWidget *window_bets; + GtkWidget *vbox1; + GtkWidget *label1; + GtkWidget *hseparator1; + GtkWidget *hbox1; + GtkWidget *checkbutton_bet_all_leagues; + GtkWidget *checkbutton_bet_cups; + GtkWidget *checkbutton_bet_user_recent; + GtkWidget *hseparator2; + GtkWidget *treeview_bets; + GtkWidget *button_bet_close; + GtkAccelGroup *accel_group; + GtkTooltips *tooltips; + + tooltips = gtk_tooltips_new (); + + accel_group = gtk_accel_group_new (); + + window_bets = gtk_window_new (GTK_WINDOW_TOPLEVEL); + gtk_container_set_border_width (GTK_CONTAINER (window_bets), 5); + gtk_window_set_position (GTK_WINDOW (window_bets), GTK_WIN_POS_CENTER); + gtk_window_set_modal (GTK_WINDOW (window_bets), TRUE); + gtk_window_set_default_size (GTK_WINDOW (window_bets), 600, 700); + + vbox1 = gtk_vbox_new (FALSE, 3); + gtk_widget_show (vbox1); + gtk_container_add (GTK_CONTAINER (window_bets), vbox1); + + label1 = gtk_label_new (_("Betting -- Left click on odd to place or remove bet")); + gtk_widget_show (label1); + gtk_box_pack_start (GTK_BOX (vbox1), label1, FALSE, FALSE, 0); + + hseparator1 = gtk_hseparator_new (); + gtk_widget_show (hseparator1); + gtk_box_pack_start (GTK_BOX (vbox1), hseparator1, FALSE, FALSE, 0); + gtk_widget_set_size_request (hseparator1, 1, 10); + + hbox1 = gtk_hbox_new (FALSE, 0); + gtk_widget_show (hbox1); + gtk_box_pack_start (GTK_BOX (vbox1), hbox1, FALSE, FALSE, 0); + + checkbutton_bet_all_leagues = gtk_check_button_new_with_mnemonic (_("Show matches from all leagues")); + gtk_widget_show (checkbutton_bet_all_leagues); + gtk_box_pack_start (GTK_BOX (hbox1), checkbutton_bet_all_leagues, TRUE, TRUE, 0); + gtk_tooltips_set_tip (tooltips, checkbutton_bet_all_leagues, _("Whether to show matches of all leagues. Use the options window to toggle permanently."), NULL); + + checkbutton_bet_cups = gtk_check_button_new_with_mnemonic (_("Show matches from cups")); + gtk_widget_show (checkbutton_bet_cups); + gtk_box_pack_start (GTK_BOX (hbox1), checkbutton_bet_cups, FALSE, FALSE, 0); + gtk_tooltips_set_tip (tooltips, checkbutton_bet_cups, _("Whether to show cup matches. Use the options window to toggle permanently."), NULL); + + checkbutton_bet_user_recent = gtk_check_button_new_with_mnemonic (_("Show only my recent bets")); + gtk_widget_show (checkbutton_bet_user_recent); + gtk_box_pack_start (GTK_BOX (hbox1), checkbutton_bet_user_recent, TRUE, TRUE, 0); + gtk_tooltips_set_tip (tooltips, checkbutton_bet_user_recent, _("Whether to show only your bets in the recent bets list"), NULL); + + hseparator2 = gtk_hseparator_new (); + gtk_widget_show (hseparator2); + gtk_box_pack_start (GTK_BOX (vbox1), hseparator2, FALSE, FALSE, 0); + gtk_widget_set_size_request (hseparator2, 1, 10); + + treeview_bets = gtk_tree_view_new (); + gtk_widget_show (treeview_bets); + gtk_box_pack_start (GTK_BOX (vbox1), treeview_bets, TRUE, TRUE, 0); + + button_bet_close = gtk_button_new_from_stock ("gtk-close"); + gtk_widget_show (button_bet_close); + gtk_box_pack_start (GTK_BOX (vbox1), button_bet_close, FALSE, FALSE, 0); + gtk_tooltips_set_tip (tooltips, button_bet_close, _("Esc"), NULL); + gtk_widget_add_accelerator (button_bet_close, "clicked", accel_group, + GDK_Escape, 0, + GTK_ACCEL_VISIBLE); + + g_signal_connect ((gpointer) window_bets, "delete_event", + G_CALLBACK (on_window_bets_delete_event), + NULL); + g_signal_connect ((gpointer) checkbutton_bet_all_leagues, "button_press_event", + G_CALLBACK (on_checkbutton_bet_all_leagues_button_press_event), + NULL); + g_signal_connect ((gpointer) checkbutton_bet_cups, "button_press_event", + G_CALLBACK (on_checkbutton_bet_cups_button_press_event), + NULL); + g_signal_connect ((gpointer) checkbutton_bet_user_recent, "button_press_event", + G_CALLBACK (on_checkbutton_bet_user_recent_button_press_event), + NULL); + g_signal_connect ((gpointer) treeview_bets, "button_press_event", + G_CALLBACK (on_treeview_bets_button_press_event), + NULL); + g_signal_connect ((gpointer) button_bet_close, "clicked", + G_CALLBACK (on_button_bet_close_clicked), + NULL); + + /* Store pointers to all widgets, for use by lookup_widget(). */ + GLADE_HOOKUP_OBJECT_NO_REF (window_bets, window_bets, "window_bets"); + GLADE_HOOKUP_OBJECT (window_bets, vbox1, "vbox1"); + GLADE_HOOKUP_OBJECT (window_bets, label1, "label1"); + GLADE_HOOKUP_OBJECT (window_bets, hseparator1, "hseparator1"); + GLADE_HOOKUP_OBJECT (window_bets, hbox1, "hbox1"); + GLADE_HOOKUP_OBJECT (window_bets, checkbutton_bet_all_leagues, "checkbutton_bet_all_leagues"); + GLADE_HOOKUP_OBJECT (window_bets, checkbutton_bet_cups, "checkbutton_bet_cups"); + GLADE_HOOKUP_OBJECT (window_bets, checkbutton_bet_user_recent, "checkbutton_bet_user_recent"); + GLADE_HOOKUP_OBJECT (window_bets, hseparator2, "hseparator2"); + GLADE_HOOKUP_OBJECT (window_bets, treeview_bets, "treeview_bets"); + GLADE_HOOKUP_OBJECT (window_bets, button_bet_close, "button_bet_close"); + GLADE_HOOKUP_OBJECT_NO_REF (window_bets, tooltips, "tooltips"); + + gtk_window_add_accel_group (GTK_WINDOW (window_bets), accel_group); + + return window_bets; +} + diff --git a/src/misc3_interface.h b/src/misc3_interface.h new file mode 100644 index 00000000..f58f7f15 --- /dev/null +++ b/src/misc3_interface.h @@ -0,0 +1,5 @@ +/* + * DO NOT EDIT THIS FILE - it is generated by Glade. + */ + +GtkWidget* create_window_bets (void);