From a8004c0df1e0306baf25dce363b74081620ac035 Mon Sep 17 00:00:00 2001 From: Chris Lumens Date: Thu, 7 Jun 2012 11:50:13 -0400 Subject: Add a little right pointing arrow to the active mountpoint selector. --- data/pixmaps/right-arrow-icon.png | Bin 0 -> 499 bytes pyanaconda/ui/gui/spokes/custom.py | 1 - widgets/src/MountpointSelector.c | 55 +++++++++++++++++++++++++++++++++---- 3 files changed, 49 insertions(+), 7 deletions(-) create mode 100644 data/pixmaps/right-arrow-icon.png diff --git a/data/pixmaps/right-arrow-icon.png b/data/pixmaps/right-arrow-icon.png new file mode 100644 index 000000000..371f50350 Binary files /dev/null and b/data/pixmaps/right-arrow-icon.png differ diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py index 3a7fb6a38..ee7c204b0 100644 --- a/pyanaconda/ui/gui/spokes/custom.py +++ b/pyanaconda/ui/gui/spokes/custom.py @@ -29,7 +29,6 @@ # all that kind of stuff. If this is the last device in one of those containers, all # the containers should be deleted too. # - Tabbing behavior in the accordion is weird. -# - The currently selected MS does not have a little > arrow shown. # - When all members of a page are removed, the page should be removed from the # accordion and the RHS should be updated to display something else. diff --git a/widgets/src/MountpointSelector.c b/widgets/src/MountpointSelector.c index 38bc42511..3bc5910f9 100644 --- a/widgets/src/MountpointSelector.c +++ b/widgets/src/MountpointSelector.c @@ -17,7 +17,10 @@ * Author: Chris Lumens */ +#include #include +#include +#include #include "MountpointSelector.h" #include "intl.h" @@ -118,7 +121,7 @@ static void anaconda_mountpoint_selector_class_init(AnacondaMountpointSelectorCl * anaconda_mountpoint_selector_new: * * Creates a new #AnacondaMountpointSelector, which is a selectable display for a - * single mountpoint. Many mountpoints may be pot together into a list, displaying + * single mountpoint. Many mountpoints may be put together into a list, displaying * all configured filesystems at once. * * Returns: A new #AnacondaMountpointSelector. @@ -127,7 +130,33 @@ GtkWidget *anaconda_mountpoint_selector_new() { return g_object_new(ANACONDA_TYPE_MOUNTPOINT_SELECTOR, NULL); } +static gchar *find_pixmap(const gchar *file) { + const gchar *envvar; + gchar **paths, **iterator = NULL; + + envvar = g_getenv("PIXMAPPATH"); + if (!envvar) + envvar = g_strdup("/usr/share/anaconda/pixmaps"); + + paths = g_strsplit(envvar, ":", 0); + iterator = paths; + + while (*iterator != NULL) { + gchar *path = g_strjoin("/", *iterator, file, NULL); + + if (!g_access(path, R_OK)) + return path; + + g_free(path); + iterator++; + } + + g_strfreev(paths); + return NULL; +} + static void anaconda_mountpoint_selector_init(AnacondaMountpointSelector *mountpoint) { + gchar *pixmap_path; char *markup; mountpoint->priv = G_TYPE_INSTANCE_GET_PRIVATE(mountpoint, @@ -147,8 +176,15 @@ static void anaconda_mountpoint_selector_init(AnacondaMountpointSelector *mountp gtk_grid_set_column_spacing(GTK_GRID(mountpoint->priv->grid), 12); gtk_widget_set_margin_left(GTK_WIDGET(mountpoint->priv->grid), 30); - /* Create the icons. */ - mountpoint->priv->arrow = NULL; + /* Create the icon. We don't need to check if find_pixmap returned NULL + * since gtk_image_new_from_file will just display a broken image icon in + * that case. That's good enough error notification. + */ + pixmap_path = find_pixmap("right-arrow-icon.png"); + mountpoint->priv->arrow = gtk_image_new_from_file(pixmap_path); + gtk_widget_set_no_show_all(GTK_WIDGET(mountpoint->priv->arrow), TRUE); + gtk_widget_set_margin_right(GTK_WIDGET(mountpoint->priv->arrow), 6); + g_free(pixmap_path); /* Create the name label. */ mountpoint->priv->name_label = gtk_label_new(NULL); @@ -162,7 +198,7 @@ static void anaconda_mountpoint_selector_init(AnacondaMountpointSelector *mountp mountpoint->priv->size_label = gtk_label_new(NULL); markup = g_markup_printf_escaped("%s", _(DEFAULT_SIZE)); gtk_label_set_markup(GTK_LABEL(mountpoint->priv->size_label), markup); - gtk_misc_set_alignment(GTK_MISC(mountpoint->priv->size_label), 0, 0); + gtk_misc_set_alignment(GTK_MISC(mountpoint->priv->size_label), 0, 0.5); g_free(markup); /* Create the mountpoint label. */ @@ -175,7 +211,8 @@ static void anaconda_mountpoint_selector_init(AnacondaMountpointSelector *mountp /* Add everything to the grid, add the grid to the widget. */ gtk_grid_attach(GTK_GRID(mountpoint->priv->grid), mountpoint->priv->name_label, 0, 0, 1, 1); - gtk_grid_attach(GTK_GRID(mountpoint->priv->grid), mountpoint->priv->size_label, 1, 0, 1, 1); + gtk_grid_attach(GTK_GRID(mountpoint->priv->grid), mountpoint->priv->size_label, 1, 0, 1, 2); + gtk_grid_attach(GTK_GRID(mountpoint->priv->grid), mountpoint->priv->arrow, 2, 0, 1, 2); gtk_grid_attach(GTK_GRID(mountpoint->priv->grid), mountpoint->priv->mountpoint_label, 0, 1, 1, 2); gtk_container_add(GTK_CONTAINER(mountpoint), mountpoint->priv->grid); @@ -232,8 +269,14 @@ static gboolean anaconda_mountpoint_selector_focus_changed(GtkWidget *widget, Gd GtkStateFlags new_state; new_state = gtk_widget_get_state_flags(widget) & ~GTK_STATE_FOCUSED; - if (event->in) + if (event->in) { + gtk_widget_show(GTK_WIDGET(ANACONDA_MOUNTPOINT_SELECTOR(widget)->priv->arrow)); new_state |= GTK_STATE_FOCUSED; + } + else { + gtk_widget_hide(GTK_WIDGET(ANACONDA_MOUNTPOINT_SELECTOR(widget)->priv->arrow)); + } + gtk_widget_set_state_flags(widget, new_state, TRUE); return FALSE; } -- cgit