94
91
GDestroyNotify destroy_data);
96
static void rb_library_source_ui_prefs_sync (RBLibrarySource *source);
97
static void rb_library_source_preferences_sync (RBLibrarySource *source);
99
static void rb_library_source_library_location_changed (GConfClient *client,
102
RBLibrarySource *source);
103
static void rb_library_source_layout_path_changed (GConfClient *client,
106
RBLibrarySource *source);
107
static void rb_library_source_layout_filename_changed (GConfClient *client,
110
RBLibrarySource *source);
111
static void rb_library_source_edit_profile_clicked_cb (GtkButton *button,
112
RBLibrarySource *source);
113
static void rb_library_source_ui_pref_changed (GConfClient *client,
116
RBLibrarySource *source);
93
static void library_settings_changed_cb (GSettings *settings, const char *key, RBLibrarySource *source);
94
static void db_settings_changed_cb (GSettings *settings, const char *key, RBLibrarySource *source);
117
95
static gboolean rb_library_source_library_location_cb (GtkEntry *entry,
118
96
GdkEventFocus *event,
119
97
RBLibrarySource *source);
120
static void rb_library_source_watch_toggled_cb (GtkToggleButton *button,
121
RBLibrarySource *source);
122
98
static void rb_library_source_sync_child_sources (RBLibrarySource *source);
123
99
static void rb_library_source_path_changed_cb (GtkComboBox *box,
124
100
RBLibrarySource *source);
126
102
RBLibrarySource *source);
127
103
static void rb_library_source_format_changed_cb (GtkWidget *widget,
128
104
RBLibrarySource *source);
129
static void layout_example_label_update (RBLibrarySource *source);
105
static void rb_library_source_install_plugins_cb (GtkWidget *widget,
106
RBLibrarySource *source);
107
static void update_layout_example_label (RBLibrarySource *source);
130
108
static RhythmDBImportJob *maybe_create_import_job (RBLibrarySource *source);
132
#define CONF_UI_LIBRARY_DIR CONF_PREFIX "/ui/library"
133
#define CONF_STATE_LIBRARY_DIR CONF_PREFIX "/state/library"
134
#define CONF_STATE_LIBRARY_SORTING CONF_PREFIX "/state/library/sorting"
135
#define CONF_STATE_PANED_POSITION CONF_PREFIX "/state/library/paned_position"
136
#define CONF_STATE_SHOW_BROWSER CONF_PREFIX "/state/library/show_browser"
206
178
page_class->receive_drag = impl_receive_drag;
207
179
page_class->get_status = impl_get_status;
209
source_class->impl_get_browser_key = impl_get_browser_key;
210
181
source_class->impl_can_copy = (RBSourceFeatureFunc) rb_true_function;
211
182
source_class->impl_can_paste = (RBSourceFeatureFunc) impl_can_paste;
212
183
source_class->impl_paste = impl_paste;
213
184
source_class->impl_want_uri = impl_want_uri;
214
185
source_class->impl_add_uri = impl_add_uri;
216
browser_source_class->impl_get_paned_key = impl_get_paned_key;
217
187
browser_source_class->impl_has_drop_support = (RBBrowserSourceFeatureFunc) rb_true_function;
219
189
g_type_class_add_private (klass, sizeof (RBLibrarySourcePrivate));
221
gnome_media_profiles_init (eel_gconf_client_get_global ());
243
211
source->priv->db = NULL;
246
if (source->priv->ui_dir_notify_id != 0) {
247
eel_gconf_notification_remove (source->priv->ui_dir_notify_id);
248
source->priv->ui_dir_notify_id = 0;
251
if (source->priv->library_location_notify_id != 0) {
252
eel_gconf_notification_remove (source->priv->library_location_notify_id);
253
source->priv->library_location_notify_id = 0;
256
if (source->priv->layout_path_notify_id != 0) {
257
eel_gconf_notification_remove (source->priv->layout_path_notify_id);
258
source->priv->layout_path_notify_id = 0;
261
if (source->priv->layout_filename_notify_id != 0) {
262
eel_gconf_notification_remove (source->priv->layout_filename_notify_id);
263
source->priv->layout_filename_notify_id = 0;
214
if (source->priv->settings) {
215
g_object_unref (source->priv->settings);
216
source->priv->settings = NULL;
219
if (source->priv->db_settings) {
220
g_object_unref (source->priv->db_settings);
221
source->priv->db_settings = NULL;
266
224
if (source->priv->import_jobs != NULL) {
329
277
g_object_get (source, "shell", &shell, NULL);
330
278
g_object_get (shell, "db", &source->priv->db, NULL);
280
source->priv->settings = g_settings_new ("org.gnome.rhythmbox.library");
281
g_signal_connect_object (source->priv->settings, "changed", G_CALLBACK (library_settings_changed_cb), source, 0);
283
source->priv->db_settings = g_settings_new ("org.gnome.rhythmbox.rhythmdb");
284
g_signal_connect_object (source->priv->db_settings, "changed", G_CALLBACK (db_settings_changed_cb), source, 0);
332
286
g_signal_connect_object (source->priv->db, "load-complete", G_CALLBACK (db_load_complete_cb), source, 0);
334
rb_library_source_ui_prefs_sync (source);
336
288
/* Set up the default library location if there's no library location set */
337
list = eel_gconf_get_string_list (CONF_LIBRARY_LOCATION);
338
if (g_slist_length (list) == 0) {
289
locations = g_settings_get_strv (source->priv->db_settings, "locations");
290
if (g_strv_length (locations) == 0) {
339
291
char *music_dir_uri;
341
293
music_dir_uri = g_filename_to_uri (rb_music_dir (), NULL, NULL);
342
294
if (music_dir_uri != NULL) {
343
list = g_slist_prepend (list, music_dir_uri);
344
eel_gconf_set_string_list (CONF_LIBRARY_LOCATION, list);
347
/* ensure all library locations are URIs and not file paths */
349
gboolean update = FALSE;
350
for (t = list; t != NULL; t = t->next) {
353
location = (char *)t->data;
354
if (location[0] == '/') {
355
char *uri = g_filename_to_uri (location, NULL, NULL);
357
rb_debug ("converting library location path %s to URI %s", location, uri);
366
eel_gconf_set_string_list (CONF_LIBRARY_LOCATION, list);
295
const char *set_locations[2];
296
set_locations[0] = music_dir_uri;
297
set_locations[1] = NULL;
298
g_settings_set_strv (source->priv->db_settings, "locations", set_locations);
300
g_free (music_dir_uri);
369
rb_slist_deep_free (list);
371
source->priv->library_location_notify_id =
372
eel_gconf_notification_add (CONF_LIBRARY_LOCATION,
373
(GConfClientNotifyFunc) rb_library_source_library_location_changed, source);
375
source->priv->ui_dir_notify_id =
376
eel_gconf_notification_add (CONF_UI_LIBRARY_DIR,
377
(GConfClientNotifyFunc) rb_library_source_ui_pref_changed, source);
303
g_strfreev (locations);
379
305
songs = rb_source_get_entry_view (RB_SOURCE (source));
407
334
"audio-x-generic",
337
settings = g_settings_new ("org.gnome.rhythmbox.library");
410
338
source = RB_SOURCE (g_object_new (RB_TYPE_LIBRARY_SOURCE,
411
339
"name", _("Music"),
412
340
"entry-type", RHYTHMDB_ENTRY_TYPE_SONG,
413
"sorting-key", CONF_STATE_LIBRARY_SORTING,
416
343
"populate", FALSE, /* wait until the database is loaded */
344
"settings", g_settings_get_child (settings, "source"),
418
346
if (icon != NULL) {
419
347
g_object_unref (icon);
349
g_object_unref (settings);
422
351
rb_shell_register_entry_type_for_source (shell, source, RHYTHMDB_ENTRY_TYPE_SONG);
463
387
gtk_widget_destroy (GTK_WIDGET (dialog));
391
update_library_locations (RBLibrarySource *source)
395
if (source->priv->library_location_entry == NULL) {
399
locations = g_settings_get_strv (source->priv->db_settings, "locations");
401
/* don't trigger the change notification */
402
g_signal_handlers_block_by_func (G_OBJECT (source->priv->library_location_entry),
403
G_CALLBACK (rb_library_source_library_location_cb),
406
if (g_strv_length (locations) == 1) {
409
gtk_widget_set_sensitive (source->priv->library_location_entry, TRUE);
411
path = g_uri_unescape_string (locations[0], NULL);
412
gtk_entry_set_text (GTK_ENTRY (source->priv->library_location_entry), path);
414
} else if (g_strv_length (locations) == 0) {
415
/* no library directories */
416
gtk_widget_set_sensitive (source->priv->library_location_entry, TRUE);
417
gtk_entry_set_text (GTK_ENTRY (source->priv->library_location_entry), "");
419
/* multiple library directories */
420
gtk_widget_set_sensitive (source->priv->library_location_entry, FALSE);
421
gtk_entry_set_text (GTK_ENTRY (source->priv->library_location_entry), _("Multiple locations set"));
424
g_signal_handlers_unblock_by_func (G_OBJECT (source->priv->library_location_entry),
425
G_CALLBACK (rb_library_source_library_location_cb),
428
g_strfreev (locations);
432
update_layout_path (RBLibrarySource *source)
438
value = g_settings_get_string (source->priv->settings, "layout-path");
441
for (i = 0; library_layout_paths[i].path != NULL; i++) {
442
if (g_strcmp0 (library_layout_paths[i].path, value) == 0) {
449
if (source->priv->layout_path_menu != NULL) {
450
gtk_combo_box_set_active (GTK_COMBO_BOX (source->priv->layout_path_menu), active);
453
update_layout_example_label (source);
457
update_layout_filename (RBLibrarySource *source)
463
value = g_settings_get_string (source->priv->settings, "layout-filename");
466
for (i = 0; library_layout_filenames[i].path != NULL; i++) {
467
if (strcmp (library_layout_filenames[i].path, value) == 0) {
474
gtk_combo_box_set_active (GTK_COMBO_BOX (source->priv->layout_filename_menu), active);
476
update_layout_example_label (source);
480
update_preferred_media_type (RBLibrarySource *source)
487
str = g_settings_get_string (source->priv->settings, "preferred-media-type");
488
if (gtk_tree_model_get_iter_first (source->priv->profile_model, &iter)) {
492
gtk_tree_model_get (source->priv->profile_model, &iter,
495
if (g_strcmp0 (media_type, str) == 0) {
496
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (source->priv->preferred_format_menu), &iter);
500
} while (done == FALSE && gtk_tree_model_iter_next (source->priv->profile_model, &iter));
504
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (source->priv->preferred_format_menu), NULL);
511
db_settings_changed_cb (GSettings *settings, const char *key, RBLibrarySource *source)
513
if (g_strcmp0 (key, "locations") == 0) {
514
update_library_locations (source);
515
rb_library_source_sync_child_sources (source);
520
library_settings_changed_cb (GSettings *settings, const char *key, RBLibrarySource *source)
522
if (g_strcmp0 (key, "layout-path") == 0) {
523
rb_debug ("layout path changed");
524
update_layout_path (source);
525
} else if (g_strcmp0 (key, "layout-filename") == 0) {
526
rb_debug ("layout filename changed");
527
update_layout_filename (source);
528
} else if (g_strcmp0 (key, "preferred-media-type") == 0) {
529
rb_debug ("preferred media type changed");
530
update_preferred_media_type (source);
466
534
static GtkWidget *
467
535
impl_get_config_widget (RBDisplayPage *asource, RBShellPreferences *prefs)
469
537
RBLibrarySource *source = RB_LIBRARY_SOURCE (asource);
538
GtkCellRenderer *renderer;
539
GstEncodingTarget *target;
470
540
GtkBuilder *builder;
475
546
if (source->priv->config_widget)
531
601
_(library_layout_filenames[i].title));
534
tmp = gtk_builder_get_object (builder, "edit_profile_button");
604
/* not implemented yet */
605
tmp = gtk_builder_get_object (builder, "profile_settings_button");
535
606
g_signal_connect (tmp,
537
G_CALLBACK (rb_library_source_edit_profile_clicked_cb),
608
G_CALLBACK (rb_library_source_profile_settings_clicked_cb),
540
tmp = gtk_builder_get_object (builder, "preferred_format_menu_box");
541
label = gtk_builder_get_object (builder, "preferred_format_menu_label");
542
source->priv->preferred_format_menu = gm_audio_profile_choose_new ();
543
gtk_box_pack_start (GTK_BOX (tmp), source->priv->preferred_format_menu, TRUE, TRUE, 0);
544
gtk_label_set_mnemonic_widget (GTK_LABEL (label), source->priv->preferred_format_menu);
610
gtk_widget_set_sensitive (GTK_WIDGET (tmp), FALSE);
612
target = rb_gst_get_default_encoding_target ();
613
source->priv->profile_model = GTK_TREE_MODEL (gtk_tree_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER));
614
for (p = gst_encoding_target_get_profiles (target); p != NULL; p = p->next) {
615
GstEncodingProfile *profile = GST_ENCODING_PROFILE (p->data);
618
media_type = rb_gst_encoding_profile_get_media_type (profile);
619
if (media_type == NULL) {
622
gtk_tree_store_insert_with_values (GTK_TREE_STORE (source->priv->profile_model),
627
1, gst_encoding_profile_get_description (profile),
633
source->priv->preferred_format_menu = GTK_WIDGET (gtk_builder_get_object (builder, "format_select_combo"));
634
gtk_combo_box_set_model (GTK_COMBO_BOX (source->priv->preferred_format_menu), source->priv->profile_model);
635
gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (source->priv->preferred_format_menu), 1);
636
renderer = gtk_cell_renderer_text_new ();
637
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (source->priv->preferred_format_menu), renderer, TRUE);
638
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (source->priv->preferred_format_menu), renderer, "text", 1, NULL);
545
640
g_signal_connect (G_OBJECT (source->priv->preferred_format_menu),
547
642
G_CALLBACK (rb_library_source_format_changed_cb),
550
645
source->priv->layout_example_label = GTK_WIDGET (gtk_builder_get_object (builder, "layout_example_label"));
552
rb_library_source_preferences_sync (source);
647
source->priv->install_plugins_button = GTK_WIDGET (gtk_builder_get_object (builder, "install_plugins_button"));
648
gtk_widget_set_no_show_all (source->priv->install_plugins_button, TRUE);
649
g_signal_connect (G_OBJECT (source->priv->install_plugins_button), "clicked", G_CALLBACK (rb_library_source_install_plugins_cb), source);
651
update_library_locations (source);
652
update_preferred_media_type (source);
654
update_layout_path (source);
655
update_layout_filename (source);
554
657
return source->priv->config_widget;
558
rb_library_source_library_location_changed (GConfClient *client,
561
RBLibrarySource *source)
563
if (source->priv->config_widget)
564
rb_library_source_preferences_sync (source);
566
rb_library_source_sync_child_sources (source);
570
rb_library_source_ui_prefs_sync (RBLibrarySource *source)
572
if (source->priv->config_widget)
573
rb_library_source_preferences_sync (source);
577
rb_library_source_ui_pref_changed (GConfClient *client,
580
RBLibrarySource *source)
582
rb_debug ("ui pref changed");
583
rb_library_source_ui_prefs_sync (source);
587
rb_library_source_preferences_sync (RBLibrarySource *source)
591
GConfClient *gconf_client;
593
rb_debug ("syncing pref dialog state");
595
/* library location */
596
list = eel_gconf_get_string_list (CONF_LIBRARY_LOCATION);
598
/* don't trigger the change notification */
599
g_signal_handlers_block_by_func (G_OBJECT (source->priv->library_location_entry),
600
G_CALLBACK (rb_library_source_library_location_cb),
603
if (g_slist_length (list) == 1) {
606
gtk_widget_set_sensitive (source->priv->library_location_entry, TRUE);
608
path = g_uri_unescape_string (list->data, NULL);
609
gtk_entry_set_text (GTK_ENTRY (source->priv->library_location_entry), path);
611
} else if (g_slist_length (list) == 0) {
612
/* no library directories */
613
gtk_widget_set_sensitive (source->priv->library_location_entry, TRUE);
614
gtk_entry_set_text (GTK_ENTRY (source->priv->library_location_entry), "");
616
/* multiple library directories */
617
gtk_widget_set_sensitive (source->priv->library_location_entry, FALSE);
618
gtk_entry_set_text (GTK_ENTRY (source->priv->library_location_entry), _("Multiple locations set"));
621
g_signal_handlers_unblock_by_func (G_OBJECT (source->priv->library_location_entry),
622
G_CALLBACK (rb_library_source_library_location_cb),
625
rb_slist_deep_free (list);
628
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (source->priv->watch_library_check),
629
eel_gconf_get_boolean (CONF_MONITOR_LIBRARY));
631
/* preferred format */
632
str = eel_gconf_get_string (CONF_LIBRARY_PREFERRED_FORMAT);
634
gm_audio_profile_choose_set_active (source->priv->preferred_format_menu, str);
638
source->priv->layout_path_notify_id =
639
eel_gconf_notification_add (CONF_LIBRARY_LAYOUT_PATH,
640
(GConfClientNotifyFunc) rb_library_source_layout_path_changed, source);
641
source->priv->layout_filename_notify_id =
642
eel_gconf_notification_add (CONF_LIBRARY_LAYOUT_FILENAME,
643
(GConfClientNotifyFunc) rb_library_source_layout_filename_changed, source);
645
gconf_client = eel_gconf_client_get_global ();
647
rb_library_source_layout_path_changed (gconf_client, -1,
648
gconf_client_get_entry (gconf_client, CONF_LIBRARY_LAYOUT_PATH, NULL, TRUE, NULL),
650
/* layout filename */
651
rb_library_source_layout_filename_changed (gconf_client, -1,
652
gconf_client_get_entry (gconf_client, CONF_LIBRARY_LAYOUT_FILENAME, NULL, TRUE, NULL),
657
661
rb_library_source_library_location_cb (GtkEntry *entry,
658
662
GdkEventFocus *event,
659
663
RBLibrarySource *source)
662
665
const char *path;
666
const char *locations[2] = { NULL, NULL };
668
672
uri = g_file_get_uri (file);
669
673
g_object_unref (file);
672
list = g_slist_prepend (NULL, (gpointer)uri);
674
eel_gconf_set_string_list (CONF_LIBRARY_LOCATION, list);
676
rb_slist_deep_free (list);
679
g_settings_set_strv (source->priv->db_settings, "locations", locations);
682
rb_library_source_watch_toggled_cb (GtkToggleButton *button, RBLibrarySource *source)
686
active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (source->priv->watch_library_check));
687
eel_gconf_set_boolean (CONF_MONITOR_LIBRARY, active);
691
impl_get_browser_key (RBSource *source)
693
return g_strdup (CONF_STATE_SHOW_BROWSER);
697
impl_get_paned_key (RBBrowserSource *status)
699
return g_strdup (CONF_STATE_PANED_POSITION);
703
686
impl_receive_drag (RBDisplayPage *asource, GtkSelectionData *data)
772
756
index = gtk_combo_box_get_active (box);
773
757
if (index >= 0) {
774
758
filename = library_layout_filenames[index].path;
775
eel_gconf_set_string (CONF_LIBRARY_LAYOUT_FILENAME, filename);
759
g_settings_set_string (source->priv->settings, "layout-filename", filename);
780
764
rb_library_source_format_changed_cb (GtkWidget *widget, RBLibrarySource *source)
782
GMAudioProfile *profile;
784
profile = gm_audio_profile_choose_get_active (widget);
785
eel_gconf_set_string (CONF_LIBRARY_PREFERRED_FORMAT, gm_audio_profile_get_id (profile));
787
layout_example_label_update (source);
767
char *media_type = NULL;
768
GstEncodingProfile *profile;
771
/* get selected media type */
772
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter) == FALSE)
774
gtk_tree_model_get (GTK_TREE_MODEL (source->priv->profile_model),
780
g_settings_set_string (source->priv->settings, "preferred-media-type", media_type);
782
update_layout_example_label (source);
784
/* indicate whether additional plugins are required to encode in this format */
785
encoder = rb_encoder_new ();
786
if (rb_encoder_get_missing_plugins (encoder, profile, NULL, NULL)) {
787
rb_debug ("additional plugins are required to encode %s", media_type);
788
gtk_widget_set_visible (source->priv->install_plugins_button, TRUE);
789
/* not a great way to handle this situation; probably should describe
790
* the plugins that are missing when automatic install isn't available.
792
gtk_widget_set_sensitive (source->priv->install_plugins_button,
793
gst_install_plugins_supported ());
795
rb_debug ("can encode %s", media_type);
796
gtk_widget_set_visible (source->priv->install_plugins_button, FALSE);
802
plugin_install_done_cb (gpointer inst, gboolean retry, RBLibrarySource *source)
804
rb_library_source_format_changed_cb (source->priv->preferred_format_menu, source);
808
rb_library_source_install_plugins_cb (GtkWidget *widget, RBLibrarySource *source)
811
GstEncodingProfile *profile;
817
media_type = g_settings_get_string (source->priv->settings, "preferred-media-type");
818
profile = rb_gst_get_encoding_profile (media_type);
819
if (profile == NULL) {
820
g_warning ("no encoding profile available for %s, so how can we install plugins?",
827
/* get plugin details */
828
encoder = rb_encoder_new ();
829
if (rb_encoder_get_missing_plugins (encoder, profile, &details, NULL) == FALSE) {
831
g_object_unref (encoder);
835
/* attempt installation */
836
closure = g_cclosure_new ((GCallback) plugin_install_done_cb,
837
g_object_ref (source),
838
(GClosureNotify) g_object_unref);
839
g_closure_set_marshal (closure, g_cclosure_marshal_VOID__BOOLEAN);
841
rb_missing_plugins_install ((const char **)details, TRUE, closure);
843
g_closure_sink (closure);
844
g_strfreev (details);
911
string = sanitize_path (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM));
971
string = sanitize_path (strip_chars, rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM));
914
string = sanitize_path (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM_FOLDED));
974
string = sanitize_path (strip_chars, rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ALBUM_FOLDED));
917
string = sanitize_path (rb_refstring_get (albumartist));
977
string = sanitize_path (strip_chars, rb_refstring_get (albumartist));
920
string = sanitize_path (rb_refstring_get_folded (albumartist));
980
string = sanitize_path (strip_chars, rb_refstring_get_folded (albumartist));
923
string = sanitize_path (rb_refstring_get (albumartist_sort));
983
string = sanitize_path (strip_chars, rb_refstring_get (albumartist_sort));
926
string = sanitize_path (rb_refstring_get_folded (albumartist_sort));
986
string = sanitize_path (strip_chars, rb_refstring_get_folded (albumartist_sort));
929
989
string = g_strdup_printf ("%u", (guint)rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_YEAR));
955
string = sanitize_path (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE));
1015
string = sanitize_path (strip_chars, rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE));
958
string = sanitize_path (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE_FOLDED));
1018
string = sanitize_path (strip_chars, rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_TITLE_FOLDED));
961
string = sanitize_path (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST));
1021
string = sanitize_path (strip_chars, rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST));
964
string = sanitize_path (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST_FOLDED));
1024
string = sanitize_path (strip_chars, rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST_FOLDED));
967
string = sanitize_path (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST_SORTNAME));
1027
string = sanitize_path (strip_chars, rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST_SORTNAME));
970
string = sanitize_path (rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST_SORTNAME_FOLDED));
1030
string = sanitize_path (strip_chars, rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_ARTIST_SORTNAME_FOLDED));
973
1033
/* Track number */
1013
GMAudioProfile *profile;
1073
gboolean strip_chars;
1014
1075
RhythmDBEntryType *entry_type;
1015
1076
RhythmDBEntry *sample_entry;
1017
profile = gm_audio_profile_choose_get_active (source->priv->preferred_format_menu);
1078
media_type = g_settings_get_string (source->priv->settings, "preferred-media-type");
1019
/* TODO: sucky. Replace with get-gconf-key-with-default mojo */
1020
file_pattern = eel_gconf_get_string (CONF_LIBRARY_LAYOUT_FILENAME);
1080
file_pattern = g_settings_get_string (source->priv->settings, "layout-filename");
1021
1081
if (file_pattern == NULL) {
1022
1082
file_pattern = g_strdup (library_layout_filenames[0].path);
1024
tmp = sanitize_pattern (file_pattern);
1084
strip_chars = g_settings_get_boolean (source->priv->settings, "strip-chars");
1085
tmp = sanitize_pattern (strip_chars, file_pattern);
1025
1086
g_free (file_pattern);
1026
1087
file_pattern = tmp;
1028
path_pattern = eel_gconf_get_string (CONF_LIBRARY_LAYOUT_PATH);
1089
path_pattern = g_settings_get_string (source->priv->settings, "layout-path");
1029
1090
if (path_pattern == NULL) {
1030
1091
path_pattern = g_strdup (library_layout_paths[0].path);
1034
1095
sample_entry = rhythmdb_entry_example_new (source->priv->db, entry_type, NULL);
1035
1096
g_object_unref (entry_type);
1037
file_value = filepath_parse_pattern (source->priv->db, file_pattern, sample_entry);
1038
path_value = filepath_parse_pattern (source->priv->db, path_pattern, sample_entry);
1098
file_value = filepath_parse_pattern (source, file_pattern, sample_entry);
1099
path_value = filepath_parse_pattern (source, path_pattern, sample_entry);
1039
1100
rhythmdb_entry_unref (sample_entry);
1041
1102
example = g_build_filename (G_DIR_SEPARATOR_S, path_value, file_value, NULL);
1052
profile ? gm_audio_profile_get_extension (profile) : "ogg",
1113
media_type ? rb_gst_media_type_to_extension (media_type) : "ogg",
1053
1114
"</i></small>", NULL);
1054
1115
g_free (example);
1116
g_free (media_type);
1056
1118
gtk_label_set_markup (GTK_LABEL (source->priv->layout_example_label), format);
1057
1119
g_free (format);
1061
rb_library_source_layout_path_changed (GConfClient *client,
1064
RBLibrarySource *source)
1070
g_return_if_fail (entry != NULL);
1071
g_return_if_fail (strcmp (entry->key, CONF_LIBRARY_LAYOUT_PATH) == 0);
1073
rb_debug ("layout path changed");
1075
if (entry->value == NULL) {
1076
value = g_strdup (library_layout_paths[0].path);
1077
} else if (entry->value->type == GCONF_VALUE_STRING) {
1078
value = g_strdup (gconf_value_get_string (entry->value));
1084
for (i = 0; library_layout_paths[i].path != NULL; i++) {
1085
if (strcmp (library_layout_paths[i].path, value) == 0) {
1092
gtk_combo_box_set_active (GTK_COMBO_BOX (source->priv->layout_path_menu), active);
1094
layout_example_label_update (source);
1098
rb_library_source_layout_filename_changed (GConfClient *client,
1101
RBLibrarySource *source)
1107
g_return_if_fail (entry != NULL);
1108
g_return_if_fail (strcmp (entry->key, CONF_LIBRARY_LAYOUT_FILENAME) == 0);
1110
rb_debug ("layout filename changed");
1112
if (entry->value == NULL) {
1113
value = g_strdup (library_layout_filenames[0].path);
1114
} else if (entry->value->type == GCONF_VALUE_STRING) {
1115
value = g_strdup (gconf_value_get_string (entry->value));
1121
for (i = 0; library_layout_filenames[i].path != NULL; i++) {
1122
if (strcmp (library_layout_filenames[i].path, value) == 0) {
1129
gtk_combo_box_set_active (GTK_COMBO_BOX (source->priv->layout_filename_menu), active);
1131
layout_example_label_update (source);
1135
1123
* Build the absolute filename for the specified track.
1151
1139
char *filename;
1152
1140
char *string = NULL;
1155
1143
char *layout_path;
1156
1144
char *layout_filename;
1158
list = eel_gconf_get_string_list (CONF_LIBRARY_LOCATION);
1159
layout_path = eel_gconf_get_string (CONF_LIBRARY_LAYOUT_PATH);
1160
layout_filename = eel_gconf_get_string (CONF_LIBRARY_LAYOUT_FILENAME);
1162
if (list == NULL || layout_path == NULL || layout_filename == NULL) {
1145
gboolean strip_chars;
1147
locations = g_settings_get_strv (source->priv->db_settings, "locations");
1148
layout_path = g_settings_get_string (source->priv->settings, "layout-path");
1149
layout_filename = g_settings_get_string (source->priv->settings, "layout-filename");
1150
strip_chars = g_settings_get_boolean (source->priv->settings, "strip-chars");
1152
if (locations == NULL || layout_path == NULL || layout_filename == NULL) {
1163
1153
/* emit warning */
1164
rb_debug ("Could not retrieve settings from GConf");
1154
rb_debug ("Could not retrieve library layout settings");
1168
tmp = sanitize_pattern (layout_filename);
1158
tmp = sanitize_pattern (strip_chars, layout_filename);
1169
1159
g_free (layout_filename);
1170
1160
layout_filename = tmp;
1172
realpath = filepath_parse_pattern (source->priv->db, layout_path, entry);
1162
realpath = filepath_parse_pattern (source, layout_path, entry);
1174
library_location = g_file_new_for_uri ((const char *)list->data);
1164
library_location = g_file_new_for_uri ((const char *)locations[0]);
1175
1165
dir = g_file_resolve_relative_path (library_location, realpath);
1176
1166
g_object_unref (library_location);
1177
1167
g_free (realpath);
1179
realfile = filepath_parse_pattern (source->priv->db, layout_filename, entry);
1169
realfile = filepath_parse_pattern (source, layout_filename, entry);
1180
1170
if (extension) {
1181
1171
filename = g_strdup_printf ("%s.%s", realfile, extension);
1182
1172
g_free (realfile);
1201
1191
static gboolean
1202
1192
impl_can_paste (RBSource *asource)
1194
RBLibrarySource *source = RB_LIBRARY_SOURCE (asource);
1205
1196
gboolean can_paste = TRUE;
1208
list = eel_gconf_get_string_list (CONF_LIBRARY_LOCATION);
1209
can_paste = (list != NULL);
1210
rb_slist_deep_free (list);
1212
str = eel_gconf_get_string (CONF_LIBRARY_LAYOUT_PATH);
1213
can_paste &= (str != NULL);
1216
str = eel_gconf_get_string (CONF_LIBRARY_LAYOUT_FILENAME);
1217
can_paste &= (str != NULL);
1220
str = eel_gconf_get_string (CONF_LIBRARY_PREFERRED_FORMAT);
1221
can_paste &= (str != NULL);
1199
locations = g_settings_get_strv (source->priv->db_settings, "locations");
1200
can_paste = (g_strv_length (locations) > 0);
1201
g_strfreev (locations);
1203
str = g_settings_get_string (source->priv->settings, "layout-path");
1204
can_paste &= (str != NULL);
1207
str = g_settings_get_string (source->priv->settings, "layout-filename");
1208
can_paste &= (str != NULL);
1211
str = g_settings_get_string (source->priv->settings, "preferred-media-type");
1212
can_paste &= (str != NULL);
1223
1215
return can_paste;
1305
1300
g_object_get (shell, "track-transfer-queue", &xferq, NULL);
1306
1301
g_object_unref (shell);
1308
batch = rb_track_transfer_batch_new (NULL, NULL, NULL, G_OBJECT (source));
1303
target = gst_encoding_target_new ("rhythmbox-library", "device", "", NULL);
1305
/* set up profile for user's preferred format */
1306
preferred_media_type = g_settings_get_string (source->priv->settings, "preferred-media-type");
1307
profile = rb_gst_get_encoding_profile (preferred_media_type);
1308
g_free (preferred_media_type);
1309
/* have a preset as part of the user settings too? would that work for containerful streams,
1310
* where the interesting settings are on the stream inside the container?
1312
if (profile != NULL) {
1313
gst_encoding_target_add_profile (target, profile);
1316
/* set up profile for copying, which accepts any format */
1317
profile = GST_ENCODING_PROFILE (gst_encoding_audio_profile_new (gst_caps_new_any (), NULL, NULL, 1));
1318
gst_encoding_profile_set_name (profile, "copy");
1319
gst_encoding_target_add_profile (target, profile);
1321
batch = rb_track_transfer_batch_new (target, NULL, G_OBJECT (source));
1309
1322
g_signal_connect_object (batch, "get-dest-uri", G_CALLBACK (get_dest_uri_cb), source, 0);
1310
1323
g_signal_connect_object (batch, "track-done", G_CALLBACK (track_done_cb), source, 0);
1536
1549
rb_library_source_sync_child_sources (RBLibrarySource *source)
1540
list = eel_gconf_get_string_list (CONF_LIBRARY_LOCATION);
1554
locations = g_settings_get_strv (source->priv->db_settings, "locations");
1542
1556
/* FIXME: don't delete and re-create sources that are still there */
1543
1557
g_list_foreach (source->priv->child_sources, (GFunc)rb_display_page_delete_thyself, NULL);
1544
1558
g_list_free (source->priv->child_sources);
1545
1559
source->priv->child_sources = NULL;
1547
if (g_slist_length (list) > 1)
1548
g_slist_foreach (list, (GFunc)rb_library_source_add_child_source, source);
1549
rb_slist_deep_free (list);
1561
num_locations = g_strv_length (locations);
1562
if (num_locations > 1) {
1564
for (i = 0; i < num_locations; i++) {
1565
rb_library_source_add_child_source (locations[i], source);
1568
g_strfreev (locations);