summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eel/eel-labeled-image.c59
1 files changed, 38 insertions, 21 deletions
diff --git a/eel/eel-labeled-image.c b/eel/eel-labeled-image.c
index a69f6295..02b28bdc 100644
--- a/eel/eel-labeled-image.c
+++ b/eel/eel-labeled-image.c
@@ -378,7 +378,7 @@ eel_labeled_image_draw (GtkWidget *widget,
{
EelLabeledImage *labeled_image;
EelIRect label_bounds;
- GtkStyle *style;
+ GtkStyleContext *context;
GdkWindow *window;
g_assert (EEL_IS_LABELED_IMAGE (widget));
@@ -386,22 +386,27 @@ eel_labeled_image_draw (GtkWidget *widget,
labeled_image = EEL_LABELED_IMAGE (widget);
- style = gtk_widget_get_style (widget);
+ context = gtk_widget_get_style_context (widget);
+ gtk_style_context_save (context);
+
window = gtk_widget_get_window (widget);
- if (gtk_widget_get_state (widget) == GTK_STATE_SELECTED ||
- gtk_widget_get_state (widget) == GTK_STATE_ACTIVE)
+ if (gtk_widget_get_state_flags (widget) == GTK_STATE_FLAG_SELECTED ||
+ gtk_widget_get_state_flags (widget) == GTK_STATE_FLAG_ACTIVE)
{
label_bounds = eel_labeled_image_get_label_bounds (EEL_LABELED_IMAGE (widget));
- gtk_paint_flat_box (style,
- cr,
- gtk_widget_get_state (widget),
- GTK_SHADOW_NONE,
- widget,
- "eel-labeled-image",
- label_bounds.x0, label_bounds.y0,
- label_bounds.x1 - label_bounds.x0,
- label_bounds.y1 - label_bounds.y0);
+ gtk_widget_get_state_flags (widget);
+ gtk_render_background (context,
+ cr,
+ label_bounds.x0, label_bounds.y0,
+ label_bounds.x1 - label_bounds.x0,
+ label_bounds.y1 - label_bounds.y0);
+
+ gtk_render_frame (context,
+ cr,
+ label_bounds.x0, label_bounds.y0,
+ label_bounds.x1 - label_bounds.x0,
+ label_bounds.y1 - label_bounds.y0);
}
if (labeled_image_show_label (labeled_image))
@@ -421,16 +426,16 @@ eel_labeled_image_draw (GtkWidget *widget,
if (gtk_widget_has_focus (widget))
{
label_bounds = eel_labeled_image_get_image_bounds (EEL_LABELED_IMAGE (widget));
- gtk_paint_focus (style,
- cr,
- GTK_STATE_NORMAL,
- widget,
- "eel-focusable-labeled-image",
- label_bounds.x0, label_bounds.y0,
- label_bounds.x1 - label_bounds.x0,
- label_bounds.y1 - label_bounds.y0);
+ gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_NORMAL, TRUE);
+ gtk_render_focus (context,
+ cr,
+ label_bounds.x0, label_bounds.y0,
+ label_bounds.x1 - label_bounds.x0,
+ label_bounds.y1 - label_bounds.y0);
}
+ gtk_style_context_restore (context);
+
return FALSE;
}
#else
@@ -1639,11 +1644,19 @@ eel_labeled_image_set_selected (EelLabeledImage *labeled_image,
GtkStateType state;
g_return_if_fail (EEL_IS_LABELED_IMAGE (labeled_image));
+#if GTK_CHECK_VERSION (3, 0, 0)
+ state = selected ? GTK_STATE_FLAG_SELECTED : GTK_STATE_FLAG_NORMAL;
+
+ gtk_widget_set_state_flags (GTK_WIDGET (labeled_image), state, TRUE);
+ gtk_widget_set_state_flags (labeled_image->details->image, state, TRUE);
+ gtk_widget_set_state_flags (labeled_image->details->label, state, TRUE);
+#else
state = selected ? GTK_STATE_SELECTED : GTK_STATE_NORMAL;
gtk_widget_set_state (GTK_WIDGET (labeled_image), state);
gtk_widget_set_state (labeled_image->details->image, state);
gtk_widget_set_state (labeled_image->details->label, state);
+#endif
}
/**
@@ -1658,7 +1671,11 @@ eel_labeled_image_get_selected (EelLabeledImage *labeled_image)
{
g_return_val_if_fail (EEL_IS_LABELED_IMAGE (labeled_image), FALSE);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ return gtk_widget_get_state_flags (GTK_WIDGET (labeled_image)) == GTK_STATE_FLAG_SELECTED;
+#else
return gtk_widget_get_state (GTK_WIDGET (labeled_image)) == GTK_STATE_SELECTED;
+#endif
}
/**