58
60
static RBSourceEOFType default_handle_eos (RBSource *source);
59
61
static gboolean default_show_popup (RBSource *source);
60
62
static void default_delete_thyself (RBSource *source);
63
static RBEntryView* default_get_entry_view (RBSource *source);
61
64
static void default_activate (RBSource *source);
62
65
static void default_deactivate (RBSource *source);
63
static gboolean default_disconnect (RBSource *source);
64
66
static void default_add_to_queue (RBSource *source, RBSource *queue);
65
static char *default_get_status (RBSource *source);
67
static void default_get_status (RBSource *source, char **text, char **progress_text, float *progress);
68
static void default_move_to_trash (RBSource *source);
69
static GList * default_get_ui_actions (RBSource *source);
70
static GList * default_get_search_actions (RBSource *source);
67
72
static void rb_source_row_deleted_cb (GtkTreeModel *model,
117
126
klass->impl_can_browse = (RBSourceFeatureFunc) rb_false_function;
118
127
klass->impl_get_browser_key = default_get_browser_key;
119
klass->impl_get_extra_views = default_get_extra_views;
128
klass->impl_browser_toggled = NULL;
129
klass->impl_get_property_views = default_get_property_views;
120
130
klass->impl_can_rename = default_can_rename;
121
131
klass->impl_can_search = default_can_search;
122
132
klass->impl_can_cut = (RBSourceFeatureFunc) rb_false_function;
133
klass->impl_can_paste = (RBSourceFeatureFunc) rb_false_function;
123
134
klass->impl_can_delete = (RBSourceFeatureFunc) rb_false_function;
124
135
klass->impl_can_copy = (RBSourceFeatureFunc) rb_false_function;
125
136
klass->impl_can_add_to_queue = (RBSourceFeatureFunc) rb_false_function;
126
137
klass->impl_can_move_to_trash = (RBSourceFeatureFunc) rb_false_function;
127
klass->impl_get_pixbuf = default_get_pixbuf;
138
klass->impl_get_entry_view = default_get_entry_view;
139
klass->impl_have_url = (RBSourceFeatureFunc) rb_false_function;
128
140
klass->impl_copy = default_copy;
129
141
klass->impl_reset_filters = default_reset_filters;
130
142
klass->impl_song_properties = default_song_properties;
250
279
g_source_remove (priv->idle_status_changed_id);
252
281
g_object_unref (G_OBJECT (priv->query_model));
283
if (priv->pixbuf != NULL) {
284
g_object_unref (priv->pixbuf);
254
287
g_free (priv->name);
256
289
G_OBJECT_CLASS (rb_source_parent_class)->finalize (object);
293
rb_source_set_pixbuf (RBSource *source,
296
RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (source);
298
g_return_if_fail (RB_IS_SOURCE (source));
300
if (priv->pixbuf != NULL) {
301
g_object_unref (priv->pixbuf);
304
priv->pixbuf = pixbuf;
306
if (priv->pixbuf != NULL) {
307
g_object_ref (priv->pixbuf);
260
312
rb_source_set_property (GObject *object,
265
317
RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (object);
266
318
RhythmDBQueryModel *model;
267
319
RBSource *source = RB_SOURCE (object);
272
323
g_free (priv->name);
273
324
priv->name = g_strdup (g_value_get_string (value));
327
rb_source_set_pixbuf (source, g_value_get_object (value));
276
330
priv->shell = g_value_get_object (value);
348
407
case PROP_QUERY_MODEL:
349
408
g_value_set_object (value, priv->query_model);
410
case PROP_SOURCELIST_GROUP:
411
g_value_set_enum (value, priv->sourcelist_group);
352
414
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
358
default_get_status (RBSource *source)
420
default_get_status (RBSource *source, char **text, char **progress_text, float *progress)
360
422
RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (source);
361
if (priv->query_model)
362
return rhythmdb_query_model_compute_status_normal (priv->query_model);
364
return g_strdup ("");
423
/* hack to get these strings marked for translation */
425
ngettext ("%d song", "%d songs", 0);
427
if (priv->query_model) {
428
*text = rhythmdb_query_model_compute_status_normal (priv->query_model,
431
if (rhythmdb_query_model_has_pending_changes (priv->query_model))
434
*text = g_strdup ("");
368
439
* rb_source_get_status:
369
440
* @status: a #RBSource
372
* Some Random comments
374
* Returns: The status string
441
* @text: holds the returned status text (allocated)
442
* @progress_text: holds the returned text for the progress bar (allocated)
443
* @progress: holds the progress value
445
* Returns the details to display in the status bar for the source.
446
* If the progress value returned is less than zero, the progress bar
447
* will pulse. If the progress value is greater than or equal to 1,
448
* the progress bar will be hidden.
451
rb_source_get_status (RBSource *source, char **text, char **progress_text, float *progress)
453
RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
455
klass->impl_get_status (source, text, progress_text, progress);
459
default_get_browser_key (RBSource *source)
377
rb_source_get_status (RBSource *source)
379
RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
381
return klass->impl_get_status (source);
385
default_get_browser_key (RBSource *source)
391
465
rb_source_get_browser_key (RBSource *source)
393
467
RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
975
rb_source_gather_hash_keys (char *key, gpointer unused, GList **data)
977
*data = g_list_prepend (*data, key);
981
rb_source_gather_selected_properties (RBSource *source,
982
RhythmDBPropType prop)
984
GList *selected, *tem;
985
GHashTable *selected_set;
987
selected_set = g_hash_table_new (g_str_hash, g_str_equal);
988
selected = rb_entry_view_get_selected_entries (rb_source_get_entry_view (RB_SOURCE (source)));
989
for (tem = selected; tem; tem = tem->next) {
990
RhythmDBEntry *entry = tem->data;
991
char *val = g_strdup (rhythmdb_entry_get_string (entry, prop));
992
g_hash_table_insert (selected_set, val, NULL);
995
g_list_free (selected);
998
g_hash_table_foreach (selected_set, (GHFunc) rb_source_gather_hash_keys,
1000
g_hash_table_destroy (selected_set);
1005
_rb_source_register_action_group (RBSource *source,
1006
const char *group_name,
1007
GtkActionEntry *actions,
1011
GtkUIManager *uimanager;
1012
GList *actiongroups;
1014
GtkActionGroup *group;
1016
g_object_get (G_OBJECT (source), "ui-manager", &uimanager, NULL);
1017
actiongroups = gtk_ui_manager_get_action_groups (uimanager);
1019
/* Don't create the action group if it's already registered */
1020
for (i = actiongroups; i != NULL; i = i->next) {
1023
name = gtk_action_group_get_name (GTK_ACTION_GROUP (i->data));
1024
if (strcmp (name, group_name) == 0) {
1025
g_object_unref (G_OBJECT (uimanager));
1026
return GTK_ACTION_GROUP (i->data);
1030
group = gtk_action_group_new (group_name);
1031
gtk_action_group_set_translation_domain (group,
1033
gtk_action_group_add_actions (group,
1034
actions, num_actions,
1036
gtk_ui_manager_insert_action_group (uimanager, group, 0);
1037
g_object_unref (G_OBJECT (uimanager));
1043
_autohide_update_visibility (RBSource *source, GtkTreeModel *model, int adjust)
1045
gint count = gtk_tree_model_iter_n_children (model, NULL) + adjust;
1046
/* only update the property if it will have actually changed */
1048
g_object_set (G_OBJECT (source), "visibility", (count > 0), NULL);
1052
_rb_autohide_source_row_deleted_cb (GtkTreeModel *model,
1056
_autohide_update_visibility (source, model, -1);
1060
_rb_autohide_source_row_inserted_cb (GtkTreeModel *model,
1065
_autohide_update_visibility (source, model, 0);
1069
_rb_source_hide_when_empty (RBSource *source,
1070
RhythmDBQueryModel *model)
1072
g_signal_connect_object (G_OBJECT (model), "row-deleted",
1073
G_CALLBACK (_rb_autohide_source_row_deleted_cb),
1075
g_signal_connect_object (G_OBJECT (model), "row-inserted",
1076
G_CALLBACK (_rb_autohide_source_row_inserted_cb),
1080
/* This should really be standard. */
1081
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
1084
rb_source_eof_type_get_type (void)
1086
static GType etype = 0;
1089
static const GEnumValue values[] = {
1090
ENUM_ENTRY (RB_SOURCE_EOF_ERROR, "Display error when playing entry ends"),
1091
ENUM_ENTRY (RB_SOURCE_EOF_STOP, "Stop playback when playing entry ends"),
1092
ENUM_ENTRY (RB_SOURCE_EOF_RETRY, "Restart playing when playing entry ends"),
1093
ENUM_ENTRY (RB_SOURCE_EOF_NEXT, "Start next entry when playing entry ends"),
1097
etype = g_enum_register_static ("RBSourceEOFType", values);
1104
rb_sourcelist_group_get_type (void)
1106
static GType etype = 0;
1109
static const GEnumValue values[] = {
1110
ENUM_ENTRY (RB_SOURCELIST_GROUP_FIXED, "Fixed single instance source"),
1111
ENUM_ENTRY (RB_SOURCELIST_GROUP_PERSISTANT, "Persistant multiple-instance source"),
1112
ENUM_ENTRY (RB_SOURCELIST_GROUP_REMOVABLE, "Source representing a removable device"),
1113
ENUM_ENTRY (RB_SOURCELIST_GROUP_TRANSIENT, "Transient source (eg. network shares)"),
1117
etype = g_enum_register_static ("RBSourcelistGroupType", values);