[gtk+] Update _gtk_button_paint() arguments to GtkStyleContext
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Update _gtk_button_paint() arguments to GtkStyleContext
- Date: Mon, 10 Jan 2011 02:53:02 +0000 (UTC)
commit e0e36b621f8008569d5ebfab453008f5fd34e7ea
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Jan 10 02:26:28 2011 +0100
Update _gtk_button_paint() arguments to GtkStyleContext
The detail strings weren't in use anymore, and the state
argument is now a GtkStateFlags. GtkToggleButton has been
updated as well.
gtk/gtkbutton.c | 21 +++++++--------------
gtk/gtkbutton.h | 5 +----
gtk/gtktogglebutton.c | 18 ++++++------------
3 files changed, 14 insertions(+), 30 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 374d7df..d86ca46 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -1555,10 +1555,7 @@ _gtk_button_paint (GtkButton *button,
cairo_t *cr,
int width,
int height,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- const gchar *main_detail,
- const gchar *default_detail)
+ GtkStateFlags state)
{
GtkButtonPrivate *priv = button->priv;
GtkWidget *widget;
@@ -1571,12 +1568,12 @@ _gtk_button_paint (GtkButton *button,
GtkAllocation allocation;
GdkWindow *window;
GtkStyleContext *context;
- GtkStateFlags state;
widget = GTK_WIDGET (button);
-
context = gtk_widget_get_style_context (widget);
- state = gtk_widget_get_state_flags (widget);
+
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, state);
gtk_button_get_props (button, &default_border, &default_outside_border, NULL, &interior_focus);
gtk_style_context_get_style (context,
@@ -1616,9 +1613,6 @@ _gtk_button_paint (GtkButton *button,
height -= 2 * (focus_width + focus_pad);
}
- state = gtk_widget_get_state_flags (widget);
- gtk_style_context_set_state (context, state);
-
if (priv->relief != GTK_RELIEF_NONE || priv->depressed ||
state & GTK_STATE_FLAG_PRELIGHT)
{
@@ -1671,6 +1665,8 @@ _gtk_button_paint (GtkButton *button,
gtk_border_free (border);
}
+
+ gtk_style_context_restore (context);
}
static gboolean
@@ -1678,14 +1674,11 @@ gtk_button_draw (GtkWidget *widget,
cairo_t *cr)
{
GtkButton *button = GTK_BUTTON (widget);
- GtkButtonPrivate *priv = button->priv;
_gtk_button_paint (button, cr,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget),
- gtk_widget_get_state (widget),
- priv->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
- "button", "buttondefault");
+ gtk_widget_get_state_flags (widget));
GTK_WIDGET_CLASS (gtk_button_parent_class)->draw (widget, cr);
diff --git a/gtk/gtkbutton.h b/gtk/gtkbutton.h
index 0bab7e6..2ad602e 100644
--- a/gtk/gtkbutton.h
+++ b/gtk/gtkbutton.h
@@ -127,10 +127,7 @@ void _gtk_button_paint (GtkButton *button,
cairo_t *cr,
int width,
int height,
- GtkStateType state_type,
- GtkShadowType shadow_type,
- const gchar *main_detail,
- const gchar *default_detail);
+ GtkStateFlags state);
G_END_DECLS
diff --git a/gtk/gtktogglebutton.c b/gtk/gtktogglebutton.c
index 7b8ae49..43dbd49 100644
--- a/gtk/gtktogglebutton.c
+++ b/gtk/gtktogglebutton.c
@@ -471,25 +471,19 @@ gtk_toggle_button_draw (GtkWidget *widget,
GtkToggleButtonPrivate *priv = toggle_button->priv;
GtkWidget *child = gtk_bin_get_child (GTK_BIN (widget));
GtkButton *button = GTK_BUTTON (widget);
- GtkStateType state_type;
- GtkShadowType shadow_type;
+ GtkStateType state;
- state_type = gtk_widget_get_state (widget);
+ state = gtk_widget_get_state_flags (widget);
if (priv->inconsistent)
- {
- if (state_type == GTK_STATE_ACTIVE)
- state_type = GTK_STATE_NORMAL;
- shadow_type = GTK_SHADOW_ETCHED_IN;
- }
- else
- shadow_type = button->priv->depressed ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
+ state |= GTK_STATE_FLAG_INCONSISTENT;
+ else if (button->priv->depressed)
+ state |= GTK_STATE_FLAG_ACTIVE;
_gtk_button_paint (button, cr,
gtk_widget_get_allocated_width (widget),
gtk_widget_get_allocated_height (widget),
- state_type, shadow_type,
- "togglebutton", "togglebuttondefault");
+ state);
if (child)
gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]