[gnome-disk-utility] Avoid hiding widgets only to show them again



commit d2e881b91ea0e315779df5a4be697f1ada34b791
Author: David Zeuthen <zeuthen gmail com>
Date:   Fri Jan 4 12:29:52 2013 -0500

    Avoid hiding widgets only to show them again
    
    Doing so causes focus problems resulting in the inability to click a
    button if, say, the window is continously updated (e.g. update_all()
    called several times a second).
    
    This problem manifested itself if the user was creating disk images
    for two devices and the first finished before the second. Since the
    second was still in progress the window was continously updated. This
    resulted in an inability to click the eject button for the former.
    
    Signed-off-by: David Zeuthen <zeuthen gmail com>

 src/disks/gduwindow.c |   52 +++++++++++++++++++++++++++++++++++-------------
 1 files changed, 38 insertions(+), 14 deletions(-)
---
diff --git a/src/disks/gduwindow.c b/src/disks/gduwindow.c
index 0a1f905..379ae36 100644
--- a/src/disks/gduwindow.c
+++ b/src/disks/gduwindow.c
@@ -1591,13 +1591,13 @@ gdu_window_constructed (GObject *object)
 
   /* cancel-button for drive job */
   g_signal_connect (window->devtab_drive_job_cancel_button,
-                    "pressed",
+                    "clicked",
                     G_CALLBACK (on_drive_job_cancel_button_clicked),
                     window);
 
   /* cancel-button for job */
   g_signal_connect (window->devtab_job_cancel_button,
-                    "pressed",
+                    "clicked",
                     G_CALLBACK (on_job_cancel_button_clicked),
                     window);
 
@@ -2768,7 +2768,6 @@ update_device_page_for_drive (GduWindow      *window,
   gtk_widget_show (window->devtab_drive_box);
   gtk_widget_show (window->devtab_drive_vbox);
   gtk_widget_show (window->devtab_drive_buttonbox);
-  gtk_widget_show (window->devtab_drive_eject_button);
   gtk_widget_show (window->devtab_drive_generic_button);
 
   if (udisks_object_info_get_media_icon (info) != NULL)
@@ -3514,6 +3513,33 @@ device_page_ensure_grid (GduWindow *window)
 }
 
 static void
+maybe_hide (GtkWidget *widget,
+            gpointer   user_data)
+{
+  GduWindow *window = GDU_WINDOW (user_data);
+
+  /* Don't hide drive box since visibility of its children (buttons)
+   * are controlled in update_for_show_flags() - hiding it here only
+   * to show it later may cause focus problems so the buttons can't
+   * be clicked if the window is continously updated (say, a job is
+   * running).
+   *
+   * Same for the grid containing the job widgets. Their visibility is
+   * manually controlled in update_jobs().
+   */
+  if (widget == window->devtab_drive_box ||
+      widget == window->devtab_drive_job_grid ||
+      widget == window->devtab_job_grid)
+    {
+      /* do nothing */
+    }
+  else
+    {
+      gtk_widget_hide (widget);
+    }
+}
+
+static void
 update_device_page (GduWindow      *window,
                     ShowFlags      *show_flags)
 {
@@ -3524,18 +3550,16 @@ update_device_page (GduWindow      *window,
   UDisksMDRaid *mdraid;
   UDisksLoop *loop = NULL;
   guint64 size;
-  GList *children;
-  GList *l;
 
-  /* first hide everything */
-  gtk_container_foreach (GTK_CONTAINER (window->devtab_drive_table), (GtkCallback) gtk_widget_hide, NULL);
-  gtk_container_foreach (GTK_CONTAINER (window->devtab_table), (GtkCallback) gtk_widget_hide, NULL);
-  children = gtk_action_group_list_actions (GTK_ACTION_GROUP (gtk_builder_get_object (window->builder, "devtab-actions")));
-  for (l = children; l != NULL; l = l->next)
-    gtk_action_set_visible (GTK_ACTION (l->data), FALSE);
-  g_list_free (children);
+  /* First hide everything
+   *
+   * (TODO: this is wrong as hiding a widget only to show it again, is
+   * a cause for bad focus problems in GTK+)
+   */
+  gtk_container_foreach (GTK_CONTAINER (window->devtab_drive_table), maybe_hide, window);
+  gtk_container_foreach (GTK_CONTAINER (window->devtab_table), maybe_hide, window);
 
-  /* Hide all Drive-specific items - will be turned on again in update_device_page_for_drive() */
+  /* Hide all Drive-specific menu items - will be turned on again in update_device_page_for_drive() */
   gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_drive_sep_1));
   gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_view_smart));
   gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_disk_settings));
@@ -3544,7 +3568,7 @@ update_device_page (GduWindow      *window,
   gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_resume_now));
   gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_power_off));
 
-  /* Hide all MDRaid-specific items - will be turned on again in update_device_page_for_mdraid() */
+  /* Hide all MDRaid-specific menu items - will be turned on again in update_device_page_for_mdraid() */
   gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_mdraid_sep_1));
   gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_mdraid_disks));
   gtk_widget_hide (GTK_WIDGET (window->generic_drive_menu_item_mdraid_start_data_scrubbing));



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