gel-misc

gel-misc

Synopsis

#define             GEL_DEFINE_QUARK_FUNC               (name)
#define             GEL_DEFINE_WEAK_REF_CALLBACK        (name)
gboolean            (*GelFilterFunc)                    (const gpointer data,
                                                         gpointer user_data);
enum                GelPathComponent;
gchar *             (*GelPrintFunc)                     (const gpointer data);
enum                GelResourceType;
                    GelSignalDef;
gchar *             gel_8601_date_now                   (void);
GList *             gel_dir_read                        (gchar *path,
                                                         gboolean absolute,
                                                         GError **error);
gchar **            gel_file_strings                    (gchar *pathname);
#define             gel_free_and_invalidate             (obj,
                                                         value,
                                                         func)
#define             gel_free_and_invalidate_with_args   (obj,
                                                         value,
                                                         func,
                                                         ...)
const gchar *       gel_get_package_data_dir            (void);
const gchar *       gel_get_package_lib_dir             (void);
const gchar *       gel_get_package_name                (void);
void                gel_init                            (const gchar *package_name,
                                                         const gchar *lib_dir,
                                                         const gchar *data_dir);
void                gel_list_bisect                     (GList *input,
                                                         GList **accepted,
                                                         GList **rejected,
                                                         GelFilterFunc callback,
                                                         gpointer data);
#define             gel_list_deep_free                  (list,
                                                         callback)
#define             gel_list_deep_free_with_data        (list,
                                                         callback,
                                                         user_data)
GList *             gel_list_filter                     (GList *input,
                                                         GelFilterFunc callback,
                                                         gpointer user_data);
gchar *             gel_list_join                       (const gchar *separator,
                                                         GList *list);
void                gel_list_printf                     (GList *list,
                                                         const gchar *format,
                                                         GelPrintFunc stringify_func);
gchar **            gel_list_to_strv                    (GList *list,
                                                         gboolean copy);
void                gel_object_class_print_properties   (GObjectClass *object);
guint               gel_object_get_ref_count            (GObject *object);
const gchar *       gel_object_get_type_name            (GObject *object);
void                gel_object_interface_print_properties
                                                        (gpointer interface);
#define             gel_propagate_error_or_warm         (dst,
                                                         src,
                                                         ...)
gchar *             gel_resource_locate                 (GelResourceType type,
                                                         gchar *resource);
const gchar *       gel_resource_type_get_env           (GelResourceType type);
gchar *             gel_resource_type_get_system_dir    (GelResourceType type);
gchar *             gel_resource_type_get_user_dir      (GelResourceType type);
guint               gel_run_once_on_idle                (GSourceFunc callback,
                                                         gpointer data,
                                                         GDestroyNotify destroy);
guint               gel_run_once_on_timeout             (guint interval,
                                                         GSourceFunc callback,
                                                         gpointer data,
                                                         GDestroyNotify destroy);
void                gel_show_to_user                    (const gchar *uri);
#define             gel_slist_deep_free                 (list,
                                                         callback)
#define             gel_slist_deep_free_with_data       (list,
                                                         callback,
                                                         user_data)
#define             gel_slist_printf                    (list,
                                                         format,
                                                         func)
#define             gel_str_or_text                     (str,
                                                         text)
gchar **            gel_strv_concat                     (gchar **strv_a,
                                                         ...);
gchar **            gel_strv_copy                       (gchar **strv,
                                                         gboolean deep);
gchar **            gel_strv_delete                     (gchar **strv,
                                                         gint index);
GList *             gel_strv_to_list                    (gchar **strv,
                                                         gboolean copy);
#define             gel_warn_fix_implementation

Description

Details

GEL_DEFINE_QUARK_FUNC()

#define             GEL_DEFINE_QUARK_FUNC(name)

name: Name for use in the quark function, use 'foo' for quark_foo()

Defines a quark function


GEL_DEFINE_WEAK_REF_CALLBACK()

#define             GEL_DEFINE_WEAK_REF_CALLBACK(name)

name: Name for use in the weak ref callback, use 'foo' for foo_weak_ref_cb

Defines a weak ref function for use with g_object_weak_ref


GelFilterFunc ()

gboolean            (*GelFilterFunc)                    (const gpointer data,
                                                         gpointer user_data);

data: Data to filter or not user_data: User data

Filters out (or not) data from a larger set of values

Returns :

TRUE if data is accepted (NOT sure about this, refer to caller function documentation)

enum GelPathComponent

typedef enum {
	GEL_PATH_COMPONENT_BASENAME,
	GEL_PATH_COMPONENT_DIRNAME,
	GEL_PATH_COMPONENT_PATHNAME,
	GEL_PATH_N_COMPONENTS
} GelPathComponent;

Used for access returned data from gel_file_strings

GEL_PATH_COMPONENT_BASENAME

Basename of a path string

GEL_PATH_COMPONENT_DIRNAME

Dirname of a path string

GEL_PATH_COMPONENT_PATHNAME

Full path string

GEL_PATH_N_COMPONENTS

Helper define

GelPrintFunc ()

gchar *             (*GelPrintFunc)                     (const gpointer data);

data: (transfer none): gpointer holind data to dump

Converts data to printable strings

Returns :

Data in a printable form. [transfer full]

enum GelResourceType

typedef enum {
	GEL_RESOURCE_TYPE_UI,     // ui/
	GEL_RESOURCE_TYPE_IMAGE,  // pixmaps/
	GEL_RESOURCE_TYPE_SHARED, // lib/
	GEL_RESOURCE_TYPE_OTHER,  // "./"

	GEL_RESOURCE_N_TYPES
} GelResourceType;

GEL_RESOURCE_TYPE_UI: A .ui file, a UI definition understandable by GtkBuilder GEL_RESOURCE_TYPE_IMAGE: An image in any format loadable by Gtk+ GEL_RESOURCE_TYPE_SHARED: A shared object (.so, .dylib, .dll) GEL_RESOURCE_OTHER: Other types

GelResourceType describes which type of file to locate, each type, except GEL_RESOURCE_OTHER, is searched in specific locations, where GEL_RESOURCE_OTHER is searched at '.'

For specific information about search paths you should to read the code of gel/gel-misc.c.


GelSignalDef

typedef struct {
	gchar *object, *signal;
	GCallback callback;
	gpointer data;
	gboolean swapped;
} GelSignalDef;

Defines a signal

gchar *object;

Name of the object

gchar *signal;

Signal name

GCallback callback;

GCallback to connect

gpointer data;

data to pass to callback or NULL

gboolean swapped;

Whatever to use swapped version of g_signal_connect()

gel_8601_date_now ()

gchar *             gel_8601_date_now                   (void);

gel_dir_read ()

GList *             gel_dir_read                        (gchar *path,
                                                         gboolean absolute,
                                                         GError **error);

gel_file_strings ()

gchar **            gel_file_strings                    (gchar *pathname);

gel_free_and_invalidate()

#define             gel_free_and_invalidate(obj,value,func)

gel_free_and_invalidate_with_args()

#define             gel_free_and_invalidate_with_args(obj,value,func,...)

gel_get_package_data_dir ()

const gchar *       gel_get_package_data_dir            (void);

Get package data_dir from libgel

Returns :

package data_dir of the app using libgel This string is owned by libgel and should NOT be freeded. [transfer none]

gel_get_package_lib_dir ()

const gchar *       gel_get_package_lib_dir             (void);

Get package libdir from libgel

Returns :

package libdir of the app using libgel This string is owned by libgel and should NOT be freeded. [transfer none]

gel_get_package_name ()

const gchar *       gel_get_package_name                (void);

Get package name from libgel

Returns :

package name of the app using libgel. This string is owned by libgel and should NOT be freeded. [transfer none]

gel_init ()

void                gel_init                            (const gchar *package_name,
                                                         const gchar *lib_dir,
                                                         const gchar *data_dir);

package_name: Name of the package/app using libgel. Something like 'foo' or 'bar'. lib_dir: libdir for the app, in most cases something like /usr/local/lib or /usr/lib data_dir: datadir for the app, in most cases something like /usr/local/share or /usr/share

Initializes the library


gel_list_bisect ()

void                gel_list_bisect                     (GList *input,
                                                         GList **accepted,
                                                         GList **rejected,
                                                         GelFilterFunc callback,
                                                         gpointer data);

input: A GList to bisect accepted: (inout): A GList to store accepted elements, NULL is not allowed rejected: (inout): A GList to store rejected elements, NULL is not allowed callback: A GelFilterFunc data: data to pass to callback

Bisect (split) a GList based on the criteria of callback. Callback is called in form of callback(element,data). If callback returns TRUE element is stored in accepted, else element is stored in rejected.

Original list is completly freeded, since all of his elements are moved to accepted or rejected. Neither of accepted or rejected can be NULL because elements will be leaked.


gel_list_deep_free()

#define gel_list_deep_free(list,callback) gel_list_deep_free_with_data(list,(GFunc)callback,NULL)

Deep free a GList. callback is invoked to free each element of list

list :

A GList

callback :

A GFunc callback

gel_list_deep_free_with_data()

#define             gel_list_deep_free_with_data(list,callback,user_data)

Deep free a GList. callback is invoked to free each element of list with data as second argument

list :

A GList

callback :

A GFunc callback

user_data :

User data to pass to callback as second argument

gel_list_filter ()

GList *             gel_list_filter                     (GList *input,
                                                         GelFilterFunc callback,
                                                         gpointer user_data);

input: A GList to filter callback: A GelFilterFunc used for filtering user_data: data to pass to callback

Filters input's elements to return a newly created GList based on the criteria of callback, if TRUE is returned, element is included in the returned list.

Note that elements itself are not copied.

See also: gel_list_bisect()

Returns :

The filtered list. [transfer container]

gel_list_join ()

gchar *             gel_list_join                       (const gchar *separator,
                                                         GList *list);

gel_list_printf ()

void                gel_list_printf                     (GList *list,
                                                         const gchar *format,
                                                         GelPrintFunc stringify_func);

list: A GList format: (allow-none): Format to use for print each the stringified element. By default "s\n" stringify_func: The GelPrintFunc to use for stringify elements

Prints a GList to stdout using format for each element and stringify_func to stringify elements.


gel_list_to_strv ()

gchar **            gel_list_to_strv                    (GList *list,
                                                         gboolean copy);

list: A GList to convert to gchar** copy: if TRUE the data is also copied

Converts a GList to a gchar** optionally copying data (a gchar element-type is assumed)

Returns :

A gchar** with the elements of list

gel_object_class_print_properties ()

void                gel_object_class_print_properties   (GObjectClass *object);

gel_object_get_ref_count ()

guint               gel_object_get_ref_count            (GObject *object);

object: A GObject

Get the number of references over the object

Returns :

The number of references

gel_object_get_type_name ()

const gchar *       gel_object_get_type_name            (GObject *object);

object: A GObject

Get object's class printable name

Returns :

A string containing the object's class name. This string is owned by glib-object and should NOT be freeded. [transfer none]

gel_object_interface_print_properties ()

void                gel_object_interface_print_properties
                                                        (gpointer interface);

gel_propagate_error_or_warm()

#define             gel_propagate_error_or_warm(dst,src,...)

gel_resource_locate ()

gchar *             gel_resource_locate                 (GelResourceType type,
                                                         gchar *resource);

gel_resource_type_get_env ()

const gchar *       gel_resource_type_get_env           (GelResourceType type);

gel_resource_type_get_system_dir ()

gchar *             gel_resource_type_get_system_dir    (GelResourceType type);

gel_resource_type_get_user_dir ()

gchar *             gel_resource_type_get_user_dir      (GelResourceType type);

gel_run_once_on_idle ()

guint               gel_run_once_on_idle                (GSourceFunc callback,
                                                         gpointer data,
                                                         GDestroyNotify destroy);

gel_run_once_on_timeout ()

guint               gel_run_once_on_timeout             (guint interval,
                                                         GSourceFunc callback,
                                                         gpointer data,
                                                         GDestroyNotify destroy);

gel_show_to_user ()

void                gel_show_to_user                    (const gchar *uri);

gel_slist_deep_free()

#define gel_slist_deep_free(list,callback) gel_list_deep_free((GList*)list, callback)

See gel_list_deep_free()

list :

A GSList

callback :

A GFunc callback

gel_slist_deep_free_with_data()

#define gel_slist_deep_free_with_data(list,callback,user_data) gel_list_deep_free_with_data((GList*)list,callback,user_data)

See gel_list_deep_free_with_data()

list :

A GSList

callback :

A GFunc callback

user_data :

User data to pass to callback as second argument

gel_slist_printf()

#define gel_slist_printf(list,format,func) gel_list_printf((GList*) list, format, func)

See gel_list_printf()


gel_str_or_text()

#define gel_str_or_text(str, text) (str ? str : text)

gel_strv_concat ()

gchar **            gel_strv_concat                     (gchar **strv_a,
                                                         ...);

strv_a: The first NULL-terminate array of strings Varargs: a NULL-terminated list of NULL-terminate array of strings

Concatenates a set of NULL-terminate array of strings (commonly refered as strv) into a single one.

Returns :

the new strv with all the strings copied. [transfer full]

gel_strv_copy ()

gchar **            gel_strv_copy                       (gchar **strv,
                                                         gboolean deep);

gel_strv_delete ()

gchar **            gel_strv_delete                     (gchar **strv,
                                                         gint index);

gel_strv_to_list ()

GList *             gel_strv_to_list                    (gchar **strv,
                                                         gboolean copy);

strv: A NULL-terminated array of strings copy: if TRUE the data is also copied

Coverts a gchar** to a GList, see also gel_list_to_strv()

Returns :

A GList with the elements of strv

gel_warn_fix_implementation

#define             gel_warn_fix_implementation()