summaryrefslogtreecommitdiffstats
path: root/widgets/src
diff options
context:
space:
mode:
authorChris Lumens <clumens@redhat.com>2012-12-11 17:07:04 -0500
committerChris Lumens <clumens@redhat.com>2012-12-12 10:14:50 -0500
commit801fe3e280e170c90f0c8f2bf4f7cfeea4d52160 (patch)
tree1a6aada1f4dc883d4bdac3156a34e89ab6f6011b /widgets/src
parent7c75486cb60b1c766b15b0ad8dc0708999e6baf2 (diff)
Add a gradient background to spoke headers (mizmo, clumens).
The idea here is that by adding a gradient up top, the "Done" button looks more like it belongs with the header than with the widgets down in the spoke. It also subtly makes the spoke look like a subpart of the hub. Adding this required adding an additional internal widget, which means also changing all existing glade files to include this internal widget. Make sure to build new glade support and install locally (or use the proper makefile targets) before editing.
Diffstat (limited to 'widgets/src')
-rw-r--r--widgets/src/BaseWindow.c26
-rw-r--r--widgets/src/BaseWindow.h1
-rw-r--r--widgets/src/SpokeWindow.c35
3 files changed, 59 insertions, 3 deletions
diff --git a/widgets/src/BaseWindow.c b/widgets/src/BaseWindow.c
index 510572249..23b9998e1 100644
--- a/widgets/src/BaseWindow.c
+++ b/widgets/src/BaseWindow.c
@@ -90,7 +90,7 @@ struct _AnacondaBaseWindowPrivate {
gboolean is_beta, info_shown;
GtkWidget *main_box, *event_box, *info_bar;
GtkWidget *alignment;
- GtkWidget *nav_area, *action_area;
+ GtkWidget *nav_box, *nav_area, *action_area;
GtkWidget *name_label, *distro_label, *beta_label;
/* Untranslated versions of various things. */
@@ -209,13 +209,19 @@ static void anaconda_base_window_init(AnacondaBaseWindow *win) {
/* Then the navigation area that sits as the first item in the main box
* for every Window class.
*/
+
+ win->priv->nav_box = gtk_event_box_new();
+ gtk_widget_set_app_paintable(win->priv->nav_box, TRUE);
+ gtk_box_pack_start(GTK_BOX(win->priv->main_box), win->priv->nav_box, FALSE, FALSE, 0);
+
win->priv->nav_area = gtk_grid_new();
gtk_grid_set_row_homogeneous(GTK_GRID(win->priv->nav_area), FALSE);
gtk_grid_set_column_homogeneous(GTK_GRID(win->priv->nav_area), FALSE);
gtk_widget_set_margin_left(win->priv->nav_area, 6);
gtk_widget_set_margin_right(win->priv->nav_area, 6);
gtk_widget_set_margin_top(win->priv->nav_area, 6);
- gtk_box_pack_start(GTK_BOX(win->priv->main_box), win->priv->nav_area, FALSE, FALSE, 0);
+
+ gtk_container_add(GTK_CONTAINER(win->priv->nav_box), win->priv->nav_area);
/* Second in the main box is an alignment, because we want to be able
* to control the amount of space the Window's content takes up on the
@@ -375,6 +381,20 @@ GtkWidget *anaconda_base_window_get_nav_area(AnacondaBaseWindow *win) {
}
/**
+ * anaconda_base_window_get_nav_area_background_window:
+ * @win: a #AnacondaBaseWindow
+ *
+ * Returns the event box that houses background window of the navigation area of @win.
+ *
+ * Returns: (transfer none): The event box
+ *
+ * Since: 1.0
+ */
+GtkWidget *anaconda_base_window_get_nav_area_background_window(AnacondaBaseWindow *win) {
+ return win->priv->nav_box;
+}
+
+/**
* anaconda_base_window_get_main_box:
* @win: a #AnacondaBaseWindow
*
@@ -576,6 +596,8 @@ anaconda_base_window_buildable_get_internal_child (GtkBuildable *buildable,
return G_OBJECT(anaconda_base_window_get_main_box(ANACONDA_BASE_WINDOW(buildable)));
else if (!strcmp(childname, "nav_area"))
return G_OBJECT(ANACONDA_BASE_WINDOW(buildable)->priv->nav_area);
+ else if (!strcmp(childname, "nav_box"))
+ return G_OBJECT(ANACONDA_BASE_WINDOW(buildable)->priv->nav_box);
else if (!strcmp(childname, "alignment"))
return G_OBJECT(ANACONDA_BASE_WINDOW(buildable)->priv->alignment);
else if (!strcmp(childname, "action_area"))
diff --git a/widgets/src/BaseWindow.h b/widgets/src/BaseWindow.h
index ef9c21068..6c08ee8c4 100644
--- a/widgets/src/BaseWindow.h
+++ b/widgets/src/BaseWindow.h
@@ -80,6 +80,7 @@ GtkWidget *anaconda_base_window_get_action_area (AnacondaBaseWindow *win);
GtkWidget *anaconda_base_window_get_alignment (AnacondaBaseWindow *win);
GtkWidget *anaconda_base_window_get_main_box (AnacondaBaseWindow *win);
GtkWidget *anaconda_base_window_get_nav_area (AnacondaBaseWindow *win);
+GtkWidget *anaconda_base_window_get_nav_area_background_window (AnacondaBaseWindow *win);
G_END_DECLS
diff --git a/widgets/src/SpokeWindow.c b/widgets/src/SpokeWindow.c
index bafc5ab1f..16ce3f87a 100644
--- a/widgets/src/SpokeWindow.c
+++ b/widgets/src/SpokeWindow.c
@@ -124,12 +124,45 @@ GtkWidget *anaconda_spoke_window_new() {
}
static void anaconda_spoke_window_init(AnacondaSpokeWindow *win) {
- GtkWidget *nav_area;
+ GError *error;
+ GtkWidget *nav_area, *nav_box;
+ GdkPixbuf *pixbuf;
+ cairo_pattern_t *pattern;
+ cairo_surface_t *surface;
+ cairo_t *cr;
win->priv = G_TYPE_INSTANCE_GET_PRIVATE(win,
ANACONDA_TYPE_SPOKE_WINDOW,
AnacondaSpokeWindowPrivate);
+ /* Set the background gradient in the header. If we fail to load the
+ * background for any reason, just print an error message and display the
+ * header without an image.
+ */
+ error = NULL;
+ pixbuf = gdk_pixbuf_new_from_file("/usr/share/anaconda/pixmaps/anaconda_spoke_header.png", &error);
+ if (!pixbuf) {
+ fprintf(stderr, "could not load header background: %s\n", error->message);
+ g_error_free(error);
+ } else {
+ nav_box = anaconda_base_window_get_nav_area_background_window(ANACONDA_BASE_WINDOW(win));
+ gtk_widget_set_size_request(nav_box, -1, gdk_pixbuf_get_height (pixbuf));
+ gtk_widget_realize(nav_box);
+
+ surface = gdk_window_create_similar_surface(gtk_widget_get_window(nav_box), CAIRO_CONTENT_COLOR_ALPHA,
+ gdk_pixbuf_get_width(pixbuf), gdk_pixbuf_get_height(pixbuf));
+ cr = cairo_create(surface);
+
+ gdk_cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
+ cairo_paint(cr);
+ cairo_destroy(cr);
+ pattern = cairo_pattern_create_for_surface(surface);
+ cairo_surface_destroy(surface);
+
+ cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REPEAT);
+ gdk_window_set_background_pattern(gtk_widget_get_window(nav_box), pattern);
+ }
+
/* Set some default properties. */
gtk_window_set_modal(GTK_WINDOW(win), TRUE);