summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2016-05-31 21:24:24 +0200
committerraveit65 <[email protected]>2016-07-02 10:50:56 +0200
commit6eb433420c347de2384dcfe3dbbd7b5fc97117da (patch)
tree6341e5b1287cc6a46b15133d48b617c83f431ce3
parentf03e84290b3d79198e8be486da31b5b1c90aa991 (diff)
downloadcaja-6eb433420c347de2384dcfe3dbbd7b5fc97117da.tar.bz2
caja-6eb433420c347de2384dcfe3dbbd7b5fc97117da.tar.xz
GTK+3 eel-labeled-image: simplify code for port to GtkStyleContext
-rw-r--r--eel/eel-labeled-image.c82
1 files changed, 59 insertions, 23 deletions
diff --git a/eel/eel-labeled-image.c b/eel/eel-labeled-image.c
index d9ff49cd..a69f6295 100644
--- a/eel/eel-labeled-image.c
+++ b/eel/eel-labeled-image.c
@@ -375,10 +375,67 @@ static int
#if GTK_CHECK_VERSION (3, 0, 0)
eel_labeled_image_draw (GtkWidget *widget,
cairo_t *cr)
+{
+ EelLabeledImage *labeled_image;
+ EelIRect label_bounds;
+ GtkStyle *style;
+ GdkWindow *window;
+
+ g_assert (EEL_IS_LABELED_IMAGE (widget));
+ g_assert (gtk_widget_get_realized (widget));
+
+ labeled_image = EEL_LABELED_IMAGE (widget);
+
+ style = gtk_widget_get_style (widget);
+ window = gtk_widget_get_window (widget);
+ if (gtk_widget_get_state (widget) == GTK_STATE_SELECTED ||
+ gtk_widget_get_state (widget) == GTK_STATE_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);
+ }
+
+ if (labeled_image_show_label (labeled_image))
+ {
+ eel_gtk_container_child_expose_event (GTK_CONTAINER (widget),
+ labeled_image->details->label,
+ cr);
+ }
+
+ if (labeled_image_show_image (labeled_image))
+ {
+ eel_gtk_container_child_expose_event (GTK_CONTAINER (widget),
+ labeled_image->details->image,
+ cr);
+ }
+
+ 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);
+ }
+
+ return FALSE;
+}
#else
eel_labeled_image_expose_event (GtkWidget *widget,
GdkEventExpose *event)
-#endif
{
EelLabeledImage *labeled_image;
EelIRect label_bounds;
@@ -387,9 +444,7 @@ eel_labeled_image_expose_event (GtkWidget *widget,
g_assert (EEL_IS_LABELED_IMAGE (widget));
g_assert (gtk_widget_get_realized (widget));
-#if !GTK_CHECK_VERSION (3, 0, 0)
g_assert (event != NULL);
-#endif
labeled_image = EEL_LABELED_IMAGE (widget);
@@ -401,16 +456,10 @@ eel_labeled_image_expose_event (GtkWidget *widget,
label_bounds = eel_labeled_image_get_label_bounds (EEL_LABELED_IMAGE (widget));
gtk_paint_flat_box (style,
-#if GTK_CHECK_VERSION (3, 0, 0)
- cr,
-#else
window,
-#endif
gtk_widget_get_state (widget),
GTK_SHADOW_NONE,
-#if !GTK_CHECK_VERSION (3, 0, 0)
&event->area,
-#endif
widget,
"eel-labeled-image",
label_bounds.x0, label_bounds.y0,
@@ -422,37 +471,23 @@ eel_labeled_image_expose_event (GtkWidget *widget,
{
eel_gtk_container_child_expose_event (GTK_CONTAINER (widget),
labeled_image->details->label,
-#if GTK_CHECK_VERSION (3, 0, 0)
- cr);
-#else
event);
-#endif
}
if (labeled_image_show_image (labeled_image))
{
eel_gtk_container_child_expose_event (GTK_CONTAINER (widget),
labeled_image->details->image,
-#if GTK_CHECK_VERSION (3, 0, 0)
- cr);
-#else
event);
-#endif
}
if (gtk_widget_has_focus (widget))
{
label_bounds = eel_labeled_image_get_image_bounds (EEL_LABELED_IMAGE (widget));
gtk_paint_focus (style,
-#if GTK_CHECK_VERSION (3, 0, 0)
- cr,
-#else
window,
-#endif
GTK_STATE_NORMAL,
-#if !GTK_CHECK_VERSION (3, 0, 0)
&event->area,
-#endif
widget,
"eel-focusable-labeled-image",
label_bounds.x0, label_bounds.y0,
@@ -462,6 +497,7 @@ eel_labeled_image_expose_event (GtkWidget *widget,
return FALSE;
}
+#endif
static void
eel_labeled_image_map (GtkWidget *widget)