Crossfire Client, Trunk  R18666
Data Structures | Defines | Functions | Variables
/home/leaf/crossfire/client/trunk/gtk-v2/src/info.c File Reference
#include <gtk/gtk.h>
#include <glade/glade.h>
#include "client.h"
#include "image.h"
#include "main.h"
#include "gtk2proto.h"
#include "msgtypes.h"
Include dependency graph for info.c:

Go to the source code of this file.

Data Structures

struct  info_buffer_t
 A buffer record that supports suppression of duplicate messages. This buffer holds data for messages that are monitored for suppression of duplicates. The buffer holds all data passed to message_callback(), including type, subtype, suggested color, and the text. Age and count fields are provided to track the time a message is in the buffer, and how many times it occured during the time it is buffered. More...
struct  buffer_parameter_t
 A container for a single buffer control parameter like output count or time. The structure holds a widget pointer, a state variable to track the widget value, and a default value. More...
struct  buffer_control_t
 A container for all of the buffer control parameters like output count and time. The structure holds widget pointers, a state variables to track the parameter values, and the client built-in defaults. Only the final initializer for output_count and output_time is used as a default. More...
struct  boolean_widget_t
 A container that holds the pointer and state of a checkbox control. Each Message Control dialog checkbox is tracked in one of these structs. More...
struct  message_control_t
 A container for all of the checkboxes associated with a single message type. More...
struct  msgctrl_data_t
 Descriptive message type names with pane routing and buffer enable. A single struct defines a hard-coded, player-friendly, descriptive name to use for a single message type. All other fields in the structure define routing of messages to either or both client message panels, and whether or not messages of this type are passed through the duplicate suppression buffer system. This struct is intended to be used as the base type of an array that contains one struct per message type defined in newclient.h. The hard-coding of the descriptive name for the message type here is not ideal as it would be nicer to have it alongside the MSG_TYPE_* defines. More...

Defines

#define NUM_TEXT_VIEWS   2

Functions

void set_text_tag_from_style (GtkTextTag *tag, GtkStyle *style, GtkStyle *base_style)
void add_tags_to_textbuffer (Info_Pane *pane, GtkTextBuffer *textbuf)
void add_style_to_textbuffer (Info_Pane *pane, GtkStyle *base_style)
void info_get_styles (void)
void info_init (GtkWidget *window_root)
void add_marked_text_to_pane (Info_Pane *pane, const char *message, int type, int subtype, int orig_color)
void draw_ext_info (int orig_color, int type, int subtype, const char *message)
void info_buffer_init (void)
void info_buffer_flush (const int id)
void info_buffer_tick (void)
void menu_clear (void)
void set_scroll (const char *s)
void set_autorepeat (const char *s)
int get_info_width (void)
void msgctrl_init (GtkWidget *window_root)
void update_msgctrl_configuration (void)
void save_msgctrl_configuration (void)
void load_msgctrl_configuration (void)
void default_msgctrl_configuration (void)
void read_msgctrl_configuration (void)
void on_msgctrl_button_save_clicked (GtkButton *button, gpointer user_data)
void on_msgctrl_button_load_clicked (GtkButton *button, gpointer user_data)
void on_msgctrl_button_defaults_clicked (GtkButton *button, gpointer user_data)
void on_msgctrl_button_apply_clicked (GtkButton *button, gpointer user_data)
void on_msgctrl_button_close_clicked (GtkButton *button, gpointer user_data)
void on_msgctrl_activate (GtkMenuItem *menuitem, gpointer user_data)

Variables

const char *const rcsid_gtk2_info_c = "$Id: info.c 14516 2011-06-06 21:27:21Z ryo_saeba $"
const char *const usercolorname [NUM_COLORS]
Info_Pane info_pane [NUM_TEXT_VIEWS]
const char *const colorname [NUM_COLORS]

GTK V2 Message Control System.

Supports a client-side implementation of what used to be provided by the server output-count and output-sync commands. These defines presently control the way the system works. The hardcoded values here are temporary and shall give way to client commands and/or a GUI method of configuring the system. Turn off the output count/sync by setting MESSAGE_COUNT_MAX to 1. It should be safe to experiment with most values as long as none of them are set less than 1, and as long as the two buffer sizes are set to reasonable values (buffer sizes include the terminating null character).

#define MESSAGE_BUFFER_COUNT   10
#define MESSAGE_BUFFER_SIZE   56
#define COUNT_BUFFER_SIZE   16
#define MESSAGE_COUNT_MAX   16
#define MESSAGE_AGE_MAX   16
GtkWidget * msgctrl_window
GtkWidget * msgctrl_table
struct info_buffer_t info_buffer [MESSAGE_BUFFER_COUNT]
struct buffer_control_t buffer_control
message_control_t msgctrl_widgets [MSG_TYPE_LAST-1]
struct msgctrl_data_t msgctrl_defaults [MSG_TYPE_LAST-1]

Detailed Description

This covers drawing text to the info window.

Definition in file info.c.


Define Documentation

#define COUNT_BUFFER_SIZE   16

The maximum size of the tag that indicates the number of times a message occured while buffered. Example: "4 times "

Definition at line 125 of file info.c.

#define MESSAGE_AGE_MAX   16

The maximum time in client ticks, that a message resides in a buffer before it is sent to a client panel for display. 8 ticks is roughly 1 second.

Definition at line 135 of file info.c.

#define MESSAGE_BUFFER_COUNT   10

The maximum number of messages to concurrently monitor for duplicate occurances.

Definition at line 117 of file info.c.

#define MESSAGE_BUFFER_SIZE   56

The maximum allowable size of messages that are checked for duplicate reduction.

Definition at line 121 of file info.c.

#define MESSAGE_COUNT_MAX   16

The maximum number of times a buffered message may repeat before it is sent to a client panel for for display.

Definition at line 130 of file info.c.

#define NUM_TEXT_VIEWS   2

EndOf GTK V2 Font Style Definitions. The number of supported message panes (normal + critical). This define is meant to support anything that iterates over all the information panels. It does nothing to help remove or document hardcoded panel numbers throughout the code.

Todo:
Create defines for each panel and replace panel numbers with the defines describing the panel. This integer declaration is to that account.c knows how many are being used here, and can add appropriately.

Definition at line 69 of file info.c.


Function Documentation

void add_marked_text_to_pane ( Info_Pane pane,
const char *  message,
int  type,
int  subtype,
int  orig_color 
)

This just does the work of taking text (which may have markup) and putting it into the target pane. This is a lower level than the draw_ext_info() below, as it does not do message routing. This is called from draw_ext_info() below, as well as account.c to update news/motd/rules.

Parameters:
panePointer to the pane info to draw info.
messageMessage that is parsed and displayed.
typeType of the message - for default coloring information.
subtypeSubtype of message - used for default coloring information.
orig_colorLegacy color hint not based on type that is used when a theme does not define a style for the message.
Note:
Note both type and subtype are the values passed to draw_ext_info().

< Only if we get a [color] tag should we care, otherwise, the type/subtype should dictate color (unless no style set!)

Definition at line 793 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void add_style_to_textbuffer ( Info_Pane pane,
GtkStyle *  base_style 
)

This is like add_tags_to_textbuffer above, but styles can be changed during the run of the client. So this has to be separate to note it it might be a reload.

Parameters:
paneMessage panel number to update.
base_styleBase style if retrieved - may be null.

Definition at line 406 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void add_tags_to_textbuffer ( Info_Pane pane,
GtkTextBuffer *  textbuf 
)

Adds the various tags to the next buffer. If textbuf is non-null, then it also sets the text buffer for that pane to textbuf. This is called right now by info_get_styles() below and from within the account code.

Parameters:
paneMessage panel number to add buffer to.
textbufText buffer to apply tags to. It is allowed to be null if info_pane[pane].textbuffer has already been set.

Definition at line 356 of file info.c.

Here is the caller graph for this function:

Setup the state of the message control dialog so the configuration matches the default settings built in to the client.

Iterate through each message type. For each, copy the built-in client default to the Message Control dialog state variables. All supported defaults are copied, not just the ones supported by the layout.

Definition at line 1763 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void draw_ext_info ( int  orig_color,
int  type,
int  subtype,
const char *  message 
)

A message processor that accepts messages along with meta information color and type. The message type and subtype are analyzed to select font and other text attributes. All gtk-v2 client messages pass through this processor before being output. Before addition of the output buffering feature, this was the message callback function. It is a separate function so that it can be called both by the callback, and but buffer maintenance functions.

Client-sourced messages generally should be passed directly to this handler instead of to the callback. This will save some overhead as the callback implements a system that coalesces duplicate messages - a feature that is not really applicable to most messages that do not come from the server.

Parameters:
orig_colorSuggested text color that type/subtype can over-ride.
typeMessage type. See MSG_TYPE definitions in newclient.h.
subtypeMessage subtype. See MSG_TYPE_*_* values in newclient.h.
messageThe message text to display.

< When 0, the type is valid and may be used to pick the panel routing, otherwise the message can only go to the main message pane.

Definition at line 894 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int get_info_width ( void  )

This is used by the common help system to determine when to wrap. Should be able to get width of window, and divide by character width - however, still not perfect if we are using a variable width font. Actually, GTK can do word wrapping for us, so maybe the real fix is to have it to the word wrapping and just run a sufficiently large value.

Returns:
The width of the info window in characters.
Todo:
Configure automatic line wrap in message panels and get rid of the hardcoded 40-character wrap.

Definition at line 1309 of file info.c.

Here is the caller graph for this function:

void info_get_styles ( void  )

Loads up values from the style file. Note that the actual name of the style file is set elsewhere.

This function is designed so that it should be possible to call it multiple times - it will release old style data and load up new values. In this way, a user should be able to change styles on the fly and have things work.

Definition at line 496 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void info_init ( GtkWidget *  window_root)

Initialize the information panels in the client. These panels are the client areas where text is drawn.

Parameters:
window_rootPointer to the parent (root) application window.

Definition at line 628 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void load_msgctrl_configuration ( void  )

Setup the state of the message control dialog so the configuration matches a previously saved configuration.

Definition at line 1577 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void menu_clear ( void  )

Clears all the message panels. It is not clear why someone would use it, but is called from the common area, and so is supported here.

Definition at line 1267 of file info.c.

void msgctrl_init ( GtkWidget *  window_root)

Initialize the message control panel by populating it with descriptions of each message type along with checkboxes that are used to configure the routing and duplicate suppression system. If previously saved settings are found on disk, they are loaded and applied, otherwise the built in client defaults are loaded and applied. This initialization must occur after the info_init() function runs.

Parameters:
window_rootThe client main window
Todo:
Panes that are unsupported in the current layout should always have their routing disabled, and should disallow user interaction with the control but this logic is not yet implemented.

Definition at line 1328 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void on_msgctrl_activate ( GtkMenuItem *  menuitem,
gpointer  user_data 
)

Shows the message control dialog when the menu item is activated. The settings shown on the dialog when it is activated are the settings currently in use.

Parameters:
menuitem
user_data

Definition at line 1899 of file info.c.

Here is the caller graph for this function:

void on_msgctrl_button_apply_clicked ( GtkButton *  button,
gpointer  user_data 
)

When the message control dialog apply button is pressed, the currently displayed settings are applied. The dialog is not dismissed, but remains open for further adjustments to be made.

Parameters:
button
user_data

Definition at line 1869 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void on_msgctrl_button_close_clicked ( GtkButton *  button,
gpointer  user_data 
)

When the message control dialog close button is pressed, the currently displayed settings are applied and the dialog is dismissed.

Parameters:
button
user_data

Definition at line 1883 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void on_msgctrl_button_defaults_clicked ( GtkButton *  button,
gpointer  user_data 
)

When the message control dialog defaults button is pressed, the default settings built into the client are restored and applied.

Parameters:
button
user_data

Definition at line 1854 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void on_msgctrl_button_load_clicked ( GtkButton *  button,
gpointer  user_data 
)

When the message control dialog load button is pressed, the settings last saved are restored and applied. It may be used to "undo" both applied and unapplied setting changes.

Parameters:
button
user_data

Definition at line 1840 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void on_msgctrl_button_save_clicked ( GtkButton *  button,
gpointer  user_data 
)

When the message control dialog save button is pressed, the currently shown settings are applied for immediate use and they are saved to disk so the settings persist across client sessions. Saved settings automatically load and apply when the client is started.

Parameters:
button
user_data

Definition at line 1824 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void read_msgctrl_configuration ( void  )

Reads the state of the message control dialog and applies the settings to the msgctrl_widgets[] state variables that control the message routing and duplicate suppression system.

Definition at line 1785 of file info.c.

Here is the caller graph for this function:

void save_msgctrl_configuration ( void  )

Applies the current state of the checkboxes to the msgctrl_widgets state variables and saves the settings to disk so the configuration persists across client sessions.

Definition at line 1510 of file info.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void set_autorepeat ( const char *  s)

A stub function that does nothing. These are callbacks used by the common code, but they are not implemented in GTK, either because it makes no sense (set_scroll for example), or because it may not be technically possible to do so if we limit ourselves to proper GTK2 code (Eg, don't mess with the internals of X or platform specific issues)

Parameters:
s

Definition at line 1297 of file info.c.

void set_scroll ( const char *  s)

A stub function that does nothing. These are callbacks used by the common code, but they are not implemented in GTK, either because it makes no sense (set_scroll for example), or because it may not be technically possible to do so if we limit ourselves to proper GTK2 code (Eg, don't mess with the internals of X or platform specific issues)

Parameters:
s

Definition at line 1284 of file info.c.

void set_text_tag_from_style ( GtkTextTag *  tag,
GtkStyle *  style,
GtkStyle *  base_style 
)

EndOf GTK V2 Message Control System. Sets attributes in the text tag from a style. Best I can gather, there is no way to take all of the attributes from a style and apply them directly to a text tag, hence this function to do the work. GtkTextTags also know what attributes are set and which are not set - thus, you can apply multiple tags to the same text, and get all of the effects. For styles, that isn't the case - a style contains all of the information. So this function also compares the loaded style from the base style, and only sets the attributes that are different.

Parameters:
tagText tag to set values on.
styleStyle name to get values from.
base_styleBase style for the widget to compare against.

Definition at line 323 of file info.c.

Here is the caller graph for this function:

Update the state of the message control dialog so the configuration matches the currently selected settings. Do not call this before msgctrl_widgets[] is initialized. It also really only makes sense to call it if changes have been made to msgctrl_widgets[].

Definition at line 1480 of file info.c.

Here is the caller graph for this function:


Variable Documentation

const char* const colorname[NUM_COLORS]

Definition at line 60 of file main.c.

Several buffers that support suppression of duplicates even even when the duplicates are alternate with other messages.

Definition at line 73 of file info.c.

A data structure to track how to handle each message type in with respect to panel routing and output count.

GtkWidget* msgctrl_table

The message control table where routing and buffer configuration is set up.

Definition at line 113 of file info.c.

All of the checkbox widgets for the entire message control dialog.

Definition at line 237 of file info.c.

GtkWidget* msgctrl_window

The message control dialog where routing and buffer configuration is set up.

Definition at line 109 of file info.c.

const char* const rcsid_gtk2_info_c = "$Id: info.c 14516 2011-06-06 21:27:21Z ryo_saeba $"

Definition at line 1 of file info.c.

const char* const usercolorname[NUM_COLORS]

Definition at line 80 of file main.c.