Crossfire Client, Trunk  R20507
Macros | Functions | Variables
config.c File Reference

Implement client configuration dialog. More...

#include "client.h"
#include <ctype.h>
#include <gtk/gtk.h>
#include "image.h"
#include "main.h"
#include "mapdata.h"
#include "gtk2proto.h"
Include dependency graph for config.c:

Go to the source code of this file.

Macros

#define IS_DIFFERENT(TYPE)   (want_config[TYPE] != use_config[TYPE])
 
#define THEME_DEFAULT   CF_DATADIR "/themes/Standard"
 

Functions

static void combo_box_text_remove_all (GtkComboBoxText *combo_box)
 Removes all the text entries from the combo box. More...
 
static int combobox_get_value (GtkComboBox *combobox, int column)
 Get an integer value from 'column' of the active field in 'combobox'. More...
 
void config_check ()
 Sanity check values set in want_config and copy them over to use_config when all of them are acceptable. More...
 
void config_init (GtkWidget *window_root)
 
void config_load ()
 Load settings from the user's configuration file into want_config. More...
 
static void config_load_legacy ()
 Load settings from the legacy file format. More...
 
void init_theme ()
 
void load_theme (int reload)
 
void load_window_positions (GtkWidget *window_root)
 Resize the client window and its panels using saved window positions. More...
 
static void on_config_close (GtkButton *button, gpointer user_data)
 
void on_configure_activate (GtkWidget *menuitem, gpointer user_data)
 
void on_save_window_position_activate (GtkMenuItem *menuitem, gpointer user_data)
 Handles saving of the window positions when the Client | Save Window Position menu item is activated. More...
 
static void read_config_dialog (void)
 This is basically the opposite of setup_config_dialog() above - instead of setting the display state appropriately, we read the display state and update the want_config values. More...
 
void save_defaults ()
 This function saves user settings chosen using the configuration popup dialog. More...
 
void save_winpos ()
 Save client window positions to a file unique to each layout. More...
 
static void setup_config_dialog ()
 
static char * ui_name ()
 Return the basename of the current UI file. More...
 

Variables

static GKeyFile * config
 
GtkWidget * config_button_cache
 
GtkWidget * config_button_download
 
GtkWidget * config_button_echo
 
GtkWidget * config_button_fasttcp
 
GtkWidget * config_button_fog
 
GtkWidget * config_button_foodbeep
 
GtkWidget * config_button_grad_color
 
GtkWidget * config_button_smoothing
 
GtkWidget * config_button_sound
 
GtkWidget * config_button_timestamp
 
GtkComboBox * config_combobox_displaymode
 
GtkComboBoxText * config_combobox_faceset
 
GtkComboBox * config_combobox_lighting
 
GtkWidget * config_dialog
 
static GString * config_path
 
static char ** default_files = NULL
 Sets up player-specific client and layout rc files and handles loading of a client theme if one is selected. More...
 
static char * theme = THEME_DEFAULT
 
GtkFileChooser * theme_filechooser
 
GtkFileChooser * ui_filechooser
 

Detailed Description

Implement client configuration dialog.

Definition in file config.c.

Macro Definition Documentation

◆ IS_DIFFERENT

#define IS_DIFFERENT (   TYPE)    (want_config[TYPE] != use_config[TYPE])

Definition at line 622 of file config.c.

Referenced by read_config_dialog().

◆ THEME_DEFAULT

#define THEME_DEFAULT   CF_DATADIR "/themes/Standard"

Definition at line 41 of file config.c.

Referenced by load_theme().

Function Documentation

◆ combo_box_text_remove_all()

static void combo_box_text_remove_all ( GtkComboBoxText *  combo_box)
static

Removes all the text entries from the combo box.

This function is not available in GTK+2, so implement it ourselves.

Definition at line 533 of file config.c.

Referenced by setup_config_dialog().

Here is the caller graph for this function:

◆ combobox_get_value()

static int combobox_get_value ( GtkComboBox *  combobox,
int  column 
)
static

Get an integer value from 'column' of the active field in 'combobox'.

Definition at line 627 of file config.c.

Referenced by read_config_dialog().

Here is the caller graph for this function:

◆ config_check()

void config_check ( )

Sanity check values set in want_config and copy them over to use_config when all of them are acceptable.

This function should be called after config_load() and parse_args().

Definition at line 311 of file config.c.

References CFG_DM_OPENGL, CFG_DM_PIXMAP, CFG_DM_SDL, CONFIG_CACHE, CONFIG_DARKNESS, CONFIG_DISPLAYMODE, CONFIG_DOWNLOAD, CONFIG_ICONSCALE, CONFIG_LIGHTING, CONFIG_MAPHEIGHT, CONFIG_MAPSCALE, CONFIG_MAPWIDTH, CONFIG_RESISTS, DEFAULT_IMAGE_SIZE, image_size, LOG(), LOG_ERROR, LOG_WARNING, map_image_half_size, map_image_size, MAP_MAX_SIZE, mapdata_init(), use_config, and want_config.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ config_init()

void config_init ( GtkWidget *  window_root)

◆ config_load()

void config_load ( void  )

Load settings from the user's configuration file into want_config.

Definition at line 395 of file config.c.

References config, config_dir, config_load_legacy(), config_names, CONFIG_NUMS, config_path, face_info, theme, use_config, want_config, Face_Information_struct::want_faceset, and window_xml_file.

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ config_load_legacy()

static void config_load_legacy ( )
static

Load settings from the legacy file format.

Definition at line 199 of file config.c.

References CFG_DM_SDL, CFG_LT_PIXEL, CFG_LT_TILE, CONFIG_DISPLAYMODE, CONFIG_LIGHTING, CONFIG_MAPHEIGHT, CONFIG_MAPWIDTH, config_names, CONFIG_NUMS, CONFIG_POPUPS, CONFIG_RESISTS, CONFIG_SPLASH, face_info, LOG(), LOG_INFO, LOG_WARNING, MAX_BUF, theme, want_config, Face_Information_struct::want_faceset, and window_xml_file.

Referenced by config_load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ init_theme()

void init_theme ( )

Definition at line 76 of file config.c.

References config_dir, default_files, MAX_BUF, and ui_name().

Referenced by init_ui().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_theme()

void load_theme ( int  reload)

◆ load_window_positions()

void load_window_positions ( GtkWidget *  window_root)

Resize the client window and its panels using saved window positions.

Parameters
window_rootThe client's main window.

Definition at line 822 of file config.c.

References config, ui_name(), and window_xml.

Referenced by init_ui().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_config_close()

static void on_config_close ( GtkButton *  button,
gpointer  user_data 
)
static

Definition at line 758 of file config.c.

References config_dialog, read_config_dialog(), and save_defaults().

Referenced by config_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_configure_activate()

void on_configure_activate ( GtkWidget *  menuitem,
gpointer  user_data 
)

Definition at line 753 of file config.c.

References config_dialog, and setup_config_dialog().

Referenced by init_menu_items(), and metaserver_ui_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ on_save_window_position_activate()

void on_save_window_position_activate ( GtkMenuItem *  menuitem,
gpointer  user_data 
)

Handles saving of the window positions when the Client | Save Window Position menu item is activated.

Parameters
menuitem
user_data

Definition at line 808 of file config.c.

References save_winpos().

Referenced by init_menu_items().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read_config_dialog()

static void read_config_dialog ( void  )
static

◆ save_defaults()

void save_defaults ( void  )

This function saves user settings chosen using the configuration popup dialog.

Definition at line 440 of file config.c.

References config, config_names, CONFIG_NUMS, config_path, draw_ext_info(), face_info, MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_CONFIG, NDI_RED, theme, want_config, Face_Information_struct::want_faceset, and window_xml_file.

Referenced by do_savedefaults(), on_config_close(), and save_winpos().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ save_winpos()

void save_winpos ( void  )

Save client window positions to a file unique to each layout.

Definition at line 767 of file config.c.

References config, draw_ext_info(), get_window_coord(), MSG_TYPE_CLIENT, MSG_TYPE_CLIENT_CONFIG, NDI_BLUE, save_defaults(), ui_name(), window_root, and window_xml.

Referenced by do_savewinpos(), and on_save_window_position_activate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_config_dialog()

static void setup_config_dialog ( )
static

◆ ui_name()

static char* ui_name ( )
static

Return the basename of the current UI file.

Definition at line 49 of file config.c.

References window_xml_file.

Referenced by init_theme(), load_window_positions(), and save_winpos().

Here is the caller graph for this function:

Variable Documentation

◆ config

GKeyFile* config
static

Definition at line 29 of file config.c.

Referenced by config_load(), load_window_positions(), save_defaults(), and save_winpos().

◆ config_button_cache

GtkWidget * config_button_cache

Definition at line 32 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_download

GtkWidget * config_button_download

Definition at line 32 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_echo

GtkWidget * config_button_echo

Definition at line 32 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_fasttcp

GtkWidget * config_button_fasttcp

Definition at line 32 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_fog

GtkWidget * config_button_fog

Definition at line 32 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_foodbeep

GtkWidget * config_button_foodbeep

Definition at line 32 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_grad_color

GtkWidget * config_button_grad_color

Definition at line 32 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_smoothing

GtkWidget * config_button_smoothing

Definition at line 32 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_sound

GtkWidget * config_button_sound

Definition at line 32 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_button_timestamp

GtkWidget * config_button_timestamp

Definition at line 32 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_combobox_displaymode

GtkComboBox* config_combobox_displaymode

Definition at line 39 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_combobox_faceset

GtkComboBoxText* config_combobox_faceset

Definition at line 38 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_combobox_lighting

GtkComboBox * config_combobox_lighting

Definition at line 39 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ config_dialog

GtkWidget* config_dialog

Definition at line 32 of file config.c.

Referenced by config_init(), on_config_close(), and on_configure_activate().

◆ config_path

GString* config_path
static

Definition at line 30 of file config.c.

Referenced by config_load(), and save_defaults().

◆ default_files

char** default_files = NULL
static

Sets up player-specific client and layout rc files and handles loading of a client theme if one is selected.

First, the player-specific rc files are added to the GTK rc default files list. ${HOME}/.crossfire/gtkrc is added first. All client sessions are affected by this rc file if it exists. Next, ${HOME}/.crossfire/[layout].gtkrc is added, where [layout] is the name of the layout file that is loaded. IE. If gtk-v2.ui is loaded, [layout] is "gtk-v2". This sets up the possibility for a player to make a layout-specific rc file. Finally, if the client theme is not "None", the client theme file is added. In most cases, the player-specific files are probably not going to exist, so the theme system will continue to work the way it always has. The player will have to "do something" to get the extra functionality. At some point, conceptually the client itself could be enhanced to allow it to save some basic settings to either or both of the player-specific rc files.

Parameters
reloadIf true, user has changed theme after initial startup. In this mode, we need to call the routines that store away private theme data. When program is starting up, this is false, because all the widgets haven't been realized yet, and the initialize routines will get the theme data at that time.

Definition at line 75 of file config.c.

Referenced by init_theme(), and load_theme().

◆ theme

char* theme = THEME_DEFAULT
static

◆ theme_filechooser

GtkFileChooser * theme_filechooser

Definition at line 37 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().

◆ ui_filechooser

GtkFileChooser* ui_filechooser

Definition at line 37 of file config.c.

Referenced by config_init(), read_config_dialog(), and setup_config_dialog().