[gnome-panel/gtk3] panel-widget: Port to GtkStyleContext
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel/gtk3] panel-widget: Port to GtkStyleContext
- Date: Fri, 21 Jan 2011 19:11:39 +0000 (UTC)
commit 6b3833a484e086cfe21b8b8030ca1e0ebba3215e
Author: Carlos Garcia Campos <carlosgc gnome org>
Date: Fri Jan 21 20:10:45 2011 +0100
panel-widget: Port to GtkStyleContext
Use GdkRGBA for the default color in panel-background instead of
GdkColor
gnome-panel/panel-background.c | 12 +++---
gnome-panel/panel-background.h | 4 +-
gnome-panel/panel-widget.c | 72 ++++++++++++++++++---------------------
3 files changed, 41 insertions(+), 47 deletions(-)
---
diff --git a/gnome-panel/panel-background.c b/gnome-panel/panel-background.c
index e875c2c..6a3081e 100644
--- a/gnome-panel/panel-background.c
+++ b/gnome-panel/panel-background.c
@@ -65,7 +65,7 @@ panel_background_prepare (PanelBackground *background)
gdk_window_set_background_pattern (background->window,
background->default_pattern);
else
- gdk_window_set_background (
+ gdk_window_set_background_rgba (
background->window, &background->default_color);
break;
case PANEL_BACK_COLOR:
@@ -672,7 +672,7 @@ panel_background_set (PanelBackground *background,
void
panel_background_set_default_style (PanelBackground *background,
- GdkColor *color,
+ GdkRGBA *color,
cairo_pattern_t *pattern)
{
g_return_if_fail (color != NULL);
@@ -814,10 +814,10 @@ panel_background_init (PanelBackground *background,
background->window = NULL;
background->default_pattern = NULL;
- background->default_color.red = 0;
- background->default_color.green = 0;
- background->default_color.blue = 0;
- background->default_color.pixel = 0;
+ background->default_color.red = 0.;
+ background->default_color.green = 0.;
+ background->default_color.blue = 0.;
+ background->default_color.alpha = 1.;
background->fit_image = FALSE;
background->stretch_image = FALSE;
diff --git a/gnome-panel/panel-background.h b/gnome-panel/panel-background.h
index d875150..a949729 100644
--- a/gnome-panel/panel-background.h
+++ b/gnome-panel/panel-background.h
@@ -60,7 +60,7 @@ struct _PanelBackground {
GdkWindow *window;
cairo_pattern_t *default_pattern;
- GdkColor default_color;
+ GdkRGBA default_color;
guint fit_image : 1;
guint stretch_image : 1;
@@ -98,7 +98,7 @@ void panel_background_set_stretch (PanelBackground *background,
void panel_background_set_rotate (PanelBackground *background,
gboolean rotate_image);
void panel_background_set_default_style (PanelBackground *background,
- GdkColor *color,
+ GdkRGBA *color,
cairo_pattern_t *pattern);
void panel_background_realized (PanelBackground *background,
GdkWindow *window);
diff --git a/gnome-panel/panel-widget.c b/gnome-panel/panel-widget.c
index 46fa550..db5c350 100644
--- a/gnome-panel/panel-widget.c
+++ b/gnome-panel/panel-widget.c
@@ -75,10 +75,9 @@ static void panel_widget_dispose (GObject *obj);
static void panel_widget_finalize (GObject *obj);
static void panel_widget_realize (GtkWidget *widget);
static void panel_widget_unrealize (GtkWidget *panel);
-static void panel_widget_state_changed (GtkWidget *widget,
- GtkStateType previous_state);
-static void panel_widget_style_set (GtkWidget *widget,
- GtkStyle *previous_style);
+static void panel_widget_state_flags_changed (GtkWidget *widget,
+ GtkStateFlags previous_state);
+static void panel_widget_style_updated (GtkWidget *widget);
static void panel_widget_background_changed (PanelBackground *background,
PanelWidget *panel);
@@ -419,8 +418,8 @@ panel_widget_class_init (PanelWidgetClass *class)
widget_class->realize = panel_widget_realize;
widget_class->unrealize = panel_widget_unrealize;
widget_class->focus = panel_widget_real_focus;
- widget_class->state_changed = panel_widget_state_changed;
- widget_class->style_set = panel_widget_style_set;
+ widget_class->state_flags_changed = panel_widget_state_flags_changed;
+ widget_class->style_updated = panel_widget_style_updated;
container_class->add = panel_widget_cadd;
container_class->remove = panel_widget_cremove;
@@ -1580,39 +1579,43 @@ panel_widget_is_cursor(PanelWidget *panel, int overlap)
}
static void
-panel_widget_style_set (GtkWidget *widget,
- GtkStyle *previous_style)
+panel_widget_set_background_default_style (GtkWidget *widget)
{
- GtkStyle *style;
- GtkStateType state;
+ GtkStyleContext *context;
+ GtkStateFlags state;
+ GdkRGBA bg_color;
+ cairo_pattern_t *bg_image;
if (gtk_widget_get_realized (widget)) {
- style = gtk_widget_get_style (widget);
- state = gtk_widget_get_state (widget);
+ context = gtk_widget_get_style_context (widget);
+ state = gtk_widget_get_state_flags (widget);
+
+ gtk_style_context_get_background_color (context, state, &bg_color);
+ gtk_style_context_get (context, state,
+ "background-image", &bg_image,
+ NULL);
panel_background_set_default_style (
&PANEL_WIDGET (widget)->background,
- &style->bg [state],
- style->background [state]);
+ &bg_color, bg_image);
+
+ if (bg_image)
+ cairo_pattern_destroy (bg_image);
}
}
static void
-panel_widget_state_changed (GtkWidget *widget,
- GtkStateType previous_state)
+panel_widget_style_updated (GtkWidget *widget)
{
- GtkStyle *style;
- GtkStateType state;
-
- if (gtk_widget_get_realized (widget)) {
- style = gtk_widget_get_style (widget);
- state = gtk_widget_get_state (widget);
+ panel_widget_set_background_default_style (widget);
+ GTK_WIDGET_CLASS (panel_widget_parent_class)->style_updated (widget);
+}
- panel_background_set_default_style (
- &PANEL_WIDGET (widget)->background,
- &style->bg [state],
- style->background [state]);
- }
+static void
+panel_widget_state_flags_changed (GtkWidget *widget,
+ GtkStateFlags previous_state)
+{
+ panel_widget_set_background_default_style (widget);
}
static gboolean
@@ -1628,10 +1631,8 @@ toplevel_configure_event (GtkWidget *widget,
static void
panel_widget_realize (GtkWidget *widget)
{
- PanelWidget *panel = (PanelWidget *) widget;
- GdkWindow *window;
- GtkStyle *style;
- GtkStateType state;
+ PanelWidget *panel = (PanelWidget *) widget;
+ GdkWindow *window;
g_signal_connect (panel->toplevel, "configure-event",
G_CALLBACK (toplevel_configure_event), panel);
@@ -1639,18 +1640,11 @@ panel_widget_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (panel_widget_parent_class)->realize (widget);
window = gtk_widget_get_window (widget);
- style = gtk_widget_get_style (widget);
- state = gtk_widget_get_state (widget);
-
/* For auto-hidden panels with a colored background, we need native
* windows to avoid some uglyness on unhide */
gdk_window_ensure_native (window);
- panel_background_set_default_style (
- &panel->background,
- &style->bg [state],
- style->background [state]);
-
+ panel_widget_set_background_default_style (widget);
panel_background_realized (&panel->background, window);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]