diff options
author | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2016-01-29 08:37:30 -0300 |
---|---|---|
committer | Juan Pablo Ugarte <juanpablougarte@gmail.com> | 2016-01-29 08:38:55 -0300 |
commit | cb60d287df2af95b07496968fefa303842ddad9f (patch) | |
tree | 5f575c584a9234dcd130dfb5b6a992b90fcc2000 /src | |
parent | 88acef602224a1a199d0ffdef9b7e02039ae66b1 (diff) | |
download | glade-cb60d287df2af95b07496968fefa303842ddad9f.tar.gz |
GladeRegistration: improved theme compatibility by using css theme colors.
Diffstat (limited to 'src')
-rw-r--r-- | src/glade-registration.c | 52 | ||||
-rw-r--r-- | src/glade-registration.css | 26 |
2 files changed, 39 insertions, 39 deletions
diff --git a/src/glade-registration.c b/src/glade-registration.c index 9990b3c0..eb749a9a 100644 --- a/src/glade-registration.c +++ b/src/glade-registration.c @@ -48,6 +48,8 @@ struct _GladeRegistrationPrivate GladeHTTP *sub_http; GCancellable *cancellable; + GdkRGBA fg_color; + /* Form widgets */ GtkWidget *name; @@ -583,35 +585,29 @@ glade_registration_set_css_provider_forall (GtkWidget *widget, gpointer data) } static gboolean -on_viewport_draw (GtkWidget *widget, cairo_t *cr) +on_viewport_draw (GtkWidget *viewport, cairo_t *cr, GladeRegistration *widget) { - GdkWindow *window = gtk_viewport_get_bin_window (GTK_VIEWPORT (widget)); - - if (gtk_cairo_should_draw_window (cr, window)) - { - GtkAllocation alloc; - gdouble scale; + GladeRegistrationPrivate *priv = GLADE_REGISTRATION (widget)->priv; + GdkRGBA *c = &priv->fg_color; + GtkAllocation alloc; + gdouble scale; - gtk_widget_get_allocation (widget, &alloc); + gtk_widget_get_allocation (viewport, &alloc); - scale = MIN (alloc.width/GLADE_LOGO_WIDTH, alloc.height/GLADE_LOGO_HEIGHT) - .1; + scale = MIN (alloc.width/GLADE_LOGO_WIDTH, alloc.height/GLADE_LOGO_HEIGHT) - .1; - cairo_save (cr); + cairo_save (cr); - cairo_set_source_rgba (cr, 0, 0, 0, .04); - cairo_scale (cr, scale, scale); - cairo_translate (cr, (alloc.width / scale) - GLADE_LOGO_WIDTH*.95, - (alloc.height / scale) - GLADE_LOGO_HEIGHT); - cairo_append_path (cr, &glade_logo_path); - cairo_fill (cr); + cairo_set_source_rgba (cr, c->red, c->green, c->blue, .04); + cairo_scale (cr, scale, scale); + cairo_translate (cr, (alloc.width / scale) - GLADE_LOGO_WIDTH*.95, + (alloc.height / scale) - GLADE_LOGO_HEIGHT); + cairo_append_path (cr, &glade_logo_path); + cairo_fill (cr); - cairo_restore (cr); - } + cairo_restore (cr); - gtk_container_propagate_draw (GTK_CONTAINER (widget), - gtk_bin_get_child (GTK_BIN (widget)), - cr); - return TRUE; + return FALSE; } static void @@ -708,6 +704,16 @@ glade_registration_get_property (GObject *object, guint prop_id, GValue *value, } static void +glade_registration_style_updated (GtkWidget *widget) +{ + GladeRegistrationPrivate *priv = GLADE_REGISTRATION (widget)->priv; + + gtk_style_context_get_color (gtk_widget_get_style_context (widget), + GTK_STATE_FLAG_NORMAL, + &priv->fg_color); +} + +static void glade_registration_class_init (GladeRegistrationClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); @@ -783,6 +789,8 @@ glade_registration_class_init (GladeRegistrationClass *klass) gtk_widget_class_bind_template_callback (widget_class, toggle_button_set_visible_on_toggle); gtk_widget_class_bind_template_callback (widget_class, toggle_button_set_sensitive_on_toggle); gtk_widget_class_bind_template_callback (widget_class, on_viewport_draw); + + widget_class->style_updated = glade_registration_style_updated; object_class->finalize = glade_registration_finalize; object_class->set_property = glade_registration_set_property; diff --git a/src/glade-registration.css b/src/glade-registration.css index df6e597b..8494aa26 100644 --- a/src/glade-registration.css +++ b/src/glade-registration.css @@ -1,6 +1,6 @@ /* * Glade - A user interface designer for GTK+ and GNOME - * Copyright (C) 2014 Juan Pablo Ugarte + * Copyright (C) 2014-2016 Juan Pablo Ugarte * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,6 +20,7 @@ * */ + GtkFrame { background: none; } @@ -28,16 +29,15 @@ GtkScrolledWindow.survey_page { border: 0px; margin: 0px; padding:0px; - background: white; background-size: 100%; } GtkButtonBox.title, GtkFrame.title { - background-color: #4a90d9; + background-color: @theme_selected_bg_color; border-radius: 8px; padding: 8px; - box-shadow: 2px 2px 4px gray; + box-shadow: 2px 2px 3px gray; } GtkFrame.title > GtkLabel { @@ -49,23 +49,19 @@ GtkFrame.title > GtkLabel { GtkFrame.survey_question { border: 4px solid; - border-color: #c1c0bf; + border-color: @borders; border-radius: 16px; padding: 8px; } GtkFrame.textbox { border-radius: 16px; - background-color: #656565; - box-shadow: 4px 4px 2px #333; + color: @theme_bg_color; + background-color: @theme_fg_color; + box-shadow: 2px 2px 4px gray; padding: 8px; } -GtkFrame.textbox GtkButton, -GtkFrame.textbox GtkLabel { - color: white; - text-shadow: 1px 1px 1px black; -} GtkLabel.textbox_title { font-size: 10pt; @@ -77,10 +73,6 @@ GtkFrame.survey_question > GtkBox > GtkLabel { font-size: 10pt; font-weight: bold; padding: 0px 0px 8px 0px; - text-shadow: 1px 1px white; -} - -GtkCheckButton:hover { - background-color:white; + text-shadow: 1px 1px @theme_bg_color; } |