summaryrefslogtreecommitdiff
path: root/eel/eel-labeled-image.c
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2016-06-26 12:59:43 +0200
committerraveit65 <[email protected]>2016-07-02 10:50:56 +0200
commit0c08ec62529640df8e6c007af8ed3e4728d31e69 (patch)
treeb7df87cd8494184e6d6fefedac70c08197a6811b /eel/eel-labeled-image.c
parente983f64abd52242d96d9ed3825395f2e1f3dea5e (diff)
downloadcaja-0c08ec62529640df8e6c007af8ed3e4728d31e69.tar.bz2
caja-0c08ec62529640df8e6c007af8ed3e4728d31e69.tar.xz
GTK+-3 eel-labeled-image: port to GtkStyleContext
Diffstat (limited to 'eel/eel-labeled-image.c')
-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
}
/**