[gnome-control-center] shell: ensure the background and foreground colours are consistent
- From: Thomas Wood <thos src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] shell: ensure the background and foreground colours are consistent
- Date: Sat, 20 Nov 2010 17:14:38 +0000 (UTC)
commit aac24399f847df62708d77cb5a0cff025a7ff30d
Author: Thomas Wood <thos gnome org>
Date: Sat Nov 20 16:31:11 2010 +0000
shell: ensure the background and foreground colours are consistent
Modify the colours of the viewport and category view widgets so that
they are consistent with the icon view.
shell/cc-shell-category-view.c | 51 ++++++++++++++++++++++++++++++++++++++++
shell/gnome-control-center.c | 25 +++++++++++++++++++
shell/shell.ui | 2 +-
3 files changed, 77 insertions(+), 1 deletions(-)
---
diff --git a/shell/cc-shell-category-view.c b/shell/cc-shell-category-view.c
index 503b1e7..6466c84 100644
--- a/shell/cc-shell-category-view.c
+++ b/shell/cc-shell-category-view.c
@@ -115,6 +115,28 @@ cc_shell_category_view_finalize (GObject *object)
}
static void
+label_style_set_cb (GtkWidget *widget,
+ GtkStyle *old_style,
+ gpointer user_data)
+{
+ GtkStyle *style;
+
+ /* "base" colours are used for the background inside CcShellCategoryView,
+ * so set the labels to use the "text" colors */
+
+ g_signal_handlers_block_by_func (widget, label_style_set_cb, NULL);
+
+ style = gtk_widget_get_style (widget);
+
+ gtk_widget_modify_fg (widget, GTK_STATE_NORMAL,
+ &style->text[GTK_STATE_NORMAL]);
+
+ g_signal_handlers_unblock_by_func (widget, label_style_set_cb, NULL);
+}
+
+
+
+static void
cc_shell_category_view_constructed (GObject *object)
{
CcShellCategoryViewPrivate *priv = CC_SHELL_CATEGORY_VIEW (object)->priv;
@@ -144,6 +166,9 @@ cc_shell_category_view_constructed (GObject *object)
gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango_attr_list_unref (attrs);
gtk_frame_set_label_widget (GTK_FRAME (object), label);
+
+ g_signal_connect (label, "style-set", G_CALLBACK (label_style_set_cb),
+ NULL);
}
/* add the iconview to the vbox */
@@ -159,11 +184,35 @@ cc_shell_category_view_constructed (GObject *object)
priv->iconview = iconview;
}
+static gboolean
+cc_shell_category_view_draw (GtkWidget *widget,
+ cairo_t *cr)
+{
+ GtkStyle *style;
+ GtkStateType state;
+ GtkAllocation allocation;
+
+ style = gtk_widget_get_style (widget);
+ state = gtk_widget_get_state (widget);
+ gtk_widget_get_allocation (widget, &allocation);
+
+
+ cairo_rectangle (cr, 0, 0, allocation.width, allocation.height);
+ gdk_cairo_set_source_color (cr, &style->base[state]);
+
+ cairo_fill (cr);
+
+ GTK_WIDGET_CLASS (cc_shell_category_view_parent_class)->draw (widget, cr);
+
+ return FALSE;
+}
+
static void
cc_shell_category_view_class_init (CcShellCategoryViewClass *klass)
{
GParamSpec *pspec;
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
g_type_class_add_private (klass, sizeof (CcShellCategoryViewPrivate));
@@ -173,6 +222,8 @@ cc_shell_category_view_class_init (CcShellCategoryViewClass *klass)
object_class->finalize = cc_shell_category_view_finalize;
object_class->constructed = cc_shell_category_view_constructed;
+ widget_class->draw = cc_shell_category_view_draw;
+
pspec = g_param_spec_string ("name",
"Name",
"Name of the category",
diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c
index 0f79f52..466387a 100644
--- a/shell/gnome-control-center.c
+++ b/shell/gnome-control-center.c
@@ -943,8 +943,28 @@ on_window_size_allocate (GtkWidget *widget,
}
static void
+viewport_style_set_cb (GtkWidget *widget,
+ GtkStyle *old_style,
+ gpointer user_data)
+{
+ GtkStyle *style;
+
+ /* use "base" colours inside the viewport */
+
+ g_signal_handlers_block_by_func (widget, viewport_style_set_cb, NULL);
+
+ style = gtk_widget_get_style (widget);
+
+ gtk_widget_modify_bg (widget, GTK_STATE_NORMAL,
+ &style->base[GTK_STATE_NORMAL]);
+
+ g_signal_handlers_unblock_by_func (widget, viewport_style_set_cb, NULL);
+}
+
+static void
gnome_control_center_init (GnomeControlCenter *self)
{
+ GtkWidget *widget;
GError *err = NULL;
GnomeControlCenterPrivate *priv;
@@ -967,6 +987,11 @@ gnome_control_center_init (GnomeControlCenter *self)
priv->notebook = W (priv->builder, "notebook");
priv->scrolled_window = W (priv->builder, "scrolledwindow1");
+
+ widget = W (priv->builder, "viewport");
+ g_signal_connect (widget, "style-set", G_CALLBACK (viewport_style_set_cb),
+ NULL);
+
gtk_widget_set_size_request (priv->scrolled_window, FIXED_WIDTH, -1);
priv->main_vbox = W (priv->builder, "main-vbox");
g_signal_connect (priv->scrolled_window, "size-allocate", G_CALLBACK (on_window_size_allocate), self);
diff --git a/shell/shell.ui b/shell/shell.ui
index 0a3654c..7d6fc72 100644
--- a/shell/shell.ui
+++ b/shell/shell.ui
@@ -79,7 +79,7 @@
<property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property>
<child>
- <object class="GtkViewport" id="viewport1">
+ <object class="GtkViewport" id="viewport">
<property name="visible">True</property>
<property name="resize_mode">queue</property>
<child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]