katze-utils

katze-utils

Synopsis

#include <katze/katze.h>

#define             katze_assign                        (lvalue,
                                                         rvalue)
#define             katze_object_assign                 (lvalue,
                                                         rvalue)
#define             katze_strv_assign                   (lvalue,
                                                         rvalue)
const gchar *       katze_str_non_null                  (const gchar *str);
GtkWidget *         katze_property_proxy                (gpointer object,
                                                         const gchar *property,
                                                         const gchar *hint);
enum                KatzeMenuPos;
void                katze_widget_popup                  (GtkWidget *widget,
                                                         GtkMenu *menu,
                                                         GdkEventButton *event,
                                                         KatzeMenuPos pos);
GtkWidget *         katze_image_menu_item_new_ellipsized
                                                        (const gchar *label);
gboolean            katze_tree_view_get_selected_iter   (GtkTreeView *treeview,
                                                         GtkTreeModel **model,
                                                         GtkTreeIter *iter);
void                katze_bookmark_populate_tree_view   (KatzeArray *array,
                                                         GtkTreeStore *model,
                                                         GtkTreeIter *parent);
gchar *             katze_strip_mnemonics               (const gchar *original);
const gchar *       katze_skip_whitespace               (const gchar *str);
gint                katze_object_get_boolean            (gpointer object,
                                                         const gchar *property);
gint                katze_object_get_int                (gpointer object,
                                                         const gchar *property);
gint                katze_object_get_enum               (gpointer object,
                                                         const gchar *property);
gchar *             katze_object_get_string             (gpointer object,
                                                         const gchar *property);
gpointer            katze_object_get_object             (gpointer object,
                                                         const gchar *property);
int                 katze_mkdir_with_parents            (const gchar *pathname,
                                                         int mode);
GtkWidget *         katze_uri_entry_new                 (GtkWidget *other_widget);
void                katze_widget_add_class              (GtkWidget *widget,
                                                         const gchar *class_name);
void                katze_assert_str_equal              (const gchar *input,
                                                         const gchar *result,
                                                         const gchar *expected);
void                katze_window_set_sensible_default_size
                                                        (GtkWindow *window);

Description

Details

katze_assign()

#define katze_assign(lvalue, rvalue) lvalue = (g_free (lvalue), rvalue)

Frees lvalue if needed and assigns it the value of rvalue.

lvalue :

a pointer

rvalue :

the new value

katze_object_assign()

#define             katze_object_assign(lvalue, rvalue)

Unrefs lvalue if needed and assigns it the value of rvalue.

lvalue :

a gobject

rvalue :

the new value

katze_strv_assign()

#define katze_strv_assign(lvalue, rvalue) lvalue = (g_strfreev (lvalue), rvalue)

Frees lvalue if needed and assigns it the value of rvalue.

lvalue :

a string list

rvalue :

the new value

Since 0.1.7


katze_str_non_null ()

const gchar *       katze_str_non_null                  (const gchar *str);

str :

a string, or NULL

Returns :

"" if str is NULL.

Since 0.4.4


katze_property_proxy ()

GtkWidget *         katze_property_proxy                (gpointer object,
                                                         const gchar *property,
                                                         const gchar *hint);

Create a widget of an appropriate type to represent the specified object's property. If the property is writable changes of the value through the widget will be reflected in the value of the property.

Supported values for hint are as follows: "blurb": the blurb of the property will be used to provide a kind of label, instead of the name. "file": the widget created will be particularly suitable for choosing an existing filename. "folder": the widget created will be particularly suitable for choosing an existing folder. "uri": the widget created will be particularly suitable for choosing an existing filename, encoded as an URI. "font": the widget created will be particularly suitable for choosing a variable-width font from installed fonts. Since 0.1.6 the following hints are also supported: "toggle": the widget created will be an empty toggle button. This is only supported with boolean properties. Since 0.1.8 "toggle" creates GtkCheckButton widgets without checkmarks. Since 0.2.0 the following hints are also supported: "font-monospace": the widget created will be particularly suitable for choosing a fixed-width font from installed fonts. Since 0.2.1 the following hints are also supported: "application-TYPE": the widget created will be particularly suitable for choosing an application to open TYPE files, ie. "text/plain". "application-CATEGORY": the widget created will be particularly suitable for choosing an application to open CATEGORY files, ie. "Network". Since 0.5.8 the CATEGORY hint is no longer supported. "custom-PROPERTY": the last value of an enumeration will be the "custom" value, where the user may enter text freely, which then updates the property PROPERTY instead. This applies only to enumerations. Since 0.4.1 mnemonics are automatically stripped. Since 0.2.9 the following hints are also supported: "languages": the widget will be particularly suitable for choosing multiple language codes, ie. "de,en_GB". Since 0.3.6 the following hints are also supported: "address": the widget will be particularly suitable for typing a valid URI or IP address and highlight errors. Since 0.4.0 the following hints are also supported: "days": the widget will be particularly suitable for choosing a period of time in days.

Any other values for hint are silently ignored.

Since 0.1.2 strings without hints and booleans are truly synchronous including property changes causing the proxy to be updated.

Since 0.2.1 the proxy may contain a label if the platform has according widgets.

object :

a GObject

property :

the name of a property

hint :

a special hint

Returns :

a new widget

enum KatzeMenuPos

typedef enum {
    KATZE_MENU_POSITION_CURSOR = 0,
    KATZE_MENU_POSITION_LEFT,
    KATZE_MENU_POSITION_RIGHT
} KatzeMenuPos;

KATZE_MENU_POSITION_CURSOR

KATZE_MENU_POSITION_LEFT

KATZE_MENU_POSITION_RIGHT


katze_widget_popup ()

void                katze_widget_popup                  (GtkWidget *widget,
                                                         GtkMenu *menu,
                                                         GdkEventButton *event,
                                                         KatzeMenuPos pos);

Pops up the given menu relative to widget. Use this instead of writing custom positioning functions.

widget :

a widget

menu :

the menu to popup

event :

a button event, or NULL

pos :

the preferred positioning

Returns :

a new label widget

katze_image_menu_item_new_ellipsized ()

GtkWidget *         katze_image_menu_item_new_ellipsized
                                                        (const gchar *label);

Creates an image menu item where the label is reasonably ellipsized for you.

label :

a label or NULL

Returns :

a new label widget

katze_tree_view_get_selected_iter ()

gboolean            katze_tree_view_get_selected_iter   (GtkTreeView *treeview,
                                                         GtkTreeModel **model,
                                                         GtkTreeIter *iter);

Determines whether there is a selection in treeview and sets the iter to the current selection.

If there is a selection and model is not NULL, it is set to the model, mainly for convenience.

Either model or iter or both can be NULL in which case no value will be assigned in any case.

treeview :

a GtkTreeView

model :

a pointer to store the model, or NULL

iter :

a pointer to store the iter, or NULL

Returns :

TRUE if there is a selection

Since 0.1.3


katze_bookmark_populate_tree_view ()

void                katze_bookmark_populate_tree_view   (KatzeArray *array,
                                                         GtkTreeStore *model,
                                                         GtkTreeIter *parent);

katze_strip_mnemonics ()

gchar *             katze_strip_mnemonics               (const gchar *original);

Parses the given string for mnemonics in the form "B_utton" or "Button (_U)" and returns a string without any mnemonics.

original :

a string with mnemonics

Returns :

a newly allocated string without mnemonics

Since 0.1.8


katze_skip_whitespace ()

const gchar *       katze_skip_whitespace               (const gchar *str);

katze_object_get_boolean ()

gint                katze_object_get_boolean            (gpointer object,
                                                         const gchar *property);

Retrieve the boolean value of the specified property.

object :

a GObject

property :

the name of the property to get

Returns :

a boolean

katze_object_get_int ()

gint                katze_object_get_int                (gpointer object,
                                                         const gchar *property);

Retrieve the integer value of the specified property.

object :

a GObject

property :

the name of the property to get

Returns :

an integer

katze_object_get_enum ()

gint                katze_object_get_enum               (gpointer object,
                                                         const gchar *property);

Retrieve the enum value of the specified property.

object :

a GObject

property :

the name of the property to get

Returns :

an enumeration

katze_object_get_string ()

gchar *             katze_object_get_string             (gpointer object,
                                                         const gchar *property);

Retrieve the string value of the specified property.

object :

a GObject

property :

the name of the property to get

Returns :

a newly allocated string

katze_object_get_object ()

gpointer            katze_object_get_object             (gpointer object,
                                                         const gchar *property);

Retrieve the object value of the specified property.

object :

a GObject

property :

the name of the property to get

Returns :

an object

katze_mkdir_with_parents ()

int                 katze_mkdir_with_parents            (const gchar *pathname,
                                                         int mode);

Create a directory if it doesn't already exist. Create intermediate parent directories as needed, too.

pathname :

a pathname in the GLib file name encoding

mode :

permissions to use for newly created directories

Returns :

0 if the directory already exists, or was successfully created. Returns -1 if an error occurred, with errno set.

Since 0.2.1


katze_uri_entry_new ()

GtkWidget *         katze_uri_entry_new                 (GtkWidget *other_widget);

Creates an entry that validates the typed URI.

If other_widget is given, it will become insensitive if the input is not a valid URI.

other_widget :

a GtkWidget, or NULL

Returns :

a GtkEntry

Since 0.3.6


katze_widget_add_class ()

void                katze_widget_add_class              (GtkWidget *widget,
                                                         const gchar *class_name);

katze_assert_str_equal ()

void                katze_assert_str_equal              (const gchar *input,
                                                         const gchar *result,
                                                         const gchar *expected);

Compares the two strings for equality, with verbose errors.

input :

a string

result :

a string

expected :

a string

Since 0.4.3


katze_window_set_sensible_default_size ()

void                katze_window_set_sensible_default_size
                                                        (GtkWindow *window);