summaryrefslogtreecommitdiffstats
path: root/widgets/src
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2012-06-07 14:00:12 -0400
committerChris Lumens <clumens@redhat.com>2012-06-07 14:00:12 -0400
commitc9984b42fce5df8fb2b6aa352c0faa8e1890d2b9 (patch)
treea2d98b5d53297338a7a7d80a4496a9f0c837ffbf /widgets/src
parenta8004c0df1e0306baf25dce363b74081620ac035 (diff)
downloadanaconda-c9984b42fce5df8fb2b6aa352c0faa8e1890d2b9.tar.gz
anaconda-c9984b42fce5df8fb2b6aa352c0faa8e1890d2b9.tar.xz
anaconda-c9984b42fce5df8fb2b6aa352c0faa8e1890d2b9.zip
Giving a MountpointSelector focus should cause it to be displayed.
This means that when you press up and down with the keyboard to navigate the accordion, whatever MS you hit will be the one displayed on the right, and whatever one you were previously on will have its changes saved. This is different from how DiskOverviews and SpokeSelectors work, but I think it makes sense. When you keyboard to a DO, you are choosing to do include it in the install. We don't want people doing that by accident. When you keyboard to a SS, it would jump you into the spoke and that wouldn't work at all. The MS, however, just changes what's displayed on part of the screen.
Diffstat (limited to 'widgets/src')
-rw-r--r--widgets/src/MountpointSelector.c47
-rw-r--r--widgets/src/MountpointSelector.h3
2 files changed, 50 insertions, 0 deletions
diff --git a/widgets/src/MountpointSelector.c b/widgets/src/MountpointSelector.c
index 3bc5910f9..7ac3983de 100644
--- a/widgets/src/MountpointSelector.c
+++ b/widgets/src/MountpointSelector.c
@@ -53,6 +53,8 @@ struct _AnacondaMountpointSelectorPrivate {
GtkWidget *grid;
GtkWidget *name_label, *size_label, *mountpoint_label;
GtkWidget *arrow;
+
+ gboolean chosen;
};
G_DEFINE_TYPE(AnacondaMountpointSelector, anaconda_mountpoint_selector, GTK_TYPE_EVENT_BOX)
@@ -60,6 +62,7 @@ G_DEFINE_TYPE(AnacondaMountpointSelector, anaconda_mountpoint_selector, GTK_TYPE
static void anaconda_mountpoint_selector_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
static void anaconda_mountpoint_selector_set_property(GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
+static void anaconda_mountpoint_selector_toggle_background(AnacondaMountpointSelector *widget);
static gboolean anaconda_mountpoint_selector_focus_changed(GtkWidget *widget, GdkEventFocus *event, gpointer user_data);
static void anaconda_mountpoint_selector_class_init(AnacondaMountpointSelectorClass *klass) {
@@ -186,6 +189,9 @@ static void anaconda_mountpoint_selector_init(AnacondaMountpointSelector *mountp
gtk_widget_set_margin_right(GTK_WIDGET(mountpoint->priv->arrow), 6);
g_free(pixmap_path);
+ /* Set some properties. */
+ mountpoint->priv->chosen = FALSE;
+
/* Create the name label. */
mountpoint->priv->name_label = gtk_label_new(NULL);
markup = g_markup_printf_escaped("<span fgcolor='black' size='large' weight='bold'>%s</span>", _(DEFAULT_NAME));
@@ -280,3 +286,44 @@ static gboolean anaconda_mountpoint_selector_focus_changed(GtkWidget *widget, Gd
gtk_widget_set_state_flags(widget, new_state, TRUE);
return FALSE;
}
+
+static void anaconda_mountpoint_selector_toggle_background(AnacondaMountpointSelector *widget) {
+ if (widget->priv->chosen) {
+ GdkRGBA color;
+ gdk_rgba_parse(&color, "#4a90d9");
+ gtk_widget_override_background_color(GTK_WIDGET(widget), GTK_STATE_FLAG_NORMAL, &color);
+ }
+ else
+ gtk_widget_override_background_color(GTK_WIDGET(widget), GTK_STATE_FLAG_NORMAL, NULL);
+}
+
+/**
+ * anaconda_mountpoint_selector_get_chosen:
+ * @widget: a #AnacondaMountpointSelector
+ *
+ * Returns whether or not this mountpoint has been chosen by the user.
+ *
+ * Returns: Whether @widget has been chosen.
+ *
+ * Since: 1.0
+ */
+gboolean anaconda_mountpoint_selector_get_chosen(AnacondaMountpointSelector *widget) {
+ return widget->priv->chosen;
+}
+
+/**
+ * anaconda_mountpoint_selector_set_chosen:
+ * @widget: a #AnacondaMountpointSelector
+ * @is_chosen: %TRUE if this mountpoint is chosen.
+ *
+ * Specifies whether the mountpoint shown by this selector has been chosen by
+ * the user. If so, a special background will be set as a visual indicator.
+ *
+ * Since: 1.0
+ */
+void anaconda_mountpoint_selector_set_chosen(AnacondaMountpointSelector *widget, gboolean is_chosen) {
+ widget->priv->chosen = is_chosen;
+ anaconda_mountpoint_selector_toggle_background(widget);
+ if (is_chosen)
+ gtk_widget_grab_focus(GTK_WIDGET(widget));
+}
diff --git a/widgets/src/MountpointSelector.h b/widgets/src/MountpointSelector.h
index e9a5b9ae4..9c04b4cac 100644
--- a/widgets/src/MountpointSelector.h
+++ b/widgets/src/MountpointSelector.h
@@ -62,6 +62,9 @@ struct _AnacondaMountpointSelectorClass {
GType anaconda_mountpoint_selector_get_type (void);
GtkWidget *anaconda_mountpoint_selector_new ();
+gboolean anaconda_mountpoint_selector_get_chosen (AnacondaMountpointSelector *widget);
+void anaconda_mountpoint_selector_set_chosen (AnacondaMountpointSelector *widget, gboolean is_chosen);
+
G_END_DECLS
#endif