2005-01-09 21:21:22 +01:00
|
|
|
#include "file.h"
|
|
|
|
#include "free.h"
|
2004-12-30 17:48:19 +01:00
|
|
|
#include "interface.h"
|
|
|
|
#include "main.h"
|
|
|
|
#include "misc_interface.h"
|
|
|
|
#include "support.h"
|
2005-01-09 21:21:22 +01:00
|
|
|
#include "variables.h"
|
|
|
|
#include "window.h"
|
2004-12-23 13:58:39 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
Show the country selection window. All files with prefix
|
|
|
|
'country_' from $HOME/.bygfoot/definitions are appended to a combo box.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
window_show_startup(void)
|
|
|
|
{
|
|
|
|
GtkWidget *window_startup =
|
2004-12-30 17:48:19 +01:00
|
|
|
window_create(WINDOW_STARTUP);
|
2004-12-23 13:58:39 +01:00
|
|
|
GtkWidget *combo_country =
|
|
|
|
lookup_widget(window_startup, "combo_country");
|
|
|
|
gchar country_dir[SMALL];
|
|
|
|
GPtrArray *dir_contents = NULL;
|
|
|
|
GList *combo_strings = NULL;
|
|
|
|
gint i;
|
|
|
|
|
2005-01-09 21:21:22 +01:00
|
|
|
file_get_definitions_dir(country_dir);
|
2004-12-23 13:58:39 +01:00
|
|
|
|
|
|
|
dir_contents = file_dir_get_contents((const gchar*)country_dir, "country_");
|
|
|
|
|
|
|
|
for(i=0;i<dir_contents->len;i++)
|
|
|
|
combo_strings = g_list_append(combo_strings,
|
|
|
|
((GString*)g_ptr_array_index(dir_contents, i))->str);
|
|
|
|
|
|
|
|
gtk_combo_set_popdown_strings(GTK_COMBO(combo_country), combo_strings);
|
|
|
|
|
2004-12-30 17:48:19 +01:00
|
|
|
free_g_string_array(&dir_contents);
|
2004-12-23 13:58:39 +01:00
|
|
|
}
|
|
|
|
|
2005-01-09 21:21:22 +01:00
|
|
|
/** Create and show the main window. */
|
|
|
|
void
|
|
|
|
window_show_main(void)
|
|
|
|
{
|
|
|
|
main_window = window_create(WINDOW_MAIN);
|
|
|
|
|
|
|
|
gtk_widget_show(main_window);
|
|
|
|
}
|
|
|
|
|
2004-12-23 13:58:39 +01:00
|
|
|
/** Set 'Bygfoot x.y.z' into the title of a window.
|
|
|
|
@param window The window widget pointer.
|
|
|
|
@see #VERS */
|
|
|
|
GtkWidget*
|
2004-12-30 17:48:19 +01:00
|
|
|
window_set_version(GtkWidget *window)
|
2004-12-23 13:58:39 +01:00
|
|
|
{
|
|
|
|
gchar buf[SMALL];
|
|
|
|
|
|
|
|
sprintf(buf, "Bygfoot Football Manager %s", VERS);
|
|
|
|
gtk_window_set_title(GTK_WINDOW(window), buf);
|
|
|
|
|
|
|
|
return window;
|
|
|
|
}
|
|
|
|
|
2004-12-30 17:48:19 +01:00
|
|
|
/** Create and show a window. Which one depends on the argument.
|
|
|
|
@param window_type An integer telling us which window to
|
|
|
|
create.
|
|
|
|
@return The pointer to the new window.
|
|
|
|
@see #Windows */
|
|
|
|
GtkWidget*
|
|
|
|
window_create(gint window_type)
|
|
|
|
{
|
|
|
|
GtkWidget *window = NULL;
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
popups_active++;
|
2004-12-30 17:48:19 +01:00
|
|
|
|
|
|
|
switch(window_type)
|
|
|
|
{
|
|
|
|
default:
|
2005-01-09 21:21:22 +01:00
|
|
|
if(main_window == NULL)
|
|
|
|
{
|
|
|
|
window = create_main_window();
|
|
|
|
popups_active--;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
window = main_window;
|
2004-12-30 17:48:19 +01:00
|
|
|
window_set_version(window);
|
|
|
|
break;
|
|
|
|
case WINDOW_STARTUP:
|
|
|
|
window = create_window_startup();
|
|
|
|
window_set_version(window);
|
|
|
|
break;
|
2005-01-09 21:21:22 +01:00
|
|
|
case WINDOW_LIVE:
|
|
|
|
window = create_window_live();
|
|
|
|
window_set_version(window);
|
2005-01-10 16:24:15 +01:00
|
|
|
gtk_spin_button_set_value(
|
|
|
|
GTK_SPIN_BUTTON(lookup_widget(window, "spinbutton_speed")),
|
|
|
|
(gfloat)options[OPT_LIVE_SPEED]);
|
2005-01-09 21:21:22 +01:00
|
|
|
break;
|
2004-12-30 17:48:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_show(window);
|
|
|
|
|
2005-01-09 21:21:22 +01:00
|
|
|
if(popups_active != 0 && main_window != NULL)
|
|
|
|
gtk_widget_set_sensitive(main_window, FALSE);
|
|
|
|
|
2004-12-30 17:48:19 +01:00
|
|
|
return window;
|
|
|
|
}
|
2005-01-09 21:21:22 +01:00
|
|
|
|
|
|
|
/** Destroy a window widget and set the popups and
|
|
|
|
main window sensitivity correctly.
|
|
|
|
@param window The window we destroy. */
|
|
|
|
void
|
|
|
|
window_destroy(GtkWidget **window)
|
|
|
|
{
|
|
|
|
if(*window == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if(*window != main_window)
|
|
|
|
{
|
|
|
|
popups_active--;
|
|
|
|
|
|
|
|
if(popups_active == 0 && main_window != NULL)
|
|
|
|
gtk_widget_set_sensitive(main_window, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
gtk_widget_destroy(*window);
|
|
|
|
|
|
|
|
*window = NULL;
|
|
|
|
}
|
|
|
|
|