summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eel/eel-canvas-rect-ellipse.c83
-rw-r--r--eel/eel-canvas-rect-ellipse.h5
-rw-r--r--eel/eel-canvas.c6
-rw-r--r--eel/eel-editable-label.c218
-rw-r--r--eel/eel-gdk-extensions.c73
-rw-r--r--eel/eel-gdk-extensions.h11
-rw-r--r--eel/eel-gdk-pixbuf-extensions.c12
-rw-r--r--eel/eel-gdk-pixbuf-extensions.h4
-rw-r--r--eel/eel-graphic-effects.c17
-rw-r--r--eel/eel-graphic-effects.h9
-rw-r--r--eel/eel-gtk-extensions.c6
-rw-r--r--libcaja-private/caja-file-conflict-dialog.c28
-rw-r--r--libcaja-private/caja-icon-canvas-item.c399
-rw-r--r--libcaja-private/caja-icon-container.c170
-rw-r--r--libcaja-private/caja-icon-dnd.c35
-rw-r--r--libcaja-private/caja-icon-info.c8
-rw-r--r--libcaja-private/caja-icon-private.h4
-rw-r--r--libcaja-private/caja-tree-view-drag-dest.c19
-rw-r--r--src/caja-location-bar.c16
-rw-r--r--src/caja-notebook.c27
-rw-r--r--src/caja-places-sidebar.c9
-rw-r--r--src/caja-sidebar-title.c105
-rw-r--r--src/caja-spatial-window.c4
-rw-r--r--src/caja-window.c28
-rw-r--r--src/file-manager/fm-list-model.c8
-rw-r--r--src/file-manager/fm-list-view.c15
-rw-r--r--src/file-manager/fm-properties-window.c84
-rw-r--r--src/file-manager/fm-tree-model.c8
28 files changed, 1236 insertions, 175 deletions
diff --git a/eel/eel-canvas-rect-ellipse.c b/eel/eel-canvas-rect-ellipse.c
index f93cc85e..0ed0c826 100644
--- a/eel/eel-canvas-rect-ellipse.c
+++ b/eel/eel-canvas-rect-ellipse.c
@@ -54,11 +54,15 @@ enum
PROP_Y1,
PROP_X2,
PROP_Y2,
+#if !GTK_CHECK_VERSION(3,0,0)
PROP_FILL_COLOR,
PROP_FILL_COLOR_GDK,
+#endif
PROP_FILL_COLOR_RGBA,
+#if !GTK_CHECK_VERSION(3,0,0)
PROP_OUTLINE_COLOR,
PROP_OUTLINE_COLOR_GDK,
+#endif
PROP_OUTLINE_COLOR_RGBA,
PROP_OUTLINE_STIPPLING,
PROP_WIDTH_PIXELS,
@@ -168,6 +172,11 @@ eel_canvas_re_class_init (EelCanvasREClass *klass)
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
+#if GTK_CHECK_VERSION(3,0,0)
+ PROP_FILL_COLOR_RGBA,
+ g_param_spec_boxed ("fill-color-rgba", NULL, NULL,
+ GDK_TYPE_RGBA,
+#else
PROP_FILL_COLOR,
g_param_spec_string ("fill-color", NULL, NULL,
NULL,
@@ -195,13 +204,20 @@ eel_canvas_re_class_init (EelCanvasREClass *klass)
PROP_OUTLINE_COLOR_GDK,
g_param_spec_boxed ("outline-color-gdk", NULL, NULL,
GDK_TYPE_COLOR,
+#endif
G_PARAM_READWRITE));
g_object_class_install_property
(gobject_class,
PROP_OUTLINE_COLOR_RGBA,
+#if GTK_CHECK_VERSION(3,0,0)
+ g_param_spec_boxed ("outline-color-rgba", NULL, NULL,
+ GDK_TYPE_RGBA,
+ G_PARAM_READWRITE));
+#else
g_param_spec_uint ("outline-color-rgba", NULL, NULL,
0, G_MAXUINT, 0,
G_PARAM_READWRITE));
+#endif
g_object_class_install_property
(gobject_class,
PROP_OUTLINE_STIPPLING,
@@ -303,8 +319,10 @@ eel_canvas_re_set_property (GObject *object,
{
EelCanvasItem *item;
EelCanvasRE *re;
+#if !GTK_CHECK_VERSION(3,0,0)
GdkColor color = { 0, 0, 0, 0, };
GdkColor *pcolor;
+#endif
g_return_if_fail (object != NULL);
g_return_if_fail (EEL_IS_CANVAS_RE (object));
@@ -338,6 +356,37 @@ eel_canvas_re_set_property (GObject *object,
eel_canvas_item_request_update (item);
break;
+#if GTK_CHECK_VERSION(3,0,0)
+ case PROP_FILL_COLOR_RGBA: {
+ GdkRGBA *color;
+
+ color = g_value_get_boxed (value);
+
+ eel_canvas_re_set_fill (re, color != NULL);
+
+ if (color != NULL) {
+ re->fill_color = *color;
+ }
+
+ eel_canvas_item_request_redraw (item);
+ break;
+ }
+
+ case PROP_OUTLINE_COLOR_RGBA: {
+ GdkRGBA *color;
+
+ color = g_value_get_boxed (value);
+
+ eel_canvas_re_set_outline (re, color != NULL);
+
+ if (color != NULL) {
+ re->outline_color = *color;
+ }
+
+ eel_canvas_item_request_redraw (item);
+ break;
+ }
+#else
case PROP_FILL_COLOR:
case PROP_FILL_COLOR_GDK:
case PROP_FILL_COLOR_RGBA:
@@ -425,6 +474,7 @@ eel_canvas_re_set_property (GObject *object,
#endif
eel_canvas_item_request_redraw (item);
break;
+#endif
case PROP_OUTLINE_STIPPLING:
re->outline_stippling = g_value_get_boolean (value);
@@ -452,6 +502,7 @@ eel_canvas_re_set_property (GObject *object,
}
}
+#if !GTK_CHECK_VERSION(3,0,0)
/* Allocates a GdkColor structure filled with the specified pixel, and puts it into the specified
* value for returning it in the get_property method.
*/
@@ -469,6 +520,7 @@ get_color_value (EelCanvasRE *re, gulong pixel, GValue *value)
g_value_set_boxed (value, &color);
}
+#endif
static void
eel_canvas_re_get_property (GObject *object,
@@ -501,6 +553,14 @@ eel_canvas_re_get_property (GObject *object,
g_value_set_double (value, re->y2);
break;
+#if GTK_CHECK_VERSION(3,0,0)
+ case PROP_FILL_COLOR_RGBA:
+ g_value_set_boxed (value, &re->fill_color);
+ break;
+
+ case PROP_OUTLINE_COLOR_RGBA:
+ g_value_set_boxed (value, &re->outline_color);
+#else
case PROP_FILL_COLOR_GDK:
get_color_value (re, re->fill_color, value);
break;
@@ -515,6 +575,7 @@ eel_canvas_re_get_property (GObject *object,
case PROP_OUTLINE_COLOR_RGBA:
g_value_set_uint (value, re->outline_color);
+#endif
break;
case PROP_OUTLINE_STIPPLING:
@@ -721,6 +782,11 @@ eel_canvas_rect_realize (EelCanvasItem *item)
static void
eel_canvas_set_source_color (cairo_t *cr,
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA *rgba)
+{
+ gdk_cairo_set_source_rgba (cr, rgba);
+#else
guint rgba)
{
cairo_set_source_rgba (cr,
@@ -728,6 +794,7 @@ eel_canvas_set_source_color (cairo_t *cr,
((rgba >> 16) & 0xff) / 255.,
((rgba >> 8) & 0xff) / 255.,
((rgba >> 0) & 0xff) / 255.);
+#endif
}
#define DASH_ON 0.8
@@ -773,7 +840,11 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose
if (re->fill_set)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ eel_canvas_set_source_color (cr, &re->fill_color);
+#else
eel_canvas_set_source_color (cr, re->fill_color);
+#endif
cairo_rectangle (cr,
cx1, cy1,
cx2 - cx1 + 1,
@@ -783,7 +854,11 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose
if (re->outline_set)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ eel_canvas_set_source_color (cr, &re->outline_color);
+#else
eel_canvas_set_source_color (cr, re->outline_color);
+#endif
if (re->width_pixels) {
cairo_set_line_width (cr, (int) re->width);
} else {
@@ -1098,13 +1173,21 @@ eel_canvas_ellipse_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExp
if (re->fill_set)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ eel_canvas_set_source_color (cr, &re->fill_color);
+#else
eel_canvas_set_source_color (cr, re->fill_color);
+#endif
cairo_fill_preserve (cr);
}
if (re->outline_set)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ eel_canvas_set_source_color (cr, &re->outline_color);
+#else
eel_canvas_set_source_color (cr, re->outline_color);
+#endif
if (re->width_pixels) {
cairo_set_line_width (cr, (int) re->width);
} else {
diff --git a/eel/eel-canvas-rect-ellipse.h b/eel/eel-canvas-rect-ellipse.h
index aaccf560..d54de4d2 100644
--- a/eel/eel-canvas-rect-ellipse.h
+++ b/eel/eel-canvas-rect-ellipse.h
@@ -84,8 +84,13 @@ extern "C" {
double x1, y1, x2, y2; /* Corners of item */
double width; /* Outline width */
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA fill_color;
+ GdkRGBA outline_color;
+#else
guint fill_color; /* Fill color, RGBA */
guint outline_color; /* Outline color, RGBA */
+#endif
gboolean outline_stippling;
diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c
index 21216a61..f1f7068d 100644
--- a/eel/eel-canvas.c
+++ b/eel/eel-canvas.c
@@ -3193,13 +3193,17 @@ eel_canvas_draw_background (EelCanvas *canvas,
cairo_t *cr)
{
cairo_rectangle_int_t rect;
+ GtkStyleContext *style_context;
+ GdkRGBA color;
if (!gdk_cairo_get_clip_rectangle (cr, &rect))
return;
cairo_save (cr);
/* By default, we use the style background. */
- gdk_cairo_set_source_color (cr, &gtk_widget_get_style (GTK_WIDGET (canvas))->bg[GTK_STATE_NORMAL]);
+ style_context = gtk_widget_get_style_context (GTK_WIDGET (canvas));
+ gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_NORMAL, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
gdk_cairo_rectangle (cr, &rect);
cairo_fill (cr);
cairo_restore (cr);
diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c
index fe7d5e2f..3edd68ef 100644
--- a/eel/eel-editable-label.c
+++ b/eel/eel-editable-label.c
@@ -100,8 +100,12 @@ static void eel_editable_label_size_allocate (GtkWidget
GtkAllocation *allocation);
static void eel_editable_label_state_changed (GtkWidget *widget,
GtkStateType state);
+#if GTK_CHECK_VERSION(3,0,0)
+static void eel_editable_label_style_updated (GtkWidget *widget);
+#else
static void eel_editable_label_style_set (GtkWidget *widget,
GtkStyle *previous_style);
+#endif
static void eel_editable_label_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir);
#if GTK_CHECK_VERSION(3,0,0)
@@ -247,7 +251,11 @@ eel_editable_label_class_init (EelEditableLabelClass *class)
#endif
widget_class->size_allocate = eel_editable_label_size_allocate;
widget_class->state_changed = eel_editable_label_state_changed;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->style_updated = eel_editable_label_style_updated;
+#else
widget_class->style_set = eel_editable_label_style_set;
+#endif
widget_class->direction_changed = eel_editable_label_direction_changed;
#if GTK_CHECK_VERSION(3,0,0)
widget_class->draw = eel_editable_label_draw;
@@ -636,6 +644,10 @@ eel_editable_label_init (EelEditableLabel *label)
label->n_bytes = 0;
gtk_widget_set_can_focus (GTK_WIDGET (label), TRUE);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (label)),
+ GTK_STYLE_CLASS_ENTRY);
+#endif
/* This object is completely private. No external entity can gain a reference
* to it; so we create it here and destroy it in finalize().
@@ -933,7 +945,12 @@ static gint
get_label_wrap_width (EelEditableLabel *label)
{
PangoLayout *layout;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *style = gtk_widget_get_style_context (GTK_WIDGET (label));
+ PangoFontDescription *desc;
+#else
GtkStyle *style = gtk_widget_get_style (GTK_WIDGET (label));
+#endif
LabelWrapWidth *wrap_width = g_object_get_data (G_OBJECT (style), "gtk-label-wrap-width");
if (!wrap_width)
@@ -943,18 +960,36 @@ get_label_wrap_width (EelEditableLabel *label)
wrap_width, label_wrap_width_free);
}
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_style_context_get (style, gtk_widget_get_state_flags (GTK_WIDGET (label)),
+ GTK_STYLE_PROPERTY_FONT, &desc,
+ NULL);
+
+ if (wrap_width->font_desc && pango_font_description_equal (wrap_width->font_desc, desc))
+ goto out;
+#else
if (wrap_width->font_desc && pango_font_description_equal (wrap_width->font_desc, style->font_desc))
return wrap_width->width;
+#endif
if (wrap_width->font_desc)
pango_font_description_free (wrap_width->font_desc);
+#if GTK_CHECK_VERSION(3,0,0)
+ wrap_width->font_desc = pango_font_description_copy (desc);
+#else
wrap_width->font_desc = pango_font_description_copy (style->font_desc);
+#endif
layout = gtk_widget_create_pango_layout (GTK_WIDGET (label),
"This long string gives a good enough length for any line to have.");
pango_layout_get_size (layout, &wrap_width->width, NULL);
g_object_unref (layout);
+#if GTK_CHECK_VERSION(3,0,0)
+
+ out:
+ pango_font_description_free (desc);
+#endif
return wrap_width->width;
}
@@ -1123,7 +1158,11 @@ eel_editable_label_size_request (GtkWidget *widget,
gint width, height;
PangoRectangle logical_rect;
gint set_width;
+#if GTK_CHECK_VERSION(3,0,0)
+ gint xpad, ypad;
+#else
gfloat xpad, ypad;
+#endif
g_assert (EEL_IS_EDITABLE_LABEL (widget));
g_assert (requisition != NULL);
@@ -1148,8 +1187,13 @@ eel_editable_label_size_request (GtkWidget *widget,
eel_editable_label_ensure_layout (label, TRUE);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_misc_get_padding (&label->misc,
+ &xpad, &ypad);
+#else
gtk_misc_get_alignment (&label->misc,
&xpad, &ypad);
+#endif
width = xpad * 2;
height = ypad * 2;
@@ -1217,8 +1261,12 @@ eel_editable_label_state_changed (GtkWidget *widget,
}
static void
+#if GTK_CHECK_VERSION(3,0,0)
+eel_editable_label_style_updated (GtkWidget *widget)
+#else
eel_editable_label_style_set (GtkWidget *widget,
GtkStyle *previous_style)
+#endif
{
EelEditableLabel *label;
@@ -1226,6 +1274,10 @@ eel_editable_label_style_set (GtkWidget *widget,
label = EEL_EDITABLE_LABEL (widget);
+#if GTK_CHECK_VERSION(3,0,0)
+ GTK_WIDGET_CLASS (eel_editable_label_parent_class)->style_updated (widget);
+#endif
+
/* We have to clear the layout, fonts etc. may have changed */
eel_editable_label_recompute (label);
@@ -1234,10 +1286,17 @@ eel_editable_label_style_set (GtkWidget *widget,
*/
if (gtk_widget_get_realized (widget))
{
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *style;
+
+ style = gtk_widget_get_style_context (widget);
+ gtk_style_context_set_background (style, gtk_widget_get_window (widget));
+#else
GtkStyle *style;
style = gtk_widget_get_style (widget);
gdk_window_set_background (gtk_widget_get_window (widget), &style->base[gtk_widget_get_state (widget)]);
+#endif
}
}
@@ -1546,15 +1605,23 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof
}
else /* Block cursor */
{
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA fg_color;
+ GtkStyleContext *style;
cairo_region_t *clip;
-#if GTK_CHECK_VERSION(3,0,0)
+ style = gtk_widget_get_style_context (widget);
+ gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &fg_color);
+
cairo_save (cr);
+ gdk_cairo_set_source_rgba (cr, &fg_color);
#else
+ cairo_region_t *clip;
+
cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
-#endif
cairo_set_source_rgb (cr, 0, 0, 0);
+#endif
cairo_rectangle (cr,
xoffset + PANGO_PIXELS (strong_pos.x),
yoffset + PANGO_PIXELS (strong_pos.y),
@@ -1566,14 +1633,27 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof
if (!block_at_line_end)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA color;
+
+#endif
clip = gdk_pango_layout_get_clip_region (label->layout,
xoffset, yoffset,
range, 1);
gdk_cairo_region (cr, clip);
cairo_clip (cr);
+#if GTK_CHECK_VERSION(3,0,0)
+
+ gtk_style_context_get_background_color (style, GTK_STATE_FLAG_FOCUSED,
+ &color);
+
+ gdk_cairo_set_source_rgba (cr,
+ &color);
+#else
gdk_cairo_set_source_color (cr,
&gtk_widget_get_style (widget)->base[GTK_STATE_NORMAL]);
+#endif
cairo_move_to (cr, xoffset, yoffset);
pango_cairo_show_layout (cr, label->layout);
@@ -1594,19 +1674,113 @@ static gint
#if GTK_CHECK_VERSION(3,0,0)
eel_editable_label_draw (GtkWidget *widget,
cairo_t *cr)
+{
+ EelEditableLabel *label;
+ GtkStyleContext *style;
+ gint x, y;
+
+ g_assert (EEL_IS_EDITABLE_LABEL (widget));
+
+ label = EEL_EDITABLE_LABEL (widget);
+ style = gtk_widget_get_style_context (widget);
+
+ gtk_render_background (style, cr,
+ 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
+
+ eel_editable_label_ensure_layout (label, TRUE);
+
+ if (gtk_widget_get_visible (widget) && gtk_widget_get_mapped (widget) &&
+ label->text)
+ {
+ get_layout_location (label, &x, &y);
+
+ gtk_render_layout (style,
+ cr,
+ x, y,
+ label->layout);
+
+ if (label->selection_anchor != label->selection_end)
+ {
+ gint range[2];
+ const char *text;
+ cairo_region_t *clip;
+ GtkStateType state;
+
+ GdkRGBA background_color;
+
+ range[0] = label->selection_anchor;
+ range[1] = label->selection_end;
+
+ /* Handle possible preedit string */
+ if (label->preedit_length > 0 &&
+ range[1] > label->selection_anchor)
+ {
+ text = pango_layout_get_text (label->layout) + label->selection_anchor;
+ range[1] += g_utf8_offset_to_pointer (text, label->preedit_length) - text;
+ }
+
+ if (range[0] > range[1])
+ {
+ gint tmp = range[0];
+ range[0] = range[1];
+ range[1] = tmp;
+ }
+
+ clip = gdk_pango_layout_get_clip_region (label->layout,
+ x, y,
+ range,
+ 1);
+
+ cairo_save (cr);
+
+ gdk_cairo_region (cr, clip);
+ cairo_clip (cr);
+
+ state = gtk_widget_get_state_flags (widget);
+ state |= GTK_STATE_FLAG_SELECTED;
+
+ gtk_style_context_get_background_color (style, state, &background_color);
+ gdk_cairo_set_source_rgba (cr, &background_color);
+ cairo_paint (cr);
+
+ gtk_style_context_save (style);
+ gtk_style_context_set_state (style, state);
+
+ gtk_render_layout (style, cr,
+ x, y, label->layout);
+
+ gtk_style_context_restore (style);
+
+ cairo_restore (cr);
+
+ cairo_region_destroy (clip);
+ }
+ else if (gtk_widget_has_focus (widget))
+ eel_editable_label_draw_cursor (label, cr, x, y);
+
+ if (label->draw_outline)
+ {
+ gtk_style_context_save (style);
+ gtk_style_context_set_state (style, gtk_widget_get_state_flags (widget));
+
+ gtk_render_frame (style, cr,
+ 0, 0,
+ gtk_widget_get_allocated_width (widget),
+ gtk_widget_get_allocated_height (widget));
+
+ gtk_style_context_restore (style);
#else
eel_editable_label_expose (GtkWidget *widget,
GdkEventExpose *event)
-#endif
{
EelEditableLabel *label;
GtkStyle *style;
+ g_assert (event != NULL);
gint x, y;
g_assert (EEL_IS_EDITABLE_LABEL (widget));
-#if !GTK_CHECK_VERSION(3,0,0)
- g_assert (event != NULL);
-#endif
label = EEL_EDITABLE_LABEL (widget);
style = gtk_widget_get_style (widget);
@@ -1619,16 +1793,10 @@ eel_editable_label_expose (GtkWidget *widget,
get_layout_location (label, &x, &y);
gtk_paint_layout (style,
-#if GTK_CHECK_VERSION(3,0,0)
- cr,
-#else
gtk_widget_get_window (widget),
-#endif
gtk_widget_get_state (widget),
TRUE,
-#if !GTK_CHECK_VERSION(3,0,0)
&event->area,
-#endif
widget,
"label",
x, y,
@@ -1663,11 +1831,8 @@ eel_editable_label_expose (GtkWidget *widget,
x, y,
range,
1);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_save (cr);
-#else
+
cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
-#endif
gdk_cairo_region (cr, clip);
cairo_clip (cr);
@@ -1682,28 +1847,19 @@ eel_editable_label_expose (GtkWidget *widget,
cairo_move_to (cr, x, y);
pango_cairo_show_layout (cr, label->layout);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_restore (cr);
-#else
cairo_destroy (cr);
-#endif
+
cairo_region_destroy (clip);
}
else if (gtk_widget_has_focus (widget))
-#if GTK_CHECK_VERSION(3,0,0)
- eel_editable_label_draw_cursor (label, cr, x, y);
-#else
eel_editable_label_draw_cursor (label, x, y);
-#endif
if (label->draw_outline)
{
GtkAllocation allocation;
gtk_widget_get_allocation (widget, &allocation);
-#if !GTK_CHECK_VERSION(3,0,0)
cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget));
-#endif
gdk_cairo_set_source_color (cr, &style->text [gtk_widget_get_state (widget)]);
cairo_set_line_width (cr, 1.0);
cairo_rectangle (cr, 0.5, 0.5,
@@ -1711,7 +1867,6 @@ eel_editable_label_expose (GtkWidget *widget,
allocation.height - 1);
cairo_stroke (cr);
-#if !GTK_CHECK_VERSION(3,0,0)
cairo_destroy (cr);
#endif
}
@@ -1728,7 +1883,11 @@ eel_editable_label_realize (GtkWidget *widget)
gint attributes_mask;
GtkAllocation allocation;
GdkWindow *window;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *style;
+#else
GtkStyle *style;
+#endif
gtk_widget_set_realized (widget, TRUE);
label = EEL_EDITABLE_LABEL (widget);
@@ -1769,10 +1928,15 @@ eel_editable_label_realize (GtkWidget *widget)
gdk_cursor_unref (attributes.cursor);
+#if GTK_CHECK_VERSION(3,0,0)
+ style = gtk_widget_get_style_context (widget);
+ gtk_style_context_set_background (style, gtk_widget_get_window (widget));
+#else
style = gtk_style_attach (gtk_widget_get_style (widget) , gtk_widget_get_window (widget));
gtk_widget_set_style (widget, style);
gdk_window_set_background (gtk_widget_get_window (widget), &style->base[gtk_widget_get_state (widget)]);
+#endif
gtk_im_context_set_client_window (label->im_context, gtk_widget_get_window (widget));
}
diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c
index 3d68d9a5..2da5bb03 100644
--- a/eel/eel-gdk-extensions.c
+++ b/eel/eel-gdk-extensions.c
@@ -420,6 +420,15 @@ eel_gdk_rgb_to_color_spec (const guint32 color)
* Return true if the given color is `dark'
*/
gboolean
+#if GTK_CHECK_VERSION(3,0,0)
+eel_gdk_rgba_is_dark (const GdkRGBA *color)
+{
+ int intensity;
+
+ intensity = ((((int) (color->red) >> 8) * 77)
+ + (((int) (color->green) >> 8) * 150)
+ + (((int) (color->blue) >> 8) * 28)) >> 8;
+#else
eel_gdk_color_is_dark (GdkColor *color)
{
int intensity;
@@ -427,6 +436,7 @@ eel_gdk_color_is_dark (GdkColor *color)
intensity = (((color->red >> 8) * 77)
+ ((color->green >> 8) * 150)
+ ((color->blue >> 8) * 28)) >> 8;
+#endif
return intensity < 128;
}
@@ -478,22 +488,34 @@ eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return,
void
#if GTK_CHECK_VERSION(3,0,0)
-eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr,
+eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr,
+ GdkRGBA *text_color,
+ GdkRGBA *shadow_color,
+ int x,
+ int y,
+ PangoLayout *layout)
+{
+ cairo_save (cr);
+
+ gdk_cairo_set_source_rgba (cr, shadow_color);
+ cairo_move_to (cr, x+1, y+1);
+ pango_cairo_show_layout (cr, layout);
+
+ gdk_cairo_set_source_rgba (cr, text_color);
+ cairo_move_to (cr, x, y);
+ pango_cairo_show_layout (cr, layout);
+
+ cairo_restore (cr);
#else
eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable,
-#endif
GdkColor *text_color,
GdkColor *shadow_color,
- int x,
- int y,
+ int x,
+ int y,
PangoLayout *layout)
{
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_save (cr);
-#else
cairo_t *cr;
cr = gdk_cairo_create (drawable);
-#endif
gdk_cairo_set_source_color (cr, shadow_color);
cairo_move_to (cr, x+1, y+1);
@@ -503,13 +525,42 @@ eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable,
cairo_move_to (cr, x, y);
pango_cairo_show_layout (cr, layout);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_restore (cr);
-#else
cairo_destroy (cr);
#endif
}
+#if GTK_CHECK_VERSION(3,0,0)
+#define CLAMP_COLOR(v) (t = (v), CLAMP (t, 0, 1))
+#define SATURATE(v) ((1.0 - saturation) * intensity + saturation * (v))
+
+void
+eel_make_color_inactive (GdkRGBA *color)
+{
+ double intensity, saturation;
+ gdouble t;
+
+ saturation = 0.7;
+ intensity = color->red * 0.30 + color->green * 0.59 + color->blue * 0.11;
+ color->red = SATURATE (color->red);
+ color->green = SATURATE (color->green);
+ color->blue = SATURATE (color->blue);
+
+ if (intensity > 0.5) {
+ color->red *= 0.9;
+ color->green *= 0.9;
+ color->blue *= 0.9;
+ } else {
+ color->red *= 1.25;
+ color->green *= 1.25;
+ color->blue *= 1.25;
+ }
+
+ color->red = CLAMP_COLOR (color->red);
+ color->green = CLAMP_COLOR (color->green);
+ color->blue = CLAMP_COLOR (color->blue);
+}
+#endif
+
#if ! defined (EEL_OMIT_SELF_CHECK)
static char *
diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h
index 2036eec4..ad94ddbd 100644
--- a/eel/eel-gdk-extensions.h
+++ b/eel/eel-gdk-extensions.h
@@ -114,7 +114,11 @@ guint32 eel_gdk_color_to_rgb (const GdkColor
GdkColor eel_gdk_rgb_to_color (guint32 color);
char * eel_gdk_rgb_to_color_spec (guint32 color);
+#if GTK_CHECK_VERSION(3,0,0)
+gboolean eel_gdk_rgba_is_dark (const GdkRGBA *color);
+#else
gboolean eel_gdk_color_is_dark (GdkColor *color);
+#endif
/* Wrapper for XParseGeometry */
EelGdkGeometryFlags eel_gdk_parse_geometry (const char *string,
@@ -124,12 +128,17 @@ EelGdkGeometryFlags eel_gdk_parse_geometry (const char
guint *height_return);
#if GTK_CHECK_VERSION(3,0,0)
void eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr,
+ GdkRGBA *text_color,
+ GdkRGBA *shadow_color,
#else
void eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable,
-#endif
GdkColor *text_color,
GdkColor *shadow_color,
+#endif
int x,
int y,
PangoLayout *layout);
+#if GTK_CHECK_VERSION(3,0,0)
+void eel_make_color_inactive (GdkRGBA *color);
+#endif
#endif /* EEL_GDK_EXTENSIONS_H */
diff --git a/eel/eel-gdk-pixbuf-extensions.c b/eel/eel-gdk-pixbuf-extensions.c
index b4cd9394..bbbffc3a 100644
--- a/eel/eel-gdk-pixbuf-extensions.c
+++ b/eel/eel-gdk-pixbuf-extensions.c
@@ -1265,7 +1265,11 @@ eel_gdk_pixbuf_render (GdkPixbuf *pixbuf,
guint saturation,
guint brightness,
guint lighten_value,
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA *color)
+#else
guint color)
+#endif
{
GdkPixbuf *temp_pixbuf, *old_pixbuf;
@@ -1277,19 +1281,27 @@ eel_gdk_pixbuf_render (GdkPixbuf *pixbuf,
else if (render_mode == 2)
{
/* colorize icon */
+#if GTK_CHECK_VERSION(3,0,0)
+ temp_pixbuf = eel_create_colorized_pixbuf (pixbuf, color);
+#else
temp_pixbuf = eel_create_colorized_pixbuf (pixbuf,
EEL_RGBA_COLOR_GET_R (color),
EEL_RGBA_COLOR_GET_G (color),
EEL_RGBA_COLOR_GET_B (color));
+#endif
}
else if (render_mode == 3)
{
/* monochromely colorize icon */
old_pixbuf = eel_create_darkened_pixbuf (pixbuf, 0, 255);
+#if GTK_CHECK_VERSION(3,0,0)
+ temp_pixbuf = eel_create_colorized_pixbuf (old_pixbuf, color);
+#else
temp_pixbuf = eel_create_colorized_pixbuf (old_pixbuf,
EEL_RGBA_COLOR_GET_R (color),
EEL_RGBA_COLOR_GET_G (color),
EEL_RGBA_COLOR_GET_B (color));
+#endif
g_object_unref (old_pixbuf);
}
else
diff --git a/eel/eel-gdk-pixbuf-extensions.h b/eel/eel-gdk-pixbuf-extensions.h
index 7d31defe..87f79a7a 100644
--- a/eel/eel-gdk-pixbuf-extensions.h
+++ b/eel/eel-gdk-pixbuf-extensions.h
@@ -151,6 +151,10 @@ GdkPixbuf * eel_gdk_pixbuf_render (GdkPixbuf *pixbuf
guint saturation,
guint brightness,
guint lighten_value,
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA *color);
+#else
guint color);
+#endif
#endif /* EEL_GDK_PIXBUF_EXTENSIONS_H */
diff --git a/eel/eel-graphic-effects.c b/eel/eel-graphic-effects.c
index ffb5beba..39309de9 100644
--- a/eel/eel-graphic-effects.c
+++ b/eel/eel-graphic-effects.c
@@ -26,7 +26,10 @@
and selection hilighting */
#include <config.h>
+
#include "eel-graphic-effects.h"
+#include "eel-glib-extensions.h"
+
#include <string.h>
/* shared utility to create a new pixbuf from the passed-in one */
@@ -169,9 +172,13 @@ eel_create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken)
GdkPixbuf *
eel_create_colorized_pixbuf (GdkPixbuf *src,
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA *color)
+#else
int red_value,
int green_value,
int blue_value)
+#endif
{
int i, j;
int width, height, has_alpha, src_row_stride, dst_row_stride;
@@ -181,6 +188,10 @@ eel_create_colorized_pixbuf (GdkPixbuf *src,
guchar *pixdest;
GdkPixbuf *dest;
+#if GTK_CHECK_VERSION(3,0,0)
+ gint red_value, green_value, blue_value;
+#endif
+
g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL);
g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src)
&& gdk_pixbuf_get_n_channels (src) == 3)
@@ -188,6 +199,12 @@ eel_create_colorized_pixbuf (GdkPixbuf *src,
&& gdk_pixbuf_get_n_channels (src) == 4), NULL);
g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL);
+#if GTK_CHECK_VERSION(3,0,0)
+ red_value = eel_round (color->red * 255);
+ green_value = eel_round (color->green * 255);
+ blue_value = eel_round (color->blue * 255);
+#endif
+
dest = create_new_pixbuf (src);
has_alpha = gdk_pixbuf_get_has_alpha (src);
diff --git a/eel/eel-graphic-effects.h b/eel/eel-graphic-effects.h
index 6ae00421..7291629b 100644
--- a/eel/eel-graphic-effects.h
+++ b/eel/eel-graphic-effects.h
@@ -26,6 +26,11 @@
#define EEL_GRAPHIC_EFFECTS_H
#include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gtk/gtk.h>
+#if GTK_CHECK_VERSION(3,0,0)
+#include <gdk/gdk.h>
+#endif
+
/* return a lightened pixbuf for pre-lighting */
GdkPixbuf *eel_create_spotlight_pixbuf (GdkPixbuf *source_pixbuf);
@@ -37,9 +42,13 @@ GdkPixbuf *eel_create_darkened_pixbuf (GdkPixbuf *source_pixbuf,
/* return a pixbuf colorized with the color specified by the parameters */
GdkPixbuf* eel_create_colorized_pixbuf (GdkPixbuf *source_pixbuf,
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA *color);
+#else
int red_value,
int green_value,
int blue_value);
+#endif
/* stretch a image frame */
GdkPixbuf *eel_stretch_frame_image (GdkPixbuf *frame_image,
diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c
index b86b2b88..4e1bbeca 100644
--- a/eel/eel-gtk-extensions.c
+++ b/eel/eel-gtk-extensions.c
@@ -406,7 +406,11 @@ eel_gtk_label_make_bold (GtkLabel *label)
* theme or user prefs, since the font desc only has the
* weight flag turned on.
*/
- gtk_widget_modify_font (GTK_WIDGET (label), font_desc);
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_override_font (GTK_WIDGET (label), font_desc);
+#else
+ gtk_widget_modify_font (GTK_WIDGET (label), font_desc);
+#endif
pango_font_description_free (font_desc);
}
diff --git a/libcaja-private/caja-file-conflict-dialog.c b/libcaja-private/caja-file-conflict-dialog.c
index cda3069b..300543b3 100644
--- a/libcaja-private/caja-file-conflict-dialog.c
+++ b/libcaja-private/caja-file-conflict-dialog.c
@@ -115,7 +115,11 @@ file_list_ready_cb (GList *files,
GdkPixbuf *pixbuf;
GtkWidget *label;
GString *str;
+#if GTK_CHECK_VERSION(3,0,0)
+ PangoAttrList *attr_list;
+#else
PangoFontDescription *desc;
+#endif
details = fcd->details;
@@ -216,15 +220,28 @@ file_list_ready_cb (GList *files,
label = gtk_label_new (primary_text);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
gtk_label_set_line_wrap_mode (GTK_LABEL (label), PANGO_WRAP_WORD_CHAR);
- gtk_widget_set_size_request (label, 350, -1);
-#if GTK_CHECK_VERSION (3, 14, 0)
+#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_set_halign (label, GTK_ALIGN_START);
+ gtk_box_pack_start (GTK_BOX (details->titles_vbox),
+ label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+
+ attr_list = pango_attr_list_new ();
+ pango_attr_list_insert (attr_list, pango_attr_weight_new (PANGO_WEIGHT_BOLD));
+ pango_attr_list_insert (attr_list, pango_attr_scale_new (PANGO_SCALE_LARGE));
+ g_object_set (label,
+ "attributes", attr_list,
+ NULL);
+
+ pango_attr_list_unref (attr_list);
#else
+ gtk_widget_set_size_request (label, 350, -1);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
-#endif
gtk_box_pack_start (GTK_BOX (details->titles_vbox),
label, FALSE, FALSE, 0);
+
gtk_widget_modify_font (label, NULL);
+
desc = pango_font_description_new ();
pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD);
pango_font_description_set_size (desc,
@@ -232,13 +249,14 @@ file_list_ready_cb (GList *files,
gtk_widget_modify_font (label, desc);
pango_font_description_free (desc);
gtk_widget_show (label);
+#endif
label = gtk_label_new (secondary_text);
gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
- gtk_widget_set_size_request (label, 350, -1);
-#if GTK_CHECK_VERSION (3, 14, 0)
+#if GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_set_halign (label, GTK_ALIGN_START);
#else
+ gtk_widget_set_size_request (label, 350, -1);
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
#endif
gtk_box_pack_start (GTK_BOX (details->titles_vbox),
diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c
index fe44b9b2..803cde76 100644
--- a/libcaja-private/caja-icon-canvas-item.c
+++ b/libcaja-private/caja-icon-canvas-item.c
@@ -224,17 +224,15 @@ static void draw_pixbuf (GdkPixbuf
static PangoLayout *get_label_layout (PangoLayout **layout,
CajaIconCanvasItem *item,
const char *text);
+#if !GTK_CHECK_VERSION(3,0,0)
static void draw_label_layout (CajaIconCanvasItem *item,
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_t *cr,
-#else
GdkDrawable *drawable,
-#endif
PangoLayout *layout,
gboolean highlight,
GdkColor *label_color,
int x,
int y);
+#endif
static gboolean hit_test_stretch_handle (CajaIconCanvasItem *item,
EelIRect canvas_rect,
GtkCornerType *corner);
@@ -542,12 +540,19 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
double item_x, item_y;
gboolean is_rtl;
cairo_t *cr;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *context;
+#endif
g_return_val_if_fail (CAJA_IS_ICON_CANVAS_ITEM (item), NULL);
canvas = EEL_CANVAS_ITEM (item)->canvas;
#if GTK_CHECK_VERSION(3,0,0)
screen = gtk_widget_get_screen (GTK_WIDGET (canvas));
+ context = gtk_widget_get_style_context (GTK_WIDGET (canvas));
+
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, "caja-canvas-item");
#else
screen = gdk_colormap_get_screen (colormap);
#endif
@@ -573,12 +578,9 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
width, height);
cr = cairo_create (surface);
- gdk_cairo_set_source_pixbuf (cr, item->details->pixbuf,
+
+ gtk_render_icon (context, cr, item->details->pixbuf,
item_offset_x, item_offset_y);
- cairo_rectangle (cr, item_offset_x, item_offset_y,
- gdk_pixbuf_get_width (item->details->pixbuf),
- gdk_pixbuf_get_height (item->details->pixbuf));
- cairo_fill (cr);
#else
pixmap = gdk_pixmap_new (gdk_screen_get_root_window (screen),
width, height,
@@ -622,6 +624,8 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item,
draw_label_text (item, cr, FALSE, icon_rect);
cairo_destroy (cr);
+ gtk_style_context_restore (context);
+
return surface;
#else
while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl))
@@ -993,7 +997,7 @@ in_single_click_mode (void)
return click_policy_auto_value == CAJA_CLICK_POLICY_SINGLE;
}
-
+#if !GTK_CHECK_VERSION(3,0,0)
/* Utility routine to create a rectangle with rounded corners.
* This could possibly move to Eel as a general purpose routine.
*/
@@ -1037,11 +1041,7 @@ make_round_rect (cairo_t *cr,
static void
draw_frame (CajaIconCanvasItem *item,
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_t *cr,
-#else
GdkDrawable *drawable,
-#endif
guint color,
gboolean create_mask,
int x,
@@ -1049,11 +1049,7 @@ draw_frame (CajaIconCanvasItem *item,
int width,
int height)
{
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_save (cr);
-#else
cairo_t *cr = gdk_cairo_create (drawable);
-#endif
/* Set the rounded rect clip region. Magic rounding value taken
* from old code.
@@ -1077,13 +1073,9 @@ draw_frame (CajaIconCanvasItem *item,
/* Paint into drawable now that we have set up the color and opacity */
cairo_fill (cr);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_restore (cr);
-#else
cairo_destroy (cr);
-#endif
}
-
+#endif
/* Keep these for a bit while we work on performance of draw_or_measure_label_text. */
/*
#define PERFORMANCE_TEST_DRAW_DISABLE
@@ -1384,9 +1376,185 @@ static void
draw_label_text (CajaIconCanvasItem *item,
#if GTK_CHECK_VERSION(3,0,0)
cairo_t *cr,
+ gboolean create_mask,
+ EelIRect icon_rect)
+{
+ CajaIconCanvasItemDetails *details;
+ CajaIconContainer *container;
+ PangoLayout *editable_layout;
+ PangoLayout *additional_layout;
+ GtkStyleContext *context;
+ GtkStateFlags state, base_state;
+ gboolean have_editable, have_additional;
+ gboolean needs_highlight, prelight_label, is_rtl_label_beside;
+ EelIRect text_rect;
+ int x;
+ int max_text_width;
+ gdouble frame_w, frame_h, frame_x, frame_y;
+ gboolean draw_frame = TRUE;
+
+#ifdef PERFORMANCE_TEST_DRAW_DISABLE
+ return;
+#endif
+
+ details = item->details;
+
+ measure_label_text (item);
+ if (details->text_height == 0 ||
+ details->text_width == 0)
+ {
+ return;
+ }
+
+ container = CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas);
+ context = gtk_widget_get_style_context (GTK_WIDGET (container));
+
+ text_rect = compute_text_rectangle (item, icon_rect, TRUE, BOUNDS_USAGE_FOR_DISPLAY);
+
+ needs_highlight = details->is_highlighted_for_selection || details->is_highlighted_for_drop;
+ is_rtl_label_beside = caja_icon_container_is_layout_rtl (container) &&
+ container->details->label_position == CAJA_ICON_LABEL_POSITION_BESIDE;
+
+ editable_layout = NULL;
+ additional_layout = NULL;
+
+ have_editable = details->editable_text != NULL && details->editable_text[0] != '\0';
+ have_additional = details->additional_text != NULL && details->additional_text[0] != '\0';
+ g_assert (have_editable || have_additional);
+
+ max_text_width = floor (caja_icon_canvas_item_get_max_text_width (item));
+
+ base_state = gtk_widget_get_state_flags (GTK_WIDGET (container));
+ base_state &= ~(GTK_STATE_FLAG_SELECTED | GTK_STATE_FLAG_PRELIGHT);
+ state = base_state;
+
+ gtk_widget_style_get (GTK_WIDGET (container),
+ "activate_prelight_icon_label", &prelight_label,
+ NULL);
+
+ /* if the icon is highlighted, do some set-up */
+ if (needs_highlight &&
+ !details->is_renaming) {
+ state |= GTK_STATE_FLAG_SELECTED;
+
+ frame_x = is_rtl_label_beside ? text_rect.x0 + item->details->text_dx : text_rect.x0;
+ frame_y = text_rect.y0;
+ frame_w = is_rtl_label_beside ? text_rect.x1 - text_rect.x0 - item->details->text_dx : text_rect.x1 - text_rect.x0;
+ frame_h = text_rect.y1 - text_rect.y0;
+ } else if (!needs_highlight && have_editable &&
+ details->text_width > 0 && details->text_height > 0 &&
+ prelight_label && item->details->is_prelit) {
+ state |= GTK_STATE_FLAG_PRELIGHT;
+
+ frame_x = text_rect.x0;
+ frame_y = text_rect.y0;
+ frame_w = text_rect.x1 - text_rect.x0;
+ frame_h = text_rect.y1 - text_rect.y0;
+ } else {
+ draw_frame = FALSE;
+ }
+
+ if (draw_frame) {
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, state);
+
+ gtk_render_frame (context, cr,
+ frame_x, frame_y,
+ frame_w, frame_h);
+ gtk_render_background (context, cr,
+ frame_x, frame_y,
+ frame_w, frame_h);
+
+ gtk_style_context_restore (context);
+ }
+
+ if (container->details->label_position == CAJA_ICON_LABEL_POSITION_BESIDE)
+ {
+ x = text_rect.x0 + 2;
+ }
+ else
+ {
+ x = text_rect.x0 + ((text_rect.x1 - text_rect.x0) - max_text_width) / 2;
+ }
+
+ if (have_editable &&
+ !details->is_renaming)
+ {
+ state = base_state;
+
+ if (prelight_label && item->details->is_prelit) {
+ state |= GTK_STATE_FLAG_PRELIGHT;
+ }
+
+ if (needs_highlight) {
+ state |= GTK_STATE_FLAG_SELECTED;
+ }
+
+ editable_layout = get_label_layout (&item->details->editable_text_layout, item, item->details->editable_text);
+ prepare_pango_layout_for_draw (item, editable_layout);
+
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, state);
+
+ gtk_render_layout (context, cr,
+ x, text_rect.y0 + TEXT_BACK_PADDING_Y,
+ editable_layout);
+
+ gtk_style_context_restore (context);
+ }
+
+ if (have_additional &&
+ !details->is_renaming)
+ {
+ state = base_state;
+
+ if (needs_highlight) {
+ state |= GTK_STATE_FLAG_SELECTED;
+ }
+
+ additional_layout = get_label_layout (&item->details->additional_text_layout, item, item->details->additional_text);
+ prepare_pango_layout_for_draw (item, additional_layout);
+
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, state);
+ gtk_style_context_add_class (context, "dim-label");
+
+ gtk_render_layout (context, cr,
+ x, text_rect.y0 + details->editable_text_height + LABEL_LINE_SPACING + TEXT_BACK_PADDING_Y,
+ additional_layout);
+ }
+
+ if (!create_mask && item->details->is_highlighted_as_keyboard_focus)
+ {
+ if (needs_highlight) {
+ state = GTK_STATE_FLAG_SELECTED;
+ }
+
+ gtk_style_context_save (context);
+ gtk_style_context_set_state (context, state);
+
+ gtk_render_focus (context,
+ cr,
+ text_rect.x0,
+ text_rect.y0,
+ text_rect.x1 - text_rect.x0,
+ text_rect.y1 - text_rect.y0);
+
+ gtk_style_context_restore (context);
+ }
+
+ if (editable_layout != NULL)
+ {
+ g_object_unref (editable_layout);
+ }
+
+ if (additional_layout != NULL)
+ {
+ g_object_unref (additional_layout);
+ }
+}
#else
GdkDrawable *drawable,
-#endif
gboolean create_mask,
EelIRect icon_rect)
{
@@ -1406,7 +1574,6 @@ draw_label_text (CajaIconCanvasItem *item,
return;
#endif
- canvas_item = EEL_CANVAS_ITEM (item);
details = item->details;
measure_label_text (item);
@@ -1417,6 +1584,7 @@ draw_label_text (CajaIconCanvasItem *item,
}
container = CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas);
+ canvas_item = EEL_CANVAS_ITEM (item);
text_rect = compute_text_rectangle (item, icon_rect, TRUE, BOUNDS_USAGE_FOR_DISPLAY);
@@ -1433,15 +1601,10 @@ draw_label_text (CajaIconCanvasItem *item,
max_text_width = floor (caja_icon_canvas_item_get_max_text_width (item));
- /* if the icon is highlighted, do some set-up */
if (needs_highlight && !details->is_renaming)
{
draw_frame (item,
-#if GTK_CHECK_VERSION(3,0,0)
- cr,
-#else
drawable,
-#endif
gtk_widget_has_focus (GTK_WIDGET (container)) ? container->details->highlight_color_rgba : container->details->active_color_rgba,
create_mask,
is_rtl_label_beside ? text_rect.x0 + item->details->text_dx : text_rect.x0,
@@ -1454,23 +1617,11 @@ draw_label_text (CajaIconCanvasItem *item,
details->is_highlighted_as_keyboard_focus))
{
/* clear the underlying icons, where the text or overlaps them. */
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_save (cr);
- cairo_set_source_rgba (cr, 0, 0, 0, 0);
- cairo_rectangle (cr,
- text_rect.x0,
- text_rect.y0,
- text_rect.x1 - text_rect.x0,
- text_rect.y1 - text_rect.y0);
- cairo_fill (cr);
- cairo_restore (cr);
-#else
gdk_window_clear_area (gtk_layout_get_bin_window (&EEL_CANVAS (container)->layout),
text_rect.x0,
text_rect.y0,
text_rect.x1 - text_rect.x0,
text_rect.y1 - text_rect.y0);
-#endif
}
if (container->details->label_position == CAJA_ICON_LABEL_POSITION_BESIDE)
@@ -1496,11 +1647,7 @@ draw_label_text (CajaIconCanvasItem *item,
if (!(prelight_label && item->details->is_prelit))
{
draw_frame (item,
-#if GTK_CHECK_VERSION(3,0,0)
- cr,
-#else
drawable,
-#endif
container->details->normal_color_rgba,
create_mask,
text_rect.x0,
@@ -1511,11 +1658,7 @@ draw_label_text (CajaIconCanvasItem *item,
else
{
draw_frame (item,
-#if GTK_CHECK_VERSION(3,0,0)
- cr,
-#else
drawable,
-#endif
container->details->prelight_color_rgba,
create_mask,
text_rect.x0,
@@ -1531,11 +1674,7 @@ draw_label_text (CajaIconCanvasItem *item,
prelight_label & item->details->is_prelit);
draw_label_layout (item,
-#if GTK_CHECK_VERSION(3,0,0)
- cr,
-#else
drawable,
-#endif
editable_layout, needs_highlight,
label_color,
x,
@@ -1553,11 +1692,7 @@ draw_label_text (CajaIconCanvasItem *item,
FALSE);
draw_label_layout (item,
-#if GTK_CHECK_VERSION(3,0,0)
- cr,
-#else
drawable,
-#endif
additional_layout, needs_highlight,
label_color,
x,
@@ -1567,15 +1702,9 @@ draw_label_text (CajaIconCanvasItem *item,
if (!create_mask && item->details->is_highlighted_as_keyboard_focus)
{
gtk_paint_focus (gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)),
-#if GTK_CHECK_VERSION(3,0,0)
- cr,
-#else
drawable,
-#endif
needs_highlight ? GTK_STATE_SELECTED : GTK_STATE_NORMAL,
-#if !GTK_CHECK_VERSION(3,0,0)
NULL,
-#endif
GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas),
"icon-container",
text_rect.x0,
@@ -1594,6 +1723,7 @@ draw_label_text (CajaIconCanvasItem *item,
g_object_unref (additional_layout);
}
}
+#endif
void
caja_icon_canvas_item_set_is_visible (CajaIconCanvasItem *item,
@@ -1667,6 +1797,10 @@ draw_stretch_handles (CajaIconCanvasItem *item,
GdkPixbuf *knob_pixbuf;
int knob_width, knob_height;
double dash = { 2.0 };
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *style;
+ GdkRGBA color;
+#endif
if (!item->details->show_stretch_handles)
{
@@ -1674,6 +1808,9 @@ draw_stretch_handles (CajaIconCanvasItem *item,
}
widget = GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas);
+#if GTK_CHECK_VERSION(3,0,0)
+ style = gtk_widget_get_style_context (widget);
+#endif
#if GTK_CHECK_VERSION(3,0,0)
cairo_save (cr);
@@ -1685,7 +1822,12 @@ draw_stretch_handles (CajaIconCanvasItem *item,
knob_height = gdk_pixbuf_get_height (knob_pixbuf);
/* first draw the box */
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_style_context_get_color (style, GTK_STATE_FLAG_SELECTED, &color);
+ gdk_cairo_set_source_rgba (cr, &color);
+#else
cairo_set_source_rgb (cr, 0, 0, 0);
+#endif
cairo_set_dash (cr, &dash, 1, 0);
cairo_set_line_width (cr, 1.0);
cairo_rectangle (cr,
@@ -1902,7 +2044,12 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item)
CajaIconContainer *container;
GdkPixbuf *temp_pixbuf, *old_pixbuf, *audio_pixbuf;
int emblem_size;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *style;
+ GdkRGBA color;
+#else
guint render_mode, saturation, brightness, lighten;
+#endif
temp_pixbuf = icon_item->details->pixbuf;
canvas = EEL_CANVAS_ITEM(icon_item)->canvas;
@@ -1915,6 +2062,10 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item)
{
old_pixbuf = temp_pixbuf;
+#if GTK_CHECK_VERSION(3,0,0)
+ temp_pixbuf = eel_create_spotlight_pixbuf (temp_pixbuf);
+ g_object_unref (old_pixbuf);
+#else
gtk_widget_style_get (GTK_WIDGET (container),
"prelight_icon_render_mode", &render_mode,
"prelight_icon_saturation", &saturation,
@@ -1932,8 +2083,7 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item)
container->details->prelight_icon_color_rgba);
g_object_unref (old_pixbuf);
}
-
-
+#endif
/* FIXME bugzilla.gnome.org 42471: This hard-wired image is inappropriate to
* this level of code, which shouldn't know that the
@@ -1983,6 +2133,18 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item)
if (icon_item->details->is_highlighted_for_selection
|| icon_item->details->is_highlighted_for_drop)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ style = gtk_widget_get_style_context (GTK_WIDGET (canvas));
+
+ if (gtk_widget_has_focus (GTK_WIDGET (canvas))) {
+ gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &color);
+ } else {
+ gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color);
+ }
+
+ old_pixbuf = temp_pixbuf;
+ temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, &color);
+#else
guint color;
old_pixbuf = temp_pixbuf;
@@ -1993,10 +2155,12 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item)
EEL_RGBA_COLOR_GET_R (color),
EEL_RGBA_COLOR_GET_G (color),
EEL_RGBA_COLOR_GET_B (color));
+#endif
g_object_unref (old_pixbuf);
}
+#if !GTK_CHECK_VERSION(3,0,0)
if (!icon_item->details->is_active
&& !icon_item->details->is_prelit
&& !icon_item->details->is_highlighted_for_selection
@@ -2022,6 +2186,7 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item)
g_object_unref (old_pixbuf);
}
}
+#endif
return temp_pixbuf;
}
@@ -2067,6 +2232,10 @@ draw_embedded_text (CajaIconCanvasItem *item,
PangoLayout *layout;
PangoContext *context;
PangoFontDescription *desc;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkWidget *widget;
+ GtkStyleContext *style_context;
+#endif
if (item->details->embedded_text == NULL ||
item->details->embedded_text_rect.width == 0 ||
@@ -2075,13 +2244,21 @@ draw_embedded_text (CajaIconCanvasItem *item,
return;
}
+#if GTK_CHECK_VERSION(3,0,0)
+ widget = GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas);
+#endif
+
if (item->details->embedded_text_layout != NULL)
{
layout = g_object_ref (item->details->embedded_text_layout);
}
else
{
+#if GTK_CHECK_VERSION(3,0,0)
+ context = gtk_widget_get_pango_context (widget);
+#else
context = gtk_widget_get_pango_context (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas));
+#endif
layout = pango_layout_new (context);
pango_layout_set_text (layout, item->details->embedded_text, -1);
@@ -2096,10 +2273,28 @@ draw_embedded_text (CajaIconCanvasItem *item,
}
#if GTK_CHECK_VERSION(3,0,0)
+ style_context = gtk_widget_get_style_context (widget);
+ gtk_style_context_save (style_context);
+ gtk_style_context_add_class (style_context, "icon-embedded-text");
+
cairo_save (cr);
+
+ cairo_rectangle (cr,
+ x + item->details->embedded_text_rect.x,
+ y + item->details->embedded_text_rect.y,
+ item->details->embedded_text_rect.width,
+ item->details->embedded_text_rect.height);
+ cairo_clip (cr);
+
+ gtk_render_layout (style_context, cr,
+ x + item->details->embedded_text_rect.x,
+ y + item->details->embedded_text_rect.y,
+ layout);
+
+ gtk_style_context_restore (style_context);
+ cairo_restore (cr);
#else
cairo_t *cr = gdk_cairo_create (drawable);
-#endif
cairo_rectangle (cr,
x + item->details->embedded_text_rect.x,
@@ -2114,9 +2309,6 @@ draw_embedded_text (CajaIconCanvasItem *item,
y + item->details->embedded_text_rect.y);
pango_cairo_show_layout (cr, layout);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_restore (cr);
-#else
cairo_destroy (cr);
#endif
}
@@ -2127,19 +2319,28 @@ static void
caja_icon_canvas_item_draw (EelCanvasItem *item,
cairo_t *cr,
cairo_region_t *region)
+{
+ CajaIconContainer *container;
#else
caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
GdkEventExpose *expose)
-#endif
{
+#endif
CajaIconCanvasItem *icon_item;
CajaIconCanvasItemDetails *details;
EelIRect icon_rect, emblem_rect;
EmblemLayout emblem_layout;
GdkPixbuf *emblem_pixbuf, *temp_pixbuf;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *context;
+
+ container = CAJA_ICON_CONTAINER (item->canvas);
+ gboolean is_rtl;
+#else
GdkRectangle pixbuf_rect;
gboolean is_rtl;
+#endif
icon_item = CAJA_ICON_CANVAS_ITEM (item);
details = icon_item->details;
@@ -2149,8 +2350,23 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
return;
}
+#if GTK_CHECK_VERSION(3,0,0)
+ context = gtk_widget_get_style_context (GTK_WIDGET (container));
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, "caja-canvas-item");
+
+#endif
icon_rect = icon_item->details->canvas_rect;
+#if GTK_CHECK_VERSION(3,0,0)
+ temp_pixbuf = map_pixbuf (icon_item);
+
+ gtk_render_icon (context, cr,
+ temp_pixbuf,
+ icon_rect.x0, icon_rect.y0);
+ g_object_unref (temp_pixbuf);
+ draw_embedded_text (icon_item, cr, icon_rect.x0, icon_rect.y0);
+#else
/* if the pre-lit or selection flag is set, make a pre-lit or darkened pixbuf and draw that instead */
/* and colorize normal pixbuf if rc wants that */
temp_pixbuf = map_pixbuf (icon_item);
@@ -2159,26 +2375,15 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
pixbuf_rect.width = gdk_pixbuf_get_width (temp_pixbuf);
pixbuf_rect.height = gdk_pixbuf_get_height (temp_pixbuf);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_save (cr);
-#else
cairo_t *cr = gdk_cairo_create (drawable);
gdk_cairo_rectangle (cr, &expose->area);
cairo_clip (cr);
-#endif
gdk_cairo_set_source_pixbuf (cr, temp_pixbuf, pixbuf_rect.x, pixbuf_rect.y);
gdk_cairo_rectangle (cr, &pixbuf_rect);
cairo_fill (cr);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_restore (cr);
-#else
cairo_destroy (cr);
-#endif
g_object_unref (temp_pixbuf);
-#if GTK_CHECK_VERSION(3,0,0)
- draw_embedded_text (icon_item, cr, icon_rect.x0, icon_rect.y0);
-#else
draw_embedded_text (icon_item, drawable, icon_rect.x0, icon_rect.y0);
#endif
@@ -2190,18 +2395,19 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable,
{
#if GTK_CHECK_VERSION(3,0,0)
draw_pixbuf (emblem_pixbuf, cr, emblem_rect.x0, emblem_rect.y0);
-#else
- draw_pixbuf (emblem_pixbuf, drawable, emblem_rect.x0, emblem_rect.y0);
-#endif
}
-#if GTK_CHECK_VERSION(3,0,0)
/* Draw stretching handles (if necessary). */
draw_stretch_handles (icon_item, cr, &icon_rect);
/* Draw the label text. */
draw_label_text (icon_item, cr, FALSE, icon_rect);
+
+ gtk_style_context_restore (context);
#else
+ draw_pixbuf (emblem_pixbuf, drawable, emblem_rect.x0, emblem_rect.y0);
+ }
+
draw_stretch_handles (icon_item, drawable, &icon_rect);
draw_label_text (icon_item, drawable, FALSE, icon_rect);
#endif
@@ -2320,22 +2526,17 @@ get_label_layout (PangoLayout **layout_cache,
return layout;
}
+#if !GTK_CHECK_VERSION(3,0,0)
static void
draw_label_layout (CajaIconCanvasItem *item,
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_t *cr,
-#else
GdkDrawable *drawable,
-#endif
PangoLayout *layout,
gboolean highlight,
GdkColor *label_color,
int x,
int y)
{
-#if !GTK_CHECK_VERSION(3,0,0)
g_return_if_fail (drawable != NULL);
-#endif
if (item->details->is_renaming)
{
@@ -2345,11 +2546,7 @@ draw_label_layout (CajaIconCanvasItem *item,
if (!highlight && (CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas)->details->use_drop_shadows))
{
/* draw a drop shadow */
-#if GTK_CHECK_VERSION(3,0,0)
- eel_cairo_draw_layout_with_drop_shadow (cr,
-#else
eel_gdk_draw_layout_with_drop_shadow (drawable,
-#endif
label_color,
&gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas))->black,
x, y,
@@ -2357,22 +2554,14 @@ draw_label_layout (CajaIconCanvasItem *item,
}
else
{
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_save (cr);
-#else
cairo_t *cr = gdk_cairo_create (drawable);
-#endif
-
gdk_cairo_set_source_color (cr, label_color);
cairo_move_to (cr, x, y);
pango_cairo_show_layout (cr, layout);
-#if GTK_CHECK_VERSION(3,0,0)
- cairo_restore (cr);
-#else
cairo_destroy (cr);
-#endif
}
}
+#endif
/* handle events */
diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c
index 8e89ce62..2cec67a5 100644
--- a/libcaja-private/caja-icon-container.c
+++ b/libcaja-private/caja-icon-container.c
@@ -120,6 +120,10 @@
#define DEFAULT_HIGHLIGHT_ALPHA 0xff
#define DEFAULT_NORMAL_ALPHA 0xff
#define DEFAULT_PRELIGHT_ALPHA 0xff
+#if GTK_CHECK_VERSION(3,0,0)
+#define DEFAULT_LIGHT_INFO_COLOR "#AAAAFD"
+#define DEFAULT_DARK_INFO_COLOR "#33337F"
+#else
#define DEFAULT_LIGHT_INFO_COLOR 0xAAAAFD
#define DEFAULT_DARK_INFO_COLOR 0x33337F
@@ -131,6 +135,7 @@
#define DEFAULT_PRELIGHT_ICON_BRIGHTNESS 255
#define DEFAULT_NORMAL_ICON_LIGHTEN 0
#define DEFAULT_PRELIGHT_ICON_LIGHTEN 0
+#endif
#define MINIMUM_EMBEDDED_TEXT_RECT_WIDTH 20
#define MINIMUM_EMBEDDED_TEXT_RECT_HEIGHT 20
@@ -176,7 +181,9 @@ static GType caja_icon_container_accessible_get_type (void);
static void activate_selected_items (CajaIconContainer *container);
static void activate_selected_items_alternate (CajaIconContainer *container,
CajaIcon *icon);
+#if !GTK_CHECK_VERSION(3, 0, 0)
static void caja_icon_container_theme_changed (gpointer user_data);
+#endif
static void compute_stretch (StretchState *start,
StretchState *current);
static CajaIcon *get_first_selected_icon (CajaIconContainer *container);
@@ -202,7 +209,9 @@ static inline void icon_get_bounding_box (CajaIcon
static gboolean is_renaming (CajaIconContainer *container);
static gboolean is_renaming_pending (CajaIconContainer *container);
static void process_pending_icon_to_rename (CajaIconContainer *container);
+#if !GTK_CHECK_VERSION(3, 0, 0)
static void setup_label_gcs (CajaIconContainer *container);
+#endif
static void caja_icon_container_stop_monitor_top_left (CajaIconContainer *container,
CajaIconData *data,
gconstpointer client);
@@ -2871,6 +2880,83 @@ rubberband_timeout_callback (gpointer data)
return TRUE;
}
+#if GTK_CHECK_VERSION(3,0,0)
+/*borrowed from Nemo, makes Caja rubberbanding follow same selectors as Nemo and presumably Nautilus */
+static void
+start_rubberbanding (CajaIconContainer *container,
+ GdkEventButton *event)
+{
+ AtkObject *accessible;
+ CajaIconContainerDetails *details;
+ CajaIconRubberbandInfo *band_info;
+ GdkRGBA bg_color, border_color;
+ GList *p;
+ CajaIcon *icon;
+ GtkStyleContext *context;
+
+ details = container->details;
+ band_info = &details->rubberband_info;
+
+ g_signal_emit (container,
+ signals[BAND_SELECT_STARTED], 0);
+
+ for (p = details->icons; p != NULL; p = p->next) {
+ icon = p->data;
+ icon->was_selected_before_rubberband = icon->is_selected;
+ }
+
+ eel_canvas_window_to_world
+ (EEL_CANVAS (container), event->x, event->y,
+ &band_info->start_x, &band_info->start_y);
+
+ context = gtk_widget_get_style_context (GTK_WIDGET (container));
+ gtk_style_context_save (context);
+ gtk_style_context_add_class (context, GTK_STYLE_CLASS_RUBBERBAND);
+
+ gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg_color);
+ gtk_style_context_get_border_color (context, GTK_STATE_FLAG_NORMAL, &border_color);
+
+ gtk_style_context_restore (context);
+
+ band_info->selection_rectangle = eel_canvas_item_new
+ (eel_canvas_root
+ (EEL_CANVAS (container)),
+ EEL_TYPE_CANVAS_RECT,
+ "x1", band_info->start_x,
+ "y1", band_info->start_y,
+ "x2", band_info->start_x,
+ "y2", band_info->start_y,
+ "fill_color_rgba", &bg_color,
+ "outline_color_rgba", &border_color,
+ "width_pixels", 1,
+ NULL);
+
+ accessible = atk_gobject_accessible_for_object
+ (G_OBJECT (band_info->selection_rectangle));
+ atk_object_set_name (accessible, "selection");
+ atk_object_set_description (accessible, _("The selection rectangle"));
+
+ band_info->prev_x = event->x - gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)));
+ band_info->prev_y = event->y - gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)));
+
+ band_info->active = TRUE;
+
+ if (band_info->timer_id == 0) {
+ band_info->timer_id = g_timeout_add
+ (RUBBERBAND_TIMEOUT_INTERVAL,
+ rubberband_timeout_callback,
+ container);
+ }
+
+ eel_canvas_item_grab (band_info->selection_rectangle,
+ (GDK_POINTER_MOTION_MASK
+ | GDK_BUTTON_RELEASE_MASK
+ | GDK_SCROLL_MASK),
+ NULL, event->time);
+}
+
+
+#else
static void
start_rubberbanding (CajaIconContainer *container,
GdkEventButton *event)
@@ -2955,6 +3041,7 @@ start_rubberbanding (CajaIconContainer *container,
| GDK_SCROLL_MASK),
NULL, event->time);
}
+#endif
static void
stop_rubberbanding (CajaIconContainer *container,
@@ -4564,7 +4651,9 @@ realize (GtkWidget *widget)
/* Set up DnD. */
caja_icon_dnd_init (container);
+#if !GTK_CHECK_VERSION(3, 0, 0)
setup_label_gcs (container);
+#endif
hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (widget));
g_signal_connect (hadj, "value_changed",
@@ -4595,6 +4684,27 @@ unrealize (GtkWidget *widget)
}
static void
+#if GTK_CHECK_VERSION(3,0,0)
+style_updated (GtkWidget *widget)
+{
+ CajaIconContainer *container;
+
+ container = CAJA_ICON_CONTAINER (widget);
+ container->details->use_drop_shadows = container->details->drop_shadows_requested;
+
+ /* Don't chain up to parent, if this is a desktop container,
+ * because that resets the background of the window.
+ */
+ if (!caja_icon_container_get_is_desktop (container)) {
+ GTK_WIDGET_CLASS (caja_icon_container_parent_class)->style_updated (widget);
+ }
+
+ if (gtk_widget_get_realized (widget))
+ {
+ invalidate_labels (container);
+ caja_icon_container_request_update_all (container);
+ }
+#else
style_set (GtkWidget *widget,
GtkStyle *previous_style)
{
@@ -4619,6 +4729,7 @@ style_set (GtkWidget *widget,
/* Don't chain up to parent, because that sets the background of the window and we're doing
that ourself with some delay, so this would cause flickering */
+#endif
}
static gboolean
@@ -6568,8 +6679,10 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
widget_class->key_press_event = key_press_event;
widget_class->popup_menu = popup_menu;
widget_class->get_accessible = get_accessible;
+#if GTK_CHECK_VERSION(3,0,0)
+ widget_class->style_updated = style_updated;
+#else
widget_class->style_set = style_set;
-#if !GTK_CHECK_VERSION(3,0,0)
widget_class->expose_event = expose_event;
#endif
widget_class->grab_notify = grab_notify_cb;
@@ -6579,13 +6692,32 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
class->start_interactive_search = caja_icon_container_start_interactive_search;
+#if GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_boxed ("selection_box_rgba",
+ "Selection Box RGBA",
+ "Color of the selection box",
+ GDK_TYPE_RGBA,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_boxed ("light_info_rgba",
+ "Light Info RGBA",
+ "Color used for information text against a dark background",
+ GDK_TYPE_RGBA,
+ G_PARAM_READABLE));
+ gtk_widget_class_install_style_property (widget_class,
+ g_param_spec_boxed ("dark_info_rgba",
+ "Dark Info RGBA",
+ "Color used for information text against a light background",
+ GDK_TYPE_RGBA,
+ G_PARAM_READABLE));
+#else
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("frame_text",
"Frame Text",
"Draw a frame around unselected text",
FALSE,
G_PARAM_READABLE));
-
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boxed ("selection_box_color",
"Selection Box Color",
@@ -6702,6 +6834,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class)
0, 255,
DEFAULT_PRELIGHT_ICON_LIGHTEN,
G_PARAM_READABLE));
+#endif
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("activate_prelight_icon_label",
"Activate Prelight Icon Label",
@@ -6867,8 +7000,10 @@ caja_icon_container_init (CajaIconContainer *container)
/* when the background changes, we must set up the label text color */
background = eel_get_widget_background (GTK_WIDGET (container));
+#if !GTK_CHECK_VERSION(3,0,0)
g_signal_connect_object (background, "appearance_changed",
G_CALLBACK (update_label_color), container, 0);
+#endif
g_signal_connect (container, "focus-in-event",
G_CALLBACK (handle_focus_in_event), NULL);
@@ -6877,8 +7012,10 @@ caja_icon_container_init (CajaIconContainer *container)
eel_background_set_use_base (background, TRUE);
+#if !GTK_CHECK_VERSION(3,0,0)
/* read in theme-dependent data */
caja_icon_container_theme_changed (container);
+#endif
if (!setup_prefs)
{
@@ -9170,12 +9307,20 @@ caja_icon_container_start_renaming_selected_item (CajaIconContainer *container,
{
eel_filename_get_rename_region (editable_text, &start_offset, &end_offset);
}
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_show (details->rename_widget);
+ gtk_widget_grab_focus (details->rename_widget);
+#endif
+
eel_editable_label_select_region (EEL_EDITABLE_LABEL (details->rename_widget),
start_offset,
end_offset);
- gtk_widget_show (details->rename_widget);
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_show (details->rename_widget);
gtk_widget_grab_focus (details->rename_widget);
+#endif
g_signal_emit (container,
signals[RENAMING_ICON], 0,
@@ -9291,15 +9436,15 @@ caja_icon_container_set_single_click_mode (CajaIconContainer *container,
container->details->single_click_mode = single_click_mode;
}
-
+#if !GTK_CHECK_VERSION(3,0,0)
/* update the label color when the background changes */
void
caja_icon_container_get_label_color (CajaIconContainer *container,
GdkColor **color,
- gboolean is_name,
- gboolean is_highlight,
- gboolean is_prelit)
+ gboolean is_name,
+ gboolean is_highlight,
+ gboolean is_prelit)
{
int idx;
@@ -9458,7 +9603,7 @@ update_label_color (EelBackground *background,
setup_label_gcs (container);
}
-
+#endif
/* Return if the icon container is a fixed size */
gboolean
@@ -9518,11 +9663,13 @@ void
caja_icon_container_set_use_drop_shadows (CajaIconContainer *container,
gboolean use_drop_shadows)
{
+#if !GTK_CHECK_VERSION(3,0,0)
gboolean frame_text;
gtk_widget_style_get (GTK_WIDGET (container),
"frame_text", &frame_text,
NULL);
+#endif
if (container->details->drop_shadows_requested == use_drop_shadows)
{
@@ -9530,12 +9677,17 @@ caja_icon_container_set_use_drop_shadows (CajaIconContainer *container,
}
container->details->drop_shadows_requested = use_drop_shadows;
+#if GTK_CHECK_VERSION(3,0,0)
+ container->details->use_drop_shadows = use_drop_shadows;
+#else
container->details->use_drop_shadows = use_drop_shadows && !frame_text;
+#endif
gtk_widget_queue_draw (GTK_WIDGET (container));
}
/* handle theme changes */
+#if !GTK_CHECK_VERSION(3,0,0)
static void
caja_icon_container_theme_changed (gpointer user_data)
{
@@ -9633,9 +9785,9 @@ caja_icon_container_theme_changed (gpointer user_data)
style->base[GTK_STATE_PRELIGHT].blue >> 8,
prelight_alpha);
-
setup_label_gcs (container);
}
+#endif
void
caja_icon_container_set_font (CajaIconContainer *container,
diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c
index 376490dc..82707150 100644
--- a/libcaja-private/caja-icon-dnd.c
+++ b/libcaja-private/caja-icon-dnd.c
@@ -144,6 +144,9 @@ create_selection_shadow (CajaIconContainer *container,
{
CajaDragSelectionItem *item;
int x1, y1, x2, y2;
+#if GTK_CHECK_VERSION(3,0,0)
+ GdkRGBA black = { 0, 0, 0, 1 };
+#endif
item = p->data;
@@ -165,7 +168,11 @@ create_selection_shadow (CajaIconContainer *container,
"y1", (double) y1,
"x2", (double) x2,
"y2", (double) y2,
- "outline_color", "black",
+#if GTK_CHECK_VERSION(3,0,0)
+ "outline-color-rgba", &black,
+#else
+ "outline_color", "black",
+#endif
"outline-stippling", TRUE,
"width_pixels", 1,
NULL);
@@ -1611,22 +1618,36 @@ drag_highlight_expose (GtkWidget *widget,
gpointer data)
#endif
{
+#if GTK_CHECK_VERSION(3,0,0)
+ gint width, height;
+ GdkWindow *window;
+ GtkStyleContext *style;
+#else
gint x, y, width, height;
GdkWindow *window;
+#endif
+#if !GTK_CHECK_VERSION(3,0,0)
x = gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (widget)));
y = gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (widget)));
+#endif
window = gtk_widget_get_window (widget);
width = gdk_window_get_width (window);
height = gdk_window_get_height (window);
#if GTK_CHECK_VERSION (3, 0, 0)
- gtk_paint_shadow (gtk_widget_get_style (widget),
+ style = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_save (style);
+ gtk_style_context_add_class (style, "dnd");
+ gtk_style_context_set_state (style, GTK_STATE_FLAG_FOCUSED);
+
+ gtk_render_frame (style,
cr,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- widget, "dnd",
- x, y, width, height);
+ 0, 0, width, height);
+
+ gtk_style_context_restore (style);
#else
gtk_paint_shadow (gtk_widget_get_style (widget), window,
GTK_STATE_NORMAL, GTK_SHADOW_OUT,
@@ -1638,7 +1659,11 @@ drag_highlight_expose (GtkWidget *widget,
cairo_set_line_width (cr, 1.0);
cairo_set_source_rgb (cr, 0, 0, 0);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cairo_rectangle (cr, 0.5, 0.5, width - 1, height - 1);
+#else
cairo_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1);
+#endif
cairo_stroke (cr);
#if !GTK_CHECK_VERSION(3,0,0)
cairo_destroy (cr);
diff --git a/libcaja-private/caja-icon-info.c b/libcaja-private/caja-icon-info.c
index 3a63bb44..d5bd542e 100644
--- a/libcaja-private/caja-icon-info.c
+++ b/libcaja-private/caja-icon-info.c
@@ -472,7 +472,13 @@ caja_icon_info_lookup (GIcon *icon,
pixbuf = NULL;
}
- return caja_icon_info_new_for_pixbuf (pixbuf);
+ icon_info = caja_icon_info_new_for_pixbuf (pixbuf);
+
+ if (pixbuf != NULL) {
+ g_object_unref (pixbuf);
+ }
+
+ return icon_info;
}
}
diff --git a/libcaja-private/caja-icon-private.h b/libcaja-private/caja-icon-private.h
index cf7ef592..9364bab7 100644
--- a/libcaja-private/caja-icon-private.h
+++ b/libcaja-private/caja-icon-private.h
@@ -211,6 +211,7 @@ struct CajaIconContainerDetails
int font_size_table[CAJA_ZOOM_LEVEL_LARGEST + 1];
/* pixbuf and color for label highlighting */
+#if !GTK_CHECK_VERSION(3,0,0)
guint32 highlight_color_rgba;
guint32 active_color_rgba;
guint32 normal_color_rgba;
@@ -220,6 +221,7 @@ struct CajaIconContainerDetails
/* colors for text labels */
GdkColor label_colors [LAST_LABEL_COLOR];
+#endif
/* State used so arrow keys don't wander if icons aren't lined up.
*/
@@ -325,11 +327,13 @@ gboolean caja_icon_container_scroll (CajaIconContainer
int delta_y);
void caja_icon_container_update_scroll_region (CajaIconContainer *container);
+#if !GTK_CHECK_VERSION(3,0,0)
/* label color for items */
void caja_icon_container_get_label_color (CajaIconContainer *container,
GdkColor **color,
gboolean first_line,
gboolean needs_highlight,
gboolean is_prelit);
+#endif
#endif /* CAJA_ICON_CONTAINER_PRIVATE_H */
diff --git a/libcaja-private/caja-tree-view-drag-dest.c b/libcaja-private/caja-tree-view-drag-dest.c
index 22a5cc51..accf7bb5 100644
--- a/libcaja-private/caja-tree-view-drag-dest.c
+++ b/libcaja-private/caja-tree-view-drag-dest.c
@@ -199,6 +199,9 @@ highlight_expose (GtkWidget *widget,
GdkWindow *bin_window;
int width;
int height;
+#if GTK_CHECK_VERSION(3,0,0)
+ GtkStyleContext *style;
+#endif
/* FIXMEchpe: is bin window right here??? */
bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget));
@@ -206,18 +209,26 @@ highlight_expose (GtkWidget *widget,
width = gdk_window_get_width(bin_window);
height = gdk_window_get_height(bin_window);
- gtk_paint_focus (gtk_widget_get_style (widget),
#if GTK_CHECK_VERSION(3,0,0)
- cr,
- gtk_widget_get_state (widget),
+ style = gtk_widget_get_style_context (widget);
+
+ gtk_style_context_save (style);
+ gtk_style_context_add_class (style, "treeview-drop-indicator");
+
+ gtk_render_focus (style,
+ cr,
+ 0, 0, width, height);
+
+ gtk_style_context_restore (style);
#else
+ gtk_paint_focus (gtk_widget_get_style (widget),
bin_window,
gtk_widget_get_state (widget),
NULL,
-#endif
widget,
"treeview-drop-indicator",
0, 0, width, height);
+#endif
return FALSE;
}
diff --git a/src/caja-location-bar.c b/src/caja-location-bar.c
index 965da186..e2a70104 100644
--- a/src/caja-location-bar.c
+++ b/src/caja-location-bar.c
@@ -614,6 +614,21 @@ caja_location_bar_update_label (CajaLocationBar *bar)
void
caja_location_bar_set_active(CajaLocationBar *location_bar, gboolean is_active)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (is_active)
+ {
+ /* reset style to default */
+ gtk_widget_override_background_color (GTK_WIDGET (location_bar->details->entry), GTK_STATE_FLAG_NORMAL, NULL);
+ }
+ else
+ {
+ GtkStyleContext *style;
+ GdkRGBA color;
+
+ style = gtk_widget_get_style_context (GTK_WIDGET (location_bar->details->entry));
+ gtk_style_context_get_background_color (style, GTK_STATE_FLAG_INSENSITIVE, &color);
+ gtk_widget_override_background_color (GTK_WIDGET (location_bar->details->entry), GTK_STATE_FLAG_ACTIVE, &color);
+#else
if(is_active)
{
/* reset style to default */
@@ -626,6 +641,7 @@ caja_location_bar_set_active(CajaLocationBar *location_bar, gboolean is_active)
style = gtk_widget_get_style (GTK_WIDGET (location_bar->details->entry));
color = style->base[GTK_STATE_INSENSITIVE];
gtk_widget_modify_base(GTK_WIDGET (location_bar->details->entry), GTK_STATE_NORMAL, &color);
+#endif
}
}
diff --git a/src/caja-notebook.c b/src/caja-notebook.c
index b5b6420e..035ef769 100644
--- a/src/caja-notebook.c
+++ b/src/caja-notebook.c
@@ -82,6 +82,7 @@ caja_notebook_class_init (CajaNotebookClass *klass)
notebook_class->insert_page = caja_notebook_insert_page;
+#if !GTK_CHECK_VERSION (3, 0, 0)
gtk_rc_parse_string ("style \"caja-tab-close-button-style\"\n"
"{\n"
"GtkWidget::focus-padding = 0\n"
@@ -90,6 +91,7 @@ caja_notebook_class_init (CajaNotebookClass *klass)
"ythickness = 0\n"
"}\n"
"widget \"*.caja-tab-close-button\" style \"caja-tab-close-button-style\"");
+#endif
signals[TAB_CLOSE_REQUEST] =
g_signal_new ("tab-close-request",
@@ -239,6 +241,31 @@ button_press_cb (CajaNotebook *notebook,
static void
caja_notebook_init (CajaNotebook *notebook)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ static const gchar css_custom[] =
+ "#caja-tab-close-button {"
+ " -GtkWidget-focus-padding : 0;"
+ " -GtkWidget-focus-line-width: 0;"
+ " xthickness: 0;"
+ " ythickness: 0;"
+ "}";
+
+ GError *error = NULL;
+ GtkCssProvider *provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider, css_custom, -1, &error);
+
+ if (error != NULL) {
+ g_warning ("Can't parse CajaNotebook's CSS custom description: %s\n", error->message);
+ g_error_free (error);
+ } else {
+ gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (notebook)),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+
+ g_object_unref (provider);
+#endif
+
gtk_notebook_set_scrollable (GTK_NOTEBOOK (notebook), TRUE);
gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c
index ce7bccdf..0fdeb9e3 100644
--- a/src/caja-places-sidebar.c
+++ b/src/caja-places-sidebar.c
@@ -27,9 +27,14 @@
#include <eel/eel-debug.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-glib-extensions.h>
+#if GTK_CHECK_VERSION(3,0,0)
+#include <eel/eel-graphic-effects.h>
+#endif
#include <eel/eel-string.h>
#include <eel/eel-stock-dialogs.h>
+#if !GTK_CHECK_VERSION(3,0,0)
#include <eel/eel-gdk-pixbuf-extensions.h>
+#endif
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
@@ -244,7 +249,11 @@ get_eject_icon (gboolean highlighted)
if (highlighted) {
GdkPixbuf *high;
+#if GTK_CHECK_VERSION(3,0,0)
+ high = eel_create_spotlight_pixbuf (eject);
+#else
high = eel_gdk_pixbuf_render (eject, 1, 255, 255, 0, 0);
+#endif
g_object_unref (eject);
eject = high;
}
diff --git a/src/caja-sidebar-title.c b/src/caja-sidebar-title.c
index baa9c5e0..ec8ef777 100644
--- a/src/caja-sidebar-title.c
+++ b/src/caja-sidebar-title.c
@@ -54,8 +54,13 @@
#define MIN_TITLE_FONT_SIZE 12
#define TITLE_PADDING 4
+#if GTK_CHECK_VERSION (3, 0, 0)
+#define DEFAULT_LIGHT_INFO_COLOR "#FFFFFF"
+#define DEFAULT_DARK_INFO_COLOR "#2A2A2A"
+#else
#define DEFAULT_LIGHT_INFO_COLOR 0xFFFFFF
#define DEFAULT_DARK_INFO_COLOR 0x2A2A2A
+#endif
#if GTK_CHECK_VERSION (3, 0, 0)
#define gtk_hbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_HORIZONTAL,Y)
@@ -97,7 +102,11 @@ struct CajaSidebarTitleDetails
GtkWidget *more_info_label;
GtkWidget *emblem_box;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA label_colors [LAST_LABEL_COLOR];
+#else
GdkColor label_colors [LAST_LABEL_COLOR];
+#endif
guint best_icon_size;
gboolean determined_icon;
};
@@ -113,6 +122,7 @@ style_set (GtkWidget *widget,
PangoFontDescription *font_desc;
GtkStyle *style;
+
g_return_if_fail (CAJA_IS_SIDEBAR_TITLE (widget));
sidebar_title = CAJA_SIDEBAR_TITLE (widget);
@@ -223,16 +233,30 @@ caja_sidebar_title_class_init (CajaSidebarTitleClass *klass)
widget_class->style_set = style_set;
gtk_widget_class_install_style_property (widget_class,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_param_spec_boxed ("light_info_rgba",
+ "Light Info RGBA",
+ "Color used for information text against a dark background",
+ GDK_TYPE_RGBA,
+#else
g_param_spec_boxed ("light_info_color",
"Light Info Color",
"Color used for information text against a dark background",
GDK_TYPE_COLOR,
+#endif
G_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_param_spec_boxed ("dark_info_rgba",
+ "Dark Info RGBA",
+ "Color used for information text against a light background",
+ GDK_TYPE_RGBA,
+#else
g_param_spec_boxed ("dark_info_color",
"Dark Info Color",
"Color used for information text against a light background",
GDK_TYPE_COLOR,
+#endif
G_PARAM_READABLE));
g_type_class_add_private (klass, sizeof (CajaSidebarTitleDetails));
@@ -246,23 +270,71 @@ caja_sidebar_title_new (void)
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+setup_gc_with_fg (CajaSidebarTitle *sidebar_title, int idx, GdkRGBA *color)
+{
+ sidebar_title->details->label_colors[idx] = *color;
+#else
setup_gc_with_fg (CajaSidebarTitle *sidebar_title, int idx, guint32 color)
{
sidebar_title->details->label_colors [idx] = eel_gdk_rgb_to_color (color);
+#endif
}
void
caja_sidebar_title_select_text_color (CajaSidebarTitle *sidebar_title,
EelBackground *background)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA *light_info_color, *dark_info_color;
+ GtkStyleContext *style;
+ GdkRGBA color;
+#else
GdkColor *light_info_color, *dark_info_color;
guint light_info_value, dark_info_value;
GtkStyle *style;
+#endif
g_assert (CAJA_IS_SIDEBAR_TITLE (sidebar_title));
g_return_if_fail (gtk_widget_get_realized (GTK_WIDGET (sidebar_title)));
/* read the info colors from the current theme; use a reasonable default if undefined */
+#if GTK_CHECK_VERSION (3, 0, 0)
+ style = gtk_widget_get_style_context (GTK_WIDGET (sidebar_title));
+ gtk_style_context_get_style (style,
+ "light_info_color", &light_info_color,
+ "dark_info_color", &dark_info_color,
+ NULL);
+
+ if (!light_info_color)
+ {
+ light_info_color = g_malloc (sizeof (GdkRGBA));
+ gdk_rgba_parse (light_info_color, DEFAULT_LIGHT_INFO_COLOR);
+ }
+
+ if (!dark_info_color)
+ {
+ light_info_color = g_malloc (sizeof (GdkRGBA));
+ gdk_rgba_parse (dark_info_color, DEFAULT_DARK_INFO_COLOR);
+ }
+
+ gtk_style_context_get_color (style, GTK_STATE_FLAG_SELECTED, &color);
+ setup_gc_with_fg (sidebar_title, LABEL_COLOR_HIGHLIGHT, &color);
+
+ gtk_style_context_get_color (style, GTK_STATE_FLAG_ACTIVE, &color);
+ setup_gc_with_fg (sidebar_title, LABEL_COLOR_ACTIVE, &color);
+
+ gtk_style_context_get_color (style, GTK_STATE_FLAG_PRELIGHT, &color);
+ setup_gc_with_fg (sidebar_title, LABEL_COLOR_PRELIGHT, &color);
+
+ gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &color);
+ setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR_HIGHLIGHT,
+ eel_gdk_rgba_is_dark (&color) ? light_info_color : dark_info_color);
+
+ gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color);
+ setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR_ACTIVE,
+ eel_gdk_rgba_is_dark (&color) ? light_info_color : dark_info_color);
+#else
gtk_widget_style_get (GTK_WIDGET (sidebar_title),
"light_info_color", &light_info_color,
"dark_info_color", &dark_info_color,
@@ -289,7 +361,6 @@ caja_sidebar_title_select_text_color (CajaSidebarTitle *sidebar_title,
dark_info_value = DEFAULT_DARK_INFO_COLOR;
}
-
setup_gc_with_fg (sidebar_title, LABEL_COLOR_HIGHLIGHT,
eel_gdk_color_to_rgb (&style->text[GTK_STATE_SELECTED]));
setup_gc_with_fg (sidebar_title, LABEL_COLOR_ACTIVE,
@@ -300,11 +371,42 @@ caja_sidebar_title_select_text_color (CajaSidebarTitle *sidebar_title,
eel_gdk_color_is_dark (&style->base[GTK_STATE_SELECTED]) ? light_info_value : dark_info_value);
setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR_ACTIVE,
eel_gdk_color_is_dark (&style->base[GTK_STATE_ACTIVE]) ? light_info_value : dark_info_value);
+#endif
/* If EelBackground is not set in the widget, we can safely
* use the foreground color from the theme, because it will
* always be displayed against the gtk background */
if (!eel_background_is_set(background))
+#if GTK_CHECK_VERSION (3, 0, 0)
+ {
+ gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &color);
+ setup_gc_with_fg (sidebar_title, LABEL_COLOR, &color);
+
+ gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color);
+ setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR,
+ eel_gdk_rgba_is_dark (&color) ?
+ light_info_color : dark_info_color);
+ }
+ else if (eel_background_is_dark (background))
+ {
+ GdkRGBA tmp;
+
+ gdk_rgba_parse (&tmp, "EFEFEF");
+ setup_gc_with_fg (sidebar_title, LABEL_COLOR, &tmp);
+ setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR, light_info_color);
+ }
+ else /* converse */
+ {
+ GdkRGBA tmp;
+
+ gdk_rgba_parse (&tmp, "000000");
+ setup_gc_with_fg (sidebar_title, LABEL_COLOR, &tmp);
+ setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR, dark_info_color);
+ }
+
+ gdk_rgba_free (dark_info_color);
+ gdk_rgba_free (light_info_color);
+#else
{
setup_gc_with_fg (sidebar_title, LABEL_COLOR,
eel_gdk_color_to_rgb (&style->text[GTK_STATE_NORMAL]));
@@ -321,6 +423,7 @@ caja_sidebar_title_select_text_color (CajaSidebarTitle *sidebar_title,
setup_gc_with_fg (sidebar_title, LABEL_COLOR, 0x000000);
setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR, dark_info_value);
}
+#endif
}
static char*
diff --git a/src/caja-spatial-window.c b/src/caja-spatial-window.c
index 4dfe9bfb..05082358 100644
--- a/src/caja-spatial-window.c
+++ b/src/caja-spatial-window.c
@@ -989,7 +989,9 @@ static const char* icon_entries[] =
static void
caja_spatial_window_init (CajaSpatialWindow *window)
{
+#if !GTK_CHECK_VERSION (3, 0, 0)
GtkRcStyle *rc_style;
+#endif
GtkWidget *arrow;
GtkWidget *hbox, *vbox;
GtkActionGroup *action_group;
@@ -1035,11 +1037,13 @@ caja_spatial_window_init (CajaSpatialWindow *window)
window);
gtk_button_set_relief (GTK_BUTTON (window->details->location_button),
GTK_RELIEF_NORMAL);
+#if !GTK_CHECK_VERSION (3, 0, 0)
rc_style = gtk_widget_get_modifier_style (window->details->location_button);
rc_style->xthickness = 0;
rc_style->ythickness = 0;
gtk_widget_modify_style (window->details->location_button,
rc_style);
+#endif
gtk_widget_show (window->details->location_button);
hbox = gtk_hbox_new (FALSE, 3);
diff --git a/src/caja-window.c b/src/caja-window.c
index c460ae98..6a1cb402 100644
--- a/src/caja-window.c
+++ b/src/caja-window.c
@@ -141,6 +141,30 @@ caja_window_init (CajaWindow *window)
GtkWidget *menu;
GtkWidget *statusbar;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ static const gchar css_custom[] =
+ "#statusbar-no-border {"
+ " -GtkStatusbar-shadow-type: none;"
+ "}"
+ "#caja-extra-view-widget {"
+ " background-color: " EXTRA_VIEW_WIDGETS_BACKGROUND ";"
+ "}";
+
+ GError *error = NULL;
+ GtkCssProvider *provider = gtk_css_provider_new ();
+ gtk_css_provider_load_from_data (provider, css_custom, -1, &error);
+
+ if (error != NULL) {
+ g_warning ("Can't parse CajaWindow's CSS custom description: %s\n", error->message);
+ g_error_free (error);
+ } else {
+ gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (window)),
+ GTK_STYLE_PROVIDER (provider),
+ GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ }
+
+ g_object_unref (provider);
+#endif
window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, CAJA_TYPE_WINDOW, CajaWindowDetails);
window->details->panes = NULL;
@@ -148,6 +172,7 @@ caja_window_init (CajaWindow *window)
window->details->show_hidden_files_mode = CAJA_WINDOW_SHOW_HIDDEN_FILES_DEFAULT;
+#if !GTK_CHECK_VERSION (3, 0, 0)
/* Remove Top border on GtkStatusBar */
gtk_rc_parse_string (
"style \"statusbar-no-border\"\n"
@@ -155,6 +180,7 @@ caja_window_init (CajaWindow *window)
" GtkStatusbar::shadow_type = GTK_SHADOW_NONE\n"
"}\n"
"widget \"*.statusbar-noborder\" style \"statusbar-no-border\"");
+#endif
/* Set initial window title */
gtk_window_set_title (GTK_WINDOW (window), _("Caja"));
@@ -2238,6 +2264,7 @@ caja_window_class_init (CajaWindowClass *class)
class->reload = caja_window_reload;
class->go_up = caja_window_go_up_signal;
+#if !GTK_CHECK_VERSION (3,0,0)
/* Allow to set the colors of the extra view widgets */
gtk_rc_parse_string ("\n"
" style \"caja-extra-view-widgets-style-internal\"\n"
@@ -2247,6 +2274,7 @@ caja_window_class_init (CajaWindowClass *class)
"\n"
" widget \"*.caja-extra-view-widget\" style:rc \"caja-extra-view-widgets-style-internal\" \n"
"\n");
+#endif
g_type_class_add_private (G_OBJECT_CLASS (class), sizeof (CajaWindowDetails));
}
diff --git a/src/file-manager/fm-list-model.c b/src/file-manager/fm-list-model.c
index 6a1692f4..1bf2d599 100644
--- a/src/file-manager/fm-list-model.c
+++ b/src/file-manager/fm-list-model.c
@@ -29,7 +29,11 @@
#include <libegg/eggtreemultidnd.h>
#include <string.h>
+#if GTK_CHECK_VERSION(3,0,0)
+#include <eel/eel-graphic-effects.h>
+#else
#include <eel/eel-gdk-pixbuf-extensions.h>
+#endif
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <libcaja-private/caja-dnd.h>
@@ -386,7 +390,11 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column
g_list_find_custom (model->details->highlight_files,
file, (GCompareFunc) caja_file_compare_location))
{
+#if GTK_CHECK_VERSION(3,0,0)
+ rendered_icon = eel_create_spotlight_pixbuf (icon);
+#else
rendered_icon = eel_gdk_pixbuf_render (icon, 1, 255, 255, 0, 0);
+#endif
if (rendered_icon != NULL)
{
diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c
index dc9bc20b..56ff9b17 100644
--- a/src/file-manager/fm-list-view.c
+++ b/src/file-manager/fm-list-view.c
@@ -3262,20 +3262,35 @@ real_set_is_active (FMDirectoryView *view,
gboolean is_active)
{
GtkWidget *tree_view;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkStyleContext *style;
+ GdkRGBA color;
+#else
GtkStyle *style;
GdkColor color;
+#endif
tree_view = GTK_WIDGET (fm_list_view_get_tree_view (FM_LIST_VIEW (view)));
if (is_active)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_override_background_color (tree_view, GTK_STATE_FLAG_NORMAL, NULL);
+#else
gtk_widget_modify_base (tree_view, GTK_STATE_NORMAL, NULL);
+#endif
}
else
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ style = gtk_widget_get_style_context (tree_view);
+ gtk_style_context_get_background_color (style, GTK_STATE_FLAG_INSENSITIVE, &color);
+ gtk_widget_override_background_color (tree_view, GTK_STATE_FLAG_NORMAL, &color);
+#else
style = gtk_widget_get_style (tree_view);
color = style->base[GTK_STATE_INSENSITIVE];
gtk_widget_modify_base (tree_view, GTK_STATE_NORMAL, &color);
+#endif
}
EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS,
diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c
index 42b30a9a..87b75a6d 100644
--- a/src/file-manager/fm-properties-window.c
+++ b/src/file-manager/fm-properties-window.c
@@ -68,6 +68,15 @@
#include <sys/mount.h>
#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
+#define USED_FILL_R 0.988235294
+#define USED_FILL_G 0.91372549
+#define USED_FILL_B 0.309803922
+
+#define FREE_FILL_R 0.447058824
+#define FREE_FILL_G 0.623529412
+#define FREE_FILL_B 0.811764706
+#else
#define USED_FILL_R (0.988235294 * 65535)
#define USED_FILL_G (0.91372549 * 65535)
#define USED_FILL_B (0.309803922 * 65535)
@@ -75,6 +84,7 @@
#define FREE_FILL_R (0.447058824 * 65535)
#define FREE_FILL_G (0.623529412 * 65535)
#define FREE_FILL_B (0.811764706 * 65535)
+#endif
#define PREVIEW_IMAGE_WIDTH 96
@@ -148,10 +158,17 @@ struct FMPropertiesWindowDetails {
guint64 volume_capacity;
guint64 volume_free;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRGBA used_color;
+ GdkRGBA free_color;
+ GdkRGBA used_stroke_color;
+ GdkRGBA free_stroke_color;
+#else
GdkColor used_color;
GdkColor free_color;
GdkColor used_stroke_color;
GdkColor free_stroke_color;
+#endif
};
#if GTK_CHECK_VERSION (3, 0, 0)
@@ -3045,6 +3062,13 @@ paint_used_legend (GtkWidget *widget,
width - 4,
height - 4);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &window->details->used_color);
+ cairo_fill_preserve (cr);
+
+ gdk_cairo_set_source_rgba (cr, &window->details->used_stroke_color);
+ cairo_stroke (cr);
+#else
cairo_set_source_rgb (cr,
(double) window->details->used_color.red / 65535,
(double) window->details->used_color.green / 65535,
@@ -3057,7 +3081,6 @@ paint_used_legend (GtkWidget *widget,
(double) window->details->used_stroke_color.blue / 65535);
cairo_stroke (cr);
-#if !GTK_CHECK_VERSION(3,0,0)
cairo_destroy (cr);
#endif
}
@@ -3089,6 +3112,13 @@ paint_free_legend (GtkWidget *widget,
width - 4,
height - 4);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &window->details->free_color);
+ cairo_fill_preserve(cr);
+
+ gdk_cairo_set_source_rgba (cr, &window->details->free_stroke_color);
+ cairo_stroke (cr);
+#else
cairo_set_source_rgb (cr,
(double) window->details->free_color.red / 65535,
(double) window->details->free_color.green / 65535,
@@ -3101,7 +3131,6 @@ paint_free_legend (GtkWidget *widget,
(double) window->details->free_stroke_color.blue / 65535);
cairo_stroke (cr);
-#if !GTK_CHECK_VERSION(3,0,0)
cairo_destroy (cr);
#endif
}
@@ -3167,6 +3196,12 @@ paint_pie_chart (GtkWidget *widget,
cairo_line_to (cr,xc,yc);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &window->details->used_color);
+ cairo_fill_preserve (cr);
+
+ gdk_cairo_set_source_rgba (cr, &window->details->used_stroke_color);
+#else
cairo_set_source_rgb (cr,
(double) window->details->used_color.red / 65535,
(double) window->details->used_color.green / 65535,
@@ -3177,6 +3212,7 @@ paint_pie_chart (GtkWidget *widget,
(double) window->details->used_stroke_color.red / 65535,
(double) window->details->used_stroke_color.green / 65535,
(double) window->details->used_stroke_color.blue / 65535);
+#endif
cairo_stroke (cr);
}
@@ -3191,6 +3227,12 @@ paint_pie_chart (GtkWidget *widget,
cairo_line_to (cr,xc,yc);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_rgba (cr, &window->details->free_color);
+ cairo_fill_preserve(cr);
+
+ gdk_cairo_set_source_rgba (cr, &window->details->free_stroke_color);
+#else
cairo_set_source_rgb (cr,
(double) window->details->free_color.red / 65535,
(double) window->details->free_color.green / 65535,
@@ -3201,6 +3243,7 @@ paint_pie_chart (GtkWidget *widget,
(double) window->details->free_stroke_color.red / 65535,
(double) window->details->free_stroke_color.green / 65535,
(double) window->details->free_stroke_color.blue / 65535);
+#endif
cairo_stroke (cr);
}
@@ -3362,17 +3405,28 @@ hls_to_rgb (gdouble *h,
}
}
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+_pie_style_shade (GdkRGBA *a,
+ GdkRGBA *b,
+#else
_pie_style_shade (GdkColor *a,
GdkColor *b,
+#endif
gdouble k)
{
gdouble red;
gdouble green;
gdouble blue;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ red = a->red;
+ green = a->green;
+ blue = a->blue;
+#else
red = (gdouble) a->red / 65535.0;
green = (gdouble) a->green / 65535.0;
blue = (gdouble) a->blue / 65535.0;
+#endif
rgb_to_hls (&red, &green, &blue);
@@ -3390,9 +3444,16 @@ _pie_style_shade (GdkColor *a,
hls_to_rgb (&red, &green, &blue);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ b->red = red;
+ b->green = green;
+ b->blue = blue;
+ b->alpha = a->alpha;
+#else
b->red = red * 65535.0;
b->green = green * 65535.0;
b->blue = blue * 65535.0;
+#endif
}
@@ -3402,10 +3463,11 @@ create_pie_widget (FMPropertiesWindow *window)
CajaFile *file;
#if GTK_CHECK_VERSION (3, 0, 0)
GtkGrid *grid;
+ GtkStyleContext *style;
#else
GtkTable *table;
-#endif
GtkStyle *style;
+#endif
GtkWidget *pie_canvas;
GtkWidget *used_canvas;
GtkWidget *used_label;
@@ -3441,22 +3503,34 @@ create_pie_widget (FMPropertiesWindow *window)
gtk_container_set_border_width (GTK_CONTAINER (grid), 5);
gtk_grid_set_column_spacing (GTK_GRID (grid), 5);
style = gtk_widget_get_style_context (GTK_WIDGET (grid));
+
+ if (!gtk_style_context_lookup_color (style, "chart_rgba_1", &window->details->used_color)) {
#else
table = GTK_TABLE (gtk_table_new (4, 3, FALSE));
style = gtk_rc_get_style (GTK_WIDGET(table));
-#endif
if (!gtk_style_lookup_color (style, "chart_color_1", &window->details->used_color)) {
+#endif
window->details->used_color.red = USED_FILL_R;
window->details->used_color.green = USED_FILL_G;
window->details->used_color.blue = USED_FILL_B;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ window->details->used_color.alpha = 1;
+#endif
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (!gtk_style_context_lookup_color (style, "chart_rgba_2", &window->details->free_color)) {
+#else
if (!gtk_style_lookup_color (style, "chart_color_2", &window->details->free_color)) {
+#endif
window->details->free_color.red = FREE_FILL_R;
window->details->free_color.green = FREE_FILL_G;
window->details->free_color.blue = FREE_FILL_B;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ window->details->free_color.alpha = 1;
+#endif
}
_pie_style_shade (&window->details->used_color, &window->details->used_stroke_color, 0.7);
@@ -6152,7 +6226,9 @@ create_properties_window (StartupData *startup_data)
NULL);
/* FIXME - HIGificiation, should be done inside GTK+ */
+#if !GTK_CHECK_VERSION (3, 0, 0)
gtk_widget_ensure_style (GTK_WIDGET (window));
+#endif
gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (window))), 12);
gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (window))), 0);
gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), 12);
diff --git a/src/file-manager/fm-tree-model.c b/src/file-manager/fm-tree-model.c
index 504dd89a..039a1ef8 100644
--- a/src/file-manager/fm-tree-model.c
+++ b/src/file-manager/fm-tree-model.c
@@ -29,7 +29,11 @@
#include <config.h>
#include "fm-tree-model.h"
+#if GTK_CHECK_VERSION(3,0,0)
+#include <eel/eel-graphic-effects.h>
+#else
#include <eel/eel-gdk-pixbuf-extensions.h>
+#endif
#include <glib/gi18n.h>
#include <libcaja-private/caja-directory.h>
#include <libcaja-private/caja-file-attributes.h>
@@ -332,7 +336,11 @@ get_menu_icon_for_file (TreeNode *node,
if (highlight)
{
+#if GTK_CHECK_VERSION(3,0,0)
+ pixbuf = eel_create_spotlight_pixbuf (retval);
+#else
pixbuf = eel_gdk_pixbuf_render (retval, 1, 255, 255, 0, 0);
+#endif
if (pixbuf != NULL)
{