1 /* 2 * Copyright (C) 2003 Colin Walters <walters@verbum.org> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2, or (at your option) 7 * any later version. 8 * 9 * The Rhythmbox authors hereby grant permission for non-GPL compatible 10 * GStreamer plugins to be used and distributed together with GStreamer 11 * and Rhythmbox. This permission is above and beyond the permissions granted 12 * by the GPL license by which Rhythmbox is covered. If you modify this code 13 * you may extend this exception to your version of the code, but you are not 14 * obligated to do so. If you do not wish to do so, delete this exception 15 * statement from your version. 16 * 17 * This program is distributed in the hope that it will be useful, 18 * but WITHOUT ANY WARRANTY; without even the implied warranty of 19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 * GNU General Public License for more details. 21 * 22 * You should have received a copy of the GNU General Public License 23 * along with this program; if not, write to the Free Software 24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 25 * 26 */ 27 28 #ifndef __RB_UTIL_H 29 #define __RB_UTIL_H 30 31 #include <stdarg.h> 32 #include <glib.h> 33 #include <gio/gio.h> 34 #include <gtk/gtk.h> 35 36 G_BEGIN_DECLS 37 38 /* Offsets for seeking forward, and rewinding in seconds */ 39 #define FFWD_OFFSET 20 40 #define RWD_OFFSET 10 41 42 #define RB_CHAIN_GOBJECT_METHOD(klass, method, instance) \ 43 if (G_OBJECT_CLASS (klass)->method != NULL) \ 44 G_OBJECT_CLASS (klass)->method (instance); 45 46 gboolean rb_true_function (gpointer dummy); 47 gboolean rb_false_function (gpointer dummy); 48 gpointer rb_null_function (gpointer dummy); 49 gpointer rb_copy_function (gpointer data); 50 51 int rb_gvalue_compare (GValue *a, GValue *b); 52 53 int rb_compare_gtimeval (GTimeVal *a, GTimeVal *b); 54 int rb_safe_strcmp (const char *a, const char *b); 55 char *rb_make_time_string (guint seconds); 56 char *rb_make_duration_string (guint duration); 57 char *rb_make_elapsed_time_string (guint elapsed, guint duration, gboolean show_remaining); 58 59 void rb_threads_init (void); 60 gboolean rb_is_main_thread (void); 61 62 gchar* rb_search_fold (const char *original); 63 gchar** rb_string_split_words (const gchar *string); 64 65 gboolean rb_string_list_equal (GList *a, GList *b); 66 gboolean rb_string_list_contains (GList *list, const char *s); 67 GList* rb_string_list_copy (GList *list); 68 69 void rb_list_deep_free (GList *list); 70 void rb_list_destroy_free (GList *list, GDestroyNotify destroyer); 71 void rb_slist_deep_free (GSList *list); 72 73 gboolean rb_str_in_strv (const char *needle, const char **haystack); 74 75 GList* rb_collate_hash_table_keys (GHashTable *table); 76 GList* rb_collate_hash_table_values (GHashTable *table); 77 78 GList* rb_uri_list_parse (const char *uri_list); 79 80 gboolean rb_signal_accumulator_object_handled (GSignalInvocationHint *hint, 81 GValue *return_accu, 82 const GValue *handler_return, 83 gpointer dummy); 84 gboolean rb_signal_accumulator_value_handled (GSignalInvocationHint *hint, 85 GValue *return_accu, 86 const GValue *handler_return, 87 gpointer dummy); 88 gboolean rb_signal_accumulator_boolean_or (GSignalInvocationHint *hint, 89 GValue *return_accu, 90 const GValue *handler_return, 91 gpointer dummy); 92 gboolean rb_signal_accumulator_value_array (GSignalInvocationHint *hint, 93 GValue *return_accu, 94 const GValue *handler_return, 95 gpointer dummy); 96 void rb_value_array_append_data (GArray *array, GType type, ...); 97 void rb_value_free (GValue *val); /* g_value_unset, g_slice_free */ 98 99 void rb_assert_locked (GMutex *mutex); 100 101 void rb_set_tree_view_column_fixed_width (GtkWidget *treeview, 102 GtkTreeViewColumn *column, 103 GtkCellRenderer *renderer, 104 const char **strings, 105 int padding); 106 107 GdkPixbuf *rb_scale_pixbuf_to_size (GdkPixbuf *pixbuf, 108 GtkIconSize size); 109 110 typedef void (*RBDelayedSyncFunc)(GSettings *settings, gpointer data); 111 112 void rb_settings_delayed_sync (GSettings *settings, RBDelayedSyncFunc sync_func, gpointer data, GDestroyNotify destroy); 113 114 void rb_menu_update_link (GMenu *menu, const char *link_attr, GMenuModel *target); 115 116 G_END_DECLS 117 118 #endif /* __RB_UTIL_H */ 119