Index: sources/rb-library-source.c
===================================================================
--- sources/rb-library-source.c (revision 4982)
+++ sources/rb-library-source.c (working copy)
@@ -281,6 +281,7 @@
RBLibrarySource *source;
RBShell *shell;
RBEntryView *songs;
+ GSList *list;
source = RB_LIBRARY_SOURCE (G_OBJECT_CLASS (rb_library_source_parent_class)
->constructor (type, n_construct_properties, construct_properties));
@@ -290,6 +291,16 @@
rb_library_source_ui_prefs_sync (source);
+ /* Set up the default library location if there's no library location set */
+ list = eel_gconf_get_string_list (CONF_LIBRARY_LOCATION);
+ if (g_slist_length (list) == 0) {
+ list = g_slist_prepend (list, g_strdup (rb_music_dir ()));
+ eel_gconf_set_string_list (CONF_LIBRARY_LOCATION, list);
+ } else {
+ g_slist_foreach (list, (GFunc) g_free, NULL);
+ g_slist_free (list);
+ }
+
source->priv->library_location_notify_id =
eel_gconf_notification_add (CONF_LIBRARY_LOCATION,
(GConfClientNotifyFunc) rb_library_source_library_location_changed, source);
@@ -609,10 +620,6 @@
if (list)
g_slist_free (list);
- /* don't do the first-run druid if the user sets the library location */
- if (list)
- eel_gconf_set_boolean (CONF_FIRST_TIME, TRUE);
-
return FALSE;
}
Index: sources/rb-podcast-source.c
===================================================================
--- sources/rb-podcast-source.c (revision 4982)
+++ sources/rb-podcast-source.c (working copy)
@@ -1246,6 +1246,9 @@
source->priv->config_widget = glade_xml_get_widget (xml, "podcast_vbox");
btn_file = glade_xml_get_widget (xml, "location_chooser");
+ gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (btn_file),
+ rb_music_dir (),
+ NULL);
download_dir = rb_podcast_manager_get_podcast_dir (source->priv->podcast_mgr);
gtk_file_chooser_set_current_folder_uri (GTK_FILE_CHOOSER (btn_file),
download_dir);
Index: lib/rb-file-helpers.c
===================================================================
--- lib/rb-file-helpers.c (revision 4982)
+++ lib/rb-file-helpers.c (working copy)
@@ -38,6 +38,7 @@
static GHashTable *files = NULL;
static char *dot_dir = NULL;
+static char *music_dir = NULL;
const char *
rb_file (const char *filename)
@@ -90,6 +91,137 @@
return dot_dir;
}
+/* Copied from xdg-user-dir-lookup.c */
+#include <stdlib.h>
+
+static char *
+xdg_user_dir_lookup (const char *type)
+{
+ FILE *file;
+ char *home_dir, *config_home, *config_file;
+ char buffer[512];
+ char *user_dir;
+ char *p, *d;
+ int len;
+ int relative;
+
+ home_dir = getenv ("HOME");
+
+ if (home_dir == NULL)
+ return strdup ("/tmp");
+
+ config_home = getenv ("XDG_CONFIG_HOME");
+ if (config_home == NULL || config_home[0] == 0)
+ {
+ config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
+ strcpy (config_file, home_dir);
+ strcat (config_file, "/.config/user-dirs.dirs");
+ }
+ else
+ {
+ config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
+ strcpy (config_file, config_home);
+ strcat (config_file, "/user-dirs.dirs");
+ }
+
+ file = fopen (config_file, "r");
+ free (config_file);
+ if (file == NULL)
+ goto error;
+
+ user_dir = NULL;
+ while (fgets (buffer, sizeof (buffer), file))
+ {
+ /* Remove newline at end */
+ len = strlen (buffer);
+ if (len > 0 && buffer[len-1] == '\n')
+ buffer[len-1] = 0;
+
+ p = buffer;
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ if (strncmp (p, "XDG_", 4) != 0)
+ continue;
+ p += 4;
+ if (strncmp (p, type, strlen (type)) != 0)
+ continue;
+ p += strlen (type);
+ if (strncmp (p, "_DIR", 4) != 0)
+ continue;
+ p += 4;
+
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ if (*p != '=')
+ continue;
+ p++;
+
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ if (*p != '"')
+ continue;
+ p++;
+
+ relative = 0;
+ if (strncmp (p, "$HOME/", 6) == 0)
+ {
+ p += 6;
+ relative = 1;
+ }
+ else if (*p != '/')
+ continue;
+
+ if (relative)
+ {
+ user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
+ strcpy (user_dir, home_dir);
+ strcat (user_dir, "/");
+ }
+ else
+ {
+ user_dir = malloc (strlen (p) + 1);
+ *user_dir = 0;
+ }
+
+ d = user_dir + strlen (user_dir);
+ while (*p && *p != '"')
+ {
+ if ((*p == '\\') && (*(p+1) != 0))
+ p++;
+ *d++ = *p++;
+ }
+ *d = 0;
+ }
+ fclose (file);
+
+ if (user_dir)
+ return user_dir;
+
+ error:
+ /* Special case desktop for historical compatibility */
+ if (strcmp (type, "DESKTOP") == 0)
+ {
+ user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
+ strcpy (user_dir, home_dir);
+ strcat (user_dir, "/Desktop");
+ return user_dir;
+ }
+ else
+ return strdup (home_dir);
+}
+
+const char *
+rb_music_dir (void)
+{
+ if (music_dir != NULL)
+ return (const char *) music_dir;
+ music_dir = xdg_user_dir_lookup ("MUSIC");
+ return (const char *) music_dir;
+}
+
void
rb_file_helpers_init (void)
{
@@ -103,7 +235,7 @@
rb_file_helpers_shutdown (void)
{
g_hash_table_destroy (files);
-
+ g_free (music_dir);
g_free (dot_dir);
}
Index: lib/rb-file-helpers.h
===================================================================
--- lib/rb-file-helpers.h (revision 4982)
+++ lib/rb-file-helpers.h (working copy)
@@ -29,6 +29,7 @@
const char * rb_file (const char *filename);
const char * rb_dot_dir (void);
+const char * rb_music_dir (void);
char * rb_canonicalise_uri (const char *uri);
Index: shell/rb-shell.c
===================================================================
--- shell/rb-shell.c (revision 4982)
+++ shell/rb-shell.c (working copy)
@@ -60,7 +60,6 @@
#include "rb-playlist-manager.h"
#include "rb-removable-media-manager.h"
#include "rb-preferences.h"
-#include "rb-druid.h"
#include "rb-shell-clipboard.h"
#include "rb-shell-player.h"
#include "rb-source-header.h"
@@ -142,9 +141,6 @@
const char *field,
GValue *metadata,
RBShell *shell);
-static void rb_shell_druid_response_cb (GtkDialog *druid,
- guint response,
- RBShell *shell);
static void rb_shell_playlist_added_cb (RBPlaylistManager *mgr, RBSource *source, RBShell *shell);
static void rb_shell_playlist_created_cb (RBPlaylistManager *mgr, RBSource *source, RBShell *shell);
@@ -1407,21 +1403,9 @@
rb_shell_sync_paned (shell);
gtk_widget_show_all (GTK_WIDGET (shell->priv->tray_icon));
- /* Stop here if this is the first time. */
- if (!eel_gconf_get_boolean (CONF_FIRST_TIME)) {
- RBDruid *druid;
- druid = rb_druid_new (shell->priv->db);
- g_signal_connect (G_OBJECT (druid),
- "response",
- G_CALLBACK (rb_shell_druid_response_cb),
- shell);
+ rb_shell_set_visibility (shell, eel_gconf_get_boolean (CONF_STATE_WINDOW_VISIBLE), TRUE);
+ gdk_notify_startup_complete ();
- gtk_widget_show_all (GTK_WIDGET (druid));
- } else {
- rb_shell_set_visibility (shell, eel_gconf_get_boolean (CONF_STATE_WINDOW_VISIBLE), TRUE);
- gdk_notify_startup_complete ();
- }
-
/* focus play if small, the entry view if not */
if (shell->priv->window_small) {
GtkWidget *play_button;
@@ -3528,15 +3512,6 @@
}
-static void
-rb_shell_druid_response_cb (GtkDialog *druid,
- guint response,
- RBShell *shell)
-{
- gtk_widget_show_all (GTK_WIDGET (shell->priv->window));
- gtk_widget_destroy (GTK_WIDGET (druid));
-}
-
static GtkBox*
rb_shell_get_box_for_ui_location (RBShell *shell, RBShellUILocation location)
{
Index: widgets/rb-dialog.c
===================================================================
--- widgets/rb-dialog.c (revision 4982)
+++ widgets/rb-dialog.c (working copy)
@@ -33,6 +33,7 @@
#include <stdarg.h>
#include "rb-dialog.h"
+#include "rb-file-helpers.h"
#include "rb-stock-icons.h"
void
@@ -104,6 +105,9 @@
}
gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (dialog), local_only);
+ gtk_file_chooser_add_shortcut_folder (GTK_FILE_CHOOSER (dialog),
+ rb_music_dir (),
+ NULL);
if (parent != NULL) {
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));