Main Page | Alphabetical List | Compound List | File List | Compound Members | File Members

gtk-utils.h File Reference

#include <gtk/gtkwidget.h>
#include <gtk/gtktextbuffer.h>
#include <gtk/gtkenums.h>
#include <gtk/gtktreestore.h>
#include <gtk/gtktreeview.h>
#include <gtk/gtktable.h>
#include <clist.h>
#include "cntree.h"
#include "message-types.h"
#include "defines.h"

Include dependency graph for gtk-utils.h:

Include dependency graph

Go to the source code of this file.

Defines

#define XEP_GTKUTILS_OK   (1 << 0)
#define XEP_GTKUTILS_CANCEL   (1 << 1)
#define XEP_GTKUTILS_FILESEL   (1 << 2)
#define GTK_DEST_CHARSET   "UTF8"
#define XEP_GTKUTILS_TREE_WIDGET(utils_tree)   (a_GtkUtils_tree_get_tree_widget(utils_tree))
#define XEP_GTKUTILS_TREE_BUTTONS(utils_tree)   (a_GtkUtils_tree_get_buttons_widget(utils_tree))
#define a_GtkUtils_entry_set_text(entry, text)   (gtk_entry_set_text(GTK_ENTRY(entry), (text) ? (text) : ""))

Typedefs

typedef int(* XePGtkUtilsSelectionCb )(void *adata, const char *fname)
typedef XePGtkUtilsTree_s XePGtkUtilsTree
typedef void *(* XePGtkUtilsTreeCb )(XePGtkUtilsTree *utils_tree, void *data)

Enumerations

enum  {
  TREE_DESCRIPTION_COL, TREE_TYPE_COL, TREE_WEIGHT_COL, TREE_POINTER_COL,
  TREE_POINTER2_COL, TREE_COL_NB
}

Functions

void a_GtkUtils_dialog_get_string (const char *title, GtkWidget *parent, const char *label_text, const char *help_text, const char *default_str, int buttons, int modal, void(*callback)(void *d, int a, gchar *s), void *data)
int a_GtkUtils_dialog_alert (const char *title, GtkWidget *parent, int type, const char *message_text, const char *help_text, int buttons, gboolean modal, gboolean async, void(*user_callback)(void *adata, int aresponse), void *user_data)
GtkWidget * a_GtkUtils_label_new_bold_large (const char *text)
GtkWidget * a_GtkUtils_label_new_bold (const char *text)
GtkWidget * a_GtkUtils_label_new_italic (const char *text)
GtkWidget * a_GtkUtils_transient_new (GtkWidget *toplevel, const char *title, int width, int height)
GtkWidget * a_GtkUtils_toplevel_new (const char *terminal, const char *title, const char **xpm_data, int width, int height)
void a_GtkUtils_file_viewer_new (const char *terminal, const char *title, const char **xpm_data, int width, int height, const char *filename, const char *data, size_t size, const char *charset)
GtkWidget * a_GtkUtils_text_view_new (const char *text, gint len, gboolean editable)
void a_GtkUtils_text_buffer_append (GtkTextBuffer *buffer, const char *text, int size)
void a_GtkUtils_text_buffer_create_tags (GtkTextBuffer *buffer)
void a_GtkUtils_text_buffer_get_header_tag (XePMessageHeaderType type, const char **header_name_tag, const char **header_value_tag)
void a_GtkUtils_text_buffer_convert_insert (GtkTextBuffer *buffer, GtkTextIter *iter, const char *text, size_t text_len, const char *source_charset)
int a_GtkUtils_text_buffer_insert_image_file (GtkTextBuffer *buffer, GtkTextIter *iter, const char *filename)
int a_GtkUtils_text_buffer_append_image_data (GtkTextBuffer *buffer, const char *data, size_t len)
void a_GtkUtils_paned_shrink_control (GtkWidget *paned, gpointer anint)
gboolean a_GtkUtils_filename_is_supported_image (const char *filename)
void a_GtkUtils_file_selection (const char *title, GtkWidget *toplevel, const char *filename, XePGtkUtilsSelectionCb callback, void *data)
void a_GtkUtils_dir_selection (const char *title, GtkWidget *toplevel, const char *dir, XePGtkUtilsSelectionCb callback, void *data)
GtkWidget * a_GtkUtils_button_new_from_stock (const char *stock_id, const char *text, gboolean use_markup, GtkIconSize icon_size)
gchar * a_GtkUtils_make_display_name (GtkWidget *toplevel)
XePGtkUtilsTreea_GtkUtils_tree_new (GtkOrientation orientation, gboolean reordable, GtkPolicyType hpolicy, GtkPolicyType vpolicy)
void a_GtkUtils_tree_free (XePGtkUtilsTree *tree)
GtkTreeStore * a_GtkUtils_tree_get_tree_store (XePGtkUtilsTree *utils_tree)
GtkWidget * a_GtkUtils_tree_get_tree_view (XePGtkUtilsTree *utils_tree)
void a_GtkUtils_tree_set_list (XePGtkUtilsTree *utils_tree, clist *list)
void a_GtkUtils_tree_set_tree (XePGtkUtilsTree *utils_tree, cntree *ntree)
GtkTreeSelection * a_GtkUtils_tree_get_selection (XePGtkUtilsTree *utils_tree)
void a_GtkUtils_tree_selection_set_mode (XePGtkUtilsTree *utils_tree, GtkSelectionMode mode)
int a_GtkUtils_tree_selected_is_expanded (XePGtkUtilsTree *utils_tree)
void a_GtkUtils_tree_set_path (XePGtkUtilsTree *utils_tree, GtkTreePath *path)
void a_GtkUtils_tree_get_selected_data (XePGtkUtilsTree *utils_tree, const char **description, int *type, int *weight, void **user_data1, void **user_data2)
void a_GtkUtils_tree_refresh (XePGtkUtilsTree *utils_tree)
void a_GtkUtils_tree_changed (XePGtkUtilsTree *utils_tree)
void a_GtkUtils_tree_clear (XePGtkUtilsTree *utils_tree)
GtkWidget * a_GtkUtils_tree_get_tree_widget (XePGtkUtilsTree *utils_tree)
GtkWidget * a_GtkUtils_tree_get_buttons_widget (XePGtkUtilsTree *utils_tree)
void a_GtkUtils_tree_set_add_callback (XePGtkUtilsTree *utils_tree, XePGtkUtilsTreeCb callback, void *data)
void a_GtkUtils_tree_set_remove_callback (XePGtkUtilsTree *utils_tree, XePGtkUtilsTreeCb callback, void *data)
void a_GtkUtils_tree_set_edit_callback (XePGtkUtilsTree *utils_tree, XePGtkUtilsTreeCb callback, void *data)
void a_GtkUtils_tree_set_top_callback (XePGtkUtilsTree *utils_tree, XePGtkUtilsTreeCb callback, void *data)
void a_GtkUtils_tree_set_changed_callback (XePGtkUtilsTree *utils_tree, XePGtkUtilsTreeCb callback, void *data)
void a_GtkUtils_tree_set_refresh_callback (XePGtkUtilsTree *utils_tree, XePGtkUtilsTreeCb callback, void *data)
void a_GtkUtils_tree_set_expanded_callback (XePGtkUtilsTree *utils_tree, XePGtkUtilsTreeCb callback, void *data)
void a_GtkUtils_tree_finalize_add (XePGtkUtilsTree *utils_tree, void *new_item)
void a_GtkUtils_tree_finalize_edit (XePGtkUtilsTree *utils_tree, void *edited_item)
void a_GtkUtils_tree_finalize_remove (XePGtkUtilsTree *utils_tree)
void a_GtkUtils_tree_finalize_top (XePGtkUtilsTree *utils_tree)
GtkWidget * a_GtkUtils_table_add_entry (GtkTable *table, const char *name, GtkWidget *label, const char *help, guint col, guint row)
GtkWidget * a_GtkUtils_table_add_entry_full (GtkTable *table, const char *name, GtkWidget *label, const char *help, guint col, guint width, guint row, guint height)
void a_GtkUtils_set_tip (GtkWidget *widget, const gchar *help)


Define Documentation

#define a_GtkUtils_entry_set_text entry,
text   )     (gtk_entry_set_text(GTK_ENTRY(entry), (text) ? (text) : ""))
 

#define GTK_DEST_CHARSET   "UTF8"
 

#define XEP_GTKUTILS_CANCEL   (1 << 1)
 

#define XEP_GTKUTILS_FILESEL   (1 << 2)
 

#define XEP_GTKUTILS_OK   (1 << 0)
 

#define XEP_GTKUTILS_TREE_BUTTONS utils_tree   )     (a_GtkUtils_tree_get_buttons_widget(utils_tree))
 

#define XEP_GTKUTILS_TREE_WIDGET utils_tree   )     (a_GtkUtils_tree_get_tree_widget(utils_tree))
 


Typedef Documentation

typedef int(* XePGtkUtilsSelectionCb)(void *adata, const char *fname)
 

typedef struct XePGtkUtilsTree_s XePGtkUtilsTree
 

typedef void*(* XePGtkUtilsTreeCb)(XePGtkUtilsTree *utils_tree, void *data)
 


Enumeration Type Documentation

anonymous enum
 

Enumeration values:
TREE_DESCRIPTION_COL 
TREE_TYPE_COL 
TREE_WEIGHT_COL 
TREE_POINTER_COL 
TREE_POINTER2_COL 
TREE_COL_NB 


Function Documentation

GtkWidget* a_GtkUtils_button_new_from_stock const char *  stock_id,
const char *  text,
gboolean  use_markup,
GtkIconSize  icon_size
 

int a_GtkUtils_dialog_alert const char *  title,
GtkWidget *  parent,
int  type,
const char *  message_text,
const char *  help_text,
int  buttons,
gboolean  modal,
gboolean  async,
void(*  user_callback)(void *adata, int aresponse),
void *  user_data
 

Open a dialog and show some message

Parameters:
title title of the dialog
the parent of the dialog
type one of XETPAN_INFO_MESSAGE, XETPAN_WARNING_MESSAGE, or XETPAN_ERROR_MESSAGE
message_text the main text of the message
help_text a help text written beneath the main text
buttons what buttons must be shown, an OR'ed value from XEP_GTKUTILS_OK and XEP_GTKUTILS_CANCEL
modal whether the dialog should be made modal to its parent
async whether the function returns immediately without waiting for the response (non zero value) in which case its return value must be ignored, or if it waits for user response, in which case its return value contains the response
user_callback a user provided callback function to call when the use made its response. This is used independetly of the async flag. First argument is the user_data provided by the user and its second argument is the response of the user (XEP_GTKUTILS_OK or XEP_GTKUTILS_CANCEL). If NULL, no user callback is called.
user_data the user data used as first argument of the user_callback
Returns:
0 if async is non-zero, or user response if async is 0

void a_GtkUtils_dialog_get_string const char *  title,
GtkWidget *  parent,
const char *  label_text,
const char *  help_text,
const char *  default_str,
int  buttons,
int  modal,
void(*  callback)(void *d, int a, gchar *s),
void *  data
 

void a_GtkUtils_dir_selection const char *  title,
GtkWidget *  toplevel,
const char *  dir,
XePGtkUtilsSelectionCb  callback,
void *  data
 

void a_GtkUtils_file_selection const char *  title,
GtkWidget *  toplevel,
const char *  filename,
XePGtkUtilsSelectionCb  callback,
void *  data
 

File selection helper function

Parameters:
title the file selection dialog title,
toplevel the toplevel window to which the file selection dialog belongs.
filename the default filename that will prefill the file name entry
callback the function to call when the user selects a file name. The callback function gets as first argument the user provided data, and as second argument the pointer to the selected filename. If the filename is to be used out of the callback function, then it has to be copied. The callback function must return 0 if successful, or non-zero if an error occured and the user will be requested to select another file.
data the user provided pointer to a data that will be passed to the callback.

void a_GtkUtils_file_viewer_new const char *  terminal,
const char *  title,
const char **  xpm_data,
int  width,
int  height,
const char *  filename,
const char *  data,
size_t  size,
const char *  charset
 

Shows the content of a file or an in-memory data as text in a separate window

Parameters:
terminal the terminal/display where the window is to be opened
title the window's title
xpm_data the window's icon as inlined char data
width window's width (0 for default, -1 for auto)
height window's height (0 for default, -1 for auto)
filename if non NULL, the name of the file which content is to be shown
data if non NULL, the in-memory data to be shown as text
size if 'data' is non NULL, its size
charset the character set of the text to be shown. If NULL, a_Utils_magic_*_get_mime_type() guesses it

gboolean a_GtkUtils_filename_is_supported_image const char *  filename  ) 
 

GtkWidget* a_GtkUtils_label_new_bold const char *  text  ) 
 

GtkWidget* a_GtkUtils_label_new_bold_large const char *  text  ) 
 

GtkWidget* a_GtkUtils_label_new_italic const char *  text  ) 
 

gchar* a_GtkUtils_make_display_name GtkWidget *  toplevel  ) 
 

void a_GtkUtils_paned_shrink_control GtkWidget *  paned,
gpointer  anint
 

Paned window super shrink control This allows a paned window to show one of its children in full size by only clicking mouse button 2 or 3

Parameters:
paned the paned window for which the shrink control is to be implemented
anint a pointer to an integer that will store the pane position while one of the children is hidden

void a_GtkUtils_set_tip GtkWidget *  widget,
const gchar *  help
 

GtkWidget* a_GtkUtils_table_add_entry GtkTable *  table,
const char *  name,
GtkWidget *  label,
const char *  help,
guint  col,
guint  row
 

GtkWidget* a_GtkUtils_table_add_entry_full GtkTable *  table,
const char *  name,
GtkWidget *  label,
const char *  help,
guint  col,
guint  width,
guint  row,
guint  height
 

void a_GtkUtils_text_buffer_append GtkTextBuffer *  buffer,
const char *  text,
int  size
 

int a_GtkUtils_text_buffer_append_image_data GtkTextBuffer *  buffer,
const char *  data,
size_t  len
 

void a_GtkUtils_text_buffer_convert_insert GtkTextBuffer *  buffer,
GtkTextIter *  iter,
const char *  text,
size_t  text_len,
const char *  source_charset
 

void a_GtkUtils_text_buffer_create_tags GtkTextBuffer *  buffer  ) 
 

void a_GtkUtils_text_buffer_get_header_tag XePMessageHeaderType  type,
const char **  header_name_tag,
const char **  header_value_tag
 

int a_GtkUtils_text_buffer_insert_image_file GtkTextBuffer *  buffer,
GtkTextIter *  iter,
const char *  filename
 

GtkWidget* a_GtkUtils_text_view_new const char *  text,
gint  len,
gboolean  editable
 

GtkWidget* a_GtkUtils_toplevel_new const char *  terminal,
const char *  title,
const char **  xpm_data,
int  width,
int  height
 

GtkWidget* a_GtkUtils_transient_new GtkWidget *  toplevel,
const char *  title,
int  width,
int  height
 

void a_GtkUtils_tree_changed XePGtkUtilsTree utils_tree  ) 
 

void a_GtkUtils_tree_clear XePGtkUtilsTree utils_tree  ) 
 

void a_GtkUtils_tree_finalize_add XePGtkUtilsTree utils_tree,
void *  new_item
 

Finalize the addition of an item when the add callback is an asynchronous function. When the callback set by a_GtkUtils_tree_set_add_callback() is a callback that returns immediately while the to be added item is not ready yet, it has to return NULL and make sure the UI of the tree widget is frozen. For this purpose, the callback opens a modal window waiting for user input. When the data is ready, a_GtkUtils_tree_finalize_add() must be called with the new data in new_item. Only after a_GtkUtils_tree_finalize_add() returns, the UI of the tree can be used again. So typically, the "close" handler of the modal window calls this function before actually closing the window. The location of to be added item is saved in utils_tree before the user callback is called and persists until a_GtkUtils_tree_finalize_add() uses them..

Parameters:
utils_tree the relevant XePGtkUtilsTree structure
new_item pointer to the newly created item that is to be added.

void a_GtkUtils_tree_finalize_edit XePGtkUtilsTree utils_tree,
void *  edited_item
 

Finalize the edition of an item when the "edit" callback was an asynchronous function. When the callback set by a_GtkUtils_tree_set_add_callback() is a callback that returns immediately while the item to edit is not ready yet, it has to return NULL and make sure the UI of the tree widget is frozen. When the user finishes editing the item, a_GtkUtils_tree_finalize_edit() should be called. It sets the edited_item in the list/tree node. This function does not free the original item.

void a_GtkUtils_tree_finalize_remove XePGtkUtilsTree utils_tree  ) 
 

void a_GtkUtils_tree_finalize_top XePGtkUtilsTree utils_tree  ) 
 

void a_GtkUtils_tree_free XePGtkUtilsTree tree  ) 
 

GtkWidget* a_GtkUtils_tree_get_buttons_widget XePGtkUtilsTree utils_tree  ) 
 

void a_GtkUtils_tree_get_selected_data XePGtkUtilsTree utils_tree,
const char **  description,
int *  type,
int *  weight,
void **  user_data1,
void **  user_data2
 

GtkTreeSelection* a_GtkUtils_tree_get_selection XePGtkUtilsTree utils_tree  ) 
 

GtkTreeStore* a_GtkUtils_tree_get_tree_store XePGtkUtilsTree utils_tree  ) 
 

GtkWidget* a_GtkUtils_tree_get_tree_view XePGtkUtilsTree utils_tree  ) 
 

GtkWidget* a_GtkUtils_tree_get_tree_widget XePGtkUtilsTree utils_tree  ) 
 

XePGtkUtilsTree* a_GtkUtils_tree_new GtkOrientation  orientation,
gboolean  reordable,
GtkPolicyType  hpolicy,
GtkPolicyType  vpolicy
 

void a_GtkUtils_tree_refresh XePGtkUtilsTree utils_tree  ) 
 

int a_GtkUtils_tree_selected_is_expanded XePGtkUtilsTree utils_tree  ) 
 

Check if the selected row is expanded or not This is guaranteed to have a valid value only within the "expanded" callback

void a_GtkUtils_tree_selection_set_mode XePGtkUtilsTree utils_tree,
GtkSelectionMode  mode
 

void a_GtkUtils_tree_set_add_callback XePGtkUtilsTree utils_tree,
XePGtkUtilsTreeCb  callback,
void *  data
 

Set the callback function that creates a new item.

Parameters:
utils_tree the XePGtkUtilsTree that will call the callback
callback the callback that is responsible to create an item. If the callback immediatly creates the new item, it must return a generic pointer to it (void *). If no item is to be created, it returns NULL. If the item is to be created after the function returns, to allow UI interaction before creating the item, it must return NULL and make block interaction with the XePGtkUtilsTree (currently possible by using a modal window). Then, when the item is created, it must call a_GtkUtils_tree_finalize_add().
data the user data passed as second argument to the callback function

void a_GtkUtils_tree_set_changed_callback XePGtkUtilsTree utils_tree,
XePGtkUtilsTreeCb  callback,
void *  data
 

void a_GtkUtils_tree_set_edit_callback XePGtkUtilsTree utils_tree,
XePGtkUtilsTreeCb  callback,
void *  data
 

void a_GtkUtils_tree_set_expanded_callback XePGtkUtilsTree utils_tree,
XePGtkUtilsTreeCb  callback,
void *  data
 

void a_GtkUtils_tree_set_list XePGtkUtilsTree utils_tree,
clist *  list
 

void a_GtkUtils_tree_set_path XePGtkUtilsTree utils_tree,
GtkTreePath *  path
 

void a_GtkUtils_tree_set_refresh_callback XePGtkUtilsTree utils_tree,
XePGtkUtilsTreeCb  callback,
void *  data
 

void a_GtkUtils_tree_set_remove_callback XePGtkUtilsTree utils_tree,
XePGtkUtilsTreeCb  callback,
void *  data
 

Set the callback function that frees an item.

Parameters:
utils_tree the XePGtkUtilsTree that will call the callback
callback the callback that is responsible to free an item. If the callback can immediatly free the item, it frees it and it returns NULL. If the free operation is to be ignored, it must return a non NULL pointer (typically, the pointer to the item that was to be freeed). If the callback cannot free immediatly the item, for example if it has to allow for UI interaction, then it returns the non NULL pointer (as if the item is not to be removed), then it has to block interaction with utils_tree (by using a modal window). When the item is finally freed, it must call a_GtkUtils_tree_finalize_remove(). The callback will find the item to remove with a_GtkUtils_tree_get_selected_data(). In case where the utils_tree is displaying a tree, the value returned by a_GtkUtils_tree_get_selected_data() is then the cntree and the use callback must remove and free all the children of the cntree. But it must not free the cntree itself because this is done by the call to a _GtkUtils_tree_finalize_remove().
data the user data passed as second argument to the callback function

void a_GtkUtils_tree_set_top_callback XePGtkUtilsTree utils_tree,
XePGtkUtilsTreeCb  callback,
void *  data
 

void a_GtkUtils_tree_set_tree XePGtkUtilsTree utils_tree,
cntree ntree
 


Generated on Wed Oct 22 15:52:27 2003 for XetPan by doxygen 1.3.2