~matttbe/ubuntu/raring/rhythmbox/lp1010619_RB_2.98

« back to all changes in this revision

Viewing changes to sources/rb-library-source.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-11-06 20:52:57 UTC
  • mfrom: (1.1.67) (214.1.1 quantal-proposed)
  • Revision ID: package-import@ubuntu.com-20121106205257-0btjh8jqley153el
Tags: 2.98-0ubuntu1
* New upstream release (LP: #1060601)
* debian/control.in:
  - Bump minimum glib, gtk, totem-plparser, clutter, and clutter-gst
  - Drop no longer needed musicbrainz dependency
* Refreshed 09_keywords.patch
* Updated 11_fix_cd_pausing.patch with fix from git
* Dropped patches applied in new version:
  - 00git_musicbrainz5.patch
  - 08_CVE-2012-3355.patch
  - dont_free_consumed_floating_gvariant.patch
  - git_scale_click.patch
  - git_crash_during_monitor.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
#include "rb-missing-plugins.h"
69
69
#include "rb-gst-media-types.h"
70
70
#include "rb-object-property-editor.h"
 
71
#include "rb-import-dialog.h"
 
72
 
 
73
#define SOURCE_PAGE             0
 
74
#define IMPORT_DIALOG_PAGE      1
71
75
 
72
76
static void rb_library_source_class_init (RBLibrarySourceClass *klass);
73
77
static void rb_library_source_init (RBLibrarySource *source);
90
94
                          RBSourceAddCallback callback,
91
95
                          gpointer data,
92
96
                          GDestroyNotify destroy_data);
 
97
static void impl_pack_content (RBBrowserSource *source, GtkWidget *content);
93
98
 
94
99
static void library_settings_changed_cb (GSettings *settings, const char *key, RBLibrarySource *source);
95
100
static void encoding_settings_changed_cb (GSettings *settings, const char *key, RBLibrarySource *source);
141
146
{
142
147
        RhythmDB *db;
143
148
 
144
 
        gboolean loading_prefs;
145
149
        RBShellPreferences *shell_prefs;
146
150
 
 
151
        GtkWidget *notebook;
147
152
        GtkWidget *config_widget;
 
153
        GtkWidget *import_dialog;
148
154
 
149
155
        GList *child_sources;
150
156
 
167
173
        gulong profile_changed_id;
168
174
        gboolean custom_settings_exists;
169
175
        gboolean profile_init;
 
176
        gboolean do_initial_import;
170
177
 
171
178
        GSettings *settings;
172
179
        GSettings *db_settings;
200
207
        source_class->impl_add_uri = impl_add_uri;
201
208
 
202
209
        browser_source_class->has_drop_support = (RBBrowserSourceFeatureFunc) rb_true_function;
 
210
        browser_source_class->pack_content = impl_pack_content;
203
211
 
204
212
        g_type_class_add_private (klass, sizeof (RBLibrarySourcePrivate));
205
213
}
275
283
}
276
284
 
277
285
static void
 
286
initial_import_job_complete_cb (RhythmDBImportJob *job, int total, RBLibrarySource *source)
 
287
{
 
288
        if (rhythmdb_import_job_get_imported (job) == 0) {
 
289
                rb_library_source_show_import_dialog (source);
 
290
        }
 
291
}
 
292
 
 
293
static void
278
294
db_load_complete_cb (RhythmDB *db, RBLibrarySource *source)
279
295
{
 
296
        RhythmDBImportJob *job;
 
297
 
280
298
        /* once the database is loaded, we can run the query to populate the library source */
281
299
        g_object_set (source, "populate", TRUE, NULL);
 
300
 
 
301
        if (source->priv->do_initial_import) {
 
302
                const char *music_dir;
 
303
                char *music_dir_uri;
 
304
                
 
305
                music_dir = rb_music_dir ();
 
306
                music_dir_uri = g_filename_to_uri (music_dir, NULL, NULL);
 
307
 
 
308
                /* create the music dir if it doesn't exist */
 
309
                if (g_file_test (music_dir, G_FILE_TEST_EXISTS) == FALSE) {
 
310
                        g_mkdir_with_parents (music_dir, 0700);
 
311
                }
 
312
 
 
313
                /* import anything that's already in there */
 
314
                job = maybe_create_import_job (source);
 
315
                rhythmdb_import_job_add_uri (job, music_dir_uri);
 
316
 
 
317
                /* if this doesn't import anything, show the import dialog */
 
318
                g_signal_connect (job, "complete", G_CALLBACK (initial_import_job_complete_cb), source);
 
319
 
 
320
                g_free (music_dir_uri);
 
321
        }
282
322
}
283
323
 
284
324
static void
289
329
        RBEntryView *songs;
290
330
        char **locations;
291
331
 
 
332
        source = RB_LIBRARY_SOURCE (object);
 
333
        source->priv->notebook = gtk_notebook_new ();
 
334
        gtk_notebook_set_show_tabs (GTK_NOTEBOOK (source->priv->notebook), FALSE);
 
335
        gtk_notebook_set_show_border (GTK_NOTEBOOK (source->priv->notebook), FALSE);
 
336
 
292
337
        RB_CHAIN_GOBJECT_METHOD (rb_library_source_parent_class, constructed, object);
293
 
        source = RB_LIBRARY_SOURCE (object);
294
338
 
295
339
        g_object_get (source, "shell", &shell, NULL);
296
340
        g_object_get (shell, "db", &source->priv->db, NULL);
297
341
 
 
342
        gtk_container_add (GTK_CONTAINER (source), source->priv->notebook);
 
343
 
 
344
        gtk_notebook_set_current_page (GTK_NOTEBOOK (source->priv->notebook), 0);
 
345
        gtk_widget_show_all (source->priv->notebook);
 
346
 
298
347
        source->priv->settings = g_settings_new ("org.gnome.rhythmbox.library");
299
348
        g_signal_connect_object (source->priv->settings, "changed", G_CALLBACK (library_settings_changed_cb), source, 0);
300
349
 
314
363
                music_dir_uri = g_filename_to_uri (rb_music_dir (), NULL, NULL);
315
364
                if (music_dir_uri != NULL) {
316
365
                        const char *set_locations[2];
 
366
 
317
367
                        set_locations[0] = music_dir_uri;
318
368
                        set_locations[1] = NULL;
319
369
                        g_settings_set_strv (source->priv->db_settings, "locations", set_locations);
320
370
 
 
371
                        source->priv->do_initial_import = TRUE;
 
372
 
321
373
                        g_free (music_dir_uri);
322
374
                }
323
375
        }
376
428
}
377
429
 
378
430
static void
 
431
impl_pack_content (RBBrowserSource *bsource, GtkWidget *content)
 
432
{
 
433
        RBLibrarySource *source = RB_LIBRARY_SOURCE (bsource);
 
434
        gtk_notebook_append_page (GTK_NOTEBOOK (source->priv->notebook), content, NULL);
 
435
        gtk_widget_show_all (content);
 
436
}
 
437
 
 
438
static void
379
439
location_response_cb (GtkDialog *dialog, int response, RBLibrarySource *source)
380
440
{
381
441
        char *uri;
1875
1935
        if (lsource->priv->import_jobs != NULL) {
1876
1936
                RhythmDBImportJob *job = RHYTHMDB_IMPORT_JOB (lsource->priv->import_jobs->data);
1877
1937
                _rb_source_set_import_status (RB_SOURCE (source), job, progress_text, progress);
 
1938
        } else if (gtk_notebook_get_current_page (GTK_NOTEBOOK (lsource->priv->notebook)) == IMPORT_DIALOG_PAGE) {
 
1939
                g_free (*text);
 
1940
                g_object_get (lsource->priv->import_dialog, "status", text, NULL);
 
1941
        }
 
1942
}
 
1943
 
 
1944
static void
 
1945
import_dialog_closed_cb (RBImportDialog *dialog, RBLibrarySource *source)
 
1946
{
 
1947
        gtk_notebook_set_current_page (GTK_NOTEBOOK (source->priv->notebook), 0);
 
1948
        rb_display_page_notify_status_changed (RB_DISPLAY_PAGE (source));
 
1949
}
 
1950
 
 
1951
static void
 
1952
import_dialog_status_notify_cb (GObject *dialog, GParamSpec *pspec, RBLibrarySource *source)
 
1953
{
 
1954
        rb_display_page_notify_status_changed (RB_DISPLAY_PAGE (source));
 
1955
}
 
1956
 
 
1957
void
 
1958
rb_library_source_show_import_dialog (RBLibrarySource *source)
 
1959
{
 
1960
        if (source->priv->import_dialog == NULL) {
 
1961
                RBShell *shell;
 
1962
 
 
1963
                g_object_get (source, "shell", &shell, NULL);
 
1964
                source->priv->import_dialog = rb_import_dialog_new (shell);
 
1965
                g_object_unref (shell);
 
1966
 
 
1967
                g_signal_connect (source->priv->import_dialog,
 
1968
                                  "closed",
 
1969
                                  G_CALLBACK (import_dialog_closed_cb),
 
1970
                                  source);
 
1971
                g_signal_connect (source->priv->import_dialog,
 
1972
                                  "notify::status",
 
1973
                                  G_CALLBACK (import_dialog_status_notify_cb),
 
1974
                                  source);
 
1975
 
 
1976
                gtk_widget_show_all (GTK_WIDGET (source->priv->import_dialog));
 
1977
                gtk_notebook_append_page (GTK_NOTEBOOK (source->priv->notebook),
 
1978
                                          source->priv->import_dialog,
 
1979
                                          NULL);
 
1980
        }
 
1981
 
 
1982
        if (gtk_notebook_get_current_page (GTK_NOTEBOOK (source->priv->notebook)) != IMPORT_DIALOG_PAGE) {
 
1983
                rb_import_dialog_reset (RB_IMPORT_DIALOG (source->priv->import_dialog));
 
1984
                gtk_notebook_set_current_page (GTK_NOTEBOOK (source->priv->notebook), IMPORT_DIALOG_PAGE);
 
1985
                rb_display_page_notify_status_changed (RB_DISPLAY_PAGE (source));
1878
1986
        }
1879
1987
}