[gnome-disk-utility/udisks2-port] Re-add tree-view header (with mnemonic) so it's easy to focus it



commit 859a0b2335b6b0bded5e96b529b5d671cd4a2e6b
Author: David Zeuthen <davidz redhat com>
Date:   Wed Jul 20 09:59:54 2011 -0400

    Re-add tree-view header (with mnemonic) so it's easy to focus it
    
    Also nuke the "Disk Drives" tree item
    
    http://people.freedesktop.org/~david/palimpsest-with-treeview-header.png
    
    Signed-off-by: David Zeuthen <davidz redhat com>

 data/ui/palimpsest.ui               |    2 +-
 src/palimpsest/gdudevicetreemodel.c |   50 +++-------------------------------
 src/palimpsest/gduwindow.c          |    8 +++++
 3 files changed, 14 insertions(+), 46 deletions(-)
---
diff --git a/data/ui/palimpsest.ui b/data/ui/palimpsest.ui
index 3a6cfe2..168db43 100644
--- a/data/ui/palimpsest.ui
+++ b/data/ui/palimpsest.ui
@@ -310,7 +310,7 @@
                   <object class="GtkTreeView" id="device-tree-treeview">
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="headers_visible">False</property>
+                    <property name="headers_visible">True</property>
                     <property name="headers_clickable">False</property>
                     <property name="show_expanders">False</property>
                     <property name="level_indentation">12</property>
diff --git a/src/palimpsest/gdudevicetreemodel.c b/src/palimpsest/gdudevicetreemodel.c
index 304051e..44d7bcc 100644
--- a/src/palimpsest/gdudevicetreemodel.c
+++ b/src/palimpsest/gdudevicetreemodel.c
@@ -33,8 +33,6 @@ struct _GduDeviceTreeModel
   UDisksClient *client;
 
   GList *current_drives;
-  GtkTreeIter drive_iter;
-  gboolean drive_iter_valid;
 
   GList *current_blocks;
   GtkTreeIter block_iter;
@@ -419,46 +417,10 @@ gdu_device_tree_model_get_client (GduDeviceTreeModel *model)
 
 /* ---------------------------------------------------------------------------------------------------- */
 
-static GtkTreeIter *
-get_drive_header_iter (GduDeviceTreeModel *model)
-{
-  gchar *s;
-
-  if (model->drive_iter_valid)
-    goto out;
-
-  s = g_strdup_printf ("<small><span foreground=\"#555555\">%s</span></small>",
-                       _("Disk Drives"));
-  gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
-                                     &model->drive_iter,
-                                     NULL, /* GtkTreeIter *parent */
-                                     0,
-                                     GDU_DEVICE_TREE_MODEL_COLUMN_IS_HEADING, TRUE,
-                                     GDU_DEVICE_TREE_MODEL_COLUMN_HEADING_TEXT, s,
-                                     GDU_DEVICE_TREE_MODEL_COLUMN_SORT_KEY, "00_drive",
-                                     -1);
-  g_free (s);
-
-  model->drive_iter_valid = TRUE;
-
- out:
-  return &model->drive_iter;
-}
-
-static void
-nuke_drive_header (GduDeviceTreeModel *model)
-{
-  if (model->drive_iter_valid)
-    {
-      gtk_tree_store_remove (GTK_TREE_STORE (model), &model->drive_iter);
-      model->drive_iter_valid = FALSE;
-    }
-}
-
 static void
 add_drive (GduDeviceTreeModel *model,
-         UDisksObject       *object,
-         GtkTreeIter        *parent)
+           UDisksObject       *object,
+           GtkTreeIter        *parent)
 {
   UDisksDrive *drive;
   GIcon *drive_icon;
@@ -485,7 +447,8 @@ add_drive (GduDeviceTreeModel *model,
   //         g_icon_to_string (drive_icon),
   //         g_icon_to_string (media_icon));
 
-  sort_key = g_strdup (g_dbus_object_get_object_path (G_DBUS_OBJECT (object))); /* for now */
+  sort_key = g_strdup_printf ("00_drives_%s",
+                              g_dbus_object_get_object_path (G_DBUS_OBJECT (object))); /* for now */
   gtk_tree_store_insert_with_values (GTK_TREE_STORE (model),
                                      &iter,
                                      parent,
@@ -572,12 +535,9 @@ update_drives (GduDeviceTreeModel *model)
     {
       UDisksObject *object = UDISKS_OBJECT (l->data);
       model->current_drives = g_list_prepend (model->current_drives, g_object_ref (object));
-      add_drive (model, object, get_drive_header_iter (model));
+      add_drive (model, object, NULL);
     }
 
-  if (g_list_length (model->current_drives) == 0)
-    nuke_drive_header (model);
-
   g_list_free (added_drives);
   g_list_free (removed_drives);
   g_list_foreach (drives, (GFunc) g_object_unref, NULL);
diff --git a/src/palimpsest/gduwindow.c b/src/palimpsest/gduwindow.c
index 597e004..826b596 100644
--- a/src/palimpsest/gduwindow.c
+++ b/src/palimpsest/gduwindow.c
@@ -301,6 +301,7 @@ gdu_window_constructed (GObject *object)
   GtkStyleContext *context;
   GDBusObjectManager *object_manager;
   GList *children, *l;
+  GtkWidget *headers_label;
 
   init_css (window);
 
@@ -356,6 +357,12 @@ gdu_window_constructed (GObject *object)
 
   tree_view = GTK_TREE_VIEW (gdu_window_get_widget (window, "device-tree-treeview"));
 
+  headers_label = gtk_label_new (NULL);
+  gtk_label_set_markup_with_mnemonic (GTK_LABEL (headers_label), _("_Devices"));
+  gtk_misc_set_alignment (GTK_MISC (headers_label), 0.0, 0.5);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (headers_label), GTK_WIDGET (tree_view));
+  gtk_widget_show_all (headers_label);
+
   gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (window->model));
   gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (window->model),
                                         GDU_DEVICE_TREE_MODEL_COLUMN_SORT_KEY,
@@ -369,6 +376,7 @@ gdu_window_constructed (GObject *object)
                     window);
 
   column = gtk_tree_view_column_new ();
+  gtk_tree_view_column_set_widget (column, headers_label);
   gtk_tree_view_append_column (tree_view, column);
 
   renderer = gtk_cell_renderer_text_new ();



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