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.
This commit is contained in:
Thomas Wood 2010-11-20 16:31:11 +00:00
parent 907b0904b4
commit aac24399f8
3 changed files with 77 additions and 1 deletions

View file

@ -114,6 +114,28 @@ cc_shell_category_view_finalize (GObject *object)
G_OBJECT_CLASS (cc_shell_category_view_parent_class)->finalize (object); G_OBJECT_CLASS (cc_shell_category_view_parent_class)->finalize (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 static void
cc_shell_category_view_constructed (GObject *object) cc_shell_category_view_constructed (GObject *object)
{ {
@ -144,6 +166,9 @@ cc_shell_category_view_constructed (GObject *object)
gtk_label_set_attributes (GTK_LABEL (label), attrs); gtk_label_set_attributes (GTK_LABEL (label), attrs);
pango_attr_list_unref (attrs); pango_attr_list_unref (attrs);
gtk_frame_set_label_widget (GTK_FRAME (object), label); 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 */ /* add the iconview to the vbox */
@ -159,11 +184,35 @@ cc_shell_category_view_constructed (GObject *object)
priv->iconview = iconview; 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 static void
cc_shell_category_view_class_init (CcShellCategoryViewClass *klass) cc_shell_category_view_class_init (CcShellCategoryViewClass *klass)
{ {
GParamSpec *pspec; GParamSpec *pspec;
GObjectClass *object_class = G_OBJECT_CLASS (klass); GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
g_type_class_add_private (klass, sizeof (CcShellCategoryViewPrivate)); 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->finalize = cc_shell_category_view_finalize;
object_class->constructed = cc_shell_category_view_constructed; object_class->constructed = cc_shell_category_view_constructed;
widget_class->draw = cc_shell_category_view_draw;
pspec = g_param_spec_string ("name", pspec = g_param_spec_string ("name",
"Name", "Name",
"Name of the category", "Name of the category",

View file

@ -942,9 +942,29 @@ on_window_size_allocate (GtkWidget *widget,
gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (self->priv->scrolled_window), height); gtk_scrolled_window_set_min_content_height (GTK_SCROLLED_WINDOW (self->priv->scrolled_window), height);
} }
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 static void
gnome_control_center_init (GnomeControlCenter *self) gnome_control_center_init (GnomeControlCenter *self)
{ {
GtkWidget *widget;
GError *err = NULL; GError *err = NULL;
GnomeControlCenterPrivate *priv; GnomeControlCenterPrivate *priv;
@ -967,6 +987,11 @@ gnome_control_center_init (GnomeControlCenter *self)
priv->notebook = W (priv->builder, "notebook"); priv->notebook = W (priv->builder, "notebook");
priv->scrolled_window = W (priv->builder, "scrolledwindow1"); 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); gtk_widget_set_size_request (priv->scrolled_window, FIXED_WIDTH, -1);
priv->main_vbox = W (priv->builder, "main-vbox"); priv->main_vbox = W (priv->builder, "main-vbox");
g_signal_connect (priv->scrolled_window, "size-allocate", G_CALLBACK (on_window_size_allocate), self); g_signal_connect (priv->scrolled_window, "size-allocate", G_CALLBACK (on_window_size_allocate), self);

View file

@ -79,7 +79,7 @@
<property name="hscrollbar_policy">never</property> <property name="hscrollbar_policy">never</property>
<property name="vscrollbar_policy">automatic</property> <property name="vscrollbar_policy">automatic</property>
<child> <child>
<object class="GtkViewport" id="viewport1"> <object class="GtkViewport" id="viewport">
<property name="visible">True</property> <property name="visible">True</property>
<property name="resize_mode">queue</property> <property name="resize_mode">queue</property>
<child> <child>