From a461e0a356a76f81076d78dd3b08a854884cdeeb Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Sat, 26 Dec 2015 19:55:08 +0100 Subject: GTK3 icon-dnd: fix DnD highlighting regression taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=7bd06fa --- libcaja-private/caja-icon-dnd.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 376490dc..38820aa9 100644 --- a/libcaja-private/caja-icon-dnd.c +++ b/libcaja-private/caja-icon-dnd.c @@ -1611,11 +1611,17 @@ drag_highlight_expose (GtkWidget *widget, gpointer data) #endif { +#if GTK_CHECK_VERSION(3,0,0) + gint width, height; +#else gint x, y, width, height; +#endif GdkWindow *window; +#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); @@ -1626,7 +1632,7 @@ drag_highlight_expose (GtkWidget *widget, cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT, widget, "dnd", - x, y, width, height); + 0, 0, width, height); #else gtk_paint_shadow (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, @@ -1638,7 +1644,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); -- cgit v1.2.1 From 4df0d0df37e1a69a4c6bcd76580adc736d1f4e5f Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Sat, 26 Dec 2015 20:31:28 +0100 Subject: GTK3 file-conflict-dialog: port to GtkStyleContext taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=5da941e --- libcaja-private/caja-file-conflict-dialog.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-file-conflict-dialog.c b/libcaja-private/caja-file-conflict-dialog.c index cda3069b..28887f88 100644 --- a/libcaja-private/caja-file-conflict-dialog.c +++ b/libcaja-private/caja-file-conflict-dialog.c @@ -115,7 +115,12 @@ file_list_ready_cb (GList *files, GdkPixbuf *pixbuf; GtkWidget *label; GString *str; +#if GTK_CHECK_VERSION(3,0,0) + PangoFontDescription *desc, *old_desc; + GtkStyleContext *style; +#else PangoFontDescription *desc; +#endif details = fcd->details; @@ -219,18 +224,35 @@ file_list_ready_cb (GList *files, gtk_widget_set_size_request (label, 350, -1); #if GTK_CHECK_VERSION (3, 14, 0) gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_box_pack_start (GTK_BOX (details->titles_vbox), + label, FALSE, FALSE, 0); + + style = gtk_widget_get_style_context (label); + gtk_style_context_get_style (style, + GTK_STYLE_PROPERTY_FONT, &old_desc, + NULL); + + desc = pango_font_description_new (); + pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD); + pango_font_description_set_size (desc, + pango_font_description_get_size (old_desc) * PANGO_SCALE_LARGE); + gtk_widget_override_font (label, desc); + pango_font_description_free (desc); + pango_font_description_free (old_desc); #else 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, pango_font_description_get_size (gtk_widget_get_style (label)->font_desc) * PANGO_SCALE_LARGE); gtk_widget_modify_font (label, desc); pango_font_description_free (desc); +#endif gtk_widget_show (label); label = gtk_label_new (secondary_text); -- cgit v1.2.1 From dca1155b3473e91ef12b03dca1506b86ccbaba07 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Sun, 27 Dec 2015 01:46:55 +0100 Subject: GTK3 icon-canvas-item: port to GtkStyleContext taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=fc74332 --- libcaja-private/caja-icon-canvas-item.c | 90 +++++++++++++++++++++++++++------ 1 file changed, 74 insertions(+), 16 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index fe44b9b2..b48583ba 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -232,7 +232,11 @@ static void draw_label_layout (CajaIconCanvasItem #endif PangoLayout *layout, gboolean highlight, +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA *label_color, +#else GdkColor *label_color, +#endif int x, int y); static gboolean hit_test_stretch_handle (CajaIconCanvasItem *item, @@ -1039,10 +1043,11 @@ static void draw_frame (CajaIconCanvasItem *item, #if GTK_CHECK_VERSION(3,0,0) cairo_t *cr, + GdkRGBA *color, #else GdkDrawable *drawable, -#endif guint color, +#endif gboolean create_mask, int x, int y, @@ -1068,11 +1073,15 @@ draw_frame (CajaIconCanvasItem *item, */ } +#if GTK_CHECK_VERSION(3,0,0) + gdk_cairo_set_source_rgba (cr, color); +#else cairo_set_source_rgba (cr, EEL_RGBA_COLOR_GET_R (color) / 255.0, EEL_RGBA_COLOR_GET_G (color) / 255.0, EEL_RGBA_COLOR_GET_B (color) / 255.0, EEL_RGBA_COLOR_GET_A (color) / 255.0); +#endif /* Paint into drawable now that we have set up the color and opacity */ cairo_fill (cr); @@ -1395,7 +1404,11 @@ draw_label_text (CajaIconCanvasItem *item, CajaIconContainer *container; PangoLayout *editable_layout; PangoLayout *additional_layout; +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA label_color; +#else GdkColor *label_color; +#endif gboolean have_editable, have_additional; gboolean needs_frame, needs_highlight, prelight_label, is_rtl_label_beside; EelIRect text_rect; @@ -1439,10 +1452,11 @@ draw_label_text (CajaIconCanvasItem *item, draw_frame (item, #if GTK_CHECK_VERSION(3,0,0) cr, + gtk_widget_has_focus (GTK_WIDGET (container)) ? &container->details->highlight_color_rgba : &container->details->active_color_rgba, #else drawable, -#endif gtk_widget_has_focus (GTK_WIDGET (container)) ? container->details->highlight_color_rgba : container->details->active_color_rgba, +#endif create_mask, is_rtl_label_beside ? text_rect.x0 + item->details->text_dx : text_rect.x0, text_rect.y0, @@ -1498,10 +1512,11 @@ draw_label_text (CajaIconCanvasItem *item, draw_frame (item, #if GTK_CHECK_VERSION(3,0,0) cr, + &container->details->normal_color_rgba, #else drawable, -#endif container->details->normal_color_rgba, +#endif create_mask, text_rect.x0, text_rect.y0, @@ -1513,10 +1528,11 @@ draw_label_text (CajaIconCanvasItem *item, draw_frame (item, #if GTK_CHECK_VERSION(3,0,0) cr, + &container->details->prelight_color_rgba, #else drawable, -#endif container->details->prelight_color_rgba, +#endif create_mask, text_rect.x0, text_rect.y0, @@ -1533,11 +1549,13 @@ draw_label_text (CajaIconCanvasItem *item, draw_label_layout (item, #if GTK_CHECK_VERSION(3,0,0) cr, + editable_layout, needs_highlight, + &label_color, #else drawable, -#endif editable_layout, needs_highlight, label_color, +#endif x, text_rect.y0 + TEXT_BACK_PADDING_Y); } @@ -1555,29 +1573,30 @@ draw_label_text (CajaIconCanvasItem *item, draw_label_layout (item, #if GTK_CHECK_VERSION(3,0,0) cr, + additional_layout, needs_highlight, + &label_color, #else drawable, -#endif additional_layout, needs_highlight, label_color, +#endif x, text_rect.y0 + details->editable_text_height + LABEL_LINE_SPACING + TEXT_BACK_PADDING_Y); } 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, + gtk_render_focus (gtk_widget_get_style_context (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)), + cr, #else + gtk_paint_focus (gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)), 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", +#endif text_rect.x0, text_rect.y0, text_rect.x1 - text_rect.x0, @@ -1667,6 +1686,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 +1697,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 +1711,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, @@ -1929,7 +1960,11 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item) saturation, brightness, lighten, +#if GTK_CHECK_VERSION(3,0,0) + &container->details->prelight_icon_color_rgba); +#else container->details->prelight_icon_color_rgba); +#endif g_object_unref (old_pixbuf); } @@ -1983,6 +2018,17 @@ 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) + GdkRGBA *color; + + old_pixbuf = temp_pixbuf; + + color = gtk_widget_has_focus (GTK_WIDGET (canvas)) ? + &CAJA_ICON_CONTAINER (canvas)->details->highlight_color_rgba : + &CAJA_ICON_CONTAINER (canvas)->details->active_color_rgba; + + temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, color); +#else guint color; old_pixbuf = temp_pixbuf; @@ -1993,6 +2039,7 @@ 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); } @@ -2018,7 +2065,11 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item) saturation, brightness, lighten, +#if GTK_CHECK_VERSION(3,0,0) + &container->details->normal_icon_color_rgba); +#else container->details->normal_icon_color_rgba); +#endif g_object_unref (old_pixbuf); } } @@ -2324,16 +2375,21 @@ static void draw_label_layout (CajaIconCanvasItem *item, #if GTK_CHECK_VERSION(3,0,0) cairo_t *cr, + PangoLayout *layout, + gboolean highlight, + GdkRGBA *label_color, + int x, + int y) +{ + GdkRGBA black = { 0, 0, 0, 0 }; #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 @@ -2347,11 +2403,13 @@ draw_label_layout (CajaIconCanvasItem *item, /* draw a drop shadow */ #if GTK_CHECK_VERSION(3,0,0) eel_cairo_draw_layout_with_drop_shadow (cr, + label_color, + &black, #else eel_gdk_draw_layout_with_drop_shadow (drawable, -#endif label_color, >k_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas))->black, +#endif x, y, layout); } @@ -2359,11 +2417,11 @@ draw_label_layout (CajaIconCanvasItem *item, { #if GTK_CHECK_VERSION(3,0,0) cairo_save (cr); + gdk_cairo_set_source_rgba (cr, label_color); #else cairo_t *cr = gdk_cairo_create (drawable); -#endif - gdk_cairo_set_source_color (cr, label_color); +#endif cairo_move_to (cr, x, y); pango_cairo_show_layout (cr, layout); #if GTK_CHECK_VERSION(3,0,0) -- cgit v1.2.1 From 11fe5df21deec3181bbb72a577a26f7d2bb4d8b0 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Tue, 5 Jan 2016 19:56:52 +0100 Subject: GTK3 icon-container: port to GtkStyleContext taken from: https://git.gnome.org/browse/nautilus/commit/?id=4f23a0a --- libcaja-private/caja-icon-container.c | 234 +++++++++++++++++++++++++++++++++- libcaja-private/caja-icon-dnd.c | 4 +- libcaja-private/caja-icon-private.h | 16 +++ 3 files changed, 247 insertions(+), 7 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 8e89ce62..04ca88bf 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -120,8 +120,13 @@ #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 +#endif #define DEFAULT_NORMAL_ICON_RENDER_MODE 0 #define DEFAULT_PRELIGHT_ICON_RENDER_MODE 1 @@ -2878,12 +2883,19 @@ start_rubberbanding (CajaIconContainer *container, AtkObject *accessible; CajaIconContainerDetails *details; CajaIconRubberbandInfo *band_info; +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA *fill_color_gdk; + GList *p; + CajaIcon *icon; + GtkStyleContext *style; +#else guint fill_color, outline_color; GdkColor *fill_color_gdk; guchar fill_color_alpha; GList *p; CajaIcon *icon; GtkStyle *style; +#endif details = container->details; band_info = &details->rubberband_info; @@ -2901,6 +2913,38 @@ start_rubberbanding (CajaIconContainer *container, (EEL_CANVAS (container), event->x, event->y, &band_info->start_x, &band_info->start_y); +#if GTK_CHECK_VERSION(3,0,0) + style = gtk_widget_get_style_context (GTK_WIDGET (container)); + gtk_style_context_get_style (style, + "selection_box_rgba", &fill_color_gdk, + NULL); + + if (!fill_color_gdk) + { + fill_color_gdk = g_malloc0 (sizeof (GdkRGBA)); + gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, + fill_color_gdk); + } + + if (fill_color_gdk->alpha == 1) { + fill_color_gdk->alpha = 0.25; + } + + 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", fill_color_gdk, + "outline_color_rgba", fill_color_gdk, + "width_pixels", 1, + NULL); + + gdk_rgba_free (fill_color_gdk); +#else gtk_widget_style_get (GTK_WIDGET (container), "selection_box_color", &fill_color_gdk, "selection_box_alpha", &fill_color_alpha, @@ -2930,6 +2974,7 @@ start_rubberbanding (CajaIconContainer *container, "outline_color_rgba", outline_color, "width_pixels", 1, NULL); +#endif accessible = atk_gobject_accessible_for_object (G_OBJECT (band_info->selection_rectangle)); @@ -4603,9 +4648,15 @@ style_set (GtkWidget *widget, container = CAJA_ICON_CONTAINER (widget); +#if GTK_CHECK_VERSION(3,0,0) + gtk_style_context_get_style (gtk_widget_get_style_context (GTK_WIDGET (container)), + "frame_text", &frame_text, + NULL); +#else gtk_widget_style_get (GTK_WIDGET (container), "frame_text", &frame_text, NULL); +#endif container->details->use_drop_shadows = container->details->drop_shadows_requested && !frame_text; @@ -6587,6 +6638,25 @@ caja_icon_container_class_init (CajaIconContainerClass *class) G_PARAM_READABLE)); gtk_widget_class_install_style_property (widget_class, +#if GTK_CHECK_VERSION(3,0,0) + 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, +#else g_param_spec_boxed ("selection_box_color", "Selection Box Color", "Color of the selection box", @@ -6632,6 +6702,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) "Dark Info Color", "Color used for information text against a light background", GDK_TYPE_COLOR, +#endif G_PARAM_READABLE)); gtk_widget_class_install_style_property (widget_class, @@ -6649,6 +6720,18 @@ caja_icon_container_class_init (CajaIconContainerClass *class) DEFAULT_PRELIGHT_ICON_RENDER_MODE, G_PARAM_READABLE)); gtk_widget_class_install_style_property (widget_class, +#if GTK_CHECK_VERSION(3,0,0) + g_param_spec_boxed ("normal_icon_rgba", + "Icon Normal RGBA", + "Color used for colorizing icons in normal state (default base[NORMAL])", + GDK_TYPE_RGBA, + G_PARAM_READABLE)); + gtk_widget_class_install_style_property (widget_class, + g_param_spec_boxed ("prelight_icon_rgba", + "Icon Prelight RGBA", + "Color used for colorizing prelighted icons (default base[PRELIGHT])", + GDK_TYPE_RGBA, +#else g_param_spec_boxed ("normal_icon_color", "Icon Normal Color", "Color used for colorizing icons in normal state (default base[NORMAL])", @@ -6659,6 +6742,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) "Icon Prelight Color", "Color used for colorizing prelighted icons (default base[PRELIGHT])", GDK_TYPE_COLOR, +#endif G_PARAM_READABLE)); gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("normal_icon_saturation", @@ -9296,10 +9380,14 @@ caja_icon_container_set_single_click_mode (CajaIconContainer *container, void caja_icon_container_get_label_color (CajaIconContainer *container, +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA *color, +#else GdkColor **color, - gboolean is_name, - gboolean is_highlight, - gboolean is_prelit) +#endif + gboolean is_name, + gboolean is_highlight, + gboolean is_prelit) { int idx; @@ -9349,14 +9437,24 @@ caja_icon_container_get_label_color (CajaIconContainer *container, if (color) { +#if GTK_CHECK_VERSION(3,0,0) + *color = container->details->label_colors[idx]; +#else *color = &container->details->label_colors [idx]; +#endif } } static void +#if GTK_CHECK_VERSION(3,0,0) +setup_gc_with_fg (CajaIconContainer *container, int idx, GdkRGBA *color) +{ + container->details->label_colors[idx] = *color; +#else setup_gc_with_fg (CajaIconContainer *container, int idx, guint32 color) { container->details->label_colors [idx] = eel_gdk_rgb_to_color (color); +#endif } static void @@ -9364,10 +9462,17 @@ setup_label_gcs (CajaIconContainer *container) { EelBackground *background; GtkWidget *widget; +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA *light_info_color, *dark_info_color; + gboolean frame_text; + GtkStyleContext *style; + GdkRGBA color; +#else GdkColor *light_info_color, *dark_info_color; guint light_info_value, dark_info_value; gboolean frame_text; GtkStyle *style; +#endif if (!gtk_widget_get_realized (GTK_WIDGET (container))) return; @@ -9379,6 +9484,83 @@ setup_label_gcs (CajaIconContainer *container) background = eel_get_widget_background (GTK_WIDGET (container)); /* 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 (widget); + gtk_style_context_get_style (style, + "light_info_rgba", &light_info_color, + "dark_info_rgba", &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 (container, LABEL_COLOR_HIGHLIGHT, &color); + + gtk_style_context_get_color (style, GTK_STATE_FLAG_ACTIVE, &color); + setup_gc_with_fg (container, LABEL_COLOR_ACTIVE, &color); + + gtk_style_context_get_color (style, GTK_STATE_FLAG_PRELIGHT, &color); + setup_gc_with_fg (container, LABEL_COLOR_PRELIGHT, &color); + + gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &color); + setup_gc_with_fg (container, + 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 (container, + LABEL_INFO_COLOR_ACTIVE, + eel_gdk_rgba_is_dark (&color) ? light_info_color : dark_info_color); + + /* If CajaIconContainer::frame_text is set, we can safely + * use the foreground color from the theme, because it will + * always be displayed against the gtk background */ + gtk_style_context_get_style (gtk_widget_get_style_context (GTK_WIDGET (container)), + "frame_text", &frame_text, + NULL); + + if (frame_text /* || !eel_background_is_set(background) */) + { + gtk_style_context_get_color (style, GTK_STATE_FLAG_ACTIVE, &color); + setup_gc_with_fg (container, LABEL_COLOR, &color); + + gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color); + setup_gc_with_fg (container, LABEL_INFO_COLOR, + eel_gdk_rgba_is_dark (&color) ? + light_info_color : dark_info_color); + } + else + { + if (container->details->use_drop_shadows || eel_background_is_dark (background)) + { + GdkRGBA tmp; + + gdk_rgba_parse (&tmp, "EFEFEF"); + setup_gc_with_fg (container, LABEL_COLOR, &tmp); + setup_gc_with_fg (container, LABEL_INFO_COLOR, light_info_color); + } + else /* converse */ + { + GdkRGBA tmp; + + gdk_rgba_parse (&tmp, "000000"); + setup_gc_with_fg (container, LABEL_COLOR, &tmp); + setup_gc_with_fg (container, LABEL_INFO_COLOR, dark_info_color); + } + } + gdk_rgba_free (dark_info_color); + gdk_rgba_free (light_info_color); +#else gtk_widget_style_get (GTK_WIDGET (container), "light_info_color", &light_info_color, "dark_info_color", &dark_info_color, @@ -9448,6 +9630,7 @@ setup_label_gcs (CajaIconContainer *container) dark_info_value); } } +#endif } static void @@ -9520,7 +9703,11 @@ caja_icon_container_set_use_drop_shadows (CajaIconContainer *container, { gboolean frame_text; +#if GTK_CHECK_VERSION(3,0,0) + gtk_style_context_get_style (gtk_widget_get_style_context (GTK_WIDGET (container)), +#else gtk_widget_style_get (GTK_WIDGET (container), +#endif "frame_text", &frame_text, NULL); @@ -9540,6 +9727,45 @@ static void caja_icon_container_theme_changed (gpointer user_data) { CajaIconContainer *container; +#if GTK_CHECK_VERSION(3,0,0) + GtkStyleContext *style; + GdkRGBA *prelight_icon_color, *normal_icon_color, color; + + container = CAJA_ICON_CONTAINER (user_data); + style = gtk_widget_get_style_context (GTK_WIDGET (container)); + + gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &color); + container->details->highlight_color_rgba = color; + + gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color); + container->details->active_color_rgba = color; + + /* load the prelight icon color */ + gtk_style_context_get_style (style, + "prelight_icon_rgba", &prelight_icon_color, + NULL); + gtk_style_context_get_background_color (style, GTK_STATE_FLAG_PRELIGHT, &color); + + if (!prelight_icon_color) { + prelight_icon_color = gdk_rgba_copy (&color); + } + + container->details->prelight_icon_color_rgba = *prelight_icon_color; + container->details->prelight_color_rgba = color; + + /* load the normal icon color */ + gtk_style_context_get_style (style, + "normal_icon_rgba", &normal_icon_color, + NULL); + gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color); + + if (!normal_icon_color) { + normal_icon_color = gdk_rgba_copy (&color); + } + + container->details->normal_icon_color_rgba = *normal_icon_color; + container->details->normal_color_rgba = color; +#else GtkStyle *style; GdkColor *prelight_icon_color, *normal_icon_color; guchar highlight_alpha, normal_alpha, prelight_alpha; @@ -9632,7 +9858,7 @@ caja_icon_container_theme_changed (gpointer user_data) style->base[GTK_STATE_PRELIGHT].green >> 8, style->base[GTK_STATE_PRELIGHT].blue >> 8, prelight_alpha); - +#endif setup_label_gcs (container); } diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 38820aa9..0a1cac87 100644 --- a/libcaja-private/caja-icon-dnd.c +++ b/libcaja-private/caja-icon-dnd.c @@ -1628,10 +1628,8 @@ drag_highlight_expose (GtkWidget *widget, height = gdk_window_get_height (window); #if GTK_CHECK_VERSION (3, 0, 0) - gtk_paint_shadow (gtk_widget_get_style (widget), + gtk_render_frame (gtk_widget_get_style_context (widget), cr, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - widget, "dnd", 0, 0, width, height); #else gtk_paint_shadow (gtk_widget_get_style (widget), window, diff --git a/libcaja-private/caja-icon-private.h b/libcaja-private/caja-icon-private.h index cf7ef592..0c36188f 100644 --- a/libcaja-private/caja-icon-private.h +++ b/libcaja-private/caja-icon-private.h @@ -211,6 +211,17 @@ struct CajaIconContainerDetails int font_size_table[CAJA_ZOOM_LEVEL_LARGEST + 1]; /* pixbuf and color for label highlighting */ +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA highlight_color_rgba; + GdkRGBA active_color_rgba; + GdkRGBA normal_color_rgba; + GdkRGBA prelight_color_rgba; + GdkRGBA prelight_icon_color_rgba; + GdkRGBA normal_icon_color_rgba; + + /* colors for text labels */ + GdkRGBA label_colors [LAST_LABEL_COLOR]; +#else guint32 highlight_color_rgba; guint32 active_color_rgba; guint32 normal_color_rgba; @@ -220,6 +231,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. */ @@ -327,7 +339,11 @@ void caja_icon_container_update_scroll_region (CajaIconContainer /* label color for items */ void caja_icon_container_get_label_color (CajaIconContainer *container, +#if GTK_CHECK_VERSION(3,0,0) + GdkRGBA *color, +#else GdkColor **color, +#endif gboolean first_line, gboolean needs_highlight, gboolean is_prelit); -- cgit v1.2.1 From 5425761290d94b208efea117e3b6a865e9157b92 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Wed, 6 Jan 2016 22:16:38 +0100 Subject: GTK3 icon-container: fix rendering of text on the desktop taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=2e5f7a23350016c67bb9e9cca86a9fb2360d79e2 --- libcaja-private/caja-icon-canvas-item.c | 2 +- libcaja-private/caja-icon-container.c | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index b48583ba..1249cba6 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -2381,7 +2381,7 @@ draw_label_layout (CajaIconCanvasItem *item, int x, int y) { - GdkRGBA black = { 0, 0, 0, 0 }; + GdkRGBA black = { 0, 0, 0, 1 }; #else GdkDrawable *drawable, PangoLayout *layout, diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 04ca88bf..4cf35d30 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -121,8 +121,8 @@ #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" +#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 @@ -9494,13 +9494,13 @@ setup_label_gcs (CajaIconContainer *container) if (!light_info_color) { light_info_color = g_malloc (sizeof (GdkRGBA)); - gdk_rgba_parse (light_info_color, DEFAULT_LIGHT_INFO_COLOR); + g_assert (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); + dark_info_color = g_malloc (sizeof (GdkRGBA)); + g_assert (gdk_rgba_parse (dark_info_color, DEFAULT_DARK_INFO_COLOR)); } gtk_style_context_get_color (style, GTK_STATE_FLAG_SELECTED, &color); @@ -9545,7 +9545,7 @@ setup_label_gcs (CajaIconContainer *container) { GdkRGBA tmp; - gdk_rgba_parse (&tmp, "EFEFEF"); + gdk_rgba_parse (&tmp, "#EFEFEF"); setup_gc_with_fg (container, LABEL_COLOR, &tmp); setup_gc_with_fg (container, LABEL_INFO_COLOR, light_info_color); } @@ -9553,7 +9553,7 @@ setup_label_gcs (CajaIconContainer *container) { GdkRGBA tmp; - gdk_rgba_parse (&tmp, "000000"); + gdk_rgba_parse (&tmp, "#000000"); setup_gc_with_fg (container, LABEL_COLOR, &tmp); setup_gc_with_fg (container, LABEL_INFO_COLOR, dark_info_color); } -- cgit v1.2.1 From d74c80ebae7d2acd4804ac1d20f6d77b1df53a2a Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Mon, 4 Jan 2016 22:11:54 +0100 Subject: Gtk3 tree-view-drag-dest: port to GtkStyleContext taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=f8bdf9c --- libcaja-private/caja-tree-view-drag-dest.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-tree-view-drag-dest.c b/libcaja-private/caja-tree-view-drag-dest.c index 22a5cc51..2d76a1c1 100644 --- a/libcaja-private/caja-tree-view-drag-dest.c +++ b/libcaja-private/caja-tree-view-drag-dest.c @@ -206,18 +206,19 @@ 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), + gtk_render_focus (gtk_widget_get_style_context (widget), + cr, + 0, 0, width, height); #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; } -- cgit v1.2.1 From 34031cbce020b242d523258e06565c6a00c54e5d Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Thu, 7 Jan 2016 23:42:36 +0100 Subject: GTK3 icon-info: plug a leak taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=705d814 --- libcaja-private/caja-icon-info.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'libcaja-private') 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; } } -- cgit v1.2.1 From 01e61137a215658271f8b727ba56b8b2272fe1b2 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Thu, 7 Jan 2016 23:53:55 +0100 Subject: GTK3 icon-canvas-item: set the right style class taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=0668960 --- libcaja-private/caja-icon-canvas-item.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index 1249cba6..476b8839 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -1587,7 +1587,17 @@ draw_label_text (CajaIconCanvasItem *item, if (!create_mask && item->details->is_highlighted_as_keyboard_focus) { #if GTK_CHECK_VERSION(3,0,0) - gtk_render_focus (gtk_widget_get_style_context (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)), + GtkStyleContext *style; + + style = gtk_widget_get_style_context (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)); + + gtk_style_context_save (style); + gtk_style_context_add_class (style, "icon-container"); + gtk_style_context_set_state (style, + needs_highlight ? + GTK_STATE_FLAG_SELECTED : GTK_STATE_FLAG_ACTIVE); + + gtk_render_focus (style, cr, #else gtk_paint_focus (gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)), @@ -1601,6 +1611,10 @@ draw_label_text (CajaIconCanvasItem *item, text_rect.y0, text_rect.x1 - text_rect.x0, text_rect.y1 - text_rect.y0); +#if GTK_CHECK_VERSION(3,0,0) + + gtk_style_context_restore (style); +#endif } if (editable_layout != NULL) -- cgit v1.2.1 From 85faafb667ca2ab548347814595ac9b305c024b8 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Fri, 8 Jan 2016 00:11:42 +0100 Subject: Gtk3 tree-drag-dest: set the right style class taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=18e3369 --- libcaja-private/caja-tree-view-drag-dest.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-tree-view-drag-dest.c b/libcaja-private/caja-tree-view-drag-dest.c index 2d76a1c1..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)); @@ -207,9 +210,16 @@ highlight_expose (GtkWidget *widget, height = gdk_window_get_height(bin_window); #if GTK_CHECK_VERSION(3,0,0) - gtk_render_focus (gtk_widget_get_style_context (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, -- cgit v1.2.1 From c0e9c136368c537209932431774edef5bb6b8982 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Fri, 8 Jan 2016 00:22:27 +0100 Subject: GTK3 icon-dnd: set the right style class, and use GdkRGBA taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=5d811bb --- libcaja-private/caja-icon-dnd.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 0a1cac87..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); @@ -1613,10 +1620,12 @@ drag_highlight_expose (GtkWidget *widget, { #if GTK_CHECK_VERSION(3,0,0) gint width, height; + GdkWindow *window; + GtkStyleContext *style; #else gint x, y, width, height; -#endif GdkWindow *window; +#endif #if !GTK_CHECK_VERSION(3,0,0) x = gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (widget))); @@ -1628,9 +1637,17 @@ drag_highlight_expose (GtkWidget *widget, height = gdk_window_get_height (window); #if GTK_CHECK_VERSION (3, 0, 0) - gtk_render_frame (gtk_widget_get_style_context (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, 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, -- cgit v1.2.1 From 6a19cea2b87a4977a70b1bd6e14edb09a5ebde62 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Fri, 8 Jan 2016 00:34:11 +0100 Subject: GTK3 icon-container: don't malloc() GdkRGBA colors manually As GdkRGBA might or might not use internally a different allocator, like g_slice. This should fix some memory corruption issues, thanks to Alban Browaeys for tracking down the bug. taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=4c026bf --- libcaja-private/caja-icon-container.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 4cf35d30..645e76ba 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -2884,7 +2884,7 @@ start_rubberbanding (CajaIconContainer *container, CajaIconContainerDetails *details; CajaIconRubberbandInfo *band_info; #if GTK_CHECK_VERSION(3,0,0) - GdkRGBA *fill_color_gdk; + GdkRGBA *fill_color_gdk, color; GList *p; CajaIcon *icon; GtkStyleContext *style; @@ -2921,9 +2921,9 @@ start_rubberbanding (CajaIconContainer *container, if (!fill_color_gdk) { - fill_color_gdk = g_malloc0 (sizeof (GdkRGBA)); gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, - fill_color_gdk); + &color); + fill_color_gdk = gdk_rgba_copy (&color); } if (fill_color_gdk->alpha == 1) { @@ -9493,14 +9493,14 @@ setup_label_gcs (CajaIconContainer *container) if (!light_info_color) { - light_info_color = g_malloc (sizeof (GdkRGBA)); - g_assert (gdk_rgba_parse (light_info_color, DEFAULT_LIGHT_INFO_COLOR)); + gdk_rgba_parse (&color, DEFAULT_LIGHT_INFO_COLOR); + light_info_color = gdk_rgba_copy (&color); } if (!dark_info_color) { - dark_info_color = g_malloc (sizeof (GdkRGBA)); - g_assert (gdk_rgba_parse (dark_info_color, DEFAULT_DARK_INFO_COLOR)); + gdk_rgba_parse (&color, DEFAULT_DARK_INFO_COLOR); + dark_info_color = gdk_rgba_copy (&color); } gtk_style_context_get_color (style, GTK_STATE_FLAG_SELECTED, &color); -- cgit v1.2.1 From e5708b8799ecd7b74b0c6d890677c0281b762cee Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Fri, 8 Jan 2016 21:24:28 +0100 Subject: GTK3 icon-container: fix rendering of text on the desktop taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=2e5f7a2 --- libcaja-private/caja-icon-container.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 645e76ba..203f1b8e 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -2884,7 +2884,7 @@ start_rubberbanding (CajaIconContainer *container, CajaIconContainerDetails *details; CajaIconRubberbandInfo *band_info; #if GTK_CHECK_VERSION(3,0,0) - GdkRGBA *fill_color_gdk, color; + GdkRGBA *fill_color_gdk, outline, color; GList *p; CajaIcon *icon; GtkStyleContext *style; @@ -2930,6 +2930,9 @@ start_rubberbanding (CajaIconContainer *container, fill_color_gdk->alpha = 0.25; } + outline = *fill_color_gdk; + eel_make_color_inactive (&outline); + band_info->selection_rectangle = eel_canvas_item_new (eel_canvas_root (EEL_CANVAS (container)), @@ -2939,7 +2942,7 @@ start_rubberbanding (CajaIconContainer *container, "x2", band_info->start_x, "y2", band_info->start_y, "fill_color_rgba", fill_color_gdk, - "outline_color_rgba", fill_color_gdk, + "outline_color_rgba", &outline, "width_pixels", 1, NULL); -- cgit v1.2.1 From 390400e11e888ee65d4620a03615c5aa23e4d089 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Fri, 8 Jan 2016 00:39:38 +0100 Subject: GTK3 icon-container: plug a memory leak taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=f394ce8 --- libcaja-private/caja-icon-container.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 203f1b8e..9aa26dac 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -9768,6 +9768,11 @@ caja_icon_container_theme_changed (gpointer user_data) container->details->normal_icon_color_rgba = *normal_icon_color; container->details->normal_color_rgba = color; + + setup_label_gcs (container); + + gdk_rgba_free (prelight_icon_color); + gdk_rgba_free (normal_icon_color); #else GtkStyle *style; GdkColor *prelight_icon_color, *normal_icon_color; @@ -9861,9 +9866,9 @@ caja_icon_container_theme_changed (gpointer user_data) style->base[GTK_STATE_PRELIGHT].green >> 8, style->base[GTK_STATE_PRELIGHT].blue >> 8, prelight_alpha); -#endif setup_label_gcs (container); +#endif } void -- cgit v1.2.1 From fa7dd4677f4196750d0c752c7b1823fdd7c54cbb Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Fri, 8 Jan 2016 22:04:08 +0100 Subject: GTK3 icon-container: remove useless theming properties taken from: https://git.gnome.org/browse/nautilus/commit/?id=e2ca42cac78cb0287a1bbb73030e7bba8b171970 --- libcaja-private/caja-icon-canvas-item.c | 16 ++++++--- libcaja-private/caja-icon-container.c | 57 +++++++++++++++++---------------- 2 files changed, 41 insertions(+), 32 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index 476b8839..4dcd2566 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -1410,7 +1410,11 @@ draw_label_text (CajaIconCanvasItem *item, GdkColor *label_color; #endif gboolean have_editable, have_additional; +#if GTK_CHECK_VERSION(3,0,0) + gboolean needs_highlight, prelight_label, is_rtl_label_beside; +#else gboolean needs_frame, needs_highlight, prelight_label, is_rtl_label_beside; +#endif EelIRect text_rect; int x; int max_text_width; @@ -1502,10 +1506,16 @@ draw_label_text (CajaIconCanvasItem *item, prepare_pango_layout_for_draw (item, editable_layout); gtk_widget_style_get (GTK_WIDGET (container), +#if !GTK_CHECK_VERSION(3,0,0) "frame_text", &needs_frame, +#endif "activate_prelight_icon_label", &prelight_label, NULL); +#if GTK_CHECK_VERSION(3,0,0) + if (!needs_highlight && details->text_width > 0 && details->text_height > 0) +#else if (needs_frame && !needs_highlight && details->text_width > 0 && details->text_height > 0) +#endif { if (!(prelight_label && item->details->is_prelit)) { @@ -2058,6 +2068,7 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item) 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 @@ -2079,14 +2090,11 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item) saturation, brightness, lighten, -#if GTK_CHECK_VERSION(3,0,0) - &container->details->normal_icon_color_rgba); -#else container->details->normal_icon_color_rgba); -#endif g_object_unref (old_pixbuf); } } +#endif return temp_pixbuf; } diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 9aa26dac..1bad9f26 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -4647,21 +4647,21 @@ style_set (GtkWidget *widget, GtkStyle *previous_style) { CajaIconContainer *container; +#if !GTK_CHECK_VERSION(3,0,0) gboolean frame_text; +#endif container = CAJA_ICON_CONTAINER (widget); #if GTK_CHECK_VERSION(3,0,0) - gtk_style_context_get_style (gtk_widget_get_style_context (GTK_WIDGET (container)), - "frame_text", &frame_text, - NULL); + container->details->use_drop_shadows = container->details->drop_shadows_requested; #else gtk_widget_style_get (GTK_WIDGET (container), "frame_text", &frame_text, NULL); -#endif container->details->use_drop_shadows = container->details->drop_shadows_requested && !frame_text; +#endif caja_icon_container_theme_changed (CAJA_ICON_CONTAINER (widget)); @@ -6633,15 +6633,8 @@ caja_icon_container_class_init (CajaIconContainerClass *class) class->start_interactive_search = caja_icon_container_start_interactive_search; - 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, #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", @@ -6659,7 +6652,15 @@ caja_icon_container_class_init (CajaIconContainerClass *class) "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", "Color of the selection box", @@ -6705,7 +6706,6 @@ caja_icon_container_class_init (CajaIconContainerClass *class) "Dark Info Color", "Color used for information text against a light background", GDK_TYPE_COLOR, -#endif G_PARAM_READABLE)); gtk_widget_class_install_style_property (widget_class, @@ -6715,6 +6715,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 3, DEFAULT_NORMAL_ICON_RENDER_MODE, G_PARAM_READABLE)); +#endif gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("prelight_icon_render_mode", "Prelight Icon Render Mode", @@ -6722,8 +6723,8 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 3, DEFAULT_PRELIGHT_ICON_RENDER_MODE, G_PARAM_READABLE)); - gtk_widget_class_install_style_property (widget_class, #if GTK_CHECK_VERSION(3,0,0) + gtk_widget_class_install_style_property (widget_class, g_param_spec_boxed ("normal_icon_rgba", "Icon Normal RGBA", "Color used for colorizing icons in normal state (default base[NORMAL])", @@ -6734,7 +6735,9 @@ caja_icon_container_class_init (CajaIconContainerClass *class) "Icon Prelight RGBA", "Color used for colorizing prelighted icons (default base[PRELIGHT])", GDK_TYPE_RGBA, + G_PARAM_READABLE)); #else + gtk_widget_class_install_style_property (widget_class, g_param_spec_boxed ("normal_icon_color", "Icon Normal Color", "Color used for colorizing icons in normal state (default base[NORMAL])", @@ -6745,7 +6748,6 @@ caja_icon_container_class_init (CajaIconContainerClass *class) "Icon Prelight Color", "Color used for colorizing prelighted icons (default base[PRELIGHT])", GDK_TYPE_COLOR, -#endif G_PARAM_READABLE)); gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("normal_icon_saturation", @@ -6754,6 +6756,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 255, DEFAULT_NORMAL_ICON_SATURATION, G_PARAM_READABLE)); +#endif gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("prelight_icon_saturation", "Prelight Icon Saturation", @@ -6761,6 +6764,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 255, DEFAULT_PRELIGHT_ICON_SATURATION, G_PARAM_READABLE)); +#if !GTK_CHECK_VERSION(3,0,0) gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("normal_icon_brightness", "Normal Icon Brightness", @@ -6768,6 +6772,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 255, DEFAULT_NORMAL_ICON_BRIGHTNESS, G_PARAM_READABLE)); +#endif gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("prelight_icon_brightness", "Prelight Icon Brightness", @@ -6775,6 +6780,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 255, DEFAULT_PRELIGHT_ICON_BRIGHTNESS, G_PARAM_READABLE)); +#if !GTK_CHECK_VERSION(3,0,0) gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("normal_icon_lighten", "Normal Icon Lighten", @@ -6782,6 +6788,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 255, DEFAULT_NORMAL_ICON_LIGHTEN, G_PARAM_READABLE)); +#endif gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("prelight_icon_lighten", "Prelight Icon Lighten", @@ -9467,7 +9474,6 @@ setup_label_gcs (CajaIconContainer *container) GtkWidget *widget; #if GTK_CHECK_VERSION(3,0,0) GdkRGBA *light_info_color, *dark_info_color; - gboolean frame_text; GtkStyleContext *style; GdkRGBA color; #else @@ -9525,14 +9531,7 @@ setup_label_gcs (CajaIconContainer *container) LABEL_INFO_COLOR_ACTIVE, eel_gdk_rgba_is_dark (&color) ? light_info_color : dark_info_color); - /* If CajaIconContainer::frame_text is set, we can safely - * use the foreground color from the theme, because it will - * always be displayed against the gtk background */ - gtk_style_context_get_style (gtk_widget_get_style_context (GTK_WIDGET (container)), - "frame_text", &frame_text, - NULL); - - if (frame_text /* || !eel_background_is_set(background) */) + if (!caja_icon_container_get_is_desktop (container)) { gtk_style_context_get_color (style, GTK_STATE_FLAG_ACTIVE, &color); setup_gc_with_fg (container, LABEL_COLOR, &color); @@ -9704,15 +9703,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; -#if GTK_CHECK_VERSION(3,0,0) - gtk_style_context_get_style (gtk_widget_get_style_context (GTK_WIDGET (container)), -#else gtk_widget_style_get (GTK_WIDGET (container), -#endif "frame_text", &frame_text, NULL); +#endif if (container->details->drop_shadows_requested == use_drop_shadows) { @@ -9720,7 +9717,11 @@ 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)); } -- cgit v1.2.1 From f700d63c933877362ed1cb92d8bddd2df1e29227 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Fri, 8 Jan 2016 00:41:46 +0100 Subject: GTK3 icon-container: fix a couple of ACTIVE -> NORMAL typos taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=d0d9059 --- libcaja-private/caja-icon-container.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 1bad9f26..9a6095e7 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -9533,10 +9533,10 @@ setup_label_gcs (CajaIconContainer *container) if (!caja_icon_container_get_is_desktop (container)) { - gtk_style_context_get_color (style, GTK_STATE_FLAG_ACTIVE, &color); + gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &color); setup_gc_with_fg (container, LABEL_COLOR, &color); - gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color); + gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color); setup_gc_with_fg (container, LABEL_INFO_COLOR, eel_gdk_rgba_is_dark (&color) ? light_info_color : dark_info_color); @@ -9761,7 +9761,7 @@ caja_icon_container_theme_changed (gpointer user_data) gtk_style_context_get_style (style, "normal_icon_rgba", &normal_icon_color, NULL); - gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color); + gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color); if (!normal_icon_color) { normal_icon_color = gdk_rgba_copy (&color); -- cgit v1.2.1 From 288ceb4c5d5af35676031754db51cc1c5c53105f Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Fri, 8 Jan 2016 00:50:35 +0100 Subject: GTK3 icon-container: fix setting the selection when renaming Closes: bgo #642766 taken from: https://git.gnome.org/browse/nautilus/commit/?id=a8a5b8d --- libcaja-private/caja-icon-container.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 9a6095e7..93af49bc 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -9264,12 +9264,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, -- cgit v1.2.1 From b03a4c4078440f3ec1baea7ea158606f3c68e277 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Sat, 9 Jan 2016 01:11:39 +0100 Subject: GTK3 icon-canvas-item: use eel_create_spotlight_pixbuf() Instead of passing eel_pixbuf_render() always the same values taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=a1fa4ea --- libcaja-private/caja-icon-canvas-item.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index 4dcd2566..4bfffebf 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -1957,7 +1957,9 @@ 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) guint render_mode, saturation, brightness, lighten; +#endif temp_pixbuf = icon_item->details->pixbuf; canvas = EEL_CANVAS_ITEM(icon_item)->canvas; @@ -1970,6 +1972,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, @@ -1984,15 +1990,10 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item) saturation, brightness, lighten, -#if GTK_CHECK_VERSION(3,0,0) - &container->details->prelight_icon_color_rgba); -#else container->details->prelight_icon_color_rgba); -#endif 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 -- cgit v1.2.1 From e2942ccb6206376293044bf0f7c885505e6a1113 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Sat, 9 Jan 2016 01:14:42 +0100 Subject: GTK3 icon-container: hook to style_updated instead of style_set taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=a083fa0 --- libcaja-private/caja-icon-container.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 93af49bc..fa93bf1e 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -4643,19 +4643,24 @@ unrealize (GtkWidget *widget) } static void +#if GTK_CHECK_VERSION(3,0,0) +style_updated (GtkWidget *widget) +{ + CajaIconContainer *container; + + GTK_WIDGET_CLASS (caja_icon_container_parent_class)->style_updated (widget); + + container = CAJA_ICON_CONTAINER (widget); + container->details->use_drop_shadows = container->details->drop_shadows_requested; +#else style_set (GtkWidget *widget, GtkStyle *previous_style) { CajaIconContainer *container; -#if !GTK_CHECK_VERSION(3,0,0) gboolean frame_text; -#endif container = CAJA_ICON_CONTAINER (widget); -#if GTK_CHECK_VERSION(3,0,0) - container->details->use_drop_shadows = container->details->drop_shadows_requested; -#else gtk_widget_style_get (GTK_WIDGET (container), "frame_text", &frame_text, NULL); @@ -6622,8 +6627,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; -- cgit v1.2.1 From ef3587fbf0d3e83b082ac94054799ce98b2fe52d Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Sat, 9 Jan 2016 02:49:09 +0100 Subject: GTK3 icon-container: remove unused style properties taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=e652eb0 --- libcaja-private/caja-icon-container.c | 47 +++-------------------------------- libcaja-private/caja-icon-private.h | 2 -- 2 files changed, 3 insertions(+), 46 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index fa93bf1e..b9cfa2d6 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -126,7 +126,6 @@ #else #define DEFAULT_LIGHT_INFO_COLOR 0xAAAAFD #define DEFAULT_DARK_INFO_COLOR 0x33337F -#endif #define DEFAULT_NORMAL_ICON_RENDER_MODE 0 #define DEFAULT_PRELIGHT_ICON_RENDER_MODE 1 @@ -136,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 @@ -6647,7 +6647,6 @@ caja_icon_container_class_init (CajaIconContainerClass *class) "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", @@ -6722,7 +6721,6 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 3, DEFAULT_NORMAL_ICON_RENDER_MODE, G_PARAM_READABLE)); -#endif gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("prelight_icon_render_mode", "Prelight Icon Render Mode", @@ -6730,20 +6728,6 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 3, DEFAULT_PRELIGHT_ICON_RENDER_MODE, G_PARAM_READABLE)); -#if GTK_CHECK_VERSION(3,0,0) - gtk_widget_class_install_style_property (widget_class, - g_param_spec_boxed ("normal_icon_rgba", - "Icon Normal RGBA", - "Color used for colorizing icons in normal state (default base[NORMAL])", - GDK_TYPE_RGBA, - G_PARAM_READABLE)); - gtk_widget_class_install_style_property (widget_class, - g_param_spec_boxed ("prelight_icon_rgba", - "Icon Prelight RGBA", - "Color used for colorizing prelighted icons (default base[PRELIGHT])", - GDK_TYPE_RGBA, - G_PARAM_READABLE)); -#else gtk_widget_class_install_style_property (widget_class, g_param_spec_boxed ("normal_icon_color", "Icon Normal Color", @@ -6763,7 +6747,6 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 255, DEFAULT_NORMAL_ICON_SATURATION, G_PARAM_READABLE)); -#endif gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("prelight_icon_saturation", "Prelight Icon Saturation", @@ -6771,7 +6754,6 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 255, DEFAULT_PRELIGHT_ICON_SATURATION, G_PARAM_READABLE)); -#if !GTK_CHECK_VERSION(3,0,0) gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("normal_icon_brightness", "Normal Icon Brightness", @@ -6779,7 +6761,6 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 255, DEFAULT_NORMAL_ICON_BRIGHTNESS, G_PARAM_READABLE)); -#endif gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("prelight_icon_brightness", "Prelight Icon Brightness", @@ -6787,7 +6768,6 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 255, DEFAULT_PRELIGHT_ICON_BRIGHTNESS, G_PARAM_READABLE)); -#if !GTK_CHECK_VERSION(3,0,0) gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("normal_icon_lighten", "Normal Icon Lighten", @@ -6795,7 +6775,6 @@ caja_icon_container_class_init (CajaIconContainerClass *class) 0, 255, DEFAULT_NORMAL_ICON_LIGHTEN, G_PARAM_READABLE)); -#endif gtk_widget_class_install_style_property (widget_class, g_param_spec_uint ("prelight_icon_lighten", "Prelight Icon Lighten", @@ -6803,6 +6782,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", @@ -9748,7 +9728,7 @@ caja_icon_container_theme_changed (gpointer user_data) CajaIconContainer *container; #if GTK_CHECK_VERSION(3,0,0) GtkStyleContext *style; - GdkRGBA *prelight_icon_color, *normal_icon_color, color; + GdkRGBA color; container = CAJA_ICON_CONTAINER (user_data); style = gtk_widget_get_style_context (GTK_WIDGET (container)); @@ -9759,36 +9739,15 @@ caja_icon_container_theme_changed (gpointer user_data) gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color); container->details->active_color_rgba = color; - /* load the prelight icon color */ - gtk_style_context_get_style (style, - "prelight_icon_rgba", &prelight_icon_color, - NULL); gtk_style_context_get_background_color (style, GTK_STATE_FLAG_PRELIGHT, &color); - if (!prelight_icon_color) { - prelight_icon_color = gdk_rgba_copy (&color); - } - - container->details->prelight_icon_color_rgba = *prelight_icon_color; container->details->prelight_color_rgba = color; - /* load the normal icon color */ - gtk_style_context_get_style (style, - "normal_icon_rgba", &normal_icon_color, - NULL); gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color); - if (!normal_icon_color) { - normal_icon_color = gdk_rgba_copy (&color); - } - - container->details->normal_icon_color_rgba = *normal_icon_color; container->details->normal_color_rgba = color; setup_label_gcs (container); - - gdk_rgba_free (prelight_icon_color); - gdk_rgba_free (normal_icon_color); #else GtkStyle *style; GdkColor *prelight_icon_color, *normal_icon_color; diff --git a/libcaja-private/caja-icon-private.h b/libcaja-private/caja-icon-private.h index 0c36188f..e044ca75 100644 --- a/libcaja-private/caja-icon-private.h +++ b/libcaja-private/caja-icon-private.h @@ -216,8 +216,6 @@ struct CajaIconContainerDetails GdkRGBA active_color_rgba; GdkRGBA normal_color_rgba; GdkRGBA prelight_color_rgba; - GdkRGBA prelight_icon_color_rgba; - GdkRGBA normal_icon_color_rgba; /* colors for text labels */ GdkRGBA label_colors [LAST_LABEL_COLOR]; -- cgit v1.2.1 From 8d89b454e7eb52922b2ca3847c0ac909b352e67f Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Sat, 9 Jan 2016 16:09:15 +0100 Subject: GTK3 icon-canvas-item: remove an useless snippet of drawing code taken from: https://git.gnome.org/browse/nautilus/commit/?h=gnome-3-0&id=09f0b79 --- libcaja-private/caja-icon-canvas-item.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index 4bfffebf..d57b439f 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -1466,23 +1466,13 @@ draw_label_text (CajaIconCanvasItem *item, text_rect.y0, is_rtl_label_beside ? text_rect.x1 - text_rect.x0 - item->details->text_dx : text_rect.x1 - text_rect.x0, text_rect.y1 - text_rect.y0); +#if !GTK_CHECK_VERSION(3,0,0) } else if (!needs_highlight && !details->is_renaming && (details->is_prelit || 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, -- cgit v1.2.1 From 8b37981175499c9c876648165ddb7a5f94ae6849 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Sat, 9 Jan 2016 18:12:16 +0100 Subject: GTK3 icon-canvas-item: make the icon frame transparent when not prelit This fixes icons on the desktop appearing weird taken from: https://git.gnome.org/browse/nautilus/commit/?id=6a11ecd --- libcaja-private/caja-icon-canvas-item.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index d57b439f..858a7393 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -1503,20 +1503,19 @@ draw_label_text (CajaIconCanvasItem *item, NULL); #if GTK_CHECK_VERSION(3,0,0) if (!needs_highlight && details->text_width > 0 && details->text_height > 0) + { + if (prelight_label && item->details->is_prelit) { + draw_frame (item, + cr, + &container->details->prelight_color_rgba, #else if (needs_frame && !needs_highlight && details->text_width > 0 && details->text_height > 0) -#endif { if (!(prelight_label && item->details->is_prelit)) { draw_frame (item, -#if GTK_CHECK_VERSION(3,0,0) - cr, - &container->details->normal_color_rgba, -#else drawable, container->details->normal_color_rgba, -#endif create_mask, text_rect.x0, text_rect.y0, @@ -1526,10 +1525,6 @@ draw_label_text (CajaIconCanvasItem *item, else { draw_frame (item, -#if GTK_CHECK_VERSION(3,0,0) - cr, - &container->details->prelight_color_rgba, -#else drawable, container->details->prelight_color_rgba, #endif -- cgit v1.2.1 From e9ecff6c51b4e84fc350ccfe972439ed8dbe7215 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Mon, 11 Jan 2016 15:04:04 +0100 Subject: GTK3 icon-canvas-item: use gtk_render_* methods instead of direct cairo Instead of hardcoding colors and using direct cairo calls to draw the canvas items frame/background/labels, use gtk_render_* methods directly. This has the advantage of making them more friendly with GTK+ themes (by adding a caja-canvas-item style class to the canvas context when drawing) and removes a ton of convolut taken from: https://git.gnome.org/browse/nautilus/commit/?id=95910c9 --- libcaja-private/caja-icon-canvas-item.c | 385 ++++++++++++++++++++------------ 1 file changed, 243 insertions(+), 142 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index 858a7393..d62f2c66 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -224,21 +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, -#if GTK_CHECK_VERSION(3,0,0) - GdkRGBA *label_color, -#else GdkColor *label_color, -#endif int x, int y); +#endif static gboolean hit_test_stretch_handle (CajaIconCanvasItem *item, EelIRect canvas_rect, GtkCornerType *corner); @@ -546,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 @@ -577,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, @@ -626,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)) @@ -997,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. */ @@ -1041,24 +1041,15 @@ make_round_rect (cairo_t *cr, static void draw_frame (CajaIconCanvasItem *item, -#if GTK_CHECK_VERSION(3,0,0) - cairo_t *cr, - GdkRGBA *color, -#else GdkDrawable *drawable, guint color, -#endif gboolean create_mask, int x, int y, 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. @@ -1073,26 +1064,18 @@ draw_frame (CajaIconCanvasItem *item, */ } -#if GTK_CHECK_VERSION(3,0,0) - gdk_cairo_set_source_rgba (cr, color); -#else cairo_set_source_rgba (cr, EEL_RGBA_COLOR_GET_R (color) / 255.0, EEL_RGBA_COLOR_GET_G (color) / 255.0, EEL_RGBA_COLOR_GET_B (color) / 255.0, EEL_RGBA_COLOR_GET_A (color) / 255.0); -#endif /* 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 @@ -1393,9 +1376,190 @@ 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; + 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)); + + state = GTK_STATE_FLAG_NORMAL; + 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) { + if (gtk_widget_has_focus (GTK_WIDGET (container))) { + state |= GTK_STATE_FLAG_SELECTED; + } else { + state |= GTK_STATE_FLAG_ACTIVE; + } + + 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) + { + state = GTK_STATE_FLAG_NORMAL; + + if (prelight_label && item->details->is_prelit) { + state |= GTK_STATE_FLAG_PRELIGHT; + } + + if (needs_highlight && gtk_widget_has_focus (GTK_WIDGET (container))) { + state |= GTK_STATE_FLAG_SELECTED; + } else if (needs_highlight) { + state |= GTK_STATE_FLAG_ACTIVE; + } + + 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) + { + state = GTK_STATE_FLAG_NORMAL; + + if (needs_highlight && gtk_widget_has_focus (GTK_WIDGET (container))) { + state |= GTK_STATE_FLAG_SELECTED; + } else if (needs_highlight) { + state |= GTK_STATE_FLAG_ACTIVE; + } + + 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; + } else { + state = GTK_STATE_FLAG_ACTIVE; + } + + 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) { @@ -1404,17 +1568,9 @@ draw_label_text (CajaIconCanvasItem *item, CajaIconContainer *container; PangoLayout *editable_layout; PangoLayout *additional_layout; -#if GTK_CHECK_VERSION(3,0,0) - GdkRGBA label_color; -#else GdkColor *label_color; -#endif gboolean have_editable, have_additional; -#if GTK_CHECK_VERSION(3,0,0) - gboolean needs_highlight, prelight_label, is_rtl_label_beside; -#else gboolean needs_frame, needs_highlight, prelight_label, is_rtl_label_beside; -#endif EelIRect text_rect; int x; int max_text_width; @@ -1423,7 +1579,6 @@ draw_label_text (CajaIconCanvasItem *item, return; #endif - canvas_item = EEL_CANVAS_ITEM (item); details = item->details; measure_label_text (item); @@ -1434,6 +1589,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); @@ -1450,23 +1606,16 @@ 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, - gtk_widget_has_focus (GTK_WIDGET (container)) ? &container->details->highlight_color_rgba : &container->details->active_color_rgba, -#else drawable, gtk_widget_has_focus (GTK_WIDGET (container)) ? container->details->highlight_color_rgba : container->details->active_color_rgba, -#endif create_mask, is_rtl_label_beside ? text_rect.x0 + item->details->text_dx : text_rect.x0, text_rect.y0, is_rtl_label_beside ? text_rect.x1 - text_rect.x0 - item->details->text_dx : text_rect.x1 - text_rect.x0, text_rect.y1 - text_rect.y0); -#if !GTK_CHECK_VERSION(3,0,0) } else if (!needs_highlight && !details->is_renaming && (details->is_prelit || @@ -1478,7 +1627,6 @@ draw_label_text (CajaIconCanvasItem *item, 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,19 +1644,9 @@ draw_label_text (CajaIconCanvasItem *item, prepare_pango_layout_for_draw (item, editable_layout); gtk_widget_style_get (GTK_WIDGET (container), -#if !GTK_CHECK_VERSION(3,0,0) "frame_text", &needs_frame, -#endif "activate_prelight_icon_label", &prelight_label, NULL); -#if GTK_CHECK_VERSION(3,0,0) - if (!needs_highlight && details->text_width > 0 && details->text_height > 0) - { - if (prelight_label && item->details->is_prelit) { - draw_frame (item, - cr, - &container->details->prelight_color_rgba, -#else if (needs_frame && !needs_highlight && details->text_width > 0 && details->text_height > 0) { if (!(prelight_label && item->details->is_prelit)) @@ -1527,7 +1665,6 @@ draw_label_text (CajaIconCanvasItem *item, draw_frame (item, drawable, container->details->prelight_color_rgba, -#endif create_mask, text_rect.x0, text_rect.y0, @@ -1542,15 +1679,9 @@ draw_label_text (CajaIconCanvasItem *item, prelight_label & item->details->is_prelit); draw_label_layout (item, -#if GTK_CHECK_VERSION(3,0,0) - cr, - editable_layout, needs_highlight, - &label_color, -#else drawable, editable_layout, needs_highlight, label_color, -#endif x, text_rect.y0 + TEXT_BACK_PADDING_Y); } @@ -1566,50 +1697,25 @@ draw_label_text (CajaIconCanvasItem *item, FALSE); draw_label_layout (item, -#if GTK_CHECK_VERSION(3,0,0) - cr, - additional_layout, needs_highlight, - &label_color, -#else drawable, additional_layout, needs_highlight, label_color, -#endif x, text_rect.y0 + details->editable_text_height + LABEL_LINE_SPACING + TEXT_BACK_PADDING_Y); } if (!create_mask && item->details->is_highlighted_as_keyboard_focus) { -#if GTK_CHECK_VERSION(3,0,0) - GtkStyleContext *style; - - style = gtk_widget_get_style_context (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)); - - gtk_style_context_save (style); - gtk_style_context_add_class (style, "icon-container"); - gtk_style_context_set_state (style, - needs_highlight ? - GTK_STATE_FLAG_SELECTED : GTK_STATE_FLAG_ACTIVE); - - gtk_render_focus (style, - cr, -#else gtk_paint_focus (gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)), drawable, needs_highlight ? GTK_STATE_SELECTED : GTK_STATE_NORMAL, NULL, GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas), "icon-container", -#endif text_rect.x0, text_rect.y0, text_rect.x1 - text_rect.x0, text_rect.y1 - text_rect.y0); -#if GTK_CHECK_VERSION(3,0,0) - - gtk_style_context_restore (style); -#endif } if (editable_layout != NULL) @@ -1622,6 +1728,7 @@ draw_label_text (CajaIconCanvasItem *item, g_object_unref (additional_layout); } } +#endif void caja_icon_canvas_item_set_is_visible (CajaIconCanvasItem *item, @@ -1942,7 +2049,10 @@ 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) +#if GTK_CHECK_VERSION(3,0,0) + GtkStyleContext *style; + GdkRGBA color; +#else guint render_mode, saturation, brightness, lighten; #endif @@ -2029,15 +2139,16 @@ real_map_pixbuf (CajaIconCanvasItem *icon_item) || icon_item->details->is_highlighted_for_drop) { #if GTK_CHECK_VERSION(3,0,0) - GdkRGBA *color; - - old_pixbuf = temp_pixbuf; + style = gtk_widget_get_style_context (GTK_WIDGET (canvas)); - color = gtk_widget_has_focus (GTK_WIDGET (canvas)) ? - &CAJA_ICON_CONTAINER (canvas)->details->highlight_color_rgba : - &CAJA_ICON_CONTAINER (canvas)->details->active_color_rgba; + 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); + } - temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, color); + old_pixbuf = temp_pixbuf; + temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, &color); #else guint color; @@ -2186,19 +2297,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; @@ -2208,8 +2328,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); @@ -2218,26 +2353,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 @@ -2249,18 +2373,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 @@ -2379,18 +2504,9 @@ 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, - PangoLayout *layout, - gboolean highlight, - GdkRGBA *label_color, - int x, - int y) -{ - GdkRGBA black = { 0, 0, 0, 1 }; -#else GdkDrawable *drawable, PangoLayout *layout, gboolean highlight, @@ -2399,7 +2515,6 @@ draw_label_layout (CajaIconCanvasItem *item, int y) { g_return_if_fail (drawable != NULL); -#endif if (item->details->is_renaming) { @@ -2409,36 +2524,22 @@ 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, - label_color, - &black, -#else eel_gdk_draw_layout_with_drop_shadow (drawable, label_color, >k_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas))->black, -#endif x, y, layout); } else { -#if GTK_CHECK_VERSION(3,0,0) - cairo_save (cr); - gdk_cairo_set_source_rgba (cr, label_color); -#else cairo_t *cr = gdk_cairo_create (drawable); gdk_cairo_set_source_color (cr, label_color); -#endif 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 */ -- cgit v1.2.1 From 5ec02960d6f78dd23b02af27e6f3c595ab4e99bc Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Mon, 11 Jan 2016 15:08:16 +0100 Subject: GTK3 icon-container: remove unused code caching canvas item colors Caching colors in CajaIconContainer to use them in the canvas item is not needed anymore, as gtk_render_* fetches the right values directly from the style context. taken from: https://git.gnome.org/browse/nautilus/commit/?id=77eecef --- libcaja-private/caja-icon-container.c | 133 ++++------------------------------ libcaja-private/caja-icon-private.h | 16 +--- 2 files changed, 18 insertions(+), 131 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index b9cfa2d6..d7fc3545 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -181,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); @@ -207,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); @@ -4612,7 +4616,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", @@ -4666,9 +4672,9 @@ style_set (GtkWidget *widget, NULL); container->details->use_drop_shadows = container->details->drop_shadows_requested && !frame_text; -#endif caja_icon_container_theme_changed (CAJA_ICON_CONTAINER (widget)); +#endif if (gtk_widget_get_realized (widget)) { @@ -6948,8 +6954,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); @@ -6958,8 +6966,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) { @@ -9380,16 +9390,12 @@ 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, -#if GTK_CHECK_VERSION(3,0,0) - GdkRGBA *color, -#else GdkColor **color, -#endif gboolean is_name, gboolean is_highlight, gboolean is_prelit) @@ -9442,24 +9448,14 @@ caja_icon_container_get_label_color (CajaIconContainer *container, if (color) { -#if GTK_CHECK_VERSION(3,0,0) - *color = container->details->label_colors[idx]; -#else *color = &container->details->label_colors [idx]; -#endif } } static void -#if GTK_CHECK_VERSION(3,0,0) -setup_gc_with_fg (CajaIconContainer *container, int idx, GdkRGBA *color) -{ - container->details->label_colors[idx] = *color; -#else setup_gc_with_fg (CajaIconContainer *container, int idx, guint32 color) { container->details->label_colors [idx] = eel_gdk_rgb_to_color (color); -#endif } static void @@ -9467,16 +9463,10 @@ setup_label_gcs (CajaIconContainer *container) { EelBackground *background; GtkWidget *widget; -#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; gboolean frame_text; GtkStyle *style; -#endif if (!gtk_widget_get_realized (GTK_WIDGET (container))) return; @@ -9488,76 +9478,6 @@ setup_label_gcs (CajaIconContainer *container) background = eel_get_widget_background (GTK_WIDGET (container)); /* 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 (widget); - gtk_style_context_get_style (style, - "light_info_rgba", &light_info_color, - "dark_info_rgba", &dark_info_color, - NULL); - - if (!light_info_color) - { - gdk_rgba_parse (&color, DEFAULT_LIGHT_INFO_COLOR); - light_info_color = gdk_rgba_copy (&color); - } - - if (!dark_info_color) - { - gdk_rgba_parse (&color, DEFAULT_DARK_INFO_COLOR); - dark_info_color = gdk_rgba_copy (&color); - } - - gtk_style_context_get_color (style, GTK_STATE_FLAG_SELECTED, &color); - setup_gc_with_fg (container, LABEL_COLOR_HIGHLIGHT, &color); - - gtk_style_context_get_color (style, GTK_STATE_FLAG_ACTIVE, &color); - setup_gc_with_fg (container, LABEL_COLOR_ACTIVE, &color); - - gtk_style_context_get_color (style, GTK_STATE_FLAG_PRELIGHT, &color); - setup_gc_with_fg (container, LABEL_COLOR_PRELIGHT, &color); - - gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &color); - setup_gc_with_fg (container, - 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 (container, - LABEL_INFO_COLOR_ACTIVE, - eel_gdk_rgba_is_dark (&color) ? light_info_color : dark_info_color); - - if (!caja_icon_container_get_is_desktop (container)) - { - gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &color); - setup_gc_with_fg (container, LABEL_COLOR, &color); - - gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color); - setup_gc_with_fg (container, LABEL_INFO_COLOR, - eel_gdk_rgba_is_dark (&color) ? - light_info_color : dark_info_color); - } - else - { - if (container->details->use_drop_shadows || eel_background_is_dark (background)) - { - GdkRGBA tmp; - - gdk_rgba_parse (&tmp, "#EFEFEF"); - setup_gc_with_fg (container, LABEL_COLOR, &tmp); - setup_gc_with_fg (container, LABEL_INFO_COLOR, light_info_color); - } - else /* converse */ - { - GdkRGBA tmp; - - gdk_rgba_parse (&tmp, "#000000"); - setup_gc_with_fg (container, LABEL_COLOR, &tmp); - setup_gc_with_fg (container, LABEL_INFO_COLOR, dark_info_color); - } - } - gdk_rgba_free (dark_info_color); - gdk_rgba_free (light_info_color); -#else gtk_widget_style_get (GTK_WIDGET (container), "light_info_color", &light_info_color, "dark_info_color", &dark_info_color, @@ -9627,7 +9547,6 @@ setup_label_gcs (CajaIconContainer *container) dark_info_value); } } -#endif } static void @@ -9638,7 +9557,7 @@ update_label_color (EelBackground *background, setup_label_gcs (container); } - +#endif /* Return if the icon container is a fixed size */ gboolean @@ -9722,33 +9641,11 @@ caja_icon_container_set_use_drop_shadows (CajaIconContainer *container, /* handle theme changes */ +#if !GTK_CHECK_VERSION(3,0,0) static void caja_icon_container_theme_changed (gpointer user_data) { CajaIconContainer *container; -#if GTK_CHECK_VERSION(3,0,0) - GtkStyleContext *style; - GdkRGBA color; - - container = CAJA_ICON_CONTAINER (user_data); - style = gtk_widget_get_style_context (GTK_WIDGET (container)); - - gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &color); - container->details->highlight_color_rgba = color; - - gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color); - container->details->active_color_rgba = color; - - gtk_style_context_get_background_color (style, GTK_STATE_FLAG_PRELIGHT, &color); - - container->details->prelight_color_rgba = color; - - gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color); - - container->details->normal_color_rgba = color; - - setup_label_gcs (container); -#else GtkStyle *style; GdkColor *prelight_icon_color, *normal_icon_color; guchar highlight_alpha, normal_alpha, prelight_alpha; @@ -9843,8 +9740,8 @@ caja_icon_container_theme_changed (gpointer user_data) prelight_alpha); setup_label_gcs (container); -#endif } +#endif void caja_icon_container_set_font (CajaIconContainer *container, diff --git a/libcaja-private/caja-icon-private.h b/libcaja-private/caja-icon-private.h index e044ca75..9364bab7 100644 --- a/libcaja-private/caja-icon-private.h +++ b/libcaja-private/caja-icon-private.h @@ -211,15 +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) - GdkRGBA highlight_color_rgba; - GdkRGBA active_color_rgba; - GdkRGBA normal_color_rgba; - GdkRGBA prelight_color_rgba; - - /* colors for text labels */ - GdkRGBA label_colors [LAST_LABEL_COLOR]; -#else +#if !GTK_CHECK_VERSION(3,0,0) guint32 highlight_color_rgba; guint32 active_color_rgba; guint32 normal_color_rgba; @@ -335,15 +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, -#if GTK_CHECK_VERSION(3,0,0) - GdkRGBA *color, -#else GdkColor **color, -#endif gboolean first_line, gboolean needs_highlight, gboolean is_prelit); +#endif #endif /* CAJA_ICON_CONTAINER_PRIVATE_H */ -- cgit v1.2.1 From 412486b1f4c8a0a60d9aa07b39e38ed66852ae3d Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Mon, 11 Jan 2016 17:48:12 +0100 Subject: GTK3 icon-canvas-item: render the additional text with gtk_render_layout() And add a style class for it. taken from: https://git.gnome.org/browse/nautilus/commit/?id=7732a6b https://git.gnome.org/browse/nautilus/commit/?id=2cb91c0 --- libcaja-private/caja-icon-canvas-item.c | 35 +++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index d62f2c66..69b06bee 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -2237,6 +2237,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 || @@ -2245,13 +2249,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); @@ -2266,10 +2278,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, @@ -2284,9 +2314,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 } -- cgit v1.2.1 From 8e4612599a9a6cb1f380dd6cbef9ad3d885cf77f Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Mon, 11 Jan 2016 17:56:38 +0100 Subject: GTK3 icon-canvas-item: don't draw pango layouts when renaming Fixes a regression introduced in commit 3a858857fff5e1d7e0bffcec63fea6d2a933ce27 that causes unwanted text to be drawn while renaming a file in icon view. taken from: https://git.gnome.org/browse/nautilus/commit/?id=f07aa75 --- libcaja-private/caja-icon-canvas-item.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index 69b06bee..3d719d5a 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -1478,7 +1478,8 @@ draw_label_text (CajaIconCanvasItem *item, x = text_rect.x0 + ((text_rect.x1 - text_rect.x0) - max_text_width) / 2; } - if (have_editable) + if (have_editable && + !details->is_renaming) { state = GTK_STATE_FLAG_NORMAL; @@ -1505,7 +1506,8 @@ draw_label_text (CajaIconCanvasItem *item, gtk_style_context_restore (context); } - if (have_additional) + if (have_additional && + !details->is_renaming) { state = GTK_STATE_FLAG_NORMAL; -- cgit v1.2.1 From 4974f96274a7cbc0056983dea03b2d42615714e4 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Mon, 11 Jan 2016 18:36:08 +0100 Subject: GTK3 icon-canvas-item: don't override parent container style flags When drawing the canvas item elements, don't override the parent container style flags, so we don't lose e.g. backdrop information. taken from: https://git.gnome.org/browse/nautilus/commit/?id=31dad6f --- libcaja-private/caja-icon-canvas-item.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index 3d719d5a..803cde76 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -1384,7 +1384,7 @@ draw_label_text (CajaIconCanvasItem *item, PangoLayout *editable_layout; PangoLayout *additional_layout; GtkStyleContext *context; - GtkStateFlags state; + GtkStateFlags state, base_state; gboolean have_editable, have_additional; gboolean needs_highlight, prelight_label, is_rtl_label_beside; EelIRect text_rect; @@ -1424,7 +1424,10 @@ draw_label_text (CajaIconCanvasItem *item, max_text_width = floor (caja_icon_canvas_item_get_max_text_width (item)); - state = GTK_STATE_FLAG_NORMAL; + 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); @@ -1432,11 +1435,7 @@ draw_label_text (CajaIconCanvasItem *item, /* if the icon is highlighted, do some set-up */ if (needs_highlight && !details->is_renaming) { - if (gtk_widget_has_focus (GTK_WIDGET (container))) { - state |= GTK_STATE_FLAG_SELECTED; - } else { - state |= GTK_STATE_FLAG_ACTIVE; - } + 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; @@ -1481,16 +1480,14 @@ draw_label_text (CajaIconCanvasItem *item, if (have_editable && !details->is_renaming) { - state = GTK_STATE_FLAG_NORMAL; + state = base_state; if (prelight_label && item->details->is_prelit) { state |= GTK_STATE_FLAG_PRELIGHT; } - if (needs_highlight && gtk_widget_has_focus (GTK_WIDGET (container))) { + if (needs_highlight) { state |= GTK_STATE_FLAG_SELECTED; - } else if (needs_highlight) { - state |= GTK_STATE_FLAG_ACTIVE; } editable_layout = get_label_layout (&item->details->editable_text_layout, item, item->details->editable_text); @@ -1509,12 +1506,10 @@ draw_label_text (CajaIconCanvasItem *item, if (have_additional && !details->is_renaming) { - state = GTK_STATE_FLAG_NORMAL; + state = base_state; - if (needs_highlight && gtk_widget_has_focus (GTK_WIDGET (container))) { + if (needs_highlight) { state |= GTK_STATE_FLAG_SELECTED; - } else if (needs_highlight) { - state |= GTK_STATE_FLAG_ACTIVE; } additional_layout = get_label_layout (&item->details->additional_text_layout, item, item->details->additional_text); @@ -1533,8 +1528,6 @@ draw_label_text (CajaIconCanvasItem *item, { if (needs_highlight) { state = GTK_STATE_FLAG_SELECTED; - } else { - state = GTK_STATE_FLAG_ACTIVE; } gtk_style_context_save (context); -- cgit v1.2.1 From 43e928f798eec8035a00ab9f58a0bc43a31f8ab8 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Mon, 11 Jan 2016 19:29:39 +0100 Subject: GTK3 icon-container: use the "rubberband" style class for the selection item Instead of using a custom style property. Autor: lukefromdc same as: https://git.gnome.org/browse/nautilus/commit/?id=ca7f81e2 --- libcaja-private/caja-icon-container.c | 121 ++++++++++++++++++++++------------ 1 file changed, 78 insertions(+), 43 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index d7fc3545..40a02167 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -2880,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) @@ -2887,19 +2964,12 @@ start_rubberbanding (CajaIconContainer *container, AtkObject *accessible; CajaIconContainerDetails *details; CajaIconRubberbandInfo *band_info; -#if GTK_CHECK_VERSION(3,0,0) - GdkRGBA *fill_color_gdk, outline, color; - GList *p; - CajaIcon *icon; - GtkStyleContext *style; -#else guint fill_color, outline_color; GdkColor *fill_color_gdk; guchar fill_color_alpha; GList *p; CajaIcon *icon; GtkStyle *style; -#endif details = container->details; band_info = &details->rubberband_info; @@ -2917,41 +2987,6 @@ start_rubberbanding (CajaIconContainer *container, (EEL_CANVAS (container), event->x, event->y, &band_info->start_x, &band_info->start_y); -#if GTK_CHECK_VERSION(3,0,0) - style = gtk_widget_get_style_context (GTK_WIDGET (container)); - gtk_style_context_get_style (style, - "selection_box_rgba", &fill_color_gdk, - NULL); - - if (!fill_color_gdk) - { - gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, - &color); - fill_color_gdk = gdk_rgba_copy (&color); - } - - if (fill_color_gdk->alpha == 1) { - fill_color_gdk->alpha = 0.25; - } - - outline = *fill_color_gdk; - eel_make_color_inactive (&outline); - - 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", fill_color_gdk, - "outline_color_rgba", &outline, - "width_pixels", 1, - NULL); - - gdk_rgba_free (fill_color_gdk); -#else gtk_widget_style_get (GTK_WIDGET (container), "selection_box_color", &fill_color_gdk, "selection_box_alpha", &fill_color_alpha, @@ -2981,7 +3016,6 @@ start_rubberbanding (CajaIconContainer *container, "outline_color_rgba", outline_color, "width_pixels", 1, NULL); -#endif accessible = atk_gobject_accessible_for_object (G_OBJECT (band_info->selection_rectangle)); @@ -3007,6 +3041,7 @@ start_rubberbanding (CajaIconContainer *container, | GDK_SCROLL_MASK), NULL, event->time); } +#endif static void stop_rubberbanding (CajaIconContainer *container, -- cgit v1.2.1 From 2c8e8a06a050d43d730475bf05cbd07508f32160 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Mon, 11 Jan 2016 20:38:24 +0100 Subject: GTK3 icon-container: don't chain up style-updated for the desktop container Chaining up resets the background to the default color, which is not what we want for the desktop container. Fixes https://github.com/mate-desktop/caja/issues/445 taken from: https://git.gnome.org/browse/nautilus/commit/?id=83a7d27 --- libcaja-private/caja-icon-container.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 40a02167..066da73f 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -4689,10 +4689,21 @@ style_updated (GtkWidget *widget) { CajaIconContainer *container; - GTK_WIDGET_CLASS (caja_icon_container_parent_class)->style_updated (widget); - 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_label_sizes (container); + caja_icon_container_request_update_all (container); + } #else style_set (GtkWidget *widget, GtkStyle *previous_style) @@ -4709,7 +4720,6 @@ style_set (GtkWidget *widget, container->details->use_drop_shadows = container->details->drop_shadows_requested && !frame_text; caja_icon_container_theme_changed (CAJA_ICON_CONTAINER (widget)); -#endif if (gtk_widget_get_realized (widget)) { @@ -4719,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 -- cgit v1.2.1 From 4b2d71fef886fbdffd8d1a03a337cf1e794d1252 Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Mon, 11 Jan 2016 22:25:23 +0100 Subject: GTK3 icon-container: invalidate the layout cache on style-updated This way label sizes will be recomputed if e.g. DPI settings change. https://bugzilla.gnome.org/show_bug.cgi?id=578468 taken from: https://git.gnome.org/browse/nautilus/commit/?id=2f064e5 --- libcaja-private/caja-icon-container.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 066da73f..2cec67a5 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -4701,7 +4701,7 @@ style_updated (GtkWidget *widget) if (gtk_widget_get_realized (widget)) { - invalidate_label_sizes (container); + invalidate_labels (container); caja_icon_container_request_update_all (container); } #else -- cgit v1.2.1 From 1befe8ddf08c12b5c926d269b31d270fb94b9c3e Mon Sep 17 00:00:00 2001 From: Wolfgang Ulbrich Date: Tue, 12 Jan 2016 01:21:41 +0100 Subject: GTK3 file-conflict-dialog: don't use override_font Set the PangoAttributeList on the GtkLabel instead. and 'don't force a size request on the labels' This is not required anymore in GTK+ 3 taken from: https://git.gnome.org/browse/nautilus/commit/?id=52b8185 https://git.gnome.org/browse/nautilus/commit/?id=b8077a7 https://git.gnome.org/browse/nautilus/commit/?id=1457f53 --- libcaja-private/caja-file-conflict-dialog.c | 32 +++++++++++++---------------- 1 file changed, 14 insertions(+), 18 deletions(-) (limited to 'libcaja-private') diff --git a/libcaja-private/caja-file-conflict-dialog.c b/libcaja-private/caja-file-conflict-dialog.c index 28887f88..300543b3 100644 --- a/libcaja-private/caja-file-conflict-dialog.c +++ b/libcaja-private/caja-file-conflict-dialog.c @@ -116,8 +116,7 @@ file_list_ready_cb (GList *files, GtkWidget *label; GString *str; #if GTK_CHECK_VERSION(3,0,0) - PangoFontDescription *desc, *old_desc; - GtkStyleContext *style; + PangoAttrList *attr_list; #else PangoFontDescription *desc; #endif @@ -221,25 +220,22 @@ 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); - style = gtk_widget_get_style_context (label); - gtk_style_context_get_style (style, - GTK_STYLE_PROPERTY_FONT, &old_desc, - NULL); + 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); - desc = pango_font_description_new (); - pango_font_description_set_weight (desc, PANGO_WEIGHT_BOLD); - pango_font_description_set_size (desc, - pango_font_description_get_size (old_desc) * PANGO_SCALE_LARGE); - gtk_widget_override_font (label, desc); - pango_font_description_free (desc); - pango_font_description_free (old_desc); + 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); gtk_box_pack_start (GTK_BOX (details->titles_vbox), label, FALSE, FALSE, 0); @@ -252,15 +248,15 @@ file_list_ready_cb (GList *files, pango_font_description_get_size (gtk_widget_get_style (label)->font_desc) * PANGO_SCALE_LARGE); gtk_widget_modify_font (label, desc); pango_font_description_free (desc); -#endif 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), -- cgit v1.2.1