bygfoot/src/misc2_callbacks.c

802 lines
20 KiB
C
Raw Normal View History

2005-10-20 17:45:00 +02:00
/*
2008-11-09 10:36:55 +01:00
misc2_callbacks.c
2005-11-26 17:52:51 +01:00
2008-11-09 10:36:55 +01:00
Bygfoot Football Manager -- a small and simple GTK2-based
football management game.
2005-10-20 17:45:00 +02:00
2008-11-09 10:36:55 +01:00
http://bygfoot.sourceforge.net
2005-10-20 17:45:00 +02:00
2008-11-09 10:36:55 +01:00
Copyright (C) 2005 Gyözö Both (gyboth@bygfoot.com)
2005-10-20 17:45:00 +02:00
2008-11-09 10:36:55 +01:00
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.
2005-10-20 17:45:00 +02:00
2008-11-09 10:36:55 +01:00
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.
2005-10-20 17:45:00 +02:00
2008-11-09 10:36:55 +01:00
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.
2005-10-20 17:45:00 +02:00
*/
2005-10-27 23:10:15 +02:00
#include "bet.h"
2005-05-30 17:54:20 +02:00
#include "callbacks.h"
2005-04-07 18:44:33 +02:00
#include "callback_func.h"
2005-05-13 20:20:47 +02:00
#include "debug.h"
2005-03-17 21:26:01 +01:00
#include "finance.h"
2005-07-08 11:26:00 +02:00
#include "free.h"
2005-03-18 23:03:23 +01:00
#include "game_gui.h"
#include "league.h"
#include "job.h"
2005-04-13 15:01:59 +02:00
#include "load_save.h"
2005-03-18 23:03:23 +01:00
#include "main.h"
2004-12-23 13:58:39 +01:00
#include "misc2_callbacks.h"
2005-03-21 11:16:37 +01:00
#include "misc2_callback_func.h"
2004-12-23 13:58:39 +01:00
#include "misc2_interface.h"
2005-03-27 19:59:57 +02:00
#include "player.h"
2004-12-23 13:58:39 +01:00
#include "support.h"
#include "team.h"
2005-03-19 21:04:08 +01:00
#include "transfer.h"
2005-03-27 19:59:57 +02:00
#include "treeview.h"
2005-08-20 21:39:36 +02:00
#include "treeview2.h"
2005-04-16 09:46:04 +02:00
#include "treeview_helper.h"
2005-03-18 23:03:23 +01:00
#include "user.h"
2005-03-08 09:25:46 +01:00
#include "window.h"
2004-12-23 13:58:39 +01:00
G_MODULE_EXPORT void
2004-12-23 13:58:39 +01:00
on_button_offer_ok_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_offer_ok_clicked\n");
#endif
gboolean changed = TRUE;
gchar *team_name = g_strdup(current_user.tm->name);
if(stat2 == STATUS_JOB_EXCHANGE_SHOW_TEAM)
2005-12-01 15:49:00 +01:00
changed =
misc2_callback_evaluate_job_application((Job*)statp, &current_user);
else
user_change_team(&current_user, (Team*)statp);
2005-04-25 18:49:54 +02:00
if(changed)
{
if(stat2 == STATUS_JOB_OFFER_SUCCESS ||
stat2 == STATUS_JOB_EXCHANGE_SHOW_TEAM)
user_history_add(&current_user, USER_HISTORY_JOB_OFFER_ACCEPTED,
team_name,
current_user.tm->name,
league_cup_get_name_string(current_user.tm->clid),
NULL);
stat0 = STATUS_MAIN;
game_gui_show_main();
}
2005-04-25 18:49:54 +02:00
g_free(team_name);
2004-12-23 13:58:39 +01:00
window_destroy(&window.job_offer);
2005-04-07 18:44:33 +02:00
setsav0;
2004-12-23 13:58:39 +01:00
}
G_MODULE_EXPORT void
2004-12-23 13:58:39 +01:00
on_button_offer_cancel_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_offer_cancel_clicked\n");
#endif
if(stat2 != STATUS_JOB_OFFER_SUCCESS &&
stat2 != STATUS_JOB_EXCHANGE_SHOW_TEAM)
2005-03-18 23:03:23 +01:00
{
if(users->len == 1)
main_exit_program(EXIT_USER_FIRED, NULL);
else
{
user_remove(cur_user, TRUE);
cur_user = 0;
}
}
2004-12-23 13:58:39 +01:00
window_destroy(&window.job_offer);
if(stat0 != STATUS_SHOW_JOB_EXCHANGE)
{
stat0 = STATUS_MAIN;
game_gui_show_main();
}
2004-12-23 13:58:39 +01:00
}
2005-03-08 09:25:46 +01:00
G_MODULE_EXPORT gboolean
2005-03-08 09:25:46 +01:00
on_button_warning_clicked (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_warning_clicked\n");
#endif
window_destroy(&window.warning);
2005-03-08 09:25:46 +01:00
2005-04-27 17:50:26 +02:00
if(stat4 == STATUS_SHOW_EVENT)
2005-03-18 23:03:23 +01:00
user_event_show_next();
2005-03-08 09:25:46 +01:00
return FALSE;
}
2005-03-17 21:26:01 +01:00
G_MODULE_EXPORT void
2005-03-17 21:26:01 +01:00
on_button_digits_ok_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_digits_ok_clicked\n");
#endif
2005-03-17 21:26:01 +01:00
GtkSpinButton *spinbutton1 = GTK_SPIN_BUTTON(lookup_widget(window.digits, "spinbutton1")),
*spinbutton2 = GTK_SPIN_BUTTON(lookup_widget(window.digits, "spinbutton2"));
gint values[2] =
{gtk_spin_button_get_value_as_int(spinbutton1),
gtk_spin_button_get_value_as_int(spinbutton2)};
2005-04-06 12:19:43 +02:00
gboolean destroy_window = TRUE;
2005-03-17 21:26:01 +01:00
2005-04-06 12:19:43 +02:00
switch(stat1)
2005-03-17 21:26:01 +01:00
{
2008-11-09 10:36:55 +01:00
case STATUS_GET_LOAN:
finance_get_loan(values[0]);
on_menu_show_finances_activate(NULL, NULL);
break;
case STATUS_PAY_LOAN:
finance_pay_loan(&current_user, values[0]);
on_menu_show_finances_activate(NULL, NULL);
if(current_user.debt != 0 && current_user.alr_start_week != 0)
window_show_yesno(_("Adjust repayment schedule?"));
break;
case STATUS_SHOW_TRANSFER_LIST:
if(transfer_add_offer(stat2, current_user.tm, values[0], values[1]))
game_gui_print_message(_("Your offer has been updated."));
else
game_gui_print_message(_("Your offer will be considered next week."));
break;
case STATUS_CUSTOM_STRUCTURE:
destroy_window = misc2_callback_change_structure(values[1]);
if(destroy_window && stat0 == STATUS_LIVE_GAME_PAUSE)
gtk_widget_set_sensitive(window.main, TRUE);
break;
case STATUS_SET_YA_PERCENTAGE:
current_user.youth_academy.percentage = values[1];
break;
case STATUS_PLACE_BET:
if(!bet_place(stat2, stat3, values[0]))
destroy_window = FALSE;
break;
2005-03-17 21:26:01 +01:00
}
2005-03-18 23:03:23 +01:00
2005-04-06 12:19:43 +02:00
if(destroy_window)
window_destroy(&window.digits);
2005-03-19 21:04:08 +01:00
2005-03-18 23:03:23 +01:00
game_gui_set_main_window_header();
2005-04-07 18:44:33 +02:00
setsav0;
2005-03-17 21:26:01 +01:00
}
G_MODULE_EXPORT void
2008-11-08 13:46:12 +01:00
on_button_digits_alr_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_digits_alr_clicked\n");
#endif
2008-11-08 13:46:12 +01:00
on_button_digits_ok_clicked(NULL, NULL);
on_automatic_loan_repayment_activate(NULL, NULL);
}
G_MODULE_EXPORT void
2005-03-17 21:26:01 +01:00
on_button_digits_cancel_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_digits_cancel_clicked\n");
#endif
window_destroy(&window.digits);
2005-03-17 21:26:01 +01:00
}
2005-03-20 21:49:55 +01:00
G_MODULE_EXPORT gboolean
2005-03-20 21:49:55 +01:00
on_window_yesno_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
#ifdef DEBUG
printf("on_window_yesno_delete_event\n");
#endif
2005-03-27 19:59:57 +02:00
on_button_yesno_no_clicked(NULL, NULL);
2005-03-20 21:49:55 +01:00
2005-04-27 17:50:26 +02:00
if(stat4 == STATUS_SHOW_EVENT)
user_event_show_next();
2005-03-27 19:59:57 +02:00
return FALSE;
2005-03-20 21:49:55 +01:00
}
G_MODULE_EXPORT void
2005-03-20 21:49:55 +01:00
on_button_yesno_yes_clicked (GtkButton *button,
gpointer user_data)
{
Bygfoot *bygfoot = (Bygfoot*)user_data;
#ifdef DEBUG
printf("on_button_yesno_yes_clicked\n");
#endif
window_destroy(&window.yesno);
2005-04-07 18:44:33 +02:00
setsav0;
switch(stat1)
2005-03-20 21:49:55 +01:00
{
2008-11-09 10:36:55 +01:00
default:
2009-04-29 19:18:54 +02:00
debug_print_message("on_button_yesno_yes_clicked: unknown status %d\n", stat1);
2008-11-09 10:36:55 +01:00
break;
case STATUS_PAY_LOAN:
on_automatic_loan_repayment_activate(NULL, NULL);
break;
case STATUS_FIRE_PLAYER:
player_remove_from_team(current_user.tm, stat2);
current_user.money -= stat3;
current_user.money_out[1][MON_OUT_COMPENSATIONS] -= stat3;
treeview_show_user_player_list();
game_gui_set_main_window_header();
break;
case STATUS_USER_MANAGEMENT:
user_remove(stat2, TRUE);
treeview_show_users(
GTK_TREE_VIEW(lookup_widget(window.user_management,
"treeview_user_management_users")));
treeview_show_team_list(
GTK_TREE_VIEW(lookup_widget(window.user_management,
"treeview_user_management_teams")),
FALSE, FALSE);
break;
case STATUS_QUERY_UNFIT:
load_save_autosave(bygfoot);
callback_show_next_live_game(bygfoot);
2008-11-09 10:36:55 +01:00
break;
case STATUS_QUERY_QUIT:
main_exit_program(EXIT_OK, NULL);
break;
case STATUS_QUERY_USER_NO_TURN:
load_save_autosave(bygfoot);
callback_show_next_live_game(bygfoot);
2008-11-09 10:36:55 +01:00
break;
case STATUS_QUERY_KICK_YOUTH:
free_player(&g_array_index(current_user.youth_academy.players, Player, selected_row));
g_array_remove_index(current_user.youth_academy.players, selected_row);
on_menu_show_youth_academy_activate(NULL, NULL);
selected_row = -1;
break;
2005-03-20 21:49:55 +01:00
}
2005-04-27 17:50:26 +02:00
if(stat4 == STATUS_SHOW_EVENT)
user_event_show_next();
2005-03-20 21:49:55 +01:00
}
G_MODULE_EXPORT void
2005-03-20 21:49:55 +01:00
on_button_yesno_no_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_yesno_no_clicked\n");
#endif
window_destroy(&window.yesno);
2005-04-27 17:50:26 +02:00
if(stat4 == STATUS_SHOW_EVENT)
user_event_show_next();
2005-03-20 21:49:55 +01:00
}
2005-03-25 11:54:54 +01:00
G_MODULE_EXPORT void
2005-03-25 11:54:54 +01:00
on_button_contract_offer_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_contract_offer_clicked\n");
#endif
2005-03-25 21:18:35 +01:00
misc2_callback_contract_offer();
}
2005-03-25 11:54:54 +01:00
G_MODULE_EXPORT void
2005-07-05 20:37:26 +02:00
on_button_contract_cancel_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_contract_cancel_clicked\n");
#endif
window_destroy(&window.contract);
2005-07-05 20:37:26 +02:00
}
G_MODULE_EXPORT gboolean
2005-03-25 21:18:35 +01:00
on_window_contract_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
#ifdef DEBUG
printf("on_window_contract_delete_event\n");
#endif
2005-03-25 21:18:35 +01:00
2005-07-05 20:37:26 +02:00
if(GTK_WIDGET_IS_SENSITIVE(lookup_widget(window.contract, "button_contract_cancel")))
window_destroy(&window.contract);
2005-07-05 20:37:26 +02:00
2005-03-25 21:18:35 +01:00
return TRUE;
2005-03-25 11:54:54 +01:00
}
2005-03-25 21:18:35 +01:00
2005-03-27 19:59:57 +02:00
G_MODULE_EXPORT void
2005-03-27 19:59:57 +02:00
on_entry_user_management_activate (GtkEntry *entry,
gpointer user_data)
{
#ifdef DEBUG
printf("on_entry_user_management_activate\n");
#endif
2005-03-27 19:59:57 +02:00
on_button_user_management_add_clicked(NULL, NULL);
}
G_MODULE_EXPORT void
2005-03-27 19:59:57 +02:00
on_button_user_management_add_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_user_management_add_clicked\n");
#endif
2005-03-27 19:59:57 +02:00
misc2_callback_add_user();
}
G_MODULE_EXPORT void
2005-03-27 19:59:57 +02:00
on_button_user_management_close_clicked
2008-11-09 10:36:55 +01:00
(GtkButton *button,
gpointer user_data)
2005-03-27 19:59:57 +02:00
{
#ifdef DEBUG
printf("on_button_user_management_close_clicked\n");
#endif
window_destroy(&window.user_management);
2005-06-20 14:46:57 +02:00
on_button_back_to_main_clicked(NULL, NULL);
2005-03-27 19:59:57 +02:00
}
G_MODULE_EXPORT gboolean
2005-03-27 19:59:57 +02:00
on_treeview_user_management_users_button_press_event
2008-11-09 10:36:55 +01:00
(GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
2005-03-27 19:59:57 +02:00
{
#ifdef DEBUG
printf("on_treeview_user_management_users_button_press_event\n");
#endif
2005-03-27 19:59:57 +02:00
gchar buf[SMALL];
gint idx = -1;
2005-04-16 09:46:04 +02:00
if(!treeview_helper_select_row(GTK_TREE_VIEW(widget), event))
2005-03-27 19:59:57 +02:00
return TRUE;
2005-04-16 09:46:04 +02:00
idx = treeview_helper_get_index(GTK_TREE_VIEW(widget), 0) - 1;
2005-03-27 19:59:57 +02:00
if(users->len == 1)
{
2005-05-26 18:54:22 +02:00
game_gui_show_warning(_("You can't play Bygfoot without users!"));
2005-03-27 19:59:57 +02:00
return TRUE;
}
2005-04-07 18:44:33 +02:00
stat2 = idx;
2005-10-09 11:35:44 +02:00
sprintf(buf, _("Remove user %s from the game?"), usr(idx).name);
2005-04-07 18:44:33 +02:00
window_show_yesno(buf);
2005-03-27 19:59:57 +02:00
return FALSE;
}
G_MODULE_EXPORT void
2005-03-27 19:59:57 +02:00
on_treeview_user_management_teams_row_activated
2008-11-09 10:36:55 +01:00
(GtkTreeView *treeview,
GtkTreePath *path,
GtkTreeViewColumn *column,
gpointer user_data)
2005-03-27 19:59:57 +02:00
{
#ifdef DEBUG
printf("on_treeview_user_management_teams_row_activated\n");
#endif
2005-03-27 19:59:57 +02:00
on_button_user_management_add_clicked(NULL, NULL);
}
2005-05-13 20:20:47 +02:00
G_MODULE_EXPORT gboolean
2005-05-13 20:20:47 +02:00
on_window_debug_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
#ifdef DEBUG
printf("on_window_debug_delete_event\n");
#endif
2005-05-13 20:20:47 +02:00
on_button_debug_close_activate(NULL, NULL);
return FALSE;
}
G_MODULE_EXPORT void
2005-05-13 20:20:47 +02:00
on_button_debug_apply_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_debug_apply_clicked\n");
#endif
2005-05-13 20:20:47 +02:00
GtkEntry *entry_debug =
GTK_ENTRY(lookup_widget(window.wdebug, "entry_debug"));
const gchar *entry_text = gtk_entry_get_text(entry_debug);
2005-12-10 13:21:19 +01:00
debug_action(entry_text);
2005-05-13 20:20:47 +02:00
gtk_entry_set_text(entry_debug, "");
}
G_MODULE_EXPORT void
2005-05-13 20:20:47 +02:00
on_button_debug_close_activate (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_debug_close_activate\n");
#endif
window_destroy(&window.wdebug);
2005-05-13 20:20:47 +02:00
}
G_MODULE_EXPORT void
2005-05-13 20:20:47 +02:00
on_entry_debug_activate (GtkEntry *entry,
gpointer user_data)
{
#ifdef DEBUG
printf("on_entry_debug_activate\n");
#endif
2005-05-13 20:20:47 +02:00
on_button_debug_apply_clicked(NULL, NULL);
}
2005-05-15 17:00:15 +02:00
G_MODULE_EXPORT gboolean
2005-05-15 17:00:15 +02:00
on_window_job_offer_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
#ifdef DEBUG
printf("on_window_job_offer_delete_event\n");
#endif
2005-05-15 17:00:15 +02:00
on_button_offer_cancel_clicked(NULL, NULL);
return FALSE;
}
G_MODULE_EXPORT gboolean
2005-05-15 17:00:15 +02:00
on_window_digits_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
#ifdef DEBUG
printf("on_window_digits_delete_event\n");
#endif
2005-05-15 17:00:15 +02:00
on_button_digits_cancel_clicked(NULL, NULL);
return FALSE;
}
G_MODULE_EXPORT gboolean
2005-05-15 17:00:15 +02:00
on_window_user_management_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
#ifdef DEBUG
printf("on_window_user_management_delete_event\n");
#endif
2005-05-15 17:00:15 +02:00
on_button_user_management_close_clicked(NULL, NULL);
return FALSE;
}
2005-05-22 15:33:24 +02:00
G_MODULE_EXPORT gboolean
2005-05-22 15:33:24 +02:00
on_window_help_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
#ifdef DEBUG
printf("on_window_help_delete_event\n");
#endif
2005-05-22 15:33:24 +02:00
on_button_help_close_clicked(NULL, NULL);
return FALSE;
}
G_MODULE_EXPORT void
2005-05-22 15:33:24 +02:00
on_button_help_close_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_help_close_clicked\n");
#endif
window_destroy(&window.help);
2005-05-22 15:33:24 +02:00
}
2005-05-28 10:19:56 +02:00
G_MODULE_EXPORT void
2005-05-28 10:19:56 +02:00
on_spinbutton1_activate (GtkEntry *entry,
gpointer user_data)
{
#ifdef DEBUG
printf("on_spinbutton1_activate\n");
#endif
2005-05-28 10:19:56 +02:00
gtk_spin_button_update(GTK_SPIN_BUTTON(lookup_widget(window.digits, "spinbutton1")));
on_button_digits_ok_clicked(NULL, NULL);
}
G_MODULE_EXPORT void
2005-05-28 10:19:56 +02:00
on_spinbutton2_activate (GtkEntry *entry,
gpointer user_data)
{
#ifdef DEBUG
printf("on_spinbutton2_activate\n");
#endif
2005-05-28 10:19:56 +02:00
gtk_spin_button_update(GTK_SPIN_BUTTON(lookup_widget(window.digits, "spinbutton2")));
on_button_digits_ok_clicked(NULL, NULL);
}
2005-05-30 17:54:20 +02:00
G_MODULE_EXPORT gboolean
2005-05-30 17:54:20 +02:00
on_window_transfer_dialog_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
#ifdef DEBUG
printf("on_window_transfer_dialog_delete_event\n");
#endif
2005-05-30 17:54:20 +02:00
on_button_transfer_later_clicked(NULL, NULL);
return FALSE;
}
G_MODULE_EXPORT void
2005-05-30 17:54:20 +02:00
on_button_transfer_yes_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_transfer_yes_clicked\n");
#endif
2005-05-30 17:54:20 +02:00
if(stat1 == STATUS_TRANSFER_OFFER_USER)
misc2_callback_transfer_user_player();
else if(STATUS_TRANSFER_OFFER_CPU)
misc2_callback_transfer_cpu_player();
window_destroy(&window.transfer_dialog);
2005-05-30 17:54:20 +02:00
}
G_MODULE_EXPORT void
2005-05-30 17:54:20 +02:00
on_button_transfer_no_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_transfer_no_clicked\n");
#endif
2005-06-19 13:24:25 +02:00
gint len = 1;
transoff(stat2, 0).status = TRANSFER_OFFER_REJECTED;
if(transoff(stat2, 0).tm == current_user.tm)
{
g_array_remove_index(trans(stat2).offers, 0);
len = 0;
}
if(trans(stat2).offers->len > len)
2005-05-30 17:54:20 +02:00
transfer_offers_notify(&trans(stat2), FALSE);
treeview_show_user_player_list();
game_gui_set_main_window_header();
on_button_transfers_clicked(NULL, NULL);
window_destroy(&window.transfer_dialog);
2005-05-30 17:54:20 +02:00
}
G_MODULE_EXPORT void
2005-05-30 17:54:20 +02:00
on_button_transfer_later_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_transfer_later_clicked\n");
#endif
window_destroy(&window.transfer_dialog);
2005-05-30 17:54:20 +02:00
}
2005-08-20 21:39:36 +02:00
G_MODULE_EXPORT gboolean
2005-08-20 21:39:36 +02:00
on_window_mmatches_delete_event (GtkWidget *widget,
GdkEvent *event,
gpointer user_data)
{
#ifdef DEBUG
printf("on_window_mmatches_delete_event\n");
#endif
2005-08-20 21:39:36 +02:00
on_button_mm_reload_close_clicked(NULL, NULL);
return TRUE;
}
G_MODULE_EXPORT gboolean
2005-08-20 21:39:36 +02:00
on_treeview_mmatches_button_press_event (GtkWidget *widget,
GdkEventButton *event,
gpointer user_data)
{
Bygfoot *bygfoot = (Bygfoot*)user_data;
#ifdef DEBUG
printf("on_treeview_mmatches_button_press_event\n");
#endif
2005-08-20 21:39:36 +02:00
GtkTreePath *path = NULL;
GtkTreeViewColumn *col = NULL;
gint col_num = -1, mmidx = -1;
if(!gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(widget),
event->x, event->y,
&path, &col, NULL, NULL))
return TRUE;
col_num = treeview_helper_get_col_number_column(col);
mmidx = gtk_tree_path_get_indices(path)[0];
gtk_tree_path_free(path);
if(col_num == -1 || mmidx == -1)
{
2009-04-29 19:18:54 +02:00
debug_print_message("on_treeview_mmatches_button_press_event: column or row not valid\n");
2005-08-20 21:39:36 +02:00
return TRUE;
}
misc2_callback_mmatches_button_press(widget, mmidx, col_num, bygfoot);
2005-08-21 21:58:51 +02:00
2005-08-20 21:39:36 +02:00
return TRUE;
}
G_MODULE_EXPORT void
2005-08-20 21:39:36 +02:00
on_button_mm_save_close_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_mm_save_close_clicked\n");
#endif
2005-08-20 21:39:36 +02:00
const gchar *filename =
gtk_entry_get_text(GTK_ENTRY(lookup_widget(window.mmatches, "entry_mm_file")));
2005-08-21 21:58:51 +02:00
user_mm_set_filename(filename, NULL);
2005-10-09 11:35:44 +02:00
user_mm_save_file(current_user.mmatches_file,
2005-08-21 21:58:51 +02:00
current_user.mmatches);
2005-08-20 21:39:36 +02:00
window_destroy(&window.mmatches);
2005-08-20 21:39:36 +02:00
}
G_MODULE_EXPORT void
2005-08-20 21:39:36 +02:00
on_button_mm_add_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_mm_add_clicked\n");
#endif
2005-08-20 21:39:36 +02:00
if(current_user.live_game.units->len == 0)
{
game_gui_show_warning(_("No match stored."));
return;
}
user_mm_add_last_match(FALSE, FALSE);
treeview2_show_mmatches();
}
G_MODULE_EXPORT void
2005-08-20 21:39:36 +02:00
on_button_mm_file_clicked (GtkButton *button,
gpointer user_data)
{
Bygfoot *bygfoot = (Bygfoot*)user_data;
#ifdef DEBUG
printf("on_button_mm_file_clicked\n");
#endif
2005-08-20 21:39:36 +02:00
stat5 = STATUS_SELECT_MM_FILE_LOAD;
window_show_file_sel(bygfoot);
2005-08-20 21:39:36 +02:00
}
G_MODULE_EXPORT void
2005-08-20 21:39:36 +02:00
on_button_mm_reload_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_mm_reload_clicked\n");
#endif
2005-08-20 21:39:36 +02:00
GtkWidget *treeview = lookup_widget(window.mmatches, "treeview_mmatches");
const gchar *filename =
gtk_entry_get_text(GTK_ENTRY(lookup_widget(window.mmatches, "entry_mm_file")));
gtk_widget_hide(treeview);
2005-08-21 21:58:51 +02:00
user_mm_load_file(filename, NULL);
2005-08-20 21:39:36 +02:00
treeview2_show_mmatches();
gtk_widget_show(treeview);
}
G_MODULE_EXPORT void
2005-08-20 21:39:36 +02:00
on_button_mm_reload_close_clicked (GtkButton *button,
gpointer user_data)
{
#ifdef DEBUG
printf("on_button_mm_reload_close_clicked\n");
#endif
2005-08-20 21:39:36 +02:00
on_button_mm_reload_clicked(NULL, NULL);
on_button_mm_save_close_clicked(NULL, NULL);
}
G_MODULE_EXPORT void
2005-08-21 21:58:51 +02:00
on_button_mm_import_clicked (GtkButton *button,
gpointer user_data)
{
Bygfoot *bygfoot = (Bygfoot*)user_data;
#ifdef DEBUG
printf("on_button_mm_import_clicked\n");
#endif
2005-08-21 21:58:51 +02:00
stat5 = STATUS_SELECT_MM_FILE_IMPORT;
window_show_file_sel(bygfoot);
2005-08-21 21:58:51 +02:00
}
2008-11-08 13:46:12 +01:00