/*
 * gui.h
 * 
 * Copyright (C) 2006-2007 Josef Kufner <jk@myserver.cz>
 * 
 * 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.
 *
 */
#ifndef NETBOARD_GUI_H
#define NETBOARD_GUI_H

#include <gtk/gtk.h>

#include "glade_support.h"
#include "options.h"
#include "message.h"

typedef enum {
	GUI_PAGE_BOARD,
	GUI_PAGE_CHAT,
	GUI_PAGE_GAMELOG,
	GUI_PAGE_NETLOG,
	GUI_PAGE_MAX
} GUI_PAGE;

typedef enum {
	GUI_ICON_NONE = 0,
	GUI_ICON_TIP,
	GUI_ICON_INFO,
	GUI_ICON_QUESTION,
	GUI_ICON_WARNING,
	GUI_ICON_ERROR,
	GUI_ICON_MAX
} GUI_ICON;

struct s_gui {
	int is_online;
	int is_game;
	int is_paused;
	int is_locked;
	int is_onturn;
	int can_start_game;
	int can_end_game;
	int can_select_game;
	int can_select_role;
	int semafor;
};

/* option dialog widget */
typedef enum {
	GUI_ODW_T_NONE, GUI_ODW_T_ENTRY, GUI_ODW_T_CHECKBOX, GUI_ODW_T_NUMBER, GUI_ODW_T_COMBO
} GUI_ODW_TYPE;
typedef struct {
	GUI_ODW_TYPE type;
	GtkWidget *widget;
	char opt[OPTION_MAX_OPT_LEN];
} GUI_ODW;
typedef struct {
	char cat[OPTION_MAX_CAT_LEN], mod[OPTION_MAX_MOD_LEN];
	GSList *list;
	GMemChunk *mem_chunk;
	int ok_clicked;
	char notify_target;
} GUI_ODW_LIST;

extern struct s_gui gui;

extern GtkWidget *main_window;
extern GtkWidget *dialog_connect;
extern GtkWidget *dialog_about;
extern GtkWidget *dialog_game_select;
extern GtkWidget *dialog_option_browser;
extern GtkWidget *dialog_network_profiles;

/* main window */
void gui_update_main_window(void);
GtkWidget *gui_create_main_window(void);

/* board */
void gui_enable_board(void);
void gui_disable_board(void);

/* pages (tabs) */
void gui_switch_main_page(int page);
void gui_page_notify(GUI_PAGE page);
void gui_detach_page(GUI_PAGE page);
void gui_atach_page(GUI_PAGE page);

/* statusbar */
void gui_set_statusbar_text(gchar *fmt,...);
void gui_set_semaphore(int x);
void gui_set_statusbar_clock(int is_visible, int set_icon, gchar *fmt,...);
void gui_set_statusbar_progress(int visible, gdouble fraction, gchar *fmt,...);

/* logs & chat */
void gui_append_to_chat(char *fmt, ...);
void gui_append_to_netlog(char *fmt, ...);
void gui_append_to_gamelog(char *fmt, ...);
void gui_erase_logs (void);

/* dialogs */
void gui_show_dialog_game_select(void);
void gui_show_dialog_connect(void);
void gui_show_error_message(GtkWidget *parent, char *title, char *fmt, ...);
int gui_exit_question(void);

/* chat page widgets */
void gui_update_playerlist(void);
void gui_role_clear(void);
void gui_role_add(char *role);

/* options */
void gui_show_option_browser(void);
void gui_update_option_browser(void);
void gui_store_options_with_info(void);
int gui_config_dialog_from_message(MESSAGE * msg, int notify_target);
int gui_config_dialog_from_message_wp(MESSAGE * msg, int notify_target, GtkWidget *parent_window);

/* network profiles */
void gui_show_network_profiles (void);
void gui_update_network_profiles (void);
void gui_show_network_profile_editor(char *id, GtkWidget *parent_window);
void gui_show_network_backend_config(const char *id);

/* misc */
void gui_wait_for_callback(void);

#endif
