[maemo-commits] [maemo-commits] r13584 - in projects/haf/trunk/hildon-fm: . hildon-fm

From: subversion at stage.maemo.org subversion at stage.maemo.org
Date: Tue Sep 4 17:00:06 EEST 2007
Author: marivoll
Date: 2007-09-04 16:59:57 +0300 (Tue, 04 Sep 2007)
New Revision: 13584

Modified:
   projects/haf/trunk/hildon-fm/ChangeLog
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-model.c
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-obex.c
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-obex.h
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-old-gateway.c
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-private.c
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-root.c
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-smb.c
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-smb.h
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-special-location.c
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-special-location.h
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-upnp.c
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-upnp.h
   projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.c
Log:
	Another attempt at getting the visibility of special locations
	right.  Fixes among other things N67184.  In general, rescanning
	of special locations should now work correctly and visiblity
	should be determined more reliably.
	
	* hildon-fm/hildon-file-system-private.c
	(_hildon_file_system_get_special_location): Call
	hildon_file_system_special_location_volumes_changed always, not
	just when a new location was created, since old ones might need to
	be reinitialized.

	* hildon-fm/hildon-file-system-special-location.h (struct
	_HildonFileSystemSpecialLocation): Added 'permanent' flag.
	* hildon-fm/hildon-file-system-special-location.c
	(hildon_file_system_special_location_init): Initialize it to TRUE.

	* hildon-fm/hildon-file-system-model.c (handle_finished_node): Do
	not kick permanent special locations, but kick everything else.
	(link_file_folder): Reset the present flags so that
	handle_finished_node can do its kicking.

	* hildon-fm/hildon-file-system-root.c
	(hildon_file_system_root_create_child_location): Make children
	non-permanent.
	* hildon-fm/hildon-file-system-upnp.c
	(hildon_file_system_upnp_create_child_location): Likewise.
	* hildon-fm/hildon-file-system-smb.c
	(hildon_file_system_smb_create_child_location): Likewise.

	* hildon-fm/hildon-file-system-root.c
	(root_file_folder_list_children): Do not leak reference counts for
	volumes and drives.
	
	* hildon-fm/hildon-file-system-model.c (location_rescan): Don't
	remove children before rescanning, that is too drastic.  Always
	rescan, independent of visibility or other heuristics that try to
	determine whether it is needed or not.
	(real_volumes_changed): Reverted change of 2007-08-31: Don't try
	to pick out only those locations that are affected; just call
	notify_volumes_changed on all special locations and expect them to
	deal with it.

	* hildon-fm/hildon-file-system-special-location.c,
	hildon-fm/hildon-file-system-special-location.h
	(hildon_file_system_special_location_is_visible): Added
	has_children parameter.  Changed all users to use it instead of
	trying to keep track of whether they have children or not
	themselves.

        * hildon-fm/hildon-file-system-private.c (create_child_location):
	Reverted change of 2007-08-31.  Special locations should not be
	destroyed, ever.


Modified: projects/haf/trunk/hildon-fm/ChangeLog
===================================================================
--- projects/haf/trunk/hildon-fm/ChangeLog	2007-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/ChangeLog	2007-09-04 13:59:57 UTC (rev 13584)
@@ -1,3 +1,58 @@
+2007-09-04  Marius Vollmer  <marius.vollmer at nokia.com>
+
+	Another attempt at getting the visibility of special locations
+	right.  Fixes among other things N67184.  In general, rescanning
+	of special locations should now work correctly and visiblity
+	should be determined more reliably.
+	
+	* hildon-fm/hildon-file-system-private.c
+	(_hildon_file_system_get_special_location): Call
+	hildon_file_system_special_location_volumes_changed always, not
+	just when a new location was created, since old ones might need to
+	be reinitialized.
+
+	* hildon-fm/hildon-file-system-special-location.h (struct
+	_HildonFileSystemSpecialLocation): Added 'permanent' flag.
+	* hildon-fm/hildon-file-system-special-location.c
+	(hildon_file_system_special_location_init): Initialize it to TRUE.
+
+	* hildon-fm/hildon-file-system-model.c (handle_finished_node): Do
+	not kick permanent special locations, but kick everything else.
+	(link_file_folder): Reset the present flags so that
+	handle_finished_node can do its kicking.
+
+	* hildon-fm/hildon-file-system-root.c
+	(hildon_file_system_root_create_child_location): Make children
+	non-permanent.
+	* hildon-fm/hildon-file-system-upnp.c
+	(hildon_file_system_upnp_create_child_location): Likewise.
+	* hildon-fm/hildon-file-system-smb.c
+	(hildon_file_system_smb_create_child_location): Likewise.
+
+	* hildon-fm/hildon-file-system-root.c
+	(root_file_folder_list_children): Do not leak reference counts for
+	volumes and drives.
+	
+	* hildon-fm/hildon-file-system-model.c (location_rescan): Don't
+	remove children before rescanning, that is too drastic.  Always
+	rescan, independent of visibility or other heuristics that try to
+	determine whether it is needed or not.
+	(real_volumes_changed): Reverted change of 2007-08-31: Don't try
+	to pick out only those locations that are affected; just call
+	notify_volumes_changed on all special locations and expect them to
+	deal with it.
+
+	* hildon-fm/hildon-file-system-special-location.c,
+	hildon-fm/hildon-file-system-special-location.h
+	(hildon_file_system_special_location_is_visible): Added
+	has_children parameter.  Changed all users to use it instead of
+	trying to keep track of whether they have children or not
+	themselves.
+
+        * hildon-fm/hildon-file-system-private.c (create_child_location):
+	Reverted change of 2007-08-31.  Special locations should not be
+	destroyed, ever.
+
 2007-08-31  Marius Vollmer  <marius.vollmer at nokia.com>
 
 	* hildon-fm/hildon-file-chooser-dialog.c

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-model.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-model.c	2007-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-model.c	2007-09-04 13:59:57 UTC (rev 13584)
@@ -229,18 +229,17 @@
   GtkTreeIter iter;
   HildonFileSystemModel *model = MODEL_FROM_NODE(node);
   GNode *child_node;
+  HildonFileSystemModelNode *model_node = node->data;
 
   child_node = g_node_first_child(node);
   while (child_node)
     {
       HildonFileSystemModelNode *model_node = child_node->data;
 
-      /* We do not want to ever kick off devices by accident */
-
+      /* We do not want to ever kick permanent special locations. */
+      
       if (model_node->present_flag
-	  || (model_node->location
-	      && (!hildon_file_system_special_location_failed_access
-		  (model_node->location))))
+	  || (model_node->location && model_node->location->permanent))
 	child_node = g_node_next_sibling(child_node);
       else
 	child_node = hildon_file_system_model_kick_node(child_node, model);
@@ -960,7 +959,7 @@
       gboolean result;
 
       if (model_node->location)
-        result = !hildon_file_system_special_location_is_visible(model_node->location);
+        result = !hildon_file_system_special_location_is_visible(model_node->location, g_node_first_child(node) != NULL);
       else if (!info)
         result = FALSE;
       else
@@ -1543,6 +1542,7 @@
   HildonFileSystemModelNode *model_node;
   GtkFileFolder *parent_folder;
   HandleData *handle_data;
+  GNode *child_node;
 
   g_assert(node != NULL && path != NULL);
   model_node = node->data;
@@ -1566,6 +1566,16 @@
   parent_folder = (node->parent && node->parent->data) ?
       ((HildonFileSystemModelNode *) node->parent->data)->folder : NULL;
 
+  /* Reset the present_flags.
+   */
+  child_node = g_node_first_child(node);
+  while (child_node)
+    {
+      HildonFileSystemModelNode *model_node = child_node->data;
+      model_node->present_flag = FALSE;
+      child_node = g_node_next_sibling(child_node);
+    }
+
   /* hold a reference to the model, it will be released
    * when the get_folder operation has finished
    */
@@ -1681,15 +1691,12 @@
   return node;
 }
 
-static gboolean get_locations (GNode *node, gpointer data)
+static gboolean notify_volumes_changed(GNode *node, gpointer data)
 {
     HildonFileSystemModelNode *model_node = node->data;
-    GHashTable **locations = (GHashTable **) data;
 
     if (model_node->location)
-	    g_hash_table_insert (*locations,
-				 g_strdup (model_node->location->basepath),
-				 g_object_ref (model_node->location));
+	hildon_file_system_special_location_volumes_changed(model_node->location, data);
 
     return FALSE;
 }
@@ -1698,45 +1705,15 @@
 {
     HildonFileSystemModel *model;
     HildonFileSystemModelPrivate *priv;
-    GHashTable *locations;
-    GSList *volumes;
 
     ULOG_DEBUG_F("entered");
 
     model = HILDON_FILE_SYSTEM_MODEL (data);
     priv = CAST_GET_PRIVATE(model);
 
-    volumes = gtk_file_system_list_volumes (fs);
-    locations = g_hash_table_new_full (g_str_hash, g_str_equal,
-				       (GDestroyNotify) g_free,
-				       (GDestroyNotify) g_object_unref);
-
     g_node_traverse(priv->roots,
-		    G_PRE_ORDER, G_TRAVERSE_ALL, -1,
-		    get_locations, &locations);
-
-    while (volumes) {
-	    GtkFilePath *path;
-	    GtkFileSystemVolume *volume;
-	    HildonFileSystemSpecialLocation *location;
-
-	    volume = volumes->data;
-	    path = gtk_file_system_volume_get_base_path (fs, volume);
-
-	    if (path) {
-		    location = g_hash_table_lookup (locations, path);
-
-		    if (location &&
-			(!gtk_file_system_volume_get_is_mounted (fs, volume) ||
-			 !hildon_file_system_special_location_is_visible (location))) {
-			    hildon_file_system_special_location_volumes_changed(location, fs);
-		    }
-	    }
-
-	    volumes = volumes->next;
-    }
-
-    g_hash_table_unref (locations);
+            G_PRE_ORDER, G_TRAVERSE_ALL, -1,
+            notify_volumes_changed, fs);
 }
 
 static GNode *
@@ -1759,7 +1736,6 @@
 
     priv = CAST_GET_PRIVATE(model);
 
-
     ULOG_INFO("Adding %s", (const char *) path);
 
     if (parent_folder) {
@@ -2396,20 +2372,11 @@
     g_assert(HILDON_IS_FILE_SYSTEM_SPECIAL_LOCATION(location));
     g_assert(node != NULL && node->data != NULL);
 
-    ULOG_INFO("LOCATION RESCAN: %s", location->basepath);
-
     model_node = node->data;
     model = model_node->model;
 
-    /* remove all children */
-    child = node->children;
-    while (child)
-	    child = hildon_file_system_model_kick_node(child, model);
-
-    unlink_file_folder (node);
-
-    hildon_file_system_model_reload_node
-	    (HILDON_FILE_SYSTEM_MODEL(model), node, TRUE);
+    unlink_file_folder(node);
+    link_file_folder(node, model_node->path);
 }
 
 static HildonFileSystemModelNode *

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-obex.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-obex.c	2007-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-obex.c	2007-09-04 13:59:57 UTC (rev 13584)
@@ -46,7 +46,8 @@
 hildon_file_system_obex_create_child_location (HildonFileSystemSpecialLocation *location, gchar *uri);
 
 static gboolean
-hildon_file_system_obex_is_visible (HildonFileSystemSpecialLocation *location);
+hildon_file_system_obex_is_visible (HildonFileSystemSpecialLocation *location,
+				    gboolean has_children);
 
 G_DEFINE_TYPE (HildonFileSystemObex,
                hildon_file_system_obex,
@@ -84,12 +85,9 @@
 bondings_changed (GObject *settings, GParamSpec *param, gpointer data)
 {
   HildonFileSystemObex *obex = HILDON_FILE_SYSTEM_OBEX (data);
-  gint bondings;
 
-  g_object_get (settings, "bondings", &bondings, NULL);
+  fprintf (stderr, "OBEX BONDINGS CHANGED\n");
 
-  obex->has_children = (bondings > 0);
-
   g_signal_emit_by_name (data, "changed");
   g_signal_emit_by_name (data, "rescan");
 }
@@ -108,8 +106,6 @@
     location->fixed_title = g_strdup (_("sfil_li_bluetooth"));
     location->failed_access_message = NULL;
 
-    device->has_children = FALSE;
-
     device->bonding_handler_id =
       g_signal_connect (fs_settings,
                         "notify::bondings",
@@ -171,19 +167,21 @@
 
 	g_free (new_uri);
 
+	fprintf (stderr, "OBEX CHILD %s\n", uri);
+
         child->basepath = g_strdup (uri);
         child->failed_access_message = _("sfil_ib_cannot_connect_device");
-
-        HILDON_FILE_SYSTEM_OBEX(location)->has_children = TRUE;
+	child->permanent = FALSE;
     }
 
     return child;
 }
 
 static gboolean
-hildon_file_system_obex_is_visible (HildonFileSystemSpecialLocation *location)
+hildon_file_system_obex_is_visible (HildonFileSystemSpecialLocation *location,
+				    gboolean has_children)
 {
-  return HILDON_FILE_SYSTEM_OBEX (location)->has_children;
+  return has_children;
 }
 
 /* very dependant on how things work now */

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-obex.h
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-obex.h	2007-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-obex.h	2007-09-04 13:59:57 UTC (rev 13584)
@@ -51,7 +51,6 @@
 struct _HildonFileSystemObex
 {
     HildonFileSystemRemoteDevice parent_instance;
-    gboolean has_children;
     gint bonding_handler_id;
 };
 

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-old-gateway.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-old-gateway.c	2007-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-old-gateway.c	2007-09-04 13:59:57 UTC (rev 13584)
@@ -42,7 +42,8 @@
                                             *location);
 static gboolean
 hildon_file_system_old_gateway_is_visible (HildonFileSystemSpecialLocation
-                                           *location);
+                                           *location,
+					   gboolean has_children);
 static gchar*
 hildon_file_system_old_gateway_get_display_name (HildonFileSystemSpecialLocation
                                                  *location, GtkFileSystem *fs);
@@ -135,7 +136,7 @@
 
 static gboolean
 hildon_file_system_old_gateway_is_visible (HildonFileSystemSpecialLocation
-                                           *location)
+                                           *location, gboolean has_children)
 {
     HildonFileSystemOldGateway *gateway;
     gateway = HILDON_FILE_SYSTEM_OLD_GATEWAY (location);

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-private.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-private.c	2007-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-private.c	2007-09-04 13:59:57 UTC (rev 13584)
@@ -230,15 +230,13 @@
 		       const gchar                     *uri)
 {
     HildonFileSystemSpecialLocation *location;
-    GNode *node;
 
     location = hildon_file_system_special_location_create_child_location (
 	    parent_location, (gchar *) uri);
 
     if (location) {
-	node = g_node_append_data (parent, location);
-
-	g_object_weak_ref (G_OBJECT (location), (GWeakNotify) g_node_destroy, node);
+        g_object_ref (location);
+	g_node_append_data (parent, location);
     }
 
     return location;
@@ -305,7 +303,7 @@
         g_free(data.uri);
     }
 
-    if (data.result && data.is_child)
+    if (data.result)
       hildon_file_system_special_location_volumes_changed (data.result, fs);
 
     return data.result;

Modified: 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-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-root.c	2007-09-04 13:59:57 UTC (rev 13584)
@@ -99,6 +99,8 @@
     {
       child = g_object_new (HILDON_TYPE_FILE_SYSTEM_VOLDEV, NULL);
       child->basepath = g_strdup (uri);
+      child->permanent = FALSE;
+      hildon_file_system_special_location_volumes_changed (child, NULL);
     }
 
   return child;
@@ -226,6 +228,7 @@
                                       gtk_file_system_uri_to_path (fs, uri));
         }
     }
+  g_list_foreach (volumes, (GFunc) g_object_unref, NULL);
   g_list_free (volumes);
 
   drives = gnome_vfs_volume_monitor_get_connected_drives (monitor);
@@ -243,6 +246,7 @@
           g_free (uri);
         }
     }
+  g_list_foreach (drives, (GFunc) g_object_unref, NULL);
   g_list_free (drives);
 
   return TRUE;

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-smb.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-smb.c	2007-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-smb.c	2007-09-04 13:59:57 UTC (rev 13584)
@@ -41,7 +41,8 @@
                                                *location, gchar *uri);
 
 static gboolean
-hildon_file_system_smb_is_visible (HildonFileSystemSpecialLocation *location);
+hildon_file_system_smb_is_visible (HildonFileSystemSpecialLocation *location,
+				   gboolean has_children);
 
 static gboolean
 hildon_file_system_smb_is_available (HildonFileSystemSpecialLocation *location);
@@ -86,9 +87,9 @@
 {
   HildonFileSystemSmb *smb = HILDON_FILE_SYSTEM_SMB (data);
 
-  smb->has_children = FALSE;
   g_signal_emit_by_name (data, "connection-state");
   g_signal_emit_by_name (data, "rescan");
+  g_signal_emit_by_name (data, "changed");
 }
 
 static void
@@ -106,8 +107,6 @@
     location->failed_access_message = NULL;
     location->sort_weight = SORT_WEIGHT_SMB;
 
-    device->has_children = FALSE;
-
     device->connected_handler_id =
       g_signal_connect (fs_settings,
                         "notify::iap-connected",
@@ -153,16 +152,18 @@
                                                     "qgn_list_filesys_samba");
       child->failed_access_message = _("sfil_ib_cannot_connect_device");
       child->basepath = g_strdup (uri);
-      HILDON_FILE_SYSTEM_SMB (location)->has_children = TRUE;
+      child->permanent = FALSE;
     }
 
   return child;
 }
 
 static gboolean
-hildon_file_system_smb_is_visible (HildonFileSystemSpecialLocation *location)
+hildon_file_system_smb_is_visible (HildonFileSystemSpecialLocation *location,
+				   gboolean has_children)
 {
-  if (!HILDON_FILE_SYSTEM_SMB (location)->has_children)
+  fprintf (stderr, "SMB VISIBLE (%d)\n", has_children);
+  if (!has_children)
     return FALSE;
   else
     return hildon_file_system_smb_is_available (location);
@@ -176,6 +177,7 @@
 
   fs_settings = _hildon_file_system_settings_get_instance ();
   g_object_get (fs_settings, "iap-connected", &connected, NULL);
+
   return connected;
 }
 
@@ -187,6 +189,7 @@
                                    GtkFileSystemGetFolderCallback  callback,
                                    gpointer                        data)
 {
+  fprintf (stderr, "SMB GETFOLDER\n");
   return hildon_file_system_smb_get_workgroups_folder (file_system,
                                                        path,
                                                        types,
@@ -314,6 +317,8 @@
   MyFileFolder *my_folder = MY_FILE_FOLDER (folder);
   GList *c;
 
+  fprintf (stderr, "SMB GOT CHILDREN (%d)\n", g_list_length (children));
+
   *children = NULL;
   for (c = my_folder->children; c; c = c->next)
     {
@@ -327,6 +332,8 @@
       *children = g_slist_append (*children, childrens_children);
     }
 
+  fprintf (stderr, "SMB GOT CHILDREN (%d)\n", g_list_length (children));
+
   return TRUE;
 }
 
@@ -336,6 +343,8 @@
   MyFileFolder *my_folder = MY_FILE_FOLDER (folder);
   GList *c;
 
+  fprintf (stderr, "SMB FINISHED\n");
+
   if (!gtk_file_folder_is_finished_loading (GTK_FILE_FOLDER (my_folder->root)))
     return FALSE;
 
@@ -347,6 +356,8 @@
       if (!gtk_file_folder_is_finished_loading (GTK_FILE_FOLDER (c->data)))
         return FALSE;
     }
+
+  fprintf (stderr, "SMB TRUE\n");
   return TRUE;
 }
 
@@ -400,6 +411,8 @@
       GtkFilePath *p = paths->data;
       GtkFilePath *my_p = my_file_folder_collaps_path (p);
 
+      fprintf (stderr, "SMB CHILD %s\n", gtk_file_path_get_string (my_p));
+
       my_paths = g_slist_append (my_paths, my_p);
       paths = paths->next;
     }
@@ -424,6 +437,8 @@
 
   g_object_unref (handle);
 
+  fprintf (stderr, "SMB CHILD FOLDER %p\n", folder);
+
   if (folder)
     {
       my_folder->children = g_list_append (my_folder->children,
@@ -446,6 +461,7 @@
   while (paths)
     {
       GtkFilePath *p = paths->data;
+      fprintf (stderr, "SMB ROOT %s\n", gtk_file_path_get_string (p));
       my_folder->n_children_waiting++;
       gtk_file_system_get_folder (my_folder->filesystem,
                                   p,

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-smb.h
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-smb.h	2007-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-smb.h	2007-09-04 13:59:57 UTC (rev 13584)
@@ -43,7 +43,6 @@
 struct _HildonFileSystemSmb
 {
     HildonFileSystemRemoteDevice parent_instance;
-    gboolean has_children;
     gint connected_handler_id;
 };
 

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-special-location.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-special-location.c	2007-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-special-location.c	2007-09-04 13:59:57 UTC (rev 13584)
@@ -95,6 +95,7 @@
                                           *location)
 {
     location->sort_weight = SORT_WEIGHT_DEVICE;
+    location->permanent = TRUE;
 }
 
 static void
@@ -205,7 +206,8 @@
  * are visible. */
 gboolean
 hildon_file_system_special_location_is_visible (HildonFileSystemSpecialLocation
-                                                *location)
+                                                *location,
+						gboolean has_children)
 {
     HildonFileSystemSpecialLocationClass *klass;
 
@@ -215,7 +217,7 @@
     klass = HILDON_FILE_SYSTEM_SPECIAL_LOCATION_GET_CLASS (location);
 
     if (klass->is_visible)
-        return klass->is_visible (location);
+        return klass->is_visible (location, has_children);
 
     return TRUE;
 }

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-special-location.h
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-special-location.h	2007-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-special-location.h	2007-09-04 13:59:57 UTC (rev 13584)
@@ -64,6 +64,7 @@
     const gchar *failed_access_message; /* Default failed accessa message */
     gint  sort_weight;  /* How the location behaves while sorting */
     HildonFileSystemModelItemType compatibility_type; /* For backwards compatibility */
+    gboolean permanent;
 };
 
 struct _HildonFileSystemSpecialLocationClass
@@ -76,7 +77,8 @@
   GdkPixbuf* (*get_icon) (HildonFileSystemSpecialLocation *location,
 			  GtkFileSystem *fs, GtkWidget *ref_widget, int size);
   gboolean (*is_available) (HildonFileSystemSpecialLocation *location);
-  gboolean (*is_visible) (HildonFileSystemSpecialLocation *location);
+  gboolean (*is_visible) (HildonFileSystemSpecialLocation *location,
+			  gboolean has_children);
   gchar* (*get_unavailable_reason) (HildonFileSystemSpecialLocation *location);
   gboolean (*requires_access) (HildonFileSystemSpecialLocation *location);
   gboolean (*failed_access) (HildonFileSystemSpecialLocation *location);
@@ -123,7 +125,7 @@
 /* Whether or not the location should be shown at all. For example, undefined
  * old-style gateways should not be shown at all. By default all locations
  * are visible. */
-gboolean hildon_file_system_special_location_is_visible (HildonFileSystemSpecialLocation *location);
+gboolean hildon_file_system_special_location_is_visible (HildonFileSystemSpecialLocation *location, gboolean has_children);
 
 /* Why the location should be dimmed. Used in infoprints. If the subclass
  * doesn't define this method, the default result is NULL, since by

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-upnp.c
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-upnp.c	2007-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-upnp.c	2007-09-04 13:59:57 UTC (rev 13584)
@@ -40,7 +40,8 @@
                                                *location, gchar *uri);
 
 static gboolean
-hildon_file_system_upnp_is_visible (HildonFileSystemSpecialLocation *location);
+hildon_file_system_upnp_is_visible (HildonFileSystemSpecialLocation *location,
+				    gboolean has_children);
 
 static gboolean
 hildon_file_system_upnp_is_available (HildonFileSystemSpecialLocation *location);
@@ -70,7 +71,6 @@
 {
   HildonFileSystemUpnp *upnp = HILDON_FILE_SYSTEM_UPNP (data);
 
-  upnp->has_children = FALSE;
   g_signal_emit_by_name (data, "connection-state");
   g_signal_emit_by_name (data, "rescan");
 }
@@ -90,8 +90,6 @@
     location->failed_access_message = NULL;
     location->sort_weight = SORT_WEIGHT_UPNP;
 
-    device->has_children = FALSE;
-
     device->connected_handler_id =
       g_signal_connect (fs_settings,
                         "notify::iap-connected",
@@ -142,19 +140,18 @@
       hildon_file_system_special_location_set_icon
         (child, "qgn_list_filesys_mediaserver");
       child->failed_access_message = _("sfil_ib_cannot_connect_device");
-
-      HILDON_FILE_SYSTEM_UPNP (location)->has_children = TRUE;
-
       child->basepath = g_strdup (uri);
+      child->permanent = FALSE;
     }
 
     return child;
 }
 
 static gboolean
-hildon_file_system_upnp_is_visible (HildonFileSystemSpecialLocation *location)
+hildon_file_system_upnp_is_visible (HildonFileSystemSpecialLocation *location,
+				    gboolean has_children)
 {
-  if (!HILDON_FILE_SYSTEM_UPNP (location)->has_children)
+  if (!has_children)
     return FALSE;
   else
     return hildon_file_system_upnp_is_available (location);

Modified: projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-upnp.h
===================================================================
--- projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-upnp.h	2007-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-upnp.h	2007-09-04 13:59:57 UTC (rev 13584)
@@ -43,7 +43,6 @@
 struct _HildonFileSystemUpnp
 {
     HildonFileSystemRemoteDevice parent_instance;
-    gboolean has_children;
     gint connected_handler_id;
 };
 

Modified: 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-09-04 13:56:16 UTC (rev 13583)
+++ projects/haf/trunk/hildon-fm/hildon-fm/hildon-file-system-voldev.c	2007-09-04 13:59:57 UTC (rev 13584)
@@ -43,7 +43,8 @@
 hildon_file_system_voldev_init (HildonFileSystemVoldev *device);
 
 static gboolean
-hildon_file_system_voldev_is_visible (HildonFileSystemSpecialLocation *location);
+hildon_file_system_voldev_is_visible (HildonFileSystemSpecialLocation *location,
+				      gboolean has_children);
 
 static void
 hildon_file_system_voldev_volumes_changed (HildonFileSystemSpecialLocation
@@ -155,7 +156,8 @@
 }
 
 static gboolean
-hildon_file_system_voldev_is_visible (HildonFileSystemSpecialLocation *location)
+hildon_file_system_voldev_is_visible (HildonFileSystemSpecialLocation *location,
+				      gboolean has_children)
 {
   HildonFileSystemVoldev *voldev = HILDON_FILE_SYSTEM_VOLDEV (location);
   HildonFileSystemVoldevClass *klass =
@@ -186,13 +188,14 @@
 
   ULOG_DEBUG_F("%s type: %d, used_over_usb: %d", location->basepath,
                voldev->vol_type, voldev->used_over_usb);
+
   if (voldev->volume && !voldev->used_over_usb)
     visible = gnome_vfs_volume_is_mounted (voldev->volume);
   else if (voldev->drive && voldev->vol_type == USB_STORAGE)
     visible = FALSE; /* USB drives are never visible */
   else if (voldev->drive && !voldev->used_over_usb)
     visible = (gnome_vfs_drive_is_connected (voldev->drive)
-               && !gnome_vfs_drive_is_mounted (voldev->drive));
+	       && !gnome_vfs_drive_is_mounted (voldev->drive));
 
   return visible;
 }
@@ -417,12 +420,14 @@
 	  if (voldev->vol_type == INT_CARD)
 	    {
 	      location->sort_weight = SORT_WEIGHT_INTERNAL_MMC;
-	      location->fixed_icon = g_strdup ("qgn_list_gene_internal_memory_card");
+	      location->fixed_icon =
+		g_strdup ("qgn_list_gene_internal_memory_card");
 	    }
 	  else
 	    {
 	      location->sort_weight = SORT_WEIGHT_EXTERNAL_MMC;
-	      location->fixed_icon = g_strdup ("qgn_list_gene_removable_memory_card");
+	      location->fixed_icon = 
+		g_strdup ("qgn_list_gene_removable_memory_card");
 	    }
 	  
 	  location->fixed_title = beautify_mmc_name (location->fixed_title,


More information about the maemo-commits mailing list