This adds a sidebar to the left of the standalone windows. The reason for this is to visually reinforce the left-to-right linear nature of the standalone windows. There is a variable (sidebar_width_percentage) you can set to control the percentage width of the screen that the sidebar occupies - I've set it to 18% which seems reasonable. It auto- centers the logo on top of the sidebar as well. There are three layers to the sidebar: the base color, a texture pixbuf, and the logo pixbuf on top. --- widgets/src/StandaloneWindow.c | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
diff --git a/widgets/src/StandaloneWindow.c b/widgets/src/StandaloneWindow.c index a770bc7..87ed03d 100644 --- a/widgets/src/StandaloneWindow.c +++ b/widgets/src/StandaloneWindow.c @@ -70,8 +70,75 @@ static void anaconda_standalone_window_realize(GtkWidget *widget,
G_DEFINE_TYPE(AnacondaStandaloneWindow, anaconda_standalone_window, ANACONDA_TYPE_BASE_WINDOW)
+static int get_sidebar_width(GtkWidget *window) { + GtkAllocation allocation; + /* change value below to make sidebar bigger / smaller */ + float sidebar_width_percentage = .18; + gtk_widget_get_allocation(window, &allocation); + return allocation.width * sidebar_width_percentage; +} + +static int get_sidebar_height(GtkWidget *window) { + GtkAllocation allocation; + gtk_widget_get_allocation(window, &allocation); + return allocation.height; +} + +/* function to override default drawing to insert sidebar image */ +gboolean anaconda_standalone_window_on_draw(GtkWidget *win, cairo_t *cr) { + + /* Create sidebar */ + GTK_WIDGET_CLASS(anaconda_standalone_window_parent_class)->draw(win,cr); + cairo_rectangle(cr, 0, 0, get_sidebar_width(win), get_sidebar_height(win)); + + /* Configure sidebar base color */ + /* Dark grey for RHEL: 65/255.0, 65/255.0, 62/255.0, 1 */ + /* Blue for Fedora: 60/255.0, 110/255.0, 180/255.0, 1 */ + cairo_set_source_rgba(cr, 65/255.0, 65/255.0, 62/255.0, 1); + cairo_fill_preserve(cr); + + /* Configure sidebar texture image */ + GdkPixbuf *pixbuf_background = gdk_pixbuf_new_from_file("/usr/share/anaconda/pixmaps/noise-texture.png", NULL); + cairo_surface_t *surface= gdk_cairo_surface_create_from_pixbuf(pixbuf_background, 0, gtk_widget_get_window(GTK_WIDGET(win))); + cairo_set_source_surface(cr, surface, 0, 0); + cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT); + cairo_fill(cr); + + /* Configure logo image overlaid on sidebar */ + GdkPixbuf *pixbuf_logo = gdk_pixbuf_new_from_file("/usr/share/anaconda/pixmaps/redhat-logo.png", NULL); + if (pixbuf_logo != NULL) { + double x_value = (get_sidebar_width(win) - gdk_pixbuf_get_width(pixbuf_logo))/2; + double y_value = 20; + cairo_surface_t *surface= gdk_cairo_surface_create_from_pixbuf(pixbuf_logo, 0, gtk_widget_get_window(GTK_WIDGET(win))); + cairo_set_source_surface(cr, surface, x_value, y_value); + cairo_rectangle(cr, x_value, y_value, gdk_pixbuf_get_width(pixbuf_logo), gdk_pixbuf_get_height(pixbuf_logo)); + cairo_fill(cr); + } + return TRUE; /* TRUE to avoid default draw handler */ +} + +/* Move base window content appropriate amount of space to the right to make room for sidebar */ +static void anaconda_standalone_window_size_allocate (GtkWidget *window, GtkAllocation *allocation) { + GtkAllocation child_allocation; + GtkWidget *child; + + gtk_widget_set_allocation(window, allocation); + int sidebar_width = get_sidebar_width(window); + child_allocation.x = allocation->x+sidebar_width; + child_allocation.y = allocation->y; + child_allocation.width = allocation->width-sidebar_width; + child_allocation.height = allocation->height; + + child = gtk_bin_get_child (GTK_BIN (window)); + if (child && gtk_widget_get_visible (child)) + gtk_widget_size_allocate (child, &child_allocation); +} + static void anaconda_standalone_window_class_init(AnacondaStandaloneWindowClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + widget_class->draw=anaconda_standalone_window_on_draw; + widget_class->size_allocate=anaconda_standalone_window_size_allocate;
klass->quit_clicked = NULL; klass->continue_clicked = NULL;
On 01/03/2014 01:52 PM, Máirín Duffy wrote:
This adds a sidebar to the left of the standalone windows. The reason for this is to visually reinforce the left-to-right linear nature of the standalone windows. There is a variable (sidebar_width_percentage) you can set to control the percentage width of the screen that the sidebar occupies - I've set it to 18% which seems reasonable. It auto- centers the logo on top of the sidebar as well. There are three layers to the sidebar: the base color, a texture pixbuf, and the logo pixbuf on top.
widgets/src/StandaloneWindow.c | 67 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
diff --git a/widgets/src/StandaloneWindow.c b/widgets/src/StandaloneWindow.c index a770bc7..87ed03d 100644 --- a/widgets/src/StandaloneWindow.c +++ b/widgets/src/StandaloneWindow.c @@ -70,8 +70,75 @@ static void anaconda_standalone_window_realize(GtkWidget *widget,
G_DEFINE_TYPE(AnacondaStandaloneWindow, anaconda_standalone_window, ANACONDA_TYPE_BASE_WINDOW)
+static int get_sidebar_width(GtkWidget *window) {
- GtkAllocation allocation;
- /* change value below to make sidebar bigger / smaller */
- float sidebar_width_percentage = .18;
- gtk_widget_get_allocation(window, &allocation);
- return allocation.width * sidebar_width_percentage;
+}
+static int get_sidebar_height(GtkWidget *window) {
- GtkAllocation allocation;
- gtk_widget_get_allocation(window, &allocation);
- return allocation.height;
+}
+/* function to override default drawing to insert sidebar image */ +gboolean anaconda_standalone_window_on_draw(GtkWidget *win, cairo_t *cr) {
- /* Create sidebar */
- GTK_WIDGET_CLASS(anaconda_standalone_window_parent_class)->draw(win,cr);
- cairo_rectangle(cr, 0, 0, get_sidebar_width(win), get_sidebar_height(win));
- /* Configure sidebar base color */
- /* Dark grey for RHEL: 65/255.0, 65/255.0, 62/255.0, 1 */
- /* Blue for Fedora: 60/255.0, 110/255.0, 180/255.0, 1 */
- cairo_set_source_rgba(cr, 65/255.0, 65/255.0, 62/255.0, 1);
- cairo_fill_preserve(cr);
- /* Configure sidebar texture image */
- GdkPixbuf *pixbuf_background = gdk_pixbuf_new_from_file("/usr/share/anaconda/pixmaps/noise-texture.png", NULL);
Will this logo be part of anaconda or will it come from another package? I'd rather we not hardcode /usr/share/anaconda/pixmaps, but I guess get_widgets_datadir only works right for files in the anaconda source tree.
- cairo_surface_t *surface= gdk_cairo_surface_create_from_pixbuf(pixbuf_background, 0, gtk_widget_get_window(GTK_WIDGET(win)));
- cairo_set_source_surface(cr, surface, 0, 0);
- cairo_pattern_set_extend(cairo_get_source(cr), CAIRO_EXTEND_REPEAT);
- cairo_fill(cr);
- /* Configure logo image overlaid on sidebar */
- GdkPixbuf *pixbuf_logo = gdk_pixbuf_new_from_file("/usr/share/anaconda/pixmaps/redhat-logo.png", NULL);
Same question here, also will it always be redhat-logo.png or will the Fedora version be different. Also also, the two pixbufs are never unreferenced.
- if (pixbuf_logo != NULL) {
double x_value = (get_sidebar_width(win) - gdk_pixbuf_get_width(pixbuf_logo))/2;double y_value = 20;cairo_surface_t *surface= gdk_cairo_surface_create_from_pixbuf(pixbuf_logo, 0, gtk_widget_get_window(GTK_WIDGET(win)));cairo_set_source_surface(cr, surface, x_value, y_value);cairo_rectangle(cr, x_value, y_value, gdk_pixbuf_get_width(pixbuf_logo), gdk_pixbuf_get_height(pixbuf_logo));cairo_fill(cr);- }
- return TRUE; /* TRUE to avoid default draw handler */
+}
+/* Move base window content appropriate amount of space to the right to make room for sidebar */ +static void anaconda_standalone_window_size_allocate (GtkWidget *window, GtkAllocation *allocation) {
- GtkAllocation child_allocation;
- GtkWidget *child;
- gtk_widget_set_allocation(window, allocation);
- int sidebar_width = get_sidebar_width(window);
- child_allocation.x = allocation->x+sidebar_width;
- child_allocation.y = allocation->y;
- child_allocation.width = allocation->width-sidebar_width;
- child_allocation.height = allocation->height;
- child = gtk_bin_get_child (GTK_BIN (window));
- if (child && gtk_widget_get_visible (child))
- gtk_widget_size_allocate (child, &child_allocation);
+}
static void anaconda_standalone_window_class_init(AnacondaStandaloneWindowClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
widget_class->draw=anaconda_standalone_window_on_draw;
widget_class->size_allocate=anaconda_standalone_window_size_allocate;
klass->quit_clicked = NULL; klass->continue_clicked = NULL;
Hi David,
Thanks for the review! :) Comments inline below -
On Mon, Jan 6, 2014 at 1:38 PM, David Shea dshea@redhat.com wrote:
- GdkPixbuf *pixbuf_background =
gdk_pixbuf_new_from_file("/usr/share/anaconda/pixmaps/noise-texture.png", NULL);
Will this logo be part of anaconda or will it come from another package? I'd rather we not hardcode /usr/share/anaconda/pixmaps, but I guess get_widgets_datadir only works right for files in the anaconda source tree.
I think it should come from the fedora-logos or redhat-logos package (depending on what's being installed). At least, that's how it works today, right? I think trademarks have to be in the *-logos packages because of their licensing. Is that okay? I'm not sure how else to reference the images besides that path?
- GdkPixbuf *pixbuf_logo =
gdk_pixbuf_new_from_file("/usr/share/anaconda/pixmaps/redhat-logo.png", NULL);
Same question here, also will it always be redhat-logo.png or will the Fedora version be different. Also also, the two pixbufs are never unreferenced.
Fedora will definitely have a different logo.
And unreferencing - whoops. I'll try to figure out how to do that (if you couldn't already tell, I'm super-rusty and don't normally code in C!! :( )
~m
On 01/06/2014 02:56 PM, Máirín Duffy wrote:
Hi David, Thanks for the review! :) Comments inline below -
On Mon, Jan 6, 2014 at 1:38 PM, David Shea dshea@redhat.com wrote:
- GdkPixbuf *pixbuf_background =
gdk_pixbuf_new_from_file("/usr/share/anaconda/pixmaps/noise-texture.png", NULL);
Will this logo be part of anaconda or will it come from another package? I'd rather we not hardcode /usr/share/anaconda/pixmaps, but I guess get_widgets_datadir only works right for files in the anaconda source tree.
I think it should come from the fedora-logos or redhat-logos package (depending on what's being installed). At least, that's how it works today, right? I think trademarks have to be in the *-logos packages because of their licensing. Is that okay? I'm not sure how else to reference the images besides that path?
If it's coming from another package just having the path is ok. I was mainly concerned with this going around our $ANACONDA_WIDGETS_DATA environment override for using this stuff in glade, but that wouldn't apply here.
- GdkPixbuf *pixbuf_logo =
gdk_pixbuf_new_from_file("/usr/share/anaconda/pixmaps/redhat-logo.png", NULL);
Same question here, also will it always be redhat-logo.png or will the Fedora version be different. Also also, the two pixbufs are never unreferenced.
Fedora will definitely have a different logo.
How would we change the filename in that case? Is that something else that we can do with a stylesheet?
On 01/03/2014 01:52 PM, Máirín Duffy wrote:
This adds a sidebar to the left of the standalone windows. The reason for this is to visually reinforce the left-to-right linear nature of the standalone windows. There is a variable (sidebar_width_percentage) you can set to control the percentage width of the screen that the sidebar occupies - I've set it to 18% which seems reasonable. It auto- centers the logo on top of the sidebar as well. There are three layers to the sidebar: the base color, a texture pixbuf, and the logo pixbuf on top.
And another thing...
What about right-to-left languages? Should the sidebar be on the other side?
Hi David,
On Mon, Jan 6, 2014 at 1:43 PM, David Shea dshea@redhat.com wrote:
What about right-to-left languages? Should the sidebar be on the other side?
Gosh, that's a good question. I don't know how we handled this in old school firstboot (where we also had a sidebar like this.)
I think that, if the button order changes for R-to-L (which I'm pretty sure it does) then the sidebar should move to the other side too. I can easily modify this so it can do either placement, but I'm not sure where to grab, logically, whether or not to draw it left or right from. :-/ Do you have any ideas?
~m
On 01/06/2014 02:59 PM, Máirín Duffy wrote:
Hi David,
On Mon, Jan 6, 2014 at 1:43 PM, David Shea dshea@redhat.com wrote:
What about right-to-left languages? Should the sidebar be on the other side?
Gosh, that's a good question. I don't know how we handled this in old school firstboot (where we also had a sidebar like this.)
I think that, if the button order changes for R-to-L (which I'm pretty sure it does) then the sidebar should move to the other side too. I can easily modify this so it can do either placement, but I'm not sure where to grab, logically, whether or not to draw it left or right from. :-/ Do you have any ideas?
There's a function in MountpointSelector.c, get_default_widget_direction that copies the Gtk logic but allows it to be run after program startup. We can move that to widgets-common.c and use it in the spokes and hubs.
On 01/06/2014 03:09 PM, David Shea wrote:
On 01/06/2014 02:59 PM, Máirín Duffy wrote:
Hi David,
On Mon, Jan 6, 2014 at 1:43 PM, David Shea dshea@redhat.com wrote:
What about right-to-left languages? Should the sidebar be on the other side?
Gosh, that's a good question. I don't know how we handled this in old school firstboot (where we also had a sidebar like this.)
I think that, if the button order changes for R-to-L (which I'm pretty sure it does) then the sidebar should move to the other side too. I can easily modify this so it can do either placement, but I'm not sure where to grab, logically, whether or not to draw it left or right from. :-/ Do you have any ideas?
There's a function in MountpointSelector.c, get_default_widget_direction that copies the Gtk logic but allows it to be run after program startup. We can move that to widgets-common.c and use it in the spokes and hubs.
Actually, that's been added in gtk 3.11 as gtk_get_locale_direction, so you can use that on master.
On 01/03/2014 01:52 PM, Máirín Duffy wrote:
- /* Configure sidebar base color */
- /* Dark grey for RHEL: 65/255.0, 65/255.0, 62/255.0, 1 */
- /* Blue for Fedora: 60/255.0, 110/255.0, 180/255.0, 1 */
- cairo_set_source_rgba(cr, 65/255.0, 65/255.0, 62/255.0, 1);
One more: could we do this part with a stylesheet? That would make it easier to swap between Fedora and RHEL colors.
On Mon, Jan 6, 2014 at 2:11 PM, David Shea dshea@redhat.com wrote:
On 01/03/2014 01:52 PM, Máirín Duffy wrote:
- /* Configure sidebar base color */
- /* Dark grey for RHEL: 65/255.0, 65/255.0, 62/255.0, 1 */
- /* Blue for Fedora: 60/255.0, 110/255.0, 180/255.0, 1 */
- cairo_set_source_rgba(cr, 65/255.0, 65/255.0, 62/255.0, 1);
One more: could we do this part with a stylesheet? That would make it easier to swap between Fedora and RHEL colors.
Yep, definitely, I'll work on that.
~m
From: David Shea dshea@redhat.com
Define styles for GtkLevelBar widgets at the named levels "low", "medium" and "high". Define value offsets for these names in each of the GtkLevelBar widgets we use. --- data/Makefile.am | 8 ++-- data/anaconda-gtk.css | 62 ++++++++++++++++++++++++++++++ pyanaconda/ui/gui/__init__.py | 6 +++ pyanaconda/ui/gui/spokes/lib/passphrase.py | 3 ++ pyanaconda/ui/gui/spokes/password.py | 5 +++ pyanaconda/ui/gui/spokes/user.py | 5 +++ scripts/makeupdates | 2 + 7 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 data/anaconda-gtk.css
diff --git a/data/Makefile.am b/data/Makefile.am index b7eddfe..ebbdaaf 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -21,11 +21,9 @@ SUBDIRS = command-stubs icons liveinst pixmaps systemd post-scripts
CLEANFILES = *~
-ksdir = $(datadir)/$(PACKAGE_NAME) -dist_ks_DATA = interactive-defaults.ks - -tmuxdir = $(datadir)/$(PACKAGE_NAME) -dist_tmux_DATA = tmux.conf +dist_pkgdata_DATA = interactive-defaults.ks \ + tmux.conf \ + anaconda-gtk.css
helpdir = $(datadir)/$(PACKAGE_NAME) dist_help_DATA = anaconda_options.txt diff --git a/data/anaconda-gtk.css b/data/anaconda-gtk.css new file mode 100644 index 0000000..92669ba --- /dev/null +++ b/data/anaconda-gtk.css @@ -0,0 +1,62 @@ +/* Define styles to apply to the GtkLevelBar widgets for different values. + * + * This stylesheet defines properties for "low", "medium" and "high" level bar + * levels. The level bars themselves need to define what style applies at what + * value using gtk_level_bar_add_offset_value. Gtk defines "low" and "high" by + * default, but it defines them for level bars using a continuous value between + * 0 and 1, so our discrete level bars are effectively always at the "high" + * level. + * + * Fun surprises that might change in future versions: + * + * - Defining properties for a level will set properties on both the filled + * portion and the empty portion of the level bar. So if all of the display + * properties are set, which we do, the level bar effectively becomes 100% + * filled with whatever properties are set. Copying the .empty-fill-block + * properties from the theme so that they apply at the application level + * works around this. + * + * - There's a bug in the handling of the maximum offset in that it only + * applies when value == max-value, rather than when it's between + * max-value and the next lower offset. For example, consider a + * discrete-mode level bar with a max-value of 4 and offsets defined as + * "low": 2.0, "medium": 3.0 and "high": 4.0. Value 1 will be low, + * value 2 will be medium, value 3 will be in an undefined no-man's land, + * and value 4 will be high. To get around this we re-define the default + * fill-block values as the same as fill-block.level-high. + * + * - The GNOME Adwaita theme applies a gradient to the progress bar when the + * window is focused. It does this by redefining the colors in a + * background-image property, so unless we reset background-image our colors + * will only apply when the window is out of focus, which uses the :backdrop + * selector. + */ + +@define-color anaconda_level_bar_low red; +@define-color anaconda_level_bar_medium orange; +@define-color anaconda_level_bar_high green; + +.level-bar.fill-block.level-low { + border-color: darker(@anaconda_level_bar_low); + background-color: @anaconda_level_bar_low; + background-image: none; +} + +.level-bar.fill-block.level-medium { + border-color: darker(@anaconda_level_bar_medium); + background-color: @anaconda_level_bar_medium; + background-image: none; +} + +.level-bar.fill-block, +.level-bar.fill-block.level-high { + border-color: darker(@anaconda_level_bar_high); + background-color: @anaconda_level_bar_high; + background-image: none; +} + +.level-bar.fill-block.empty-fill-block { + background-color: transparent; + background-image: none; + border-color: alpha(#000000, 0.1); +} diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py index 966bc93..3d553e8 100644 --- a/pyanaconda/ui/gui/__init__.py +++ b/pyanaconda/ui/gui/__init__.py @@ -389,6 +389,12 @@ class GraphicalUserInterface(UserInterface): settings.set_property("gtk-font-name", "Cantarell") settings.set_property("gtk-icon-theme-name", "gnome")
+ # Apply the application stylesheet + provider = Gtk.CssProvider() + provider.load_from_path("/usr/share/anaconda/anaconda-gtk.css") + Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + self._currentAction.window.show_all()
# Do this at the last possible minute. diff --git a/pyanaconda/ui/gui/spokes/lib/passphrase.py b/pyanaconda/ui/gui/spokes/lib/passphrase.py index 938130b..c85e904 100644 --- a/pyanaconda/ui/gui/spokes/lib/passphrase.py +++ b/pyanaconda/ui/gui/spokes/lib/passphrase.py @@ -60,6 +60,9 @@ class PassphraseDialog(GUIObject): self._strength_bar.set_mode(Gtk.LevelBarMode.DISCRETE) self._strength_bar.set_min_value(0) self._strength_bar.set_max_value(4) + self._strength_bar.add_offset_value("low", 2) + self._strength_bar.add_offset_value("medium", 3) + self._strength_bar.add_offset_value("high", 4) box = self.builder.get_object("strength_box") box.pack_start(self._strength_bar, False, True, 0) box.show_all() diff --git a/pyanaconda/ui/gui/spokes/password.py b/pyanaconda/ui/gui/spokes/password.py index 25c9613..70bb6e5 100644 --- a/pyanaconda/ui/gui/spokes/password.py +++ b/pyanaconda/ui/gui/spokes/password.py @@ -67,6 +67,11 @@ class PasswordSpoke(FirstbootSpokeMixIn, NormalSpoke): self.pw_bar = self.builder.get_object("password_bar") self.pw_label = self.builder.get_object("password_label")
+ # Configure levels for the password bar + self.pw_bar.add_offset_value("low", 2) + self.pw_bar.add_offset_value("medium", 3) + self.pw_bar.add_offset_value("high", 4) + def refresh(self): self.pw.grab_focus() self._checkPassword() diff --git a/pyanaconda/ui/gui/spokes/user.py b/pyanaconda/ui/gui/spokes/user.py index d9b205e..e834ebf 100644 --- a/pyanaconda/ui/gui/spokes/user.py +++ b/pyanaconda/ui/gui/spokes/user.py @@ -199,6 +199,11 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke): self.pw_bar = self.builder.get_object("password_bar") self.pw_label = self.builder.get_object("password_label")
+ # Configure levels for the password bar + self.pw_bar.add_offset_value("low", 2) + self.pw_bar.add_offset_value("medium", 3) + self.pw_bar.add_offset_value("high", 4) + # indicate when the password was set by kickstart self._user.password_kickstarted = self.data.user.seen if self._user.password_kickstarted: diff --git a/scripts/makeupdates b/scripts/makeupdates index f1d6ecc..6079fac 100755 --- a/scripts/makeupdates +++ b/scripts/makeupdates @@ -159,6 +159,8 @@ def copyUpdatedFiles(tag, updates, cwd): install_to_dir(file, "lib/systemd/system-generators") elif file == "data/tmux.conf": install_to_dir(file, "usr/share/anaconda") + elif file == "data/anaconda-gtk.css": + install_to_dir(file, "usr/share/anaconda") elif file == "data/interactive-defaults.ks": install_to_dir(file, "usr/share/anaconda") elif file == "data/liveinst/liveinst":
diff --git a/data/Makefile.am b/data/Makefile.am index b7eddfe..ebbdaaf 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -21,11 +21,9 @@ SUBDIRS = command-stubs icons liveinst pixmaps systemd post-scripts
CLEANFILES = *~
-ksdir = $(datadir)/$(PACKAGE_NAME) -dist_ks_DATA = interactive-defaults.ks
-tmuxdir = $(datadir)/$(PACKAGE_NAME) -dist_tmux_DATA = tmux.conf +dist_pkgdata_DATA = interactive-defaults.ks \
tmux.conf \anaconda-gtk.csshelpdir = $(datadir)/$(PACKAGE_NAME) dist_help_DATA = anaconda_options.txt
...
diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py index 966bc93..3d553e8 100644 --- a/pyanaconda/ui/gui/__init__.py +++ b/pyanaconda/ui/gui/__init__.py @@ -389,6 +389,12 @@ class GraphicalUserInterface(UserInterface): settings.set_property("gtk-font-name", "Cantarell") settings.set_property("gtk-icon-theme-name", "gnome")
# Apply the application stylesheetprovider = Gtk.CssProvider()provider.load_from_path("/usr/share/anaconda/anaconda-gtk.css")Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider,Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)self._currentAction.window.show_all() # Do this at the last possible minute.
...
diff --git a/scripts/makeupdates b/scripts/makeupdates index f1d6ecc..6079fac 100755 --- a/scripts/makeupdates +++ b/scripts/makeupdates @@ -159,6 +159,8 @@ def copyUpdatedFiles(tag, updates, cwd): install_to_dir(file, "lib/systemd/system-generators") elif file == "data/tmux.conf": install_to_dir(file, "usr/share/anaconda")
elif file == "data/anaconda-gtk.css":install_to_dir(file, "usr/share/anaconda") elif file == "data/interactive-defaults.ks": install_to_dir(file, "usr/share/anaconda") elif file == "data/liveinst/liveinst":
I'd really only like to see these three chunks make it to rhel7-branch. The bug referenced in the subject is a Fedora bug, which means our build checks will fail. There's nothing approved for RHEL7 to deal with the password bar.
- Chris
We need GTK stylesheet support to implement the branding/styling for bug 1045250. This work is based on a patch from David Shea. --- data/Makefile.am | 8 +++----- data/anaconda-gtk.css | 0 pyanaconda/ui/gui/__init__.py | 6 ++++++ scripts/makeupdates | 2 ++ 4 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 data/anaconda-gtk.css
diff --git a/data/Makefile.am b/data/Makefile.am index b7eddfe..ebbdaaf 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -21,11 +21,9 @@ SUBDIRS = command-stubs icons liveinst pixmaps systemd post-scripts
CLEANFILES = *~
-ksdir = $(datadir)/$(PACKAGE_NAME) -dist_ks_DATA = interactive-defaults.ks - -tmuxdir = $(datadir)/$(PACKAGE_NAME) -dist_tmux_DATA = tmux.conf +dist_pkgdata_DATA = interactive-defaults.ks \ + tmux.conf \ + anaconda-gtk.css
helpdir = $(datadir)/$(PACKAGE_NAME) dist_help_DATA = anaconda_options.txt diff --git a/data/anaconda-gtk.css b/data/anaconda-gtk.css new file mode 100644 index 0000000..e69de29 diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py index 966bc93..3d553e8 100644 --- a/pyanaconda/ui/gui/__init__.py +++ b/pyanaconda/ui/gui/__init__.py @@ -389,6 +389,12 @@ class GraphicalUserInterface(UserInterface): settings.set_property("gtk-font-name", "Cantarell") settings.set_property("gtk-icon-theme-name", "gnome")
+ # Apply the application stylesheet + provider = Gtk.CssProvider() + provider.load_from_path("/usr/share/anaconda/anaconda-gtk.css") + Gtk.StyleContext.add_provider_for_screen(Gdk.Screen.get_default(), provider, + Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION) + self._currentAction.window.show_all()
# Do this at the last possible minute. diff --git a/scripts/makeupdates b/scripts/makeupdates index f1d6ecc..6079fac 100755 --- a/scripts/makeupdates +++ b/scripts/makeupdates @@ -159,6 +159,8 @@ def copyUpdatedFiles(tag, updates, cwd): install_to_dir(file, "lib/systemd/system-generators") elif file == "data/tmux.conf": install_to_dir(file, "usr/share/anaconda") + elif file == "data/anaconda-gtk.css": + install_to_dir(file, "usr/share/anaconda") elif file == "data/interactive-defaults.ks": install_to_dir(file, "usr/share/anaconda") elif file == "data/liveinst/liveinst":
This adds a sidebar to the left of the standalone and hub windows. The reason for this is to visually reinforce the left-to-right linear nature of the standalone windows. There is a variable (sidebar_width_percentage) you can set to control the percentage width of the screen that the sidebar occupies - I've set it to 18% which seems reasonable. It auto- centers the logo on top of the sidebar as well. The sidebar is controlled by the 'sidebar' class in the css and the 'logo' class in the css. In this patch, the sidebar is set to have a grey background with a partially-transparent image texture layered on top, and a logo layered on top of that, centered horizontally 20px down from the top of the sidebar. To restyle the sidebar, you only have to change the relevant section in the anaconda-gtk.css file. --- data/anaconda-gtk.css | 34 +++++++++++++++++++++++ widgets/src/HubWindow.c | 62 +++++++++++++++++++++++++++++++++++++++++- widgets/src/StandaloneWindow.c | 56 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 151 insertions(+), 1 deletion(-)
diff --git a/data/anaconda-gtk.css b/data/anaconda-gtk.css index 92669ba..71d443e 100644 --- a/data/anaconda-gtk.css +++ b/data/anaconda-gtk.css @@ -60,3 +60,37 @@ background-image: none; border-color: alpha(#000000, 0.1); } + + +/* vendor-specific colors/images */ + +@define-color sidebar_redhat #41413e; +@define-color sidebar_fedora #006eb4; + +/* logo and sidebar classes for RHEL */ +.logo { + background-image: url('/usr/share/anaconda/pixmaps/redhat-logo.png'); + background-position: 50% 20px; + background-repeat: no-repeat; + background-color: transparent; +} + +.sidebar { + background-image: url('/usr/share/anaconda/pixmaps/redhat-bg.png'); + background-color: @sidebar_redhat; +} + +/* swap these into logo & sidebar classes for Fedora */ +/* +.logo-fedora { + background-image: url('/usr/share/anaconda/pixmaps/fedora-logo.png'); + background-position: 50% 20px; + background-repeat: no-repeat; + background-color: transparent; +} + +.sidebar-fedora { + background-image: url('/usr/share/anaconda/pixmaps/noise-texture.png'); + background-color: @sidebar_fedora; +} +*/ diff --git a/widgets/src/HubWindow.c b/widgets/src/HubWindow.c index 7f118dd..dfaee1f 100644 --- a/widgets/src/HubWindow.c +++ b/widgets/src/HubWindow.c @@ -82,9 +82,65 @@ static void anaconda_hub_window_buildable_init(GtkBuildableIface *iface); G_DEFINE_TYPE_WITH_CODE(AnacondaHubWindow, anaconda_hub_window, ANACONDA_TYPE_BASE_WINDOW, G_IMPLEMENT_INTERFACE(GTK_TYPE_BUILDABLE, anaconda_hub_window_buildable_init))
+static int get_sidebar_width(GtkWidget *window) { + GtkAllocation allocation; + /* change value below to make sidebar bigger / smaller */ + float sidebar_width_percentage = .18; + gtk_widget_get_allocation(window, &allocation); + return allocation.width * sidebar_width_percentage; +} + +static int get_sidebar_height(GtkWidget *window) { + GtkAllocation allocation; + gtk_widget_get_allocation(window, &allocation); + return allocation.height; +} + +/* function to override default drawing to insert sidebar image */ +gboolean anaconda_hub_window_on_draw(GtkWidget *win, cairo_t *cr) { + + /* calls parent class' draw handler */ + GTK_WIDGET_CLASS(anaconda_hub_window_parent_class)->draw(win,cr); + + GtkStyleContext * context = gtk_widget_get_style_context(win); + gtk_style_context_save (context); + + gtk_style_context_add_class(context, "sidebar"); + gtk_render_background(context, cr, 0, 0, get_sidebar_width(win), get_sidebar_height(win)); + gtk_style_context_remove_class(context, "sidebar"); + + gtk_style_context_add_class(context, "logo"); + gtk_render_background(context, cr, 0, 0, get_sidebar_width(win), get_sidebar_height(win)); + gtk_style_context_remove_class(context, "logo"); + + gtk_style_context_restore (context); + + + return TRUE; /* TRUE to avoid default draw handler */ +} + +/* Move base window content appropriate amount of space to the right to make room for sidebar */ +static void anaconda_hub_window_size_allocate (GtkWidget *window, GtkAllocation *allocation) { + GtkAllocation child_allocation; + GtkWidget *child; + + gtk_widget_set_allocation(window, allocation); + int sidebar_width = get_sidebar_width(window); + child_allocation.x = allocation->x+sidebar_width; + child_allocation.y = allocation->y; + child_allocation.width = allocation->width-sidebar_width; + child_allocation.height = allocation->height; + + child = gtk_bin_get_child (GTK_BIN (window)); + if (child && gtk_widget_get_visible (child)) + gtk_widget_size_allocate (child, &child_allocation); +} + static void anaconda_hub_window_class_init(AnacondaHubWindowClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); - + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + widget_class->draw=anaconda_hub_window_on_draw; + widget_class->size_allocate=anaconda_hub_window_size_allocate; g_type_class_add_private(object_class, sizeof(AnacondaHubWindowPrivate)); }
@@ -100,6 +156,8 @@ GtkWidget *anaconda_hub_window_new() { return g_object_new(ANACONDA_TYPE_HUB_WINDOW, NULL); }
+ + static void anaconda_hub_window_init(AnacondaHubWindow *win) { GtkWidget *action_area = anaconda_base_window_get_action_area(ANACONDA_BASE_WINDOW(win));
@@ -115,6 +173,8 @@ static void anaconda_hub_window_init(AnacondaHubWindow *win) { /* The hub has different alignment requirements than a spoke. */ gtk_alignment_set(GTK_ALIGNMENT(anaconda_base_window_get_alignment(ANACONDA_BASE_WINDOW(win))), 0.5, 0.0, 0.5, 1.0); + + }
/** diff --git a/widgets/src/StandaloneWindow.c b/widgets/src/StandaloneWindow.c index 2b04c49..219bb96 100644 --- a/widgets/src/StandaloneWindow.c +++ b/widgets/src/StandaloneWindow.c @@ -70,8 +70,64 @@ static void anaconda_standalone_window_realize(GtkWidget *widget,
G_DEFINE_TYPE(AnacondaStandaloneWindow, anaconda_standalone_window, ANACONDA_TYPE_BASE_WINDOW)
+static int get_sidebar_width(GtkWidget *window) { + GtkAllocation allocation; + /* change value below to make sidebar bigger / smaller */ + float sidebar_width_percentage = .18; + gtk_widget_get_allocation(window, &allocation); + return allocation.width * sidebar_width_percentage; +} + +static int get_sidebar_height(GtkWidget *window) { + GtkAllocation allocation; + gtk_widget_get_allocation(window, &allocation); + return allocation.height; +} + +/* function to override default drawing to insert sidebar image */ +gboolean anaconda_standalone_window_on_draw(GtkWidget *win, cairo_t *cr) { + + /* calls parent class' draw handler */ + GTK_WIDGET_CLASS(anaconda_standalone_window_parent_class)->draw(win,cr); + + GtkStyleContext * context = gtk_widget_get_style_context(win); + gtk_style_context_save (context); + + gtk_style_context_add_class(context, "sidebar"); + gtk_render_background(context, cr, 0, 0, get_sidebar_width(win), get_sidebar_height(win)); + gtk_style_context_remove_class(context, "sidebar"); + + gtk_style_context_add_class(context, "logo"); + gtk_render_background(context, cr, 0, 0, get_sidebar_width(win), get_sidebar_height(win)); + gtk_style_context_remove_class(context, "logo"); + + gtk_style_context_restore (context); + + return TRUE; /* TRUE to avoid default draw handler */ +} + +/* Move base window content appropriate amount of space to the right to make room for sidebar */ +static void anaconda_standalone_window_size_allocate (GtkWidget *window, GtkAllocation *allocation) { + GtkAllocation child_allocation; + GtkWidget *child; + + gtk_widget_set_allocation(window, allocation); + int sidebar_width = get_sidebar_width(window); + child_allocation.x = allocation->x+sidebar_width; + child_allocation.y = allocation->y; + child_allocation.width = allocation->width-sidebar_width; + child_allocation.height = allocation->height; + + child = gtk_bin_get_child (GTK_BIN (window)); + if (child && gtk_widget_get_visible (child)) + gtk_widget_size_allocate (child, &child_allocation); +} + static void anaconda_standalone_window_class_init(AnacondaStandaloneWindowClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + widget_class->draw=anaconda_standalone_window_on_draw; + widget_class->size_allocate=anaconda_standalone_window_size_allocate;
klass->quit_clicked = NULL; klass->continue_clicked = NULL;
diff --git a/data/anaconda-gtk.css b/data/anaconda-gtk.css index 92669ba..71d443e 100644 --- a/data/anaconda-gtk.css +++ b/data/anaconda-gtk.css @@ -60,3 +60,37 @@ background-image: none; border-color: alpha(#000000, 0.1); }
+/* vendor-specific colors/images */
+@define-color sidebar_redhat #41413e; +@define-color sidebar_fedora #006eb4;
+/* logo and sidebar classes for RHEL */ +.logo {
- background-image: url('/usr/share/anaconda/pixmaps/redhat-logo.png');
- background-position: 50% 20px;
- background-repeat: no-repeat;
- background-color: transparent;
+}
+.sidebar {
- background-image: url('/usr/share/anaconda/pixmaps/redhat-bg.png');
- background-color: @sidebar_redhat;
+}
+/* swap these into logo & sidebar classes for Fedora */ +/* +.logo-fedora {
- background-image: url('/usr/share/anaconda/pixmaps/fedora-logo.png');
- background-position: 50% 20px;
- background-repeat: no-repeat;
- background-color: transparent;
+}
+.sidebar-fedora {
- background-image: url('/usr/share/anaconda/pixmaps/noise-texture.png');
- background-color: @sidebar_fedora;
+} +*/
The -logo files will be coming out of a product.img, I assume? What are the odds we can just ensure the file is always the same name and not have to worry about different classes for different products?
diff --git a/widgets/src/HubWindow.c b/widgets/src/HubWindow.c index 7f118dd..dfaee1f 100644 --- a/widgets/src/HubWindow.c +++ b/widgets/src/HubWindow.c @@ -82,9 +82,65 @@ static void anaconda_hub_window_buildable_init(GtkBuildableIface *iface); G_DEFINE_TYPE_WITH_CODE(AnacondaHubWindow, anaconda_hub_window, ANACONDA_TYPE_BASE_WINDOW, G_IMPLEMENT_INTERFACE(GTK_TYPE_BUILDABLE, anaconda_hub_window_buildable_init))
+static int get_sidebar_width(GtkWidget *window) {
- GtkAllocation allocation;
Stylistically, I'm picky. I like whitespace. I'd like to see a newline here.
- /* change value below to make sidebar bigger / smaller */
- float sidebar_width_percentage = .18;
And this as 0.18. It just looks weird without.
- gtk_widget_get_allocation(window, &allocation);
- return allocation.width * sidebar_width_percentage;
+}
+static int get_sidebar_height(GtkWidget *window) {
- GtkAllocation allocation;
- gtk_widget_get_allocation(window, &allocation);
- return allocation.height;
+}
+/* function to override default drawing to insert sidebar image */ +gboolean anaconda_hub_window_on_draw(GtkWidget *win, cairo_t *cr) {
This function is only used in this file, yeah? So it could be static.
- /* calls parent class' draw handler */
- GTK_WIDGET_CLASS(anaconda_hub_window_parent_class)->draw(win,cr);
- GtkStyleContext * context = gtk_widget_get_style_context(win);
- gtk_style_context_save (context);
- gtk_style_context_add_class(context, "sidebar");
- gtk_render_background(context, cr, 0, 0, get_sidebar_width(win), get_sidebar_height(win));
- gtk_style_context_remove_class(context, "sidebar");
- gtk_style_context_add_class(context, "logo");
- gtk_render_background(context, cr, 0, 0, get_sidebar_width(win), get_sidebar_height(win));
- gtk_style_context_remove_class(context, "logo");
- gtk_style_context_restore (context);
- return TRUE; /* TRUE to avoid default draw handler */
+}
+/* Move base window content appropriate amount of space to the right to make room for sidebar */ +static void anaconda_hub_window_size_allocate (GtkWidget *window, GtkAllocation *allocation) {
- GtkAllocation child_allocation;
- GtkWidget *child;
- gtk_widget_set_allocation(window, allocation);
- int sidebar_width = get_sidebar_width(window);
I know gcc doesn't require it, but I like variables defined before they start getting used. Old school, I guess.
- child_allocation.x = allocation->x+sidebar_width;
- child_allocation.y = allocation->y;
- child_allocation.width = allocation->width-sidebar_width;
- child_allocation.height = allocation->height;
- child = gtk_bin_get_child (GTK_BIN (window));
- if (child && gtk_widget_get_visible (child))
- gtk_widget_size_allocate (child, &child_allocation);
Please indent the part under the if.
+}
static void anaconda_hub_window_class_init(AnacondaHubWindowClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass);
- GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
Please add a newline here.
- widget_class->draw=anaconda_hub_window_on_draw;
- widget_class->size_allocate=anaconda_hub_window_size_allocate;
And put spaces around the = operators here.
diff --git a/widgets/src/StandaloneWindow.c b/widgets/src/StandaloneWindow.c index 2b04c49..219bb96 100644 --- a/widgets/src/StandaloneWindow.c +++ b/widgets/src/StandaloneWindow.c
And then all the same comments apply to this file too.
I assume you've also checked tty1 to make sure there's no relevant gtk/glib/whatever assertions. Sometimes those are hiding there.
- Chris
On 02/04/2014 03:57 PM, Chris Lumens wrote:
The -logo files will be coming out of a product.img, I assume?
I'm not sure, where did they used to get shipped? I attached them to the bug.
What are the odds we can just ensure the file is always the same name and not have to worry about different classes for different products?
Oh yes, very smart. Sorry about that. Making the filename the same makes sense; the reason there are two styles was primarily because the background color will change (will be blue for Fedora without texture.) So I re-did the CSS so you just have to flip the color and texture settings in just that file.
1
Stylistically, I'm picky. I like whitespace. I'd like to see a newline here.
2
And this as 0.18. It just looks weird without.
3
This function is only used in this file, yeah? So it could be static.
4
I know gcc doesn't require it, but I like variables defined before they start getting used. Old school, I guess.
5
Please indent the part under the if.
6
Please add a newline here.
7
And put spaces around the = operators here.
8
And then all the same comments apply to this file too.
Okay, I have an updated version of the patch that address everything in 1-8 as well as makes the image names more generic.
I assume you've also checked tty1 to make sure there's no relevant gtk/glib/whatever assertions. Sometimes those are hiding there.
Checked it and it's surprisingly bare! :)
Will re-submit in a separate email.
~m
This adds a sidebar to the left of the standalone and hub windows. The reason for this is to visually reinforce the left-to-right linear nature of the standalone windows. There is a variable (sidebar_width_percentage) you can set to control the percentage width of the screen that the sidebar occupies - I've set it to 18% which seems reasonable. It auto- centers the logo on top of the sidebar as well. The sidebar is controlled by the 'sidebar' class in the css and the 'logo' class in the css. In this patch, the sidebar is set to have a grey background with a partially-transparent image texture layered on top, and a logo layered on top of that, centered horizontally 20px down from the top of the sidebar. To restyle the sidebar, you only have to change the relevant section in the anaconda-gtk.css file. --- data/anaconda-gtk.css | 32 +++++++++++++++++++++ widgets/src/HubWindow.c | 64 +++++++++++++++++++++++++++++++++++++++++- widgets/src/StandaloneWindow.c | 58 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 153 insertions(+), 1 deletion(-)
diff --git a/data/anaconda-gtk.css b/data/anaconda-gtk.css index e69de29..a56ddf6 100644 --- a/data/anaconda-gtk.css +++ b/data/anaconda-gtk.css @@ -0,0 +1,32 @@ +/* vendor-specific colors/images */ + +@define-color sidebar_redhat #41413e; +@define-color sidebar_fedora #006eb4; + +/* logo and sidebar classes for RHEL */ +.logo { + background-image: url('/usr/share/anaconda/pixmaps/redhat-logo.png'); + background-position: 50% 20px; + background-repeat: no-repeat; + background-color: transparent; +} + +.sidebar { + background-image: url('/usr/share/anaconda/pixmaps/redhat-bg.png'); + background-color: @sidebar_redhat; +} + +/* swap these into logo & sidebar classes for Fedora */ +/* +.logo-fedora { + background-image: url('/usr/share/anaconda/pixmaps/fedora-logo.png'); + background-position: 50% 20px; + background-repeat: no-repeat; + background-color: transparent; +} + +.sidebar-fedora { + background-image: url('/usr/share/anaconda/pixmaps/noise-texture.png'); + background-color: @sidebar_fedora; +} +*/ diff --git a/widgets/src/HubWindow.c b/widgets/src/HubWindow.c index 7f118dd..4327002 100644 --- a/widgets/src/HubWindow.c +++ b/widgets/src/HubWindow.c @@ -82,9 +82,67 @@ static void anaconda_hub_window_buildable_init(GtkBuildableIface *iface); G_DEFINE_TYPE_WITH_CODE(AnacondaHubWindow, anaconda_hub_window, ANACONDA_TYPE_BASE_WINDOW, G_IMPLEMENT_INTERFACE(GTK_TYPE_BUILDABLE, anaconda_hub_window_buildable_init))
+static int get_sidebar_width(GtkWidget *window) { + GtkAllocation allocation; + + /* change value below to make sidebar bigger / smaller */ + float sidebar_width_percentage = 0.18; + gtk_widget_get_allocation(window, &allocation); + return allocation.width * sidebar_width_percentage; +} + +static int get_sidebar_height(GtkWidget *window) { + GtkAllocation allocation; + gtk_widget_get_allocation(window, &allocation); + return allocation.height; +} + +/* function to override default drawing to insert sidebar image */ +static gboolean anaconda_hub_window_on_draw(GtkWidget *win, cairo_t *cr) { + + /* calls parent class' draw handler */ + GTK_WIDGET_CLASS(anaconda_hub_window_parent_class)->draw(win,cr); + + GtkStyleContext * context = gtk_widget_get_style_context(win); + gtk_style_context_save (context); + + gtk_style_context_add_class(context, "sidebar"); + gtk_render_background(context, cr, 0, 0, get_sidebar_width(win), get_sidebar_height(win)); + gtk_style_context_remove_class(context, "sidebar"); + + gtk_style_context_add_class(context, "logo"); + gtk_render_background(context, cr, 0, 0, get_sidebar_width(win), get_sidebar_height(win)); + gtk_style_context_remove_class(context, "logo"); + + gtk_style_context_restore (context); + + + return TRUE; /* TRUE to avoid default draw handler */ +} + +/* Move base window content appropriate amount of space to the right to make room for sidebar */ +static void anaconda_hub_window_size_allocate (GtkWidget *window, GtkAllocation *allocation) { + GtkAllocation child_allocation; + GtkWidget *child; + int sidebar_width; + + gtk_widget_set_allocation(window, allocation); + sidebar_width = get_sidebar_width(window); + child_allocation.x = allocation->x+sidebar_width; + child_allocation.y = allocation->y; + child_allocation.width = allocation->width-sidebar_width; + child_allocation.height = allocation->height; + + child = gtk_bin_get_child (GTK_BIN (window)); + if (child && gtk_widget_get_visible (child)) + gtk_widget_size_allocate (child, &child_allocation); +} + static void anaconda_hub_window_class_init(AnacondaHubWindowClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); - + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + widget_class->draw = anaconda_hub_window_on_draw; + widget_class->size_allocate = anaconda_hub_window_size_allocate; g_type_class_add_private(object_class, sizeof(AnacondaHubWindowPrivate)); }
@@ -100,6 +158,8 @@ GtkWidget *anaconda_hub_window_new() { return g_object_new(ANACONDA_TYPE_HUB_WINDOW, NULL); }
+ + static void anaconda_hub_window_init(AnacondaHubWindow *win) { GtkWidget *action_area = anaconda_base_window_get_action_area(ANACONDA_BASE_WINDOW(win));
@@ -115,6 +175,8 @@ static void anaconda_hub_window_init(AnacondaHubWindow *win) { /* The hub has different alignment requirements than a spoke. */ gtk_alignment_set(GTK_ALIGNMENT(anaconda_base_window_get_alignment(ANACONDA_BASE_WINDOW(win))), 0.5, 0.0, 0.5, 1.0); + + }
/** diff --git a/widgets/src/StandaloneWindow.c b/widgets/src/StandaloneWindow.c index 2b04c49..60bc6fd 100644 --- a/widgets/src/StandaloneWindow.c +++ b/widgets/src/StandaloneWindow.c @@ -70,8 +70,66 @@ static void anaconda_standalone_window_realize(GtkWidget *widget,
G_DEFINE_TYPE(AnacondaStandaloneWindow, anaconda_standalone_window, ANACONDA_TYPE_BASE_WINDOW)
+static int get_sidebar_width(GtkWidget *window) { + GtkAllocation allocation; + /* change value below to make sidebar bigger / smaller */ + + float sidebar_width_percentage = 0.18; + gtk_widget_get_allocation(window, &allocation); + return allocation.width * sidebar_width_percentage; +} + +static int get_sidebar_height(GtkWidget *window) { + GtkAllocation allocation; + gtk_widget_get_allocation(window, &allocation); + return allocation.height; +} + +/* function to override default drawing to insert sidebar image */ +static gboolean anaconda_standalone_window_on_draw(GtkWidget *win, cairo_t *cr) { + + /* calls parent class' draw handler */ + GTK_WIDGET_CLASS(anaconda_standalone_window_parent_class)->draw(win,cr); + + GtkStyleContext * context = gtk_widget_get_style_context(win); + gtk_style_context_save (context); + + gtk_style_context_add_class(context, "sidebar"); + gtk_render_background(context, cr, 0, 0, get_sidebar_width(win), get_sidebar_height(win)); + gtk_style_context_remove_class(context, "sidebar"); + + gtk_style_context_add_class(context, "logo"); + gtk_render_background(context, cr, 0, 0, get_sidebar_width(win), get_sidebar_height(win)); + gtk_style_context_remove_class(context, "logo"); + + gtk_style_context_restore (context); + + return TRUE; /* TRUE to avoid default draw handler */ +} + +/* Move base window content appropriate amount of space to the right to make room for sidebar */ +static void anaconda_standalone_window_size_allocate (GtkWidget *window, GtkAllocation *allocation) { + GtkAllocation child_allocation; + GtkWidget *child; + int sidebar_width; + + gtk_widget_set_allocation(window, allocation); + sidebar_width = get_sidebar_width(window); + child_allocation.x = allocation->x+sidebar_width; + child_allocation.y = allocation->y; + child_allocation.width = allocation->width-sidebar_width; + child_allocation.height = allocation->height; + + child = gtk_bin_get_child (GTK_BIN (window)); + if (child && gtk_widget_get_visible (child)) + gtk_widget_size_allocate (child, &child_allocation); +} + static void anaconda_standalone_window_class_init(AnacondaStandaloneWindowClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS(klass); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass); + widget_class->draw = anaconda_standalone_window_on_draw; + widget_class->size_allocate = anaconda_standalone_window_size_allocate;
klass->quit_clicked = NULL; klass->continue_clicked = NULL;
On Fri, Jan 03, 2014 at 01:52:57PM -0500, Máirín Duffy wrote:
+static int get_sidebar_width(GtkWidget *window) {
- GtkAllocation allocation;
- /* change value below to make sidebar bigger / smaller */
- float sidebar_width_percentage = .18;
Should use 0.18 so it is easier to read, also watch out for trailing spaces.
Also style related, 4 spaces not tabs, please.
And follow the commenting style of the other functions, I think gobject picks up on parts of it, clumens would know exactly what is needed there.
anaconda-patches@lists.fedorahosted.org