[gnome-disk-utility/udisks2-port] Update devtab page on changes



commit 8b2d5c43c53b42ad30a2021166b5653ce1af0372
Author: David Zeuthen <davidz redhat com>
Date:   Mon Mar 14 16:54:20 2011 -0400

    Update devtab page on changes
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 src/palimpsest/gduvolumegrid.c |   41 ++++++++++++++++++++--------
 src/palimpsest/gduvolumegrid.h |    4 +++
 src/palimpsest/gduwindow.c     |   57 +++++++++++++++++++++++++++++++--------
 3 files changed, 78 insertions(+), 24 deletions(-)
---
diff --git a/src/palimpsest/gduvolumegrid.c b/src/palimpsest/gduvolumegrid.c
index de7efa3..40036ae 100644
--- a/src/palimpsest/gduvolumegrid.c
+++ b/src/palimpsest/gduvolumegrid.c
@@ -1978,23 +1978,29 @@ is_disk_or_partition_in_grid (GduVolumeGrid    *grid,
   return ret;
 }
 
-static void
-maybe_update (GduVolumeGrid    *grid,
-              GDBusObjectProxy *object_proxy)
+gboolean
+gdu_volume_grid_includes_object_proxy (GduVolumeGrid       *grid,
+                                       GDBusObjectProxy    *object_proxy)
 {
   UDisksBlockDevice *block;
   const gchar *crypto_backing_device;
   GDBusObjectProxy *crypto_object_proxy;
+  gboolean ret;
 
-  //g_debug ("in maybe_update %s", g_dbus_object_proxy_get_object_path (object_proxy));
+  g_return_val_if_fail (GDU_IS_VOLUME_GRID (grid), FALSE);
+  g_return_val_if_fail (G_IS_DBUS_OBJECT_PROXY (object_proxy), FALSE);
 
+  ret = FALSE;
   crypto_object_proxy = NULL;
 
   if (grid->block_device == NULL)
     goto out;
 
   if (is_disk_or_partition_in_grid (grid, object_proxy))
-    goto update;
+    {
+      ret = TRUE;
+      goto out;
+    }
 
   /* handle when it's a crypt devices for our grid or a partition in it */
   block = UDISKS_PEEK_BLOCK_DEVICE (object_proxy);
@@ -2004,18 +2010,29 @@ maybe_update (GduVolumeGrid    *grid,
       crypto_object_proxy = g_dbus_proxy_manager_lookup (udisks_client_get_proxy_manager (grid->client),
                                                          crypto_backing_device);
       if (crypto_object_proxy != NULL)
-        if (is_disk_or_partition_in_grid (grid, crypto_object_proxy))
-          goto update;
+        {
+          if (is_disk_or_partition_in_grid (grid, crypto_object_proxy))
+            {
+              ret = TRUE;
+              goto out;
+            }
+        }
     }
 
-  goto out;
-
- update:
-  recompute_grid (grid);
-
  out:
   if (crypto_object_proxy != NULL)
     g_object_unref (crypto_object_proxy);
+  return ret;
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
+static void
+maybe_update (GduVolumeGrid    *grid,
+              GDBusObjectProxy *object_proxy)
+{
+  if (gdu_volume_grid_includes_object_proxy (grid, object_proxy))
+    recompute_grid (grid);
 }
 
 static void
diff --git a/src/palimpsest/gduvolumegrid.h b/src/palimpsest/gduvolumegrid.h
index 384726e..9d698db 100644
--- a/src/palimpsest/gduvolumegrid.h
+++ b/src/palimpsest/gduvolumegrid.h
@@ -43,6 +43,10 @@ void                      gdu_volume_grid_set_container_markup  (GduVolumeGrid
                                                                  const gchar         *text);
 void                      gdu_volume_grid_set_container_icon    (GduVolumeGrid       *grid,
                                                                  GIcon               *icon);
+
+gboolean                  gdu_volume_grid_includes_object_proxy (GduVolumeGrid       *grid,
+                                                                 GDBusObjectProxy    *object_proxy);
+
 GduVolumeGridElementType  gdu_volume_grid_get_selected_type     (GduVolumeGrid       *grid);
 GDBusObjectProxy         *gdu_volume_grid_get_selected_device   (GduVolumeGrid       *grid);
 guint64                   gdu_volume_grid_get_selected_offset   (GduVolumeGrid       *grid);
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index 99c84d6..fdbd69c 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -641,6 +641,8 @@ block_device_compare_on_preferred (GDBusObjectProxy *a,
                     udisks_block_device_get_preferred_device (UDISKS_PEEK_BLOCK_DEVICE (b)));
 }
 
+/* ---------------------------------------------------------------------------------------------------- */
+
 static void
 setup_device_page (GduWindow         *window,
                    GDBusObjectProxy *object_proxy)
@@ -706,6 +708,16 @@ setup_device_page (GduWindow         *window,
     }
 }
 
+static void update_devtab (GduWindow *window);
+
+static void
+update_device_page (GduWindow *window)
+{
+  update_devtab (window);
+}
+
+/* ---------------------------------------------------------------------------------------------------- */
+
 static void
 setup_details_page (GduWindow         *window,
                     GDBusObjectProxy *object_proxy,
@@ -727,6 +739,25 @@ setup_details_page (GduWindow         *window,
 }
 
 static void
+update_details_page (GduWindow         *window,
+                     gint              page)
+{
+  //g_debug ("update for %s, page %d",
+  //         object_proxy != NULL ? g_dbus_object_proxy_get_object_path (object_proxy) : "<none>",
+  //         page);
+
+  switch (page)
+    {
+    case DETAILS_PAGE_NOT_SELECTED:
+      break;
+
+    case DETAILS_PAGE_DEVICE:
+      update_device_page (window);
+      break;
+    }
+}
+
+static void
 select_details_page (GduWindow         *window,
                      GDBusObjectProxy  *object_proxy,
                      DetailsPage        page)
@@ -749,25 +780,27 @@ select_details_page (GduWindow         *window,
   setup_details_page (window,
                       window->current_object_proxy,
                       window->current_page);
-}
 
-static void
-update_details_page (GduWindow *window)
-{
-  teardown_details_page (window,
-                         window->current_object_proxy,
-                         window->current_page);
-  setup_details_page (window,
-                      window->current_object_proxy,
-                      window->current_page);
+  update_details_page (window, window->current_page);
 }
 
 static void
 update_all (GduWindow         *window,
             GDBusObjectProxy  *object_proxy)
 {
-  if (window->current_object_proxy == object_proxy)
-    update_details_page (window);
+  g_debug ("In %s co=%p (%s) op=%p (%s)",
+           G_STRFUNC,
+           window->current_object_proxy, g_dbus_object_proxy_get_object_path (window->current_object_proxy),
+           object_proxy, g_dbus_object_proxy_get_object_path (object_proxy));
+
+  if (window->current_page == DETAILS_PAGE_DEVICE)
+    {
+      /* this is a little too inclusive.. */
+      if (gdu_volume_grid_includes_object_proxy (GDU_VOLUME_GRID (window->volume_grid), object_proxy))
+        {
+          update_details_page (window, window->current_page);
+        }
+    }
 }
 
 static void



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