iceWing
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Data Structures | Macros | Typedefs | Enumerations | Functions
Goptions.h File Reference
#include <gtk/gtk.h>

Go to the source code of this file.

Data Structures

struct  optsListEntry
struct  optsListData
struct  optsWidget

Macros

#define OPTS_SET_ERROR   (-9999)

Typedefs

typedef struct optsListEntry optsListEntry
typedef struct optsListData optsListData
typedef struct optsWidget optsWidget
typedef gboolean(* optsLoadFunc )(void *data, char *buffer, int size)
typedef gboolean(* optsSaveFunc )(void *data, char *string)
typedef void(* optsCbackFunc )(GtkWidget *widget, int number, void *data)
typedef gboolean(* optsSetFunc )(void *value, void *newValue, void *data)
typedef void(* optsSignalFunc )(optsWidget *widget, void *newValue, void *data)

Enumerations

enum  optsListFlags { OPTS_SELECT = 1 << 0, OPTS_REORDER = 1 << 1, OPTS_ADD = 1 << 2, OPTS_DATA = 1 << 3 }
enum  optsType {
  OPTS_BOOL, OPTS_INT, OPTS_LONG, OPTS_FLOAT,
  OPTS_DOUBLE, OPTS_STRING
}
enum  optsSignal { OPTS_SIG_CHANGED = 1 << 0, OPTS_SIG_REMOVE = 1 << 1 }

Functions

char * opts_get_default_file (void)
gboolean opts_signal_connect (long page, const char *title, optsSignal sigset, optsSignalFunc cback, void *data)
gboolean opts_widget_remove (const char *title)
void opts_defvalue_remove (const char *title)
void * opts_value_get (const char *title)
long opts_value_set (const char *title, void *value)
void opts_variable_add (const char *title, optsSetFunc setval, void *data, optsType type, void *value)
void opts_varstring_add (const char *title, optsSetFunc setval, void *data, void *value, int length)
void opts_separator_create (long page, const char *title)
void opts_button_create (long page, const char *title, const char *ttip, gint *value)
void opts_buttoncb_create (long page, const char *title, const char *ttip, optsCbackFunc cback, void *data)
void opts_string_create (long page, const char *title, const char *ttip, char *value, int length)
void opts_stringenter_create (long page, const char *title, const char *ttip, char *value, int length)
void opts_filesel_create (long page, const char *title, const char *ttip, char *value, int length)
void opts_entscale_create (long page, const char *title, const char *ttip, gint *value, gint left, gint right)
void opts_float_create (long page, const char *title, const char *ttip, gfloat *value, gfloat left, gfloat right)
void opts_toggle_create (long page, const char *title, const char *ttip, gboolean *value)
void opts_option_create (long page, const char *title, const char *ttip, char **label, gint *value)
void opts_radio_create (long page, const char *title, const char *ttip, char **label, gint *value)
void opts_list_create (long page, const char *title, const char *ttip, char **label, optsListFlags flags, optsListData *value)
void opts_load (optsLoadFunc fkt, void *data)
void opts_save_remove (const char *title)
gboolean opts_save (optsSaveFunc fkt, void *data)
int opts_page_append (const char *title)

Macro Definition Documentation

#define OPTS_SET_ERROR   (-9999)

Return value for opts_value_set() if error occurs


Typedef Documentation

typedef struct optsListEntry optsListEntry

Both optsListEntry and optsListData can be passed to opts_value_set() Entries of the list widget, can be passed to opts_value_set()

typedef struct optsListData optsListData

Data for a list entry, can be passed to opts_value_set()

typedef struct optsWidget optsWidget
typedef gboolean(* optsLoadFunc)(void *data, char *buffer, int size)
typedef gboolean(* optsSaveFunc)(void *data, char *string)
typedef void(* optsCbackFunc)(GtkWidget *widget, int number, void *data)
typedef gboolean(* optsSetFunc)(void *value, void *newValue, void *data)
typedef void(* optsSignalFunc)(optsWidget *widget, void *newValue, void *data)

Enumeration Type Documentation

Flags for a list widget:

Enumerator:
OPTS_SELECT 

Toggle entries (otherwise only one entry is selected)

OPTS_REORDER 

Entries can be reordered

OPTS_ADD 

Entries can be added/removed

OPTS_DATA 

For every entry a string can be entered

enum optsType

Data type identifier for opts_variable_add()

Enumerator:
OPTS_BOOL 
OPTS_INT 
OPTS_LONG 
OPTS_FLOAT 
OPTS_DOUBLE 
OPTS_STRING 
enum optsSignal

Signal for a widget, see opts_signal_connect()

Enumerator:
OPTS_SIG_CHANGED 

The value of the widget has changed

OPTS_SIG_REMOVE 

The widget is removed


Function Documentation

char* opts_get_default_file ( void  )

  Return name of the default rcFile. Returned value is a pointer to a
  static variable.

gboolean opts_signal_connect ( long  page,
const char *  title,
optsSignal  sigset,
optsSignalFunc  cback,
void *  data 
)

  Call cback with data as last argument if one of the signals
  specified with sigset occured for the widget referenced by title.
  page: - Return value of opts_page_append() or
        - Return value of prev_get_page() or
        - Partly a pointer to a prevBuffer or
        - -1  -> title must have the form 'pageTitle.widgetTitle'
  title: Name of a widget or 'pageTitle.widgetTitle'
  Return TRUE on success.

gboolean opts_widget_remove ( const char *  title)

  Remove widget with title 'title' from options tab.
  Use 'pageTitle.widgetTitle' for the title argument.
  Return: Did the widget exist?

void opts_defvalue_remove ( const char *  title)

  Prevent any values, which are loaded from default config files to
  be set for the widget referenced by title.

void* opts_value_get ( const char *  title)

  Return a pointer to the current value from the widget referenced by
  title.
  title: 'pageTitle.widgetTitle'

long opts_value_set ( const char *  title,
void *  value 
)

  Set new value and display it in widget referenced by title.
  title: 'pageTitle.widgetTitle'
  value: strings, floats, list: a pointer to the value
        otherwise            : the value itself
  Return: Old value on sucess, OPTS_SET_ERROR otherwise (no widget
          found or value does not fit into one long(e.g. a string)).

void opts_variable_add ( const char *  title,
optsSetFunc  setval,
void *  data,
optsType  type,
void *  value 
)

  Add a non graphical value, which gets loaded/saved in the same way
  as the graphical values. If the value should be set to a new value,
  setval() is called with the old value, the new value and data as
  arguments. If setval() returns TRUE or if setval()==NULL the value
  is set automatically in the background.

void opts_varstring_add ( const char *  title,
optsSetFunc  setval,
void *  data,
void *  value,
int  length 
)
void opts_separator_create ( long  page,
const char *  title 
)

  Create a new separator with a label.
  page can be a pointer to a prevBuffer (-> new menu separator).

void opts_button_create ( long  page,
const char *  title,
const char *  ttip,
gint *  value 
)

  Create new button widgets. On button click value is set to the
  button number starting at 1. title and ttip are '|'-separated for
  the single buttons, e.g. "title1|title2" for two buttons.
  page can be a pointer to a prevBuffer (-> new menu items).

void opts_buttoncb_create ( long  page,
const char *  title,
const char *  ttip,
optsCbackFunc  cback,
void *  data 
)

  Create new button widgets. On button click cback is called with the
  button number starting at 1 and 'data'. title and ttip are
  '|'-separated for the single buttons, e.g. "title1|title2" for
  two buttons.
  page can be a pointer to a prevBuffer (-> new menu items).

void opts_string_create ( long  page,
const char *  title,
const char *  ttip,
char *  value,
int  length 
)

  Create new string widget. Max allowed length of string is length.

void opts_stringenter_create ( long  page,
const char *  title,
const char *  ttip,
char *  value,
int  length 
)

  Create new string widget with an "enter" button. The string is
  updated only on enter press or button click.  Max allowed length of
  string is length.

void opts_filesel_create ( long  page,
const char *  title,
const char *  ttip,
char *  value,
int  length 
)

  Create new string widget with an attached button to open a file
  selection widget. Max allowed length of string is length.

void opts_entscale_create ( long  page,
const char *  title,
const char *  ttip,
gint *  value,
gint  left,
gint  right 
)

  Create new integer scale widget with an attached entry widget.

void opts_float_create ( long  page,
const char *  title,
const char *  ttip,
gfloat *  value,
gfloat  left,
gfloat  right 
)

  Create new scale widget with an attached entry widget (for floats).

void opts_toggle_create ( long  page,
const char *  title,
const char *  ttip,
gboolean *  value 
)

  Create new toggle widget.
  page can be a pointer to a prevBuffer (-> new check menu item).

void opts_option_create ( long  page,
const char *  title,
const char *  ttip,
char **  label,
gint *  value 
)

  Create new option-menu widget with selectable values from label.
  The const array label must be terminated with NULL.

void opts_radio_create ( long  page,
const char *  title,
const char *  ttip,
char **  label,
gint *  value 
)

  Create new radio widget with selectable values from label.
  The const array label must be terminated with NULL.
  page can be a pointer to a prevBuffer (-> new radio menu item).

void opts_list_create ( long  page,
const char *  title,
const char *  ttip,
char **  label,
optsListFlags  flags,
optsListData value 
)

  Create new list widget with selectable values from label. The const
  array label must be terminated with NULL. Allowed meta characters
  at start of label (for 'Add entry' menu, only usefull if flags
  contain OPTS_ADD):
      '>': label is a sub menu
      '<': Back one hierarchy
  In label (only usefull if flags contain OPTS_DATA):
      '|': Separator between label and string help.
  e.g. {"\> Sub1", "Entry1|Help1", "\<\> Sub2", "Entry2|Help2", NULL}
      -> Two submenues with two entries, these two can be added to
          the list widget.
  value->entries can be NULL (-> list is filled with default values).
  If not, oldindex of last entry must be -1.

void opts_load ( optsLoadFunc  fkt,
void *  data 
)

  fkt!=NULL: Get settings for widgets and display them by periodically
             calling fkt(data,buffer,buf_len).
  fkt==NULL: Load settings of all widgets from file data (a file name
            of type char*) and display them.

void opts_save_remove ( const char *  title)

  If opts_save() is called, do not save the settings for the widget
  referenced by title.

gboolean opts_save ( optsSaveFunc  fkt,
void *  data 
)

  fkt!=NULL: Save settings of all widgets by periodically calling
            fkt(data,string) for all to be saved strings.
  fkt==NULL: Save settings of all widgets to file data (a file name
            of type char*).
  Return: TRUE if no error occurred.

int opts_page_append ( const char *  title)

  Append a new page to the options notebook. If title contains '.' or
  ' ' (a'.'b or a' 'b) the page is shown in the categories list under
  node a with entry b.
  Return: the number of the new page