diff options
| author | Tomas Bzatek <tbzatek@redhat.com> | 2009-02-13 17:37:41 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@redhat.com> | 2009-02-13 17:37:41 +0100 |
| commit | 8ff253bb34b24aa1f9b9771a7ad511a49606fc0f (patch) | |
| tree | a9f9f44dbfccc3e93df30cda6361c587554c339b /src | |
| parent | 6f341971eb56d3128dfbc7a458cf78e95d549362 (diff) | |
| download | nautilus-gdu-8ff253bb34b24aa1f9b9771a7ad511a49606fc0f.tar.gz nautilus-gdu-8ff253bb34b24aa1f9b9771a7ad511a49606fc0f.tar.xz nautilus-gdu-8ff253bb34b24aa1f9b9771a7ad511a49606fc0f.zip | |
UI cleanup in standalone mode (volume selector)
Diffstat (limited to 'src')
| -rw-r--r-- | src/gdu-utils.c | 68 | ||||
| -rw-r--r-- | src/nautilus-gdu-window.c | 14 |
2 files changed, 63 insertions, 19 deletions
diff --git a/src/gdu-utils.c b/src/gdu-utils.c index 99d48f5..111dd54 100644 --- a/src/gdu-utils.c +++ b/src/gdu-utils.c @@ -156,7 +156,7 @@ gdu_util_presentable_combo_box_create_store (GduPool *pool) GList *presentables = NULL; GtkTreeIter iter; - store = gtk_list_store_new (3, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_OBJECT); + store = gtk_list_store_new (4, G_TYPE_OBJECT, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_OBJECT); if (pool != NULL) presentables = gdu_pool_get_presentables (pool); @@ -165,32 +165,39 @@ gdu_util_presentable_combo_box_create_store (GduPool *pool) GduPresentable *toplevel_presentable; GduDevice *toplevel_device = NULL; GduDevice *device; - const char *name; - const char *device_path; - char *display_name; GdkPixbuf *pixbuf = NULL; + const char *name; + char *display_name = NULL; device = gdu_presentable_get_device (presentable); toplevel_presentable = gdu_presentable_get_toplevel (presentable); if (device != NULL && toplevel_presentable != NULL) { toplevel_device = gdu_presentable_get_device (toplevel_presentable); - name = gdu_presentable_get_name (presentable); - device_path = gdu_device_get_device_file (device); - display_name = g_strdup_printf ("<span font_desc='12'><b>%s</b></span>\n<span foreground='darkgrey'>%s</span>", name, device_path); pixbuf = gdu_util_get_pixbuf_for_presentable (presentable, GTK_ICON_SIZE_DIALOG); if (toplevel_device != NULL && gdu_device_is_removable (toplevel_device)) { + name = gdu_device_id_get_label (device); + if (name && strlen (name) > 0) + display_name = g_strdup (name); + if (! display_name) { + name = gdu_presentable_get_name (presentable); + if (name && strlen (name) > 0) + display_name = g_strdup_printf ("(%s)", name); + } + if (! display_name) + display_name = g_strdup_printf ("(%s)", gdu_device_get_device_file (device)); + gtk_list_store_append (store, &iter); /* gtk_list_store_set() refs objects itself */ gtk_list_store_set (store, &iter, 0, presentable, 1, display_name, - 2, pixbuf, + 2, gdu_device_get_device_file (device), + 3, pixbuf, -1); + g_free (display_name); } - - g_free (display_name); } if (pixbuf) @@ -207,6 +214,38 @@ gdu_util_presentable_combo_box_create_store (GduPool *pool) return store; } +static void +gdu_util_presentable_combo_box_text_renderer_func (GtkCellLayout *cell_layout, + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer user_data) +{ + gchar *name = NULL; + gchar *device_path = NULL; + gchar *display_name; + gboolean popup_shown = FALSE; + + + gtk_tree_model_get (tree_model, iter, 1, &name, 2, &device_path, -1); + g_object_get (G_OBJECT (user_data), "popup-shown", &popup_shown, NULL); + + if (popup_shown) { + display_name = g_strdup_printf ("<span font_desc='12'><b> %s</b></span>\n<span foreground='darkgrey'> %s</span>", name, device_path); + } + else { + display_name = g_strdup_printf ("<span font_desc='18'><b> %s</b></span>", name); + } + + g_object_set (cell, "markup", display_name, NULL); + + g_free (display_name); + if (name) + g_free (name); + if (device_path) + g_free (device_path); +} + GtkWidget * gdu_util_presentable_combo_box_create (GduPool *pool) { @@ -222,13 +261,14 @@ gdu_util_presentable_combo_box_create (GduPool *pool) renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, FALSE); gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, - "pixbuf", 2, + "pixbuf", 3, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, - "markup", 1, - NULL); + gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo_box), + renderer, + gdu_util_presentable_combo_box_text_renderer_func, + combo_box, NULL); gtk_combo_box_set_active (GTK_COMBO_BOX (combo_box), -1); diff --git a/src/nautilus-gdu-window.c b/src/nautilus-gdu-window.c index 7ef5223..12755c5 100644 --- a/src/nautilus-gdu-window.c +++ b/src/nautilus-gdu-window.c @@ -677,6 +677,7 @@ update_ui (FormatDialogPrivate *priv) if (priv->standalone_mode && priv->volume_selector != NULL) { gtk_widget_hide (priv->name_label); + gtk_widget_hide (priv->icon_image); } @@ -1365,6 +1366,13 @@ nautilus_gdu_spawn_dialog (GduPresentable *presentable, GtkWidget *progress_bar; int row; + + /* Selector */ + if (standalone_mode && presentable == NULL) { + priv->volume_selector = gdu_util_presentable_combo_box_create (priv->pool); + gtk_box_pack_start (GTK_BOX (content_area), priv->volume_selector, TRUE, TRUE, 0); + } + hbox = gtk_hbox_new (FALSE, 10); gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0); @@ -1374,6 +1382,7 @@ nautilus_gdu_spawn_dialog (GduPresentable *presentable, vbox3 = gtk_vbox_new (FALSE, 0); align = gtk_alignment_new (0.0, 0.5, 0.0, 0.0); + gtk_alignment_set_padding (GTK_ALIGNMENT (align), 0, 20*(priv->volume_selector != NULL), 25*(priv->volume_selector != NULL), 0); gtk_container_add (GTK_CONTAINER (align), vbox3); gtk_box_pack_start (GTK_BOX (hbox), align, TRUE, TRUE, 0); @@ -1382,11 +1391,6 @@ nautilus_gdu_spawn_dialog (GduPresentable *presentable, gtk_box_pack_start (GTK_BOX (vbox3), label, FALSE, TRUE, 0); priv->name_label = label; - if (standalone_mode && presentable == NULL) { - priv->volume_selector = gdu_util_presentable_combo_box_create (priv->pool); - gtk_box_pack_start (GTK_BOX (vbox3), priv->volume_selector, TRUE, TRUE, 0); - } - label = gtk_label_new (NULL); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (vbox3), label, FALSE, TRUE, 0); |
