~ubuntu-branches/ubuntu/precise/rhythmbox/precise-201203091205

« back to all changes in this revision

Viewing changes to sources/rb-source.c

Tags: upstream-0.9.5
ImportĀ upstreamĀ versionĀ 0.9.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 
2
 *
2
3
 *  arch-tag: Implementation of the abstract base class of all sources
3
4
 *
4
5
 *  Copyright (C) 2002 Jorn Baayen <jorn@nl.linux.org>
16
17
 *
17
18
 *  You should have received a copy of the GNU General Public License
18
19
 *  along with this program; if not, write to the Free Software
19
 
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
20
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA.
20
21
 *
21
22
 */
22
23
 
23
 
#include <config.h>
24
 
#include <libgnome/gnome-i18n.h>
 
24
#include "config.h"
 
25
 
 
26
#include <time.h>
 
27
#include <string.h>
 
28
 
 
29
#include <glib/gi18n.h>
25
30
#include <gtk/gtkuimanager.h>
26
 
#include <time.h>
27
 
 
28
31
 
29
32
#include "rb-cut-and-paste-code.h"
30
33
#include "rb-debug.h"
46
49
                                        GValue *value,
47
50
                                        GParamSpec *pspec);
48
51
 
49
 
static const char * default_get_browser_key (RBSource *source);
50
 
static GList *default_get_extra_views (RBSource *source);
 
52
static char * default_get_browser_key (RBSource *source);
 
53
static GList *default_get_property_views (RBSource *source);
51
54
static gboolean default_can_rename (RBSource *source);
52
55
static gboolean default_can_search (RBSource *source);
53
 
static GdkPixbuf *default_get_pixbuf (RBSource *source);
54
56
static GList *default_copy (RBSource *source);
55
57
static void default_reset_filters (RBSource *source);
56
58
static void default_song_properties (RBSource *source);
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);
66
71
 
67
72
static void rb_source_row_deleted_cb (GtkTreeModel *model,
68
73
                                      GtkTreePath *path,
82
87
        gboolean visible;
83
88
        RhythmDBQueryModel *query_model;
84
89
        guint idle_status_changed_id;
 
90
        GdkPixbuf *pixbuf;
 
91
        RBSourceListGroup sourcelist_group;
85
92
};
86
93
 
87
94
enum
88
95
{
89
96
        PROP_0,
90
97
        PROP_NAME,
 
98
        PROP_ICON,
91
99
        PROP_SHELL,
92
100
        PROP_UI_MANAGER,
93
101
        PROP_VISIBLE,
94
 
        PROP_QUERY_MODEL
 
102
        PROP_QUERY_MODEL,
 
103
        PROP_SOURCELIST_GROUP
95
104
};
96
105
 
97
106
enum
116
125
 
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;
135
147
        klass->impl_delete_thyself = default_delete_thyself;
136
148
        klass->impl_activate = default_activate;
137
149
        klass->impl_deactivate = default_deactivate;
138
 
        klass->impl_disconnect = default_disconnect;
139
150
        klass->impl_try_playlist = default_try_playlist;
140
151
        klass->impl_add_to_queue = default_add_to_queue;
141
152
        klass->impl_get_status = default_get_status;
 
153
        klass->impl_get_ui_actions = default_get_ui_actions;
 
154
        klass->impl_get_search_actions = default_get_search_actions;
 
155
        klass->impl_move_to_trash = default_move_to_trash;
142
156
 
143
157
        g_object_class_install_property (object_class,
144
158
                                         PROP_NAME,
147
161
                                                              "Interface name",
148
162
                                                              NULL,
149
163
                                                              G_PARAM_READWRITE));
 
164
        g_object_class_install_property (object_class,
 
165
                                         PROP_ICON,
 
166
                                         g_param_spec_object ("icon",
 
167
                                                              "Icon",
 
168
                                                              "Source Icon",
 
169
                                                              GDK_TYPE_PIXBUF,
 
170
                                                              G_PARAM_READWRITE));
150
171
 
151
172
        g_object_class_install_property (object_class,
152
173
                                         PROP_SHELL,
186
207
                                                              "RhythmDBQueryModel object",
187
208
                                                              RHYTHMDB_TYPE_QUERY_MODEL,
188
209
                                                              G_PARAM_READWRITE));
 
210
        g_object_class_install_property (object_class,
 
211
                                         PROP_SOURCELIST_GROUP,
 
212
                                         g_param_spec_enum ("sourcelist-group",
 
213
                                                            "sourcelist group",
 
214
                                                            "sourcelist group",
 
215
                                                            RB_TYPE_SOURCELIST_GROUP,
 
216
                                                            RB_SOURCELIST_GROUP_FIXED,
 
217
                                                            G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
189
218
 
190
219
        rb_source_signals[DELETED] =
191
220
                g_signal_new ("deleted",
250
279
                g_source_remove (priv->idle_status_changed_id);
251
280
        
252
281
        g_object_unref (G_OBJECT (priv->query_model));
253
 
        
 
282
 
 
283
        if (priv->pixbuf != NULL) {
 
284
                g_object_unref (priv->pixbuf);
 
285
        }
 
286
 
254
287
        g_free (priv->name);
255
288
 
256
289
        G_OBJECT_CLASS (rb_source_parent_class)->finalize (object);
257
290
}
258
291
 
 
292
void
 
293
rb_source_set_pixbuf (RBSource  *source,
 
294
                      GdkPixbuf *pixbuf)
 
295
{
 
296
        RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (source);
 
297
 
 
298
        g_return_if_fail (RB_IS_SOURCE (source));
 
299
 
 
300
        if (priv->pixbuf != NULL) {
 
301
                g_object_unref (priv->pixbuf);
 
302
        }
 
303
 
 
304
        priv->pixbuf = pixbuf;
 
305
 
 
306
        if (priv->pixbuf != NULL) {
 
307
                g_object_ref (priv->pixbuf);
 
308
        }
 
309
}
 
310
 
259
311
static void
260
312
rb_source_set_property (GObject *object,
261
 
                      guint prop_id,
262
 
                      const GValue *value,
263
 
                      GParamSpec *pspec)
 
313
                        guint prop_id,
 
314
                        const GValue *value,
 
315
                        GParamSpec *pspec)
264
316
{
265
317
        RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (object);
266
318
        RhythmDBQueryModel *model;
267
319
        RBSource *source = RB_SOURCE (object);
268
320
 
269
 
        switch (prop_id)
270
 
        {
 
321
        switch (prop_id) {
271
322
        case PROP_NAME:
272
323
                g_free (priv->name);
273
324
                priv->name = g_strdup (g_value_get_string (value));
274
325
                break;
 
326
        case PROP_ICON:
 
327
                rb_source_set_pixbuf (source, g_value_get_object (value));
 
328
                break;
275
329
        case PROP_SHELL:
276
330
                priv->shell = g_value_get_object (value);
277
331
                break;
310
364
                /* g_object_notify (G_OBJECT (source), "query-model"); */
311
365
                rb_source_notify_status_changed (source);
312
366
                break;
 
367
        case PROP_SOURCELIST_GROUP:
 
368
                priv->sourcelist_group = g_value_get_enum (value);
 
369
                break;
313
370
        default:
314
371
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
315
372
                break;
318
375
 
319
376
static void 
320
377
rb_source_get_property (GObject *object,
321
 
                      guint prop_id,
322
 
                      GValue *value,
323
 
                      GParamSpec *pspec)
 
378
                        guint prop_id,
 
379
                        GValue *value,
 
380
                        GParamSpec *pspec)
324
381
{
325
382
        RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (object);
326
383
 
327
 
        switch (prop_id)
328
 
        {
 
384
        switch (prop_id) {
329
385
        case PROP_NAME:
330
386
                g_value_set_string (value, priv->name);
331
387
                break;
 
388
        case PROP_ICON:
 
389
                g_value_set_object (value, priv->pixbuf);
 
390
                break;
332
391
        case PROP_SHELL:
333
392
                g_value_set_object (value, priv->shell);
334
393
                break;
348
407
        case PROP_QUERY_MODEL:
349
408
                g_value_set_object (value, priv->query_model);
350
409
                break;
 
410
        case PROP_SOURCELIST_GROUP:
 
411
                g_value_set_enum (value, priv->sourcelist_group);
 
412
                break;
351
413
        default:
352
414
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
353
415
                break;
354
416
        }
355
417
}
356
418
 
357
 
static char *
358
 
default_get_status (RBSource *source)
 
419
static void
 
420
default_get_status (RBSource *source, char **text, char **progress_text, float *progress)
359
421
{
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);
363
 
 
364
 
        return g_strdup ("");
 
423
        /* hack to get these strings marked for translation */
 
424
        if (0) {
 
425
                ngettext ("%d song", "%d songs", 0);
 
426
        }
 
427
        if (priv->query_model) {
 
428
                *text = rhythmdb_query_model_compute_status_normal (priv->query_model, 
 
429
                                                                    "%d song", 
 
430
                                                                    "%d songs");
 
431
                if (rhythmdb_query_model_has_pending_changes (priv->query_model))
 
432
                        *progress = -1.0f;
 
433
        } else {
 
434
                *text = g_strdup ("");
 
435
        }
365
436
}
366
437
 
367
438
/**
368
439
 * rb_source_get_status:
369
440
 * @status: a #RBSource
370
 
 *
371
 
 * FIXME:
372
 
 * Some Random comments
373
 
 *
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
 
444
 *
 
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.
375
449
 **/
 
450
void
 
451
rb_source_get_status (RBSource *source, char **text, char **progress_text, float *progress)
 
452
{
 
453
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
 
454
 
 
455
        klass->impl_get_status (source, text, progress_text, progress);
 
456
}
 
457
 
 
458
static char *
 
459
default_get_browser_key (RBSource *source)
 
460
{
 
461
        return NULL;
 
462
}
 
463
 
376
464
char *
377
 
rb_source_get_status (RBSource *source)
378
 
{
379
 
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
380
 
 
381
 
        return klass->impl_get_status (source);
382
 
}
383
 
 
384
 
static const char *
385
 
default_get_browser_key (RBSource *source)
386
 
{
387
 
        return NULL;
388
 
}
389
 
 
390
 
const char *
391
465
rb_source_get_browser_key (RBSource *source)
392
466
{
393
467
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
404
478
}
405
479
 
406
480
void
 
481
rb_source_browser_toggled (RBSource *source, gboolean enabled)
 
482
{
 
483
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
 
484
 
 
485
        if (klass->impl_browser_toggled != NULL)
 
486
                klass->impl_browser_toggled (source, enabled);
 
487
}
 
488
 
 
489
void
407
490
rb_source_notify_status_changed (RBSource *source)
408
491
{
409
492
        g_signal_emit (G_OBJECT (source), rb_source_signals[STATUS_CHANGED], 0);
424
507
 
425
508
        g_value_init (&value, G_TYPE_ULONG);
426
509
 
427
 
        current_count = entry->play_count;
 
510
        current_count = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_PLAY_COUNT);
428
511
 
429
512
        g_value_set_ulong (&value, current_count + 1);
430
513
 
452
535
}
453
536
 
454
537
static GList *
455
 
default_get_extra_views (RBSource *source)
 
538
default_get_property_views (RBSource *source)
456
539
{
457
540
        return NULL;
458
541
}
459
542
 
460
543
GList *
461
 
rb_source_get_extra_views (RBSource *source)
462
 
{
463
 
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
464
 
 
465
 
        return klass->impl_get_extra_views (source);
466
 
}
467
 
 
468
 
static GdkPixbuf *
469
 
default_get_pixbuf (RBSource *source)
470
 
{
471
 
        return NULL;
472
 
}
473
 
 
474
 
GdkPixbuf *
475
 
rb_source_get_pixbuf (RBSource *source)
476
 
{
477
 
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
478
 
 
479
 
        return klass->impl_get_pixbuf (source);
 
544
rb_source_get_property_views (RBSource *source)
 
545
{
 
546
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
 
547
 
 
548
        return klass->impl_get_property_views (source);
480
549
}
481
550
 
482
551
static gboolean
489
558
rb_source_can_rename (RBSource *source)
490
559
{
491
560
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
 
561
        RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (source);
 
562
 
 
563
        if (rb_shell_get_party_mode (priv->shell)) {
 
564
                return FALSE;
 
565
        }
492
566
 
493
567
        return klass->impl_can_rename (source);
494
568
}
538
612
}
539
613
 
540
614
gboolean
 
615
rb_source_can_paste (RBSource *source)
 
616
{
 
617
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
 
618
 
 
619
        return klass->impl_can_paste (source);
 
620
}
 
621
 
 
622
gboolean
541
623
rb_source_can_delete (RBSource *source)
542
624
{
543
625
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
 
626
        RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (source);
 
627
 
 
628
        if (rb_shell_get_party_mode (priv->shell)) {
 
629
                return FALSE;
 
630
        }
544
631
 
545
632
        return klass->impl_can_delete (source);
546
633
}
549
636
rb_source_can_move_to_trash (RBSource *source)
550
637
{
551
638
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
 
639
        RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (source);
 
640
 
 
641
        if (rb_shell_get_party_mode (priv->shell)) {
 
642
                return FALSE;
 
643
        }
552
644
 
553
645
        return klass->impl_can_move_to_trash (source);
554
646
}
631
723
        klass->impl_delete (source);
632
724
}
633
725
 
 
726
static void
 
727
default_move_to_trash (RBSource *source)
 
728
{
 
729
        GList *sel, *tem;
 
730
        RBEntryView *entry_view;
 
731
        RhythmDB *db;
 
732
        RBSourcePrivate *priv = RB_SOURCE_GET_PRIVATE (source);
 
733
 
 
734
        g_object_get (G_OBJECT (priv->shell), "db", &db, NULL);
 
735
 
 
736
        entry_view = rb_source_get_entry_view (source);
 
737
        sel = rb_entry_view_get_selected_entries (entry_view);
 
738
        for (tem = sel; tem != NULL; tem = tem->next) {
 
739
                rhythmdb_entry_move_to_trash (db, (RhythmDBEntry *)tem->data);
 
740
                rhythmdb_commit (db);
 
741
        }
 
742
        g_list_free (sel);
 
743
        g_object_unref (G_OBJECT (db));
 
744
}
 
745
 
 
746
 
634
747
void
635
748
rb_source_move_to_trash (RBSource *source)
636
749
{
763
876
        g_signal_emit (G_OBJECT (source), rb_source_signals[DELETED], 0);
764
877
}
765
878
 
 
879
static RBEntryView*
 
880
default_get_entry_view (RBSource *source)
 
881
{
 
882
        return NULL;
 
883
}
 
884
 
766
885
static void default_activate (RBSource *source)
767
886
{
768
887
        return;
773
892
        return;
774
893
}
775
894
 
776
 
static gboolean default_disconnect (RBSource *source)
777
 
{
778
 
        return TRUE;
779
 
}
780
 
 
781
895
void rb_source_activate (RBSource *source)
782
896
{
783
897
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
796
910
        return;
797
911
}
798
912
 
799
 
gboolean rb_source_disconnect (RBSource *source)
800
 
{
801
 
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
802
 
 
803
 
        return klass->impl_disconnect (source);
 
913
static GList *
 
914
default_get_ui_actions (RBSource *source)
 
915
{
 
916
        return NULL;
 
917
}
 
918
 
 
919
GList *
 
920
rb_source_get_ui_actions (RBSource *source)
 
921
{
 
922
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
 
923
 
 
924
        return klass->impl_get_ui_actions (source);
 
925
}
 
926
 
 
927
static GList *
 
928
default_get_search_actions (RBSource *source)
 
929
{
 
930
        return NULL;
 
931
}
 
932
 
 
933
GList *
 
934
rb_source_get_search_actions (RBSource *source)
 
935
{
 
936
        RBSourceClass *klass = RB_SOURCE_GET_CLASS (source);
 
937
 
 
938
        return klass->impl_get_search_actions (source);
804
939
}
805
940
 
806
941
static void
836
971
        }
837
972
}
838
973
 
839
 
 
 
974
static void
 
975
rb_source_gather_hash_keys (char *key, gpointer unused, GList **data)
 
976
{
 
977
        *data = g_list_prepend (*data, key);
 
978
}
 
979
 
 
980
GList *
 
981
rb_source_gather_selected_properties (RBSource *source,
 
982
                                      RhythmDBPropType prop)
 
983
{
 
984
        GList *selected, *tem;
 
985
        GHashTable *selected_set;
 
986
 
 
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);
 
993
        }
 
994
 
 
995
        g_list_free (selected);
 
996
        
 
997
        tem = NULL;
 
998
        g_hash_table_foreach (selected_set, (GHFunc) rb_source_gather_hash_keys,
 
999
                              &tem);
 
1000
        g_hash_table_destroy (selected_set);
 
1001
        return tem;
 
1002
}
 
1003
 
 
1004
GtkActionGroup *
 
1005
_rb_source_register_action_group (RBSource *source,
 
1006
                                  const char *group_name,
 
1007
                                  GtkActionEntry *actions,
 
1008
                                  int num_actions,
 
1009
                                  gpointer user_data)
 
1010
{
 
1011
        GtkUIManager *uimanager;
 
1012
        GList *actiongroups;
 
1013
        GList *i;
 
1014
        GtkActionGroup *group;
 
1015
 
 
1016
        g_object_get (G_OBJECT (source), "ui-manager", &uimanager, NULL);
 
1017
        actiongroups = gtk_ui_manager_get_action_groups (uimanager);
 
1018
 
 
1019
        /* Don't create the action group if it's already registered */
 
1020
        for (i = actiongroups; i != NULL; i = i->next) {
 
1021
                const gchar *name;
 
1022
 
 
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);
 
1027
                }
 
1028
        }
 
1029
 
 
1030
        group = gtk_action_group_new (group_name);
 
1031
        gtk_action_group_set_translation_domain (group,
 
1032
                                                 GETTEXT_PACKAGE);
 
1033
        gtk_action_group_add_actions (group,
 
1034
                                      actions, num_actions,
 
1035
                                      user_data);
 
1036
        gtk_ui_manager_insert_action_group (uimanager, group, 0);
 
1037
        g_object_unref (G_OBJECT (uimanager));
 
1038
 
 
1039
        return group;
 
1040
}
 
1041
 
 
1042
static void
 
1043
_autohide_update_visibility (RBSource *source, GtkTreeModel *model, int adjust)
 
1044
{
 
1045
        gint count = gtk_tree_model_iter_n_children (model, NULL) + adjust;
 
1046
        /* only update the property if it will have actually changed */
 
1047
        if (count < 2)
 
1048
                g_object_set (G_OBJECT (source), "visibility", (count > 0), NULL);
 
1049
}
 
1050
 
 
1051
static void
 
1052
_rb_autohide_source_row_deleted_cb (GtkTreeModel *model,
 
1053
                                    GtkTreePath *path,
 
1054
                                    RBSource *source)
 
1055
{
 
1056
        _autohide_update_visibility (source, model, -1);
 
1057
}
 
1058
 
 
1059
static void
 
1060
_rb_autohide_source_row_inserted_cb (GtkTreeModel *model,
 
1061
                                     GtkTreePath *path,
 
1062
                                     GtkTreeIter *iter,
 
1063
                                     RBSource *source)
 
1064
{
 
1065
        _autohide_update_visibility (source, model, 0);
 
1066
}
 
1067
 
 
1068
void
 
1069
_rb_source_hide_when_empty (RBSource *source,
 
1070
                            RhythmDBQueryModel *model)
 
1071
{
 
1072
        g_signal_connect_object (G_OBJECT (model), "row-deleted",
 
1073
                                 G_CALLBACK (_rb_autohide_source_row_deleted_cb),
 
1074
                                 source, 0);
 
1075
        g_signal_connect_object (G_OBJECT (model), "row-inserted",
 
1076
                                 G_CALLBACK (_rb_autohide_source_row_inserted_cb),
 
1077
                                 source, 0);
 
1078
}
 
1079
 
 
1080
/* This should really be standard. */
 
1081
#define ENUM_ENTRY(NAME, DESC) { NAME, "" #NAME "", DESC }
 
1082
 
 
1083
GType
 
1084
rb_source_eof_type_get_type (void)
 
1085
{
 
1086
        static GType etype = 0;
 
1087
 
 
1088
        if (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"),
 
1094
                        { 0, 0, 0 }
 
1095
                };
 
1096
 
 
1097
                etype = g_enum_register_static ("RBSourceEOFType", values);
 
1098
        }
 
1099
 
 
1100
        return etype;
 
1101
}
 
1102
 
 
1103
GType
 
1104
rb_sourcelist_group_get_type (void)
 
1105
{
 
1106
        static GType etype = 0;
 
1107
 
 
1108
        if (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)"),
 
1114
                        { 0, 0, 0 }
 
1115
                };
 
1116
 
 
1117
                etype = g_enum_register_static ("RBSourcelistGroupType", values);
 
1118
        }
 
1119
 
 
1120
        return etype;
 
1121
}