[maemo-commits] [maemo-commits] r11695 - projects/haf/trunk/hildon-fm/hildon-fm

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Wed May 16 17:09:58 EEST 2007
Author: marivoll
Date: 2007-05-16 17:09:52 +0300 (Wed, 16 May 2007)
New Revision: 11695

Added:
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-root.c
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-root.h
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.c
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.h
Modified:
   projects/haf/trunk/hildon-fm/hildon-fm/Makefile.am
Log:
	* hildon-fm/hildon-file-system-root.c,
	hildon-fm/hildon-file-system-root.h,
	hildon-fm/hildon-file-system-voldev.h,
	hildon-fm/hildon-file-system-voldev.c: New.
	* hildon-fm/Makefile.am (libhildonfm_la_SOURCES): Added them.


Modified: projects/haf/trunk/hildon-fm/hildon-fm/Makefile.am
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/Makefile.am	2007-05-16 14:06:50 UTC (rev 11694)
+++ projects/haf/trunk/hildon-fm/hildon-fm/Makefile.am	2007-05-16 14:09:52 UTC (rev 11695)
@@ -1,5 +1,5 @@
 INCLUDES = $(GTK_CFLAGS) $(GCONF_CFLAGS) $(HILDON_THUMBNAIL_CFLAGS)	\
-	   $(GWCONNECT_CFLAGS) $(DBUSGLIB_CFLAGS)			\
+	   $(GWCONNECT_CFLAGS) $(DBUSGLIB_CFLAGS) $(GNOMEVFS_CFLAGS)	\
            $(LIBOSSO_CFLAGS)						\
            $(MCE_CFLAGS) -DLOCALEDIR=\"$(localedir)\"			\
            $(LIBOSSOMIME_CFLAGS) -I$(srcdir)/..				\
@@ -14,7 +14,7 @@
 EXTRA_DIST = 
 
 libhildonfm_la_LIBADD = $(GTK_LIBS) $(GCONF_LIBS) $(HILDON_THUMBNAIL_LIBS) \
-	$(GWCONNECT_LIBS) $(DBUSGLIB_LIBS) $(LIBOSSOMIME_LIBS)
+	$(GWCONNECT_LIBS) $(DBUSGLIB_LIBS) $(LIBOSSOMIME_LIBS) $(GNOMEVFS_LIBS)
 
 libhildonfm_la_LDFLAGS = -version-info 2:0:0
 libhildonfm_la_SOURCES =			\
@@ -36,6 +36,8 @@
 	hildon-file-details-dialog.c		\
 	hildon-file-system-special-location.h	\
 	hildon-file-system-special-location.c	\
+	hildon-file-system-root.h		\
+	hildon-file-system-root.c		\
 	hildon-file-system-local-device.h	\
 	hildon-file-system-local-device.c	\
 	hildon-file-system-remote-device.h	\
@@ -52,6 +54,8 @@
 	hildon-file-system-obex.c		\
 	hildon-file-system-smb.h		\
 	hildon-file-system-smb.c		\
+	hildon-file-system-voldev.h		\
+	hildon-file-system-voldev.c		\
 	hildon-fm1-compat.h			\
 	hildon-fm1-compat.c			\
 	$(hildonfm_built_headers)		\
@@ -67,6 +71,11 @@
 	hildon-file-details-dialog.h		\
 	hildon-fm1-compat.h
 
+noinst_PROGRAMS = t
+t_SOURCES = t.c
+t_CFLAGS = $(GTK_CFLAGS) $(GNOMEVFS_CFLAGS)
+t_LDFLAGS = $(GTK_LIBS) $(GNOMEVFS_LIBS)
+
 headers_to_scan_for_enums = $(hildonincludeinst_DATA)
  
 # Generate the enums source code, with glib-mkenums:

Added: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-root.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-root.c	2007-05-16 14:06:50 UTC (rev 11694)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-root.c	2007-05-16 14:09:52 UTC (rev 11695)
@@ -0,0 +1,293 @@
+/*
+ * This file is part of hildon-fm package
+ *
+ * Copyright (C) 2006 Nokia Corporation.  All rights reserved.
+ *
+ * Contact: Marius Vollmer <marius.vollmer at nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <string.h>
+#include <glib.h>
+#define GTK_FILE_SYSTEM_ENABLE_UNSUPPORTED
+#include <gtk/gtkfilesystem.h>
+
+#include "hildon-file-common-private.h"
+#include "hildon-file-system-private.h"
+#include "hildon-file-system-root.h"
+#include "hildon-file-system-mmc.h"
+#include "hildon-file-system-voldev.h"
+#include "hildon-file-system-settings.h"
+
+static void
+hildon_file_system_root_class_init (HildonFileSystemRootClass *klass);
+static void
+hildon_file_system_root_init (HildonFileSystemRoot *device);
+
+static void
+hildon_file_system_root_volumes_changed (HildonFileSystemSpecialLocation
+                                        *location, GtkFileSystem *fs);
+
+static GtkFileSystemHandle *
+hildon_file_system_root_get_folder (HildonFileSystemSpecialLocation *location,
+				    GtkFileSystem                *filesystem,
+				    const GtkFilePath              *path,
+				    GtkFileInfoType                 types,
+				    GtkFileSystemGetFolderCallback  callback,
+				    gpointer                        data);
+
+static HildonFileSystemSpecialLocation*
+hildon_file_system_root_create_child_location (HildonFileSystemSpecialLocation
+                                               *location, gchar *uri);
+
+G_DEFINE_TYPE (HildonFileSystemRoot,
+               hildon_file_system_root,
+               HILDON_TYPE_FILE_SYSTEM_SPECIAL_LOCATION);
+
+static void
+hildon_file_system_root_class_init (HildonFileSystemRootClass *klass)
+{
+    HildonFileSystemSpecialLocationClass *location =
+            HILDON_FILE_SYSTEM_SPECIAL_LOCATION_CLASS (klass);
+
+    location->volumes_changed = hildon_file_system_root_volumes_changed;
+    location->get_folder = hildon_file_system_root_get_folder;
+    location->create_child_location =
+      hildon_file_system_root_create_child_location;
+}
+
+static void
+hildon_file_system_root_init (HildonFileSystemRoot *device)
+{
+}
+
+static void
+hildon_file_system_root_volumes_changed (HildonFileSystemSpecialLocation
+                                        *location, GtkFileSystem *fs)
+{
+  g_signal_emit_by_name (location, "rescan");
+}
+
+HildonFileSystemSpecialLocation*
+hildon_file_system_root_create_child_location (HildonFileSystemSpecialLocation
+					       *location, gchar *uri)
+{
+  HildonFileSystemSpecialLocation *child = NULL;
+
+  if (g_str_has_prefix (uri, "drive://")
+      || (g_str_has_prefix (uri, "file:///media/")
+	  && strchr (uri + 14, '/') == NULL))
+    {
+      child = g_object_new (HILDON_TYPE_FILE_SYSTEM_VOLDEV, NULL);
+      child->basepath = g_strdup (uri);
+    }
+
+  return child;
+}
+
+/* Wrapping GtkFileVolumes in a GtkFileFolder
+ */
+
+#define ROOT_TYPE_FILE_FOLDER             (root_file_folder_get_type ())
+#define ROOT_FILE_FOLDER(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), ROOT_TYPE_FILE_FOLDER, RootFileFolder))
+#define ROOT_IS_FILE_FOLDER(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ROOT_TYPE_FILE_FOLDER))
+#define ROOT_FILE_FOLDER_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), ROOT_TYPE_FILE_FOLDER, RootFileFolderClass))
+#define ROOT_IS_FILE_FOLDER_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), ROOT_TYPE_FILE_FOLDER))
+#define ROOT_FILE_FOLDER_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), ROOT_TYPE_FILE_FOLDER, RootFileFolderClass))
+
+typedef struct _RootFileFolder      RootFileFolder;
+typedef struct _RootFileFolderClass RootFileFolderClass;
+
+struct _RootFileFolderClass
+{
+  GObjectClass parent_class;
+};
+
+struct _RootFileFolder
+{
+  GObject parent_instance;
+
+  GtkFileSystem *filesystem;
+  HildonFileSystemRoot *root;
+};
+
+static GType root_file_folder_get_type (void);
+static void root_file_folder_iface_init (GtkFileFolderIface *iface);
+static void root_file_folder_init (RootFileFolder *impl);
+static void root_file_folder_finalize (GObject *object);
+
+static GtkFileInfo *root_file_folder_get_info (GtkFileFolder  *folder,
+					     const GtkFilePath    *path,
+					     GError        **error);
+static gboolean root_file_folder_list_children (GtkFileFolder  *folder,
+					      GSList        **children,
+					      GError        **error);
+static gboolean root_file_folder_is_finished_loading (GtkFileFolder *folder);
+
+G_DEFINE_TYPE_WITH_CODE (RootFileFolder, root_file_folder, G_TYPE_OBJECT,
+			 G_IMPLEMENT_INTERFACE (GTK_TYPE_FILE_FOLDER,
+						root_file_folder_iface_init))
+
+static void
+root_file_folder_class_init (RootFileFolderClass *class)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+
+  gobject_class->finalize = root_file_folder_finalize;
+}
+
+static void
+root_file_folder_iface_init (GtkFileFolderIface *iface)
+{
+  iface->get_info = root_file_folder_get_info;
+  iface->list_children = root_file_folder_list_children;
+  iface->is_finished_loading = root_file_folder_is_finished_loading;
+}
+
+static void
+root_file_folder_init (RootFileFolder *folder)
+{
+  folder->filesystem = NULL;
+  folder->root = NULL;
+}
+
+static void
+root_file_folder_finalize (GObject *object)
+{
+  RootFileFolder *folder = ROOT_FILE_FOLDER (object);
+
+  if (folder->root)
+    g_object_unref (folder->root);
+
+  G_OBJECT_CLASS (root_file_folder_parent_class)->finalize (object);
+}
+
+static GtkFileInfo *
+root_file_folder_get_info (GtkFileFolder      *folder,
+			   const GtkFilePath  *path,
+			   GError            **error)
+{
+  GtkFileInfo *info;
+
+  /* XXX - maybe provide more detail...
+   */
+
+  info = gtk_file_info_new ();
+  gtk_file_info_set_display_name (info,
+				  g_basename
+				  (gtk_file_path_get_string (path)));
+  gtk_file_info_set_is_folder (info, TRUE);
+  return info;
+}
+
+static gboolean
+root_file_folder_list_children (GtkFileFolder  *folder,
+				GSList        **children,
+				GError        **error)
+{
+  RootFileFolder *root_folder = ROOT_FILE_FOLDER (folder);
+  GtkFileSystem *fs = root_folder->filesystem;
+
+  GnomeVFSVolumeMonitor *monitor;
+  GList *volumes, *v, *drives, *d;
+
+  monitor = gnome_vfs_get_volume_monitor ();
+
+  *children = NULL;
+
+  volumes = gnome_vfs_volume_monitor_get_mounted_volumes (monitor);
+  for (v = volumes; v; v = v->next)
+    {
+      GnomeVFSVolume *volume = v->data;
+
+      if (gnome_vfs_volume_is_user_visible (volume))
+	{
+	  const char *uri = gnome_vfs_volume_get_activation_uri (volume);
+	  *children = g_slist_append (*children,
+				      gtk_file_system_uri_to_path (fs, uri));
+	}
+    }
+  g_list_free (volumes);
+
+  drives = gnome_vfs_volume_monitor_get_connected_drives (monitor);
+  for (d = drives; d; d = d->next)
+    {
+      GnomeVFSDrive *drive = d->data;
+
+      if (gnome_vfs_drive_is_user_visible (drive))
+	{
+	  char *uri =
+	    g_strdup_printf ("drive://%s",
+			     gnome_vfs_drive_get_device_path (drive));
+	  *children = g_slist_append (*children,
+				      gtk_file_system_uri_to_path (fs, uri));
+	  g_free (uri);
+	}
+    }
+  g_list_free (drives);
+
+  return TRUE;
+}
+
+static gboolean
+root_file_folder_is_finished_loading (GtkFileFolder *folder)
+{
+  return TRUE;
+}
+
+struct get_folder_clos {
+  GtkFileSystemHandle *handle;
+  RootFileFolder *root_folder;
+  GtkFileSystemGetFolderCallback callback;
+  gpointer data;
+};
+
+static gboolean
+deliver_get_folder_callback (gpointer data)
+{
+  struct get_folder_clos *clos = (struct get_folder_clos *)data;
+  clos->callback (clos->handle, GTK_FILE_FOLDER (clos->root_folder),
+		  NULL, clos->data);
+  g_free (clos);
+  return FALSE;
+}
+
+static GtkFileSystemHandle *
+hildon_file_system_root_get_folder (HildonFileSystemSpecialLocation *location,
+				    GtkFileSystem                *filesystem,
+				    const GtkFilePath              *path,
+				    GtkFileInfoType                 types,
+				    GtkFileSystemGetFolderCallback  callback,
+				    gpointer                        data)
+{
+  GtkFileSystemHandle *handle = g_object_new (GTK_TYPE_FILE_SYSTEM_HANDLE,
+					      NULL);
+  RootFileFolder *root_folder = g_object_new (ROOT_TYPE_FILE_FOLDER, NULL);
+  struct get_folder_clos *clos = g_new (struct get_folder_clos, 1);
+
+  root_folder->filesystem = filesystem;
+  root_folder->root = HILDON_FILE_SYSTEM_ROOT (location);
+  g_object_ref (location);
+
+  clos->handle = handle;
+  clos->root_folder = root_folder;
+  clos->callback = callback;
+  clos->data = data;
+
+  g_idle_add (deliver_get_folder_callback, clos);
+  return handle;
+}

Added: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-root.h
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-root.h	2007-05-16 14:06:50 UTC (rev 11694)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-root.h	2007-05-16 14:09:52 UTC (rev 11695)
@@ -0,0 +1,57 @@
+/*
+ * This file is part of hildon-fm package
+ *
+ * Copyright (C) 2007 Nokia Corporation.  All rights reserved.
+ *
+ * Contact: Marius Vollmer <marius.vollmer at nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef HILDON_FILE_SYSTEM_ROOT_H__
+#define HILDON_FILE_SYSTEM_ROOT_H__ 
+
+#include "hildon-file-system-special-location.h"
+
+G_BEGIN_DECLS
+
+#define HILDON_TYPE_FILE_SYSTEM_ROOT            (hildon_file_system_root_get_type ())
+#define HILDON_FILE_SYSTEM_ROOT(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), HILDON_TYPE_FILE_SYSTEM_ROOT, HildonFileSystemRoot))
+#define HILDON_FILE_SYSTEM_ROOT_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), HILDON_TYPE_FILE_SYSTEM_ROOT, HildonFileSystemRootClass))
+#define HILDON_IS_FILE_SYSTEM_ROOT(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HILDON_TYPE_FILE_SYSTEM_ROOT))
+#define HILDON_IS_FILE_SYSTEM_ROOT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HILDON_TYPE_FILE_SYSTEM_ROOT))
+#define HILDON_FILE_SYSTEM_ROOT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), HILDON_TYPE_FILE_SYSTEM_ROOT, HildonFileSystemRootClass))
+
+
+typedef struct _HildonFileSystemRoot HildonFileSystemRoot;
+typedef struct _HildonFileSystemRootClass HildonFileSystemRootClass;
+typedef struct _HildonFileSystemRootPrivate HildonFileSystemRootPrivate;
+
+struct _HildonFileSystemRoot
+{
+    HildonFileSystemSpecialLocation parent_instance;
+};
+
+struct _HildonFileSystemRootClass
+{
+    HildonFileSystemSpecialLocationClass parent_class;
+};
+
+GType hildon_file_system_root_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif

Added: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.c	2007-05-16 14:06:50 UTC (rev 11694)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.c	2007-05-16 14:09:52 UTC (rev 11695)
@@ -0,0 +1,193 @@
+/*
+ * This file is part of hildon-fm package
+ *
+ * Copyright (C) 2007 Nokia Corporation.  All rights reserved.
+ *
+ * Contact: Marius Vollmer <marius.vollmer at nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#include <glib.h>
+#include <string.h>
+
+#include "hildon-file-system-voldev.h"
+#include "hildon-file-system-settings.h"
+#include "hildon-file-system-dynamic-device.h"
+#include "hildon-file-common-private.h"
+#include "hildon-file-system-private.h"
+
+static void
+hildon_file_system_voldev_class_init (HildonFileSystemVoldevClass *klass);
+static void
+hildon_file_system_voldev_finalize (GObject *obj);
+static void
+hildon_file_system_voldev_init (HildonFileSystemVoldev *device);
+
+static gboolean
+hildon_file_system_voldev_is_visible (HildonFileSystemSpecialLocation *location);
+
+static void
+hildon_file_system_voldev_volumes_changed (HildonFileSystemSpecialLocation
+					   *location, GtkFileSystem *fs);
+
+G_DEFINE_TYPE (HildonFileSystemVoldev,
+               hildon_file_system_voldev,
+               HILDON_TYPE_FILE_SYSTEM_SPECIAL_LOCATION);
+
+static void
+hildon_file_system_voldev_class_init (HildonFileSystemVoldevClass *klass)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+    HildonFileSystemSpecialLocationClass *location =
+            HILDON_FILE_SYSTEM_SPECIAL_LOCATION_CLASS (klass);
+
+    gobject_class->finalize = hildon_file_system_voldev_finalize;
+
+    location->requires_access = FALSE;
+    location->is_visible = hildon_file_system_voldev_is_visible;
+    location->volumes_changed = hildon_file_system_voldev_volumes_changed;
+}
+
+static void
+hildon_file_system_voldev_init (HildonFileSystemVoldev *device)
+{
+    HildonFileSystemSpecialLocation *location;
+
+    location = HILDON_FILE_SYSTEM_SPECIAL_LOCATION (device);
+    location->compatibility_type = HILDON_FILE_SYSTEM_MODEL_MMC;
+    location->failed_access_message = NULL;
+}
+
+static void
+hildon_file_system_voldev_finalize (GObject *obj)
+{
+    HildonFileSystemVoldev *voldev;
+    
+    voldev = HILDON_FILE_SYSTEM_VOLDEV (obj);
+
+    if (voldev->volume)
+      gnome_vfs_volume_unref (voldev->volume);
+    if (voldev->drive)
+      gnome_vfs_drive_unref (voldev->drive);
+    
+    G_OBJECT_CLASS (hildon_file_system_voldev_parent_class)->finalize (obj);
+}
+
+static gboolean
+hildon_file_system_voldev_is_visible (HildonFileSystemSpecialLocation *location)
+{
+  HildonFileSystemVoldev *voldev = HILDON_FILE_SYSTEM_VOLDEV (location);
+  gboolean visible = FALSE;
+
+  if (voldev->volume)
+    visible = gnome_vfs_volume_is_mounted (voldev->volume);
+  else if (voldev->drive)
+    visible = (gnome_vfs_drive_is_connected (voldev->drive)
+	       && !gnome_vfs_drive_is_mounted (voldev->drive));
+
+  return visible;
+}
+
+static GnomeVFSDrive *
+find_drive (const char *device)
+{
+  GnomeVFSVolumeMonitor *monitor;
+  GList *drives, *d;
+  GnomeVFSDrive *drive = NULL;
+
+  monitor = gnome_vfs_get_volume_monitor ();
+
+  drives = gnome_vfs_volume_monitor_get_connected_drives (monitor);
+  for (d = drives; d; d = d->next)
+    {
+      GnomeVFSDrive *dr = d->data;
+
+      if (!strcmp (device, gnome_vfs_drive_get_device_path (dr)))
+	{
+	  drive = dr;
+	  break;
+	}
+    }
+  g_list_free (drives);
+
+  if (drive)
+    gnome_vfs_drive_ref (drive);
+
+  return drive;
+}
+
+static GnomeVFSVolume *
+find_volume (const char *uri)
+{
+  GnomeVFSVolumeMonitor *monitor;
+  GList *volumes, *v;
+  GnomeVFSVolume *volume = NULL;
+
+  monitor = gnome_vfs_get_volume_monitor ();
+
+  volumes = gnome_vfs_volume_monitor_get_mounted_volumes (monitor);
+  for (v = volumes; v; v = v->next)
+    {
+      GnomeVFSVolume *vo = v->data;
+
+      if (!strcmp (uri, gnome_vfs_volume_get_activation_uri (vo)))
+	{
+	  volume = vo;
+	  break;
+	}
+    }
+  g_list_free (volumes);
+
+  if (volume)
+    gnome_vfs_volume_ref (volume);
+
+  return volume;
+}
+
+static void
+hildon_file_system_voldev_volumes_changed (HildonFileSystemSpecialLocation
+					   *location, GtkFileSystem *fs)
+{
+  HildonFileSystemVoldev *voldev = HILDON_FILE_SYSTEM_VOLDEV (location);
+
+  if (voldev->volume)
+    gnome_vfs_volume_unref (voldev->volume);
+  if (voldev->drive)
+    gnome_vfs_drive_unref (voldev->drive);
+
+  if (g_str_has_prefix (location->basepath, "drive://"))
+    voldev->drive = find_drive (location->basepath + 8);
+  else
+    voldev->volume = find_volume (location->basepath);
+
+  if (voldev->volume)
+    {
+      location->fixed_title =
+	gnome_vfs_volume_get_display_name (voldev->volume);
+      location->fixed_icon = gnome_vfs_volume_get_icon (voldev->volume);
+    }
+  else if (voldev->drive)
+    {
+      location->fixed_title = gnome_vfs_drive_get_display_name (voldev->drive);
+      location->fixed_icon = gnome_vfs_drive_get_icon (voldev->drive);
+    }
+  
+  /* XXX */
+  location->fixed_icon = "qgn_list_filesys_mmc_root";
+
+  g_signal_emit_by_name (location, "changed");
+}

Added: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.h
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.h	2007-05-16 14:06:50 UTC (rev 11694)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.h	2007-05-16 14:09:52 UTC (rev 11695)
@@ -0,0 +1,61 @@
+/*
+ * This file is part of hildon-fm package
+ *
+ * Copyright (C) 2007 Nokia Corporation.  All rights reserved.
+ *
+ * Contact: Marius Vollmer <marius.vollmer at nokia.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA
+ *
+ */
+
+#ifndef HILDON_FILE_SYSTEM_VOLDEV_H_
+#define HILDON_FILE_SYSTEM_VOLDEV_H_ 
+
+#include "hildon-file-system-remote-device.h"
+
+#include <libgnomevfs/gnome-vfs.h>
+
+G_BEGIN_DECLS
+
+#define HILDON_TYPE_FILE_SYSTEM_VOLDEV            (hildon_file_system_voldev_get_type ())
+#define HILDON_FILE_SYSTEM_VOLDEV(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), HILDON_TYPE_FILE_SYSTEM_VOLDEV, HildonFileSystemVoldev))
+#define HILDON_FILE_SYSTEM_VOLDEV_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), HILDON_TYPE_FILE_SYSTEM_VOLDEV, HildonFileSystemVoldevClass))
+#define HILDON_IS_FILE_SYSTEM_VOLDEV(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), HILDON_TYPE_FILE_SYSTEM_VOLDEV))
+#define HILDON_IS_FILE_SYSTEM_VOLDEV_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), HILDON_TYPE_FILE_SYSTEM_VOLDEV))
+#define HILDON_FILE_SYSTEM_VOLDEV_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), HILDON_TYPE_FILE_SYSTEM_VOLDEV, HildonFileSystemVoldevClass))
+
+
+typedef struct _HildonFileSystemVoldev HildonFileSystemVoldev;
+typedef struct _HildonFileSystemVoldevClass HildonFileSystemVoldevClass;
+
+
+struct _HildonFileSystemVoldev
+{
+  HildonFileSystemSpecialLocation parent_instance;
+  GnomeVFSVolume *volume;
+  GnomeVFSDrive *drive;
+};
+
+struct _HildonFileSystemVoldevClass
+{
+    HildonFileSystemRemoteDeviceClass parent_class;
+};
+
+GType hildon_file_system_voldev_get_type (void) G_GNUC_CONST;
+
+G_END_DECLS
+
+#endif


More information about the maemo-commits mailing list