rb-util

rb-util — assorted utility functions

Synopsis

#define             FFWD_OFFSET
#define             RWD_OFFSET
#define             RB_CHAIN_GOBJECT_METHOD             (klass,
                                                         method,
                                                         instance)
gboolean            rb_true_function                    (gpointer dummy);
gboolean            rb_false_function                   (gpointer dummy);
gpointer            rb_null_function                    (gpointer dummy);
gpointer            rb_copy_function                    (gpointer data);
int                 rb_gvalue_compare                   (GValue *a,
                                                         GValue *b);
int                 rb_compare_gtimeval                 (GTimeVal *a,
                                                         GTimeVal *b);
int                 rb_safe_strcmp                      (const char *a,
                                                         const char *b);
char *              rb_make_time_string                 (guint seconds);
char *              rb_make_duration_string             (guint duration);
char *              rb_make_elapsed_time_string         (guint elapsed,
                                                         guint duration,
                                                         gboolean show_remaining);
GtkWidget *         rb_image_new_from_stock             (const gchar *stock_id,
                                                         GtkIconSize size);
void                rb_threads_init                     (void);
gboolean            rb_is_main_thread                   (void);
gchar *             rb_search_fold                      (const char *original);
gchar **            rb_string_split_words               (const gchar *string);
gboolean            rb_string_list_equal                (GList *a,
                                                         GList *b);
gboolean            rb_string_list_contains             (GList *list,
                                                         const char *s);
GList *             rb_string_list_copy                 (GList *list);
void                rb_list_deep_free                   (GList *list);
void                rb_list_destroy_free                (GList *list,
                                                         GDestroyNotify destroyer);
void                rb_slist_deep_free                  (GSList *list);
gboolean            rb_str_in_strv                      (const char *needle,
                                                         const char **haystack);
GList *             rb_collate_hash_table_keys          (GHashTable *table);
GList *             rb_collate_hash_table_values        (GHashTable *table);
GList *             rb_uri_list_parse                   (const char *uri_list);
gboolean            rb_signal_accumulator_object_handled
                                                        (GSignalInvocationHint *hint,
                                                         GValue *return_accu,
                                                         const GValue *handler_return,
                                                         gpointer dummy);
gboolean            rb_signal_accumulator_value_handled (GSignalInvocationHint *hint,
                                                         GValue *return_accu,
                                                         const GValue *handler_return,
                                                         gpointer dummy);
gboolean            rb_signal_accumulator_boolean_or    (GSignalInvocationHint *hint,
                                                         GValue *return_accu,
                                                         const GValue *handler_return,
                                                         gpointer dummy);
gboolean            rb_signal_accumulator_value_array   (GSignalInvocationHint *hint,
                                                         GValue *return_accu,
                                                         const GValue *handler_return,
                                                         gpointer dummy);
void                rb_value_array_append_data          (GArray *array,
                                                         GType type,
                                                         ...);
void                rb_value_free                       (GValue *val);
void                rb_assert_locked                    (GMutex *mutex);
void                rb_set_tree_view_column_fixed_width (GtkWidget *treeview,
                                                         GtkTreeViewColumn *column,
                                                         GtkCellRenderer *renderer,
                                                         const char **strings,
                                                         int padding);
GdkPixbuf *         rb_scale_pixbuf_to_size             (GdkPixbuf *pixbuf,
                                                         GtkIconSize size);
void                (*RBDelayedSyncFunc)                (GSettings *settings,
                                                         gpointer data);
void                rb_settings_delayed_sync            (GSettings *settings,
                                                         RBDelayedSyncFunc sync_func,
                                                         gpointer data,
                                                         GDestroyNotify destroy);
void                rb_menu_update_link                 (GMenu *menu,
                                                         const char *link_attr,
                                                         GMenuModel *target);

Description

This is a dumping ground for utility functions that may or may not be generally useful in Rhythmbox or elsewhere. Things end up here if they're clever or if they're used all over the place.

Details

FFWD_OFFSET

#define FFWD_OFFSET 20


RWD_OFFSET

#define RWD_OFFSET 10


RB_CHAIN_GOBJECT_METHOD()

#define             RB_CHAIN_GOBJECT_METHOD(klass, method, instance)


rb_true_function ()

gboolean            rb_true_function                    (gpointer dummy);


rb_false_function ()

gboolean            rb_false_function                   (gpointer dummy);


rb_null_function ()

gpointer            rb_null_function                    (gpointer dummy);


rb_copy_function ()

gpointer            rb_copy_function                    (gpointer data);


rb_gvalue_compare ()

int                 rb_gvalue_compare                   (GValue *a,
                                                         GValue *b);


rb_compare_gtimeval ()

int                 rb_compare_gtimeval                 (GTimeVal *a,
                                                         GTimeVal *b);

Compares two GTimeVal structures for sorting.

a :

left hand side

b :

right hand size

Returns :

-1 if a < b, 0 if a == b, 1 if a > b

rb_safe_strcmp ()

int                 rb_safe_strcmp                      (const char *a,
                                                         const char *b);


rb_make_time_string ()

char *              rb_make_time_string                 (guint seconds);

Constructs a string describing the specified time.

seconds :

time in seconds

Returns :

time string. [transfer full]

rb_make_duration_string ()

char *              rb_make_duration_string             (guint duration);

Constructs a string describing the specified duration. The string describes hours, minutes, and seconds, and its format is localised.

duration :

duration in seconds

Returns :

duration string. [transfer full]

rb_make_elapsed_time_string ()

char *              rb_make_elapsed_time_string         (guint elapsed,
                                                         guint duration,
                                                         gboolean show_remaining);

Constructs a string describing a playback position. The string describes hours, minutes, and seconds, and its format is localised. The string can describe either the elapsed time or the time remaining.

elapsed :

elapsed time (in seconds)

duration :

duration (in seconds)

show_remaining :

if TRUE, show the remaining time, otherwise show elapsed time

Returns :

elapsed/remaining time string. [transfer full]

rb_image_new_from_stock ()

GtkWidget *         rb_image_new_from_stock             (const gchar *stock_id,
                                                         GtkIconSize size);

Same as gtk_image_new_from_stock except that it mirrors the icons for RTL languages.

stock_id :

stock image id

size :

requested icon size

Returns :

a GtkImage of the requested stock item. [transfer full]

rb_threads_init ()

void                rb_threads_init                     (void);


rb_is_main_thread ()

gboolean            rb_is_main_thread                   (void);

Checks if currently executing on the main thread.

Returns :

TRUE if on the main thread

rb_search_fold ()

gchar *             rb_search_fold                      (const char *original);

Returns a case-folded and punctuation-stripped version of original, useful for performing text searches.

original :

the string to fold

Returns :

case-folded string. [transfer full]

rb_string_split_words ()

gchar **            rb_string_split_words               (const gchar *string);

Splits string on word boundaries using Unicode character definitions.

string :

the string to split

Returns :

NULL-terminated array of strings. [array zero-terminated=1][transfer full]

rb_string_list_equal ()

gboolean            rb_string_list_equal                (GList *a,
                                                         GList *b);


rb_string_list_contains ()

gboolean            rb_string_list_contains             (GList *list,
                                                         const char *s);


rb_string_list_copy ()

GList *             rb_string_list_copy                 (GList *list);


rb_list_deep_free ()

void                rb_list_deep_free                   (GList *list);


rb_list_destroy_free ()

void                rb_list_destroy_free                (GList *list,
                                                         GDestroyNotify destroyer);


rb_slist_deep_free ()

void                rb_slist_deep_free                  (GSList *list);


rb_str_in_strv ()

gboolean            rb_str_in_strv                      (const char *needle,
                                                         const char **haystack);


rb_collate_hash_table_keys ()

GList *             rb_collate_hash_table_keys          (GHashTable *table);


rb_collate_hash_table_values ()

GList *             rb_collate_hash_table_values        (GHashTable *table);


rb_uri_list_parse ()

GList *             rb_uri_list_parse                   (const char *uri_list);

Converts a single string containing a list of URIs into a GList of URI strings.

uri_list :

string containing URIs to parse

Returns :

GList of URI strings. [element-type utf8][transfer full]

rb_signal_accumulator_object_handled ()

gboolean            rb_signal_accumulator_object_handled
                                                        (GSignalInvocationHint *hint,
                                                         GValue *return_accu,
                                                         const GValue *handler_return,
                                                         gpointer dummy);


rb_signal_accumulator_value_handled ()

gboolean            rb_signal_accumulator_value_handled (GSignalInvocationHint *hint,
                                                         GValue *return_accu,
                                                         const GValue *handler_return,
                                                         gpointer dummy);


rb_signal_accumulator_boolean_or ()

gboolean            rb_signal_accumulator_boolean_or    (GSignalInvocationHint *hint,
                                                         GValue *return_accu,
                                                         const GValue *handler_return,
                                                         gpointer dummy);


rb_signal_accumulator_value_array ()

gboolean            rb_signal_accumulator_value_array   (GSignalInvocationHint *hint,
                                                         GValue *return_accu,
                                                         const GValue *handler_return,
                                                         gpointer dummy);


rb_value_array_append_data ()

void                rb_value_array_append_data          (GArray *array,
                                                         GType type,
                                                         ...);


rb_value_free ()

void                rb_value_free                       (GValue *val);


rb_assert_locked ()

void                rb_assert_locked                    (GMutex *mutex);


rb_set_tree_view_column_fixed_width ()

void                rb_set_tree_view_column_fixed_width (GtkWidget *treeview,
                                                         GtkTreeViewColumn *column,
                                                         GtkCellRenderer *renderer,
                                                         const char **strings,
                                                         int padding);

Sets a fixed size for a tree view column based on a set of strings to be displayed in the column.

treeview :

the GtkTreeView containing the column

column :

the GtkTreeViewColumn to size

renderer :

the GtkCellRenderer used in the column

strings :

a NULL-terminated set of strings to base the size on. [array zero-terminated=1]

padding :

a small amount of extra padding for the column

rb_scale_pixbuf_to_size ()

GdkPixbuf *         rb_scale_pixbuf_to_size             (GdkPixbuf *pixbuf,
                                                         GtkIconSize size);

Creates a new GdkPixbuf from the original one, for a target of size, respecting the aspect ratio of the image.

pixbuf :

the GdkPixbuf containing the original image

size :

a stock icon size

Returns :

scaled GdkPixbuf. [transfer full]

RBDelayedSyncFunc ()

void                (*RBDelayedSyncFunc)                (GSettings *settings,
                                                         gpointer data);


rb_settings_delayed_sync ()

void                rb_settings_delayed_sync            (GSettings *settings,
                                                         RBDelayedSyncFunc sync_func,
                                                         gpointer data,
                                                         GDestroyNotify destroy);

Synchronizes settings in the settings instance after 500ms has elapsed with no further changes.

settings :

GSettings instance

sync_func :

function to call. [allow-none]

data :

data to pass to func. [allow-none]

destroy :

function to use to free data. [allow-none]

rb_menu_update_link ()

void                rb_menu_update_link                 (GMenu *menu,
                                                         const char *link_attr,
                                                         GMenuModel *target);

Updates a submenu link to point to the specified target menu.

menu :

menu to update

link_attr :

attribute indicating the menu link to update

target :

new menu link target