2005-10-20 15:45:00 +00:00
|
|
|
/*
|
2005-11-26 16:52:51 +00:00
|
|
|
gui.c
|
|
|
|
|
2005-10-20 15:45:00 +00:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2004-12-23 12:58:39 +00:00
|
|
|
#include "gui.h"
|
2005-03-03 12:46:48 +00:00
|
|
|
#include "misc.h"
|
2005-12-01 11:50:54 +00:00
|
|
|
#include "option.h"
|
2005-03-10 20:59:39 +00:00
|
|
|
#include "support.h"
|
2005-01-09 20:21:22 +00:00
|
|
|
#include "variables.h"
|
2005-03-10 20:59:39 +00:00
|
|
|
#include "window.h"
|
2004-12-23 12:58:39 +00:00
|
|
|
|
2005-03-03 12:46:48 +00:00
|
|
|
/* Set into or append an integer into a label.
|
|
|
|
@param label The label.
|
|
|
|
@param number The number.
|
|
|
|
@param append Whether or not to append.*/
|
|
|
|
void
|
|
|
|
gui_label_set_text_from_int(GtkLabel *label, gint number, gboolean append)
|
|
|
|
{
|
|
|
|
const gchar *current_text = gtk_label_get_text(label);
|
|
|
|
gchar buf[SMALL], buf2[SMALL];
|
|
|
|
|
|
|
|
strcpy(buf, "");
|
|
|
|
strcpy(buf2, "");
|
|
|
|
|
|
|
|
if(number > 1000)
|
2005-07-01 20:51:46 +00:00
|
|
|
misc_print_grouped_int(number, buf);
|
2005-03-03 12:46:48 +00:00
|
|
|
else
|
|
|
|
sprintf(buf, "%d", number);
|
|
|
|
|
|
|
|
if(!append)
|
|
|
|
sprintf(buf2, "%s", buf);
|
|
|
|
else
|
|
|
|
sprintf(buf2, "%s%s", current_text, buf);
|
|
|
|
|
|
|
|
gtk_label_set_text(label, buf2);
|
|
|
|
}
|
|
|
|
|
2005-03-10 20:59:39 +00:00
|
|
|
/* Show a window with a progress bar.
|
|
|
|
@param value The value of the progress bar. If set to 1
|
|
|
|
or < 0 the progress bar window gets destroyed.
|
2005-11-02 21:04:19 +00:00
|
|
|
@param text The text to show in the progress bar.
|
|
|
|
@param pictype What kind of picture to show above the progress bar. */
|
2005-03-10 20:59:39 +00:00
|
|
|
void
|
2005-11-02 21:04:19 +00:00
|
|
|
gui_show_progress(gfloat value, const gchar *text, gint pictype)
|
2005-03-10 20:59:39 +00:00
|
|
|
{
|
|
|
|
GtkProgressBar *progressbar = NULL;
|
|
|
|
|
|
|
|
if(value == 1 || value < 0)
|
|
|
|
{
|
2006-03-26 14:14:45 +00:00
|
|
|
window_destroy(&window.progress);
|
2005-03-10 20:59:39 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(window.progress == NULL)
|
2005-11-02 21:04:19 +00:00
|
|
|
window_show_progress(pictype);
|
|
|
|
|
2005-03-10 20:59:39 +00:00
|
|
|
progressbar = GTK_PROGRESS_BAR(lookup_widget(window.progress, "progressbar"));
|
|
|
|
|
|
|
|
if(value >= 0 && value < 1)
|
|
|
|
gtk_progress_bar_set_fraction(progressbar, value);
|
|
|
|
else
|
|
|
|
gtk_progress_bar_pulse(progressbar);
|
|
|
|
|
|
|
|
if(text != NULL)
|
|
|
|
gtk_progress_bar_set_text(progressbar, text);
|
|
|
|
|
|
|
|
while(gtk_events_pending())
|
|
|
|
gtk_main_iteration();
|
|
|
|
}
|
2005-04-10 12:32:44 +00:00
|
|
|
|
|
|
|
/** Set either the right pair of arrows atop the right
|
|
|
|
treeview or the left pair or both to the specified
|
|
|
|
sensitivity state. */
|
|
|
|
void
|
|
|
|
gui_set_arrow_pair(gint pair, gboolean state)
|
|
|
|
{
|
|
|
|
gint i, j;
|
|
|
|
GtkWidget *buttons[2][2] =
|
|
|
|
{{lookup_widget(window.main ,"button_cl_back"),
|
|
|
|
lookup_widget(window.main ,"button_cl_forward")},
|
|
|
|
{lookup_widget(window.main ,"button_browse_back"),
|
|
|
|
lookup_widget(window.main ,"button_browse_forward")}};
|
|
|
|
|
|
|
|
if(pair < 3)
|
|
|
|
for(i=0;i<2;i++)
|
|
|
|
gtk_widget_set_sensitive(buttons[pair][i], state);
|
|
|
|
else
|
|
|
|
for(i=0;i<2;i++)
|
|
|
|
for(j=0;j<2;j++)
|
|
|
|
gtk_widget_set_sensitive(buttons[i][j], state);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Examine the status variable and set the
|
|
|
|
sensitivity of the arrows atop the right treeview
|
|
|
|
accordingly. */
|
|
|
|
void
|
|
|
|
gui_set_arrows(void)
|
|
|
|
{
|
|
|
|
gui_set_arrow_pair(3, FALSE);
|
|
|
|
|
2005-04-13 13:01:59 +00:00
|
|
|
if(stat0 == STATUS_SHOW_FIXTURES ||
|
2005-05-02 14:39:30 +00:00
|
|
|
stat0 == STATUS_BROWSE_TEAMS ||
|
|
|
|
stat0 == STATUS_SHOW_SEASON_HISTORY)
|
2005-04-10 12:32:44 +00:00
|
|
|
gui_set_arrow_pair(3, TRUE);
|
2005-04-15 13:55:59 +00:00
|
|
|
else if(stat0 == STATUS_SHOW_PLAYER_INFO ||
|
|
|
|
stat0 == STATUS_SHOW_FIXTURES_WEEK)
|
2005-04-10 12:32:44 +00:00
|
|
|
gui_set_arrow_pair(1, TRUE);
|
|
|
|
else if(stat0 == STATUS_SHOW_TABLES ||
|
2005-04-29 19:48:02 +00:00
|
|
|
stat0 == STATUS_SHOW_PLAYER_LIST ||
|
|
|
|
stat0 == STATUS_SHOW_LEAGUE_STATS)
|
2005-04-10 12:32:44 +00:00
|
|
|
gui_set_arrow_pair(0, TRUE);
|
|
|
|
}
|
2005-09-29 09:03:43 +00:00
|
|
|
|
|
|
|
/** Set the sensitivity of the live game window meters and their
|
|
|
|
eventboxes. */
|
|
|
|
void
|
|
|
|
gui_set_sensitive_lg_meters(gboolean state)
|
|
|
|
{
|
|
|
|
gtk_widget_set_sensitive(lookup_widget(window.live, "image_lg_style"), state);
|
|
|
|
gtk_widget_set_sensitive(lookup_widget(window.live, "eventbox_lg_style"), state);
|
|
|
|
gtk_widget_set_sensitive(lookup_widget(window.live, "image_lg_boost"), state);
|
|
|
|
gtk_widget_set_sensitive(lookup_widget(window.live, "eventbox_lg_boost"), state);
|
|
|
|
}
|