summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libslab/app-resizer.c22
-rw-r--r--libslab/application-tile.c34
-rw-r--r--libslab/slab-section.c50
3 files changed, 91 insertions, 15 deletions
diff --git a/libslab/app-resizer.c b/libslab/app-resizer.c
index f7d9d0a1..0e1a15b8 100644
--- a/libslab/app-resizer.c
+++ b/libslab/app-resizer.c
@@ -275,11 +275,19 @@ static gboolean
app_resizer_paint_window (GtkWidget * widget, cairo_t * cr, AppShellData * app_data)
{
cairo_save(cr);
+ GtkStyleContext *context;
+ GdkRGBA *bg_rgba = NULL;
GtkAllocation widget_allocation;
gtk_widget_get_allocation (widget, &widget_allocation);
- gdk_cairo_set_source_color (cr, gtk_widget_get_style (widget)->base);
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_get (context,
+ GTK_STATE_FLAG_NORMAL,
+ "background-color", &bg_rgba,
+ NULL);
+
+ gdk_cairo_set_source_rgba (cr, bg_rgba);
cairo_set_line_width(cr, 1);
cairo_rectangle(cr, widget_allocation.x, widget_allocation.y, widget_allocation.width, widget_allocation.height);
@@ -289,19 +297,25 @@ app_resizer_paint_window (GtkWidget * widget, cairo_t * cr, AppShellData * app_d
if (app_data->selected_group)
{
GtkWidget *selected_widget = GTK_WIDGET (app_data->selected_group);
+ GdkRGBA *rgba;
GtkAllocation selected_widget_allocation;
-
gtk_widget_get_allocation (selected_widget, &selected_widget_allocation);
- gdk_cairo_set_source_color (cr, gtk_widget_get_style (selected_widget)->light);
- cairo_set_line_width(cr, 1);
+ gtk_style_context_get (context,
+ GTK_STATE_FLAG_PRELIGHT,
+ "background-color", &rgba,
+ NULL);
+ gdk_cairo_set_source_rgba (cr, rgba);
+ cairo_set_line_width(cr, 1);
cairo_rectangle(cr, selected_widget_allocation.x, selected_widget_allocation.y, selected_widget_allocation.width, selected_widget_allocation.height);
cairo_stroke_preserve(cr);
cairo_fill(cr);
+ gdk_rgba_free (rgba);
}
cairo_restore(cr);
+ gdk_rgba_free (bg_rgba);
return FALSE;
}
diff --git a/libslab/application-tile.c b/libslab/application-tile.c
index 8492a923..ab1b4cf5 100644
--- a/libslab/application-tile.c
+++ b/libslab/application-tile.c
@@ -417,19 +417,43 @@ create_header (const gchar *name)
return header;
}
+static void
+set_background_color (GtkWidget *widget,
+ GdkRGBA *rgba)
+{
+ gchar *css;
+ GtkCssProvider *provider;
+
+ provider = gtk_css_provider_new ();
+
+ css = g_strdup_printf ("* { background-color: %s;}",
+ gdk_rgba_to_string (rgba));
+ gtk_css_provider_load_from_data (provider, css, -1, NULL);
+ g_free (css);
+
+ gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (provider);
+}
+
static GtkWidget *
create_subheader (const gchar *desc)
{
- GtkWidget *subheader;
+ GtkWidget *subheader;
+ GtkStyleContext *context;
+ GdkRGBA *rgba = NULL;
subheader = gtk_label_new (desc);
gtk_label_set_ellipsize (GTK_LABEL (subheader), PANGO_ELLIPSIZE_END);
gtk_label_set_xalign (GTK_LABEL (subheader), 0.0);
+ context = gtk_widget_get_style_context (subheader);
+ gtk_style_context_get (context,
+ GTK_STATE_FLAG_INSENSITIVE,
+ "background-color", &rgba,
+ NULL);
- gtk_widget_modify_fg (
- subheader,
- GTK_STATE_NORMAL,
- & gtk_widget_get_style (subheader)->fg [GTK_STATE_INSENSITIVE]);
+ set_background_color (subheader, rgba);
return subheader;
}
diff --git a/libslab/slab-section.c b/libslab/slab-section.c
index 530a0826..f86820cf 100644
--- a/libslab/slab-section.c
+++ b/libslab/slab-section.c
@@ -46,21 +46,59 @@ slab_section_finalize (GObject * obj)
}
static void
+set_override_color (GtkWidget *widget,
+ GdkRGBA *rgba)
+{
+ gchar *css;
+ GtkCssProvider *provider;
+
+ provider = gtk_css_provider_new ();
+
+ css = g_strdup_printf ("* { color: %s;}",
+ gdk_rgba_to_string (rgba));
+ gtk_css_provider_load_from_data (provider, css, -1, NULL);
+ g_free (css);
+
+ gtk_style_context_add_provider (gtk_widget_get_style_context (widget),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ g_object_unref (provider);
+}
+
+static void
slab_section_set_title_color (GtkWidget * widget)
{
+ GtkStyleContext *context;
+ GdkRGBA *rgba = NULL;
+
+ context = gtk_widget_get_style_context (widget);
+
switch (SLAB_SECTION (widget)->style)
{
case Style1:
- gtk_widget_modify_fg (SLAB_SECTION (widget)->title, GTK_STATE_NORMAL,
- &gtk_widget_get_style (widget)->bg[GTK_STATE_SELECTED]);
+ gtk_style_context_get (context,
+ GTK_STATE_FLAG_SELECTED,
+ "background-color", &rgba,
+ NULL);
+ set_override_color (SLAB_SECTION (widget)->title, rgba);
break;
case Style2:
if (SLAB_SECTION (widget)->selected)
- gtk_widget_modify_fg (SLAB_SECTION (widget)->title, GTK_STATE_NORMAL,
- &gtk_widget_get_style (widget)->dark[GTK_STATE_SELECTED]);
+ {
+ gtk_style_context_get (context,
+ GTK_STATE_FLAG_SELECTED,
+ "background-color", &rgba,
+ NULL);
+ set_override_color (SLAB_SECTION (widget)->title, rgba);
+ }
else
- gtk_widget_modify_fg (SLAB_SECTION (widget)->title, GTK_STATE_NORMAL,
- &gtk_widget_get_style (widget)->text[GTK_STATE_INSENSITIVE]);
+ {
+ gtk_style_context_get (context,
+ GTK_STATE_FLAG_INSENSITIVE,
+ "color", &rgba,
+ NULL);
+ set_override_color (SLAB_SECTION (widget)->title, rgba);
+ }
break;
default:
g_assert_not_reached ();