[PATCH 2/3] [filesystem] Get paths to show from the configuration files



Gets the FS_PATH strings assigned in each of the provided
configuration files. If no FS_PATH is set, then the old
behavior of showing the root's contents is done.
---
 src/filesystem/grl-filesystem.c |   41 +++++++++++++++++++++++++++++++++-----
 src/filesystem/grl-filesystem.h |    4 +++
 2 files changed, 39 insertions(+), 6 deletions(-)

diff --git a/src/filesystem/grl-filesystem.c b/src/filesystem/grl-filesystem.c
index a6381fa..85d590d 100644
--- a/src/filesystem/grl-filesystem.c
+++ b/src/filesystem/grl-filesystem.c
@@ -111,12 +111,27 @@ grl_filesystem_plugin_init (GrlPluginRegistry *registry,
                             const GrlPluginInfo *plugin,
                             GList *configs)
 {
+  GrlConfig *config;
+  GList *chosen_paths = NULL;
+
   g_debug ("filesystem_plugin_init\n");
 
   GrlFilesystemSource *source = grl_filesystem_source_new ();
   grl_plugin_registry_register_source (registry,
                                        plugin,
                                        GRL_MEDIA_PLUGIN (source));
+
+  for (; configs; configs = g_list_next (configs)) {
+    const gchar *path;
+    config = GRL_CONFIG (configs->data);
+    path = grl_config_get_string (config, GRILO_CONF_CHOSEN_PATH);
+    if (!path) {
+      continue;
+    }
+    chosen_paths = g_list_append (chosen_paths, g_strdup (path));
+  }
+  source->priv->chosen_paths = chosen_paths;
+
   return TRUE;
 }
 
@@ -385,9 +400,7 @@ create_content (GrlMedia *content,
   }
 
   /* ID: if root path, then id must be kept NULL */
-  grl_media_set_id (media,
-                    g_strcmp0 (path,
-                               G_DIR_SEPARATOR_S) == 0? NULL: path);
+  grl_media_set_id (media, path);
 
   /* URL */
   str = g_strconcat ("file://", path, NULL);
@@ -549,14 +562,30 @@ static void
 grl_filesystem_source_browse (GrlMediaSource *source,
                               GrlMediaSourceBrowseSpec *bs)
 {
-  const gchar *path;
   const gchar *id;
+  GList *chosen_paths;
 
   g_debug ("grl_filesystem_source_browse");
 
   id = grl_media_get_id (bs->container);
-  path = id ? id : G_DIR_SEPARATOR_S;
-  produce_from_path (bs, path);
+  chosen_paths = GRL_FILESYSTEM_SOURCE(source)->priv->chosen_paths;
+  if (!id && chosen_paths) {
+    guint remaining = g_list_length (chosen_paths);
+    for (; chosen_paths; chosen_paths = g_list_next (chosen_paths)) {
+      GrlMedia *content = create_content (NULL,
+					  (gchar *) chosen_paths->data,
+					  GRL_RESOLVE_FAST_ONLY);
+
+      bs->callback (source,
+		    bs->browse_id,
+		    content,
+		    --remaining,
+		    bs->user_data,
+		    NULL);
+    }
+  } else {
+    produce_from_path (bs, id ? id : G_DIR_SEPARATOR_S);
+  }
 }
 
 static void
diff --git a/src/filesystem/grl-filesystem.h b/src/filesystem/grl-filesystem.h
index 7e24211..ec24aa2 100644
--- a/src/filesystem/grl-filesystem.h
+++ b/src/filesystem/grl-filesystem.h
@@ -51,6 +51,10 @@
                               GRL_FILESYSTEM_SOURCE_TYPE,       \
                               GrlFilesystemSourceClass))
 
+/* --- Grilo Configuration --- */
+#define GRILO_CONF_CHOSEN_PATH "FS_PATH"
+
+
 typedef struct _GrlFilesystemSource GrlFilesystemSource;
 typedef struct _GrlFilesystemSourcePrivate GrlFilesystemSourcePrivate;
 
-- 
1.7.0.4



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]