30
30
#include "nautilus-icon-container.h"
32
#include "nautilus-debug-log.h"
33
32
#include "nautilus-global-preferences.h"
34
33
#include "nautilus-icon-private.h"
35
34
#include "nautilus-lib-self-check-functions.h"
35
#include "nautilus-selection-canvas-item.h"
36
36
#include "nautilus-marshal.h"
37
37
#include <atk/atkaction.h>
38
38
#include <eel/eel-accessibility.h>
39
#include <eel/eel-background.h>
40
39
#include <eel/eel-vfs-extensions.h>
41
#include <eel/eel-gdk-pixbuf-extensions.h>
42
#include <eel/eel-gnome-extensions.h>
43
40
#include <eel/eel-gtk-extensions.h>
44
41
#include <eel/eel-art-extensions.h>
45
42
#include <eel/eel-editable-label.h>
46
#include <eel/eel-marshal.h>
47
#include <eel/eel-string.h>
48
#include <eel/eel-preferences.h>
49
#include <eel/eel-enumeration.h>
50
#include <eel/eel-canvas-rect-ellipse.h>
51
44
#include <gdk/gdkkeysyms.h>
52
45
#include <gtk/gtk.h>
53
46
#include <gdk/gdkx.h>
1979
1936
GList *p, *placed_icons, *unplaced_icons;
1980
1937
int total, new_length, placed;
1981
1938
NautilusIcon *icon;
1982
int width, height, max_width, column_width, icon_width, icon_height;
1939
int height, max_width, column_width, icon_width, icon_height;
1983
1940
int x, y, x1, x2, y1, y2;
1984
1941
EelDRect icon_rect;
1985
1942
GtkAllocation allocation;
1987
1944
/* Get container dimensions */
1988
1945
gtk_widget_get_allocation (GTK_WIDGET (container), &allocation);
1989
width = CANVAS_WIDTH(container, allocation);
1990
1946
height = CANVAS_HEIGHT(container, allocation);
1992
1948
/* Determine which icons have and have not been placed */
2677
2629
(EEL_CANVAS (container), event->x, event->y,
2678
2630
&band_info->start_x, &band_info->start_y);
2680
gtk_widget_style_get (GTK_WIDGET (container),
2681
"selection_box_color", &fill_color_gdk,
2682
"selection_box_alpha", &fill_color_alpha,
2632
style = gtk_widget_get_style_context (GTK_WIDGET (container));
2633
gtk_style_context_get_style (style,
2634
"selection_box_rgba", &fill_color_gdk,
2685
2637
if (!fill_color_gdk) {
2686
style = gtk_widget_get_style (GTK_WIDGET (container));
2687
fill_color_gdk = gdk_color_copy (&style->base[GTK_STATE_SELECTED]);
2690
fill_color = eel_gdk_color_to_rgb (fill_color_gdk) << 8 | fill_color_alpha;
2692
gdk_color_free (fill_color_gdk);
2694
outline_color = fill_color | 255;
2638
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED,
2640
fill_color_gdk = gdk_rgba_copy (&color);
2643
if (fill_color_gdk->alpha == 1) {
2644
fill_color_gdk->alpha = 0.25;
2647
outline = *fill_color_gdk;
2648
eel_make_color_inactive (&outline);
2696
2650
band_info->selection_rectangle = eel_canvas_item_new
2697
2651
(eel_canvas_root
2698
2652
(EEL_CANVAS (container)),
2699
EEL_TYPE_CANVAS_RECT,
2653
NAUTILUS_TYPE_SELECTION_CANVAS_ITEM,
2700
2654
"x1", band_info->start_x,
2701
2655
"y1", band_info->start_y,
2702
2656
"x2", band_info->start_x,
2703
2657
"y2", band_info->start_y,
2704
"fill_color_rgba", fill_color,
2705
"outline_color_rgba", outline_color,
2658
"fill_color_rgba", fill_color_gdk,
2659
"outline_color_rgba", &outline,
2706
2660
"width_pixels", 1,
2663
gdk_rgba_free (fill_color_gdk);
2709
2665
accessible = atk_gobject_accessible_for_object
2710
2666
(G_OBJECT (band_info->selection_rectangle));
2711
2667
atk_object_set_name (accessible, "selection");
2712
2668
atk_object_set_description (accessible, _("The selection rectangle"));
2714
band_info->prev_x = event->x - gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container)));
2715
band_info->prev_y = event->y - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container)));
2670
band_info->prev_x = event->x - gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)));
2671
band_info->prev_y = event->y - gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)));
2717
2673
band_info->active = TRUE;
4102
setup_background (NautilusIconContainer *container)
4106
GtkStyleContext *style;
4108
if (container->details->is_desktop) {
4112
style = gtk_widget_get_style_context (GTK_WIDGET (container));
4114
DEBUG ("Container %p: setting up background, is_active %d", container,
4115
container->details->active_background);
4117
window = gtk_layout_get_bin_window (GTK_LAYOUT (container));
4119
if (!container->details->active_background) {
4120
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color);
4122
DEBUG ("Container %p, making color inactive", container);
4123
eel_make_color_inactive (&color);
4125
gtk_widget_override_background_color (GTK_WIDGET (container), GTK_STATE_FLAG_NORMAL,
4127
gtk_style_context_set_background (style, window);
4129
DEBUG ("Container %p, removing color override", container);
4130
gtk_widget_override_background_color (GTK_WIDGET (container), GTK_STATE_FLAG_NORMAL,
4132
gtk_style_context_set_background (style, window);
4154
4137
realize (GtkWidget *widget)
4157
4139
GtkAdjustment *vadj, *hadj;
4158
4140
NautilusIconContainer *container;
4164
4146
/* Ensure that the desktop window is native so the background
4165
4147
set on it is drawn by X. */
4166
4148
if (container->details->is_desktop) {
4167
gdk_x11_drawable_get_xid (gtk_layout_get_bin_window (GTK_LAYOUT (widget)));
4149
gdk_x11_window_get_xid (gtk_layout_get_bin_window (GTK_LAYOUT (widget)));
4170
4152
/* Set up DnD. */
4171
nautilus_icon_dnd_init (container, NULL);
4153
nautilus_icon_dnd_init (container);
4155
setup_background (container);
4173
4156
setup_label_gcs (container);
4175
stipple = eel_stipple_bitmap_for_screen
4176
(gdk_drawable_get_screen (GDK_DRAWABLE (gtk_widget_get_window (widget))));
4178
nautilus_icon_dnd_set_stipple (container, stipple);
4180
hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (widget));
4158
hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (widget));
4181
4159
g_signal_connect (hadj, "value_changed",
4182
4160
G_CALLBACK (handle_hadjustment_changed), widget);
4184
vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (widget));
4162
vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (widget));
4185
4163
g_signal_connect (vadj, "value_changed",
4186
4164
G_CALLBACK (handle_vadjustment_changed), widget);
4216
style_set (GtkWidget *widget,
4217
GtkStyle *previous_style)
4186
style_updated (GtkWidget *widget)
4219
4188
NautilusIconContainer *container;
4220
gboolean frame_text;
4222
4190
container = NAUTILUS_ICON_CONTAINER (widget);
4224
gtk_widget_style_get (GTK_WIDGET (container),
4225
"frame_text", &frame_text,
4228
container->details->use_drop_shadows = container->details->drop_shadows_requested && !frame_text;
4230
nautilus_icon_container_theme_changed (NAUTILUS_ICON_CONTAINER (widget));
4191
container->details->use_drop_shadows = container->details->drop_shadows_requested;
4193
/* Don't chain up to parent, if this is a desktop container,
4194
* because that resets the background of the window.
4196
if (!nautilus_icon_container_get_is_desktop (container)) {
4197
GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->style_updated (widget);
4200
nautilus_icon_container_theme_changed (NAUTILUS_ICON_CONTAINER (widget));
4232
4202
if (gtk_widget_get_realized (widget)) {
4233
4203
invalidate_label_sizes (container);
4234
4204
nautilus_icon_container_request_update_all (container);
4237
/* Don't chain up to parent, because that sets the background of the window and we're doing
4238
that ourself with some delay, so this would cause flickering */
4241
4208
static gboolean
5157
5127
/* select previous matching iter */
5158
if (event->keyval == GDK_Up || event->keyval == GDK_KP_Up) {
5128
if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_KP_Up) {
5159
5129
nautilus_icon_container_search_move (widget, container, TRUE);
5163
5133
if (((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == (GDK_CONTROL_MASK | GDK_SHIFT_MASK))
5164
&& (event->keyval == GDK_g || event->keyval == GDK_G)) {
5134
&& (event->keyval == GDK_KEY_g || event->keyval == GDK_KEY_G)) {
5165
5135
nautilus_icon_container_search_move (widget, container, TRUE);
5169
5139
/* select next matching iter */
5170
if (event->keyval == GDK_Down || event->keyval == GDK_KP_Down) {
5140
if (event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down) {
5171
5141
nautilus_icon_container_search_move (widget, container, FALSE);
5175
5145
if (((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK)
5176
&& (event->keyval == GDK_g || event->keyval == GDK_G)) {
5146
&& (event->keyval == GDK_KEY_g || event->keyval == GDK_KEY_G)) {
5177
5147
nautilus_icon_container_search_move (widget, container, FALSE);
5387
5358
switch (event->keyval) {
5360
case GDK_KEY_KP_Home:
5390
5361
keyboard_home (container, event);
5391
5362
handled = TRUE;
5365
case GDK_KEY_KP_End:
5395
5366
keyboard_end (container, event);
5396
5367
handled = TRUE;
5370
case GDK_KEY_KP_Left:
5400
5371
/* Don't eat Alt-Left, as that is used for history browsing */
5401
5372
if ((event->state & GDK_MOD1_MASK) == 0) {
5402
5373
keyboard_left (container, event);
5403
5374
handled = TRUE;
5408
5379
/* Don't eat Alt-Up, as that is used for alt-shift-Up */
5409
5380
if ((event->state & GDK_MOD1_MASK) == 0) {
5410
5381
keyboard_up (container, event);
5411
5382
handled = TRUE;
5386
case GDK_KEY_KP_Right:
5416
5387
/* Don't eat Alt-Right, as that is used for history browsing */
5417
5388
if ((event->state & GDK_MOD1_MASK) == 0) {
5418
5389
keyboard_right (container, event);
5419
5390
handled = TRUE;
5394
case GDK_KEY_KP_Down:
5424
5395
/* Don't eat Alt-Down, as that is used for Open */
5425
5396
if ((event->state & GDK_MOD1_MASK) == 0) {
5426
5397
keyboard_down (container, event);
5427
5398
handled = TRUE;
5431
5402
keyboard_space (container, event);
5432
5403
handled = TRUE;
5434
5405
#ifndef TAB_NAVIGATION_DISABLED
5436
case GDK_ISO_Left_Tab:
5407
case GDK_KEY_ISO_Left_Tab:
5437
5408
select_previous_or_next_icon (container,
5438
5409
(event->state & GDK_SHIFT_MASK) == 0, event);
5439
5410
handled = TRUE;
5413
case GDK_KEY_Return:
5414
case GDK_KEY_KP_Enter:
5444
5415
if ((event->state & GDK_SHIFT_MASK) != 0) {
5445
5416
activate_selected_items_alternate (container, NULL);
5654
5613
container = NAUTILUS_ICON_CONTAINER (object);
5655
5614
if (nautilus_icon_container_get_is_desktop (container)) {
5656
eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_DESKTOP_TEXT_ELLIPSIS_LIMIT,
5657
text_ellipsis_limit_changed_container_callback,
5658
container, G_OBJECT (container));
5615
g_signal_connect_swapped (nautilus_desktop_preferences,
5616
"changed::" NAUTILUS_PREFERENCES_DESKTOP_TEXT_ELLIPSIS_LIMIT,
5617
G_CALLBACK (text_ellipsis_limit_changed_container_callback),
5660
eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
5661
text_ellipsis_limit_changed_container_callback,
5662
container, G_OBJECT (container));
5620
g_signal_connect_swapped (nautilus_icon_view_preferences,
5621
"changed::" NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
5622
G_CALLBACK (text_ellipsis_limit_changed_container_callback),
6037
5997
widget_class->key_press_event = key_press_event;
6038
5998
widget_class->popup_menu = popup_menu;
6039
5999
widget_class->get_accessible = get_accessible;
6040
widget_class->style_set = style_set;
6041
widget_class->expose_event = expose_event;
6000
widget_class->style_updated = style_updated;
6042
6001
widget_class->grab_notify = grab_notify_cb;
6044
6003
canvas_class = EEL_CANVAS_CLASS (class);
6045
6004
canvas_class->draw_background = draw_canvas_background;
6047
6006
class->start_interactive_search = nautilus_icon_container_start_interactive_search;
6049
gtk_widget_class_install_style_property (widget_class,
6050
g_param_spec_boolean ("frame_text",
6052
"Draw a frame around unselected text",
6056
6008
gtk_widget_class_install_style_property (widget_class,
6057
g_param_spec_boxed ("selection_box_color",
6058
"Selection Box Color",
6009
g_param_spec_boxed ("selection_box_rgba",
6010
"Selection Box RGBA",
6059
6011
"Color of the selection box",
6062
gtk_widget_class_install_style_property (widget_class,
6063
g_param_spec_uchar ("selection_box_alpha",
6064
"Selection Box Alpha",
6065
"Opacity of the selection box",
6067
DEFAULT_SELECTION_BOX_ALPHA,
6070
gtk_widget_class_install_style_property (widget_class,
6071
g_param_spec_uchar ("highlight_alpha",
6073
"Opacity of the highlight for selected icons",
6075
DEFAULT_HIGHLIGHT_ALPHA,
6077
gtk_widget_class_install_style_property (widget_class,
6078
g_param_spec_uchar ("normal_alpha",
6080
"Opacity of the normal icons if frame_text is set",
6082
DEFAULT_NORMAL_ALPHA,
6084
gtk_widget_class_install_style_property (widget_class,
6085
g_param_spec_uchar ("prelight_alpha",
6087
"Opacity of the prelight icons if frame_text is set",
6089
DEFAULT_PRELIGHT_ALPHA,
6091
gtk_widget_class_install_style_property (widget_class,
6092
g_param_spec_boxed ("light_info_color",
6094
"Color used for information text against a dark background",
6097
gtk_widget_class_install_style_property (widget_class,
6098
g_param_spec_boxed ("dark_info_color",
6100
"Color used for information text against a light background",
6104
gtk_widget_class_install_style_property (widget_class,
6105
g_param_spec_uint ("normal_icon_render_mode",
6106
"Normal Icon Render Mode",
6107
"Mode of normal icons being rendered (0=normal, 1=spotlight, 2=colorize, 3=colorize-monochromely)",
6109
DEFAULT_NORMAL_ICON_RENDER_MODE,
6111
gtk_widget_class_install_style_property (widget_class,
6112
g_param_spec_uint ("prelight_icon_render_mode",
6113
"Prelight Icon Render Mode",
6114
"Mode of prelight icons being rendered (0=normal, 1=spotlight, 2=colorize, 3=colorize-monochromely)",
6116
DEFAULT_PRELIGHT_ICON_RENDER_MODE,
6118
gtk_widget_class_install_style_property (widget_class,
6119
g_param_spec_boxed ("normal_icon_color",
6120
"Icon Normal Color",
6121
"Color used for colorizing icons in normal state (default base[NORMAL])",
6124
gtk_widget_class_install_style_property (widget_class,
6125
g_param_spec_boxed ("prelight_icon_color",
6126
"Icon Prelight Color",
6127
"Color used for colorizing prelighted icons (default base[PRELIGHT])",
6130
gtk_widget_class_install_style_property (widget_class,
6131
g_param_spec_uint ("normal_icon_saturation",
6132
"Normal Icon Saturation",
6133
"Saturation of icons in normal state",
6135
DEFAULT_NORMAL_ICON_SATURATION,
6137
gtk_widget_class_install_style_property (widget_class,
6138
g_param_spec_uint ("prelight_icon_saturation",
6139
"Prelight Icon Saturation",
6140
"Saturation of icons in prelight state",
6142
DEFAULT_PRELIGHT_ICON_SATURATION,
6144
gtk_widget_class_install_style_property (widget_class,
6145
g_param_spec_uint ("normal_icon_brightness",
6146
"Normal Icon Brightness",
6147
"Brightness of icons in normal state",
6149
DEFAULT_NORMAL_ICON_BRIGHTNESS,
6151
gtk_widget_class_install_style_property (widget_class,
6152
g_param_spec_uint ("prelight_icon_brightness",
6153
"Prelight Icon Brightness",
6154
"Brightness of icons in prelight state",
6156
DEFAULT_PRELIGHT_ICON_BRIGHTNESS,
6158
gtk_widget_class_install_style_property (widget_class,
6159
g_param_spec_uint ("normal_icon_lighten",
6160
"Normal Icon Lighten",
6161
"Lighten icons in normal state",
6163
DEFAULT_NORMAL_ICON_LIGHTEN,
6165
gtk_widget_class_install_style_property (widget_class,
6166
g_param_spec_uint ("prelight_icon_lighten",
6167
"Prelight Icon Lighten",
6168
"Lighten icons in prelight state",
6170
DEFAULT_PRELIGHT_ICON_LIGHTEN,
6171
6013
G_PARAM_READABLE));
6172
6014
gtk_widget_class_install_style_property (widget_class,
6173
6015
g_param_spec_boolean ("activate_prelight_icon_label",
6295
6145
nautilus_icon_container_init (NautilusIconContainer *container)
6297
6147
NautilusIconContainerDetails *details;
6298
EelBackground *background;
6299
6148
static gboolean setup_prefs = FALSE;
6301
6150
details = g_new0 (NautilusIconContainerDetails, 1);
6303
6152
details->icon_set = g_hash_table_new (g_direct_hash, g_direct_equal);
6304
6153
details->layout_timestamp = UNDEFINED_TIME;
6306
details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD;
6154
details->active_background = TRUE;
6155
details->zoom_level = NAUTILUS_ZOOM_LEVEL_STANDARD;
6308
6157
details->font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLEST] = -2 * PANGO_SCALE;
6309
details->font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLER] = -2 * PANGO_SCALE;
6310
details->font_size_table[NAUTILUS_ZOOM_LEVEL_SMALL] = -0 * PANGO_SCALE;
6311
details->font_size_table[NAUTILUS_ZOOM_LEVEL_STANDARD] = 0 * PANGO_SCALE;
6312
details->font_size_table[NAUTILUS_ZOOM_LEVEL_LARGE] = 0 * PANGO_SCALE;
6313
details->font_size_table[NAUTILUS_ZOOM_LEVEL_LARGER] = 0 * PANGO_SCALE;
6314
details->font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST] = 0 * PANGO_SCALE;
6158
details->font_size_table[NAUTILUS_ZOOM_LEVEL_SMALLER] = -2 * PANGO_SCALE;
6159
details->font_size_table[NAUTILUS_ZOOM_LEVEL_SMALL] = -0 * PANGO_SCALE;
6160
details->font_size_table[NAUTILUS_ZOOM_LEVEL_STANDARD] = 0 * PANGO_SCALE;
6161
details->font_size_table[NAUTILUS_ZOOM_LEVEL_LARGE] = 0 * PANGO_SCALE;
6162
details->font_size_table[NAUTILUS_ZOOM_LEVEL_LARGER] = 0 * PANGO_SCALE;
6163
details->font_size_table[NAUTILUS_ZOOM_LEVEL_LARGEST] = 0 * PANGO_SCALE;
6316
6165
container->details = details;
6318
/* when the background changes, we must set up the label text color */
6319
background = eel_get_widget_background (GTK_WIDGET (container));
6321
g_signal_connect_object (background, "appearance_changed",
6322
G_CALLBACK (update_label_color), container, 0);
6324
6167
g_signal_connect (container, "focus-in-event",
6325
6168
G_CALLBACK (handle_focus_in_event), NULL);
6326
6169
g_signal_connect (container, "focus-out-event",
6327
6170
G_CALLBACK (handle_focus_out_event), NULL);
6329
eel_background_set_use_base (background, TRUE);
6331
6172
/* read in theme-dependent data */
6332
6173
nautilus_icon_container_theme_changed (container);
6333
eel_preferences_add_callback (NAUTILUS_PREFERENCES_THEME,
6334
nautilus_icon_container_theme_changed,
6337
6175
if (!setup_prefs) {
6338
eel_preferences_add_callback (NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
6339
text_ellipsis_limit_changed_callback,
6176
g_signal_connect_swapped (nautilus_icon_view_preferences,
6177
"changed::" NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
6178
G_CALLBACK (text_ellipsis_limit_changed_callback),
6341
6180
text_ellipsis_limit_changed_callback (NULL);
6343
eel_preferences_add_callback (NAUTILUS_PREFERENCES_DESKTOP_TEXT_ELLIPSIS_LIMIT,
6344
desktop_text_ellipsis_limit_changed_callback,
6182
g_signal_connect_swapped (nautilus_icon_view_preferences,
6183
"changed::" NAUTILUS_PREFERENCES_DESKTOP_TEXT_ELLIPSIS_LIMIT,
6184
G_CALLBACK (desktop_text_ellipsis_limit_changed_callback),
6346
6186
desktop_text_ellipsis_limit_changed_callback (NULL);
6348
6188
setup_prefs = TRUE;
7078
6913
icon_size = MAX (icon_size, min_image_size);
7079
6914
icon_size = MIN (icon_size, max_image_size);
6916
DEBUG ("Icon size, getting for size %d", icon_size);
7081
6918
/* Get the icons. */
7082
emblem_pixbufs = NULL;
7083
6919
embedded_text = NULL;
7084
6920
large_embedded_text = icon_size > ICON_SIZE_FOR_LARGE_EMBEDDED_TEXT;
7085
6921
icon_info = nautilus_icon_container_get_icon_images (container, icon->data, icon_size,
7087
6922
&embedded_text,
7088
6923
icon == details->drop_target,
7089
6924
large_embedded_text, &embedded_text_needs_loading,
7090
6925
&has_open_window);
7093
if (container->details->forced_icon_size > 0)
6927
if (container->details->forced_icon_size > 0) {
7094
6928
pixbuf = nautilus_icon_info_get_pixbuf_at_size (icon_info, icon_size);
7096
6930
pixbuf = nautilus_icon_info_get_pixbuf (icon_info);
7097
6933
nautilus_icon_info_get_attach_points (icon_info, &attach_points, &n_attach_points);
7098
6934
has_embedded_text_rect = nautilus_icon_info_get_embedded_rect (icon_info,
7099
6935
&embedded_text_rect);
6937
g_object_unref (icon_info);
7101
6939
if (has_embedded_text_rect && embedded_text_needs_loading) {
7102
6940
icon->is_monitored = TRUE;
8597
*color = &container->details->label_colors [idx];
8395
*color = container->details->label_colors[idx];
8600
return container->details->label_gcs [idx];
8604
setup_gc_with_fg (NautilusIconContainer *container, int idx, guint32 color)
8400
setup_gc_with_fg (NautilusIconContainer *container, int idx, GdkRGBA *color)
8609
gcolor = eel_gdk_rgb_to_color (color);
8610
container->details->label_colors [idx] = gcolor;
8612
gc = gdk_gc_new (gtk_layout_get_bin_window (GTK_LAYOUT (container)));
8613
gdk_gc_set_rgb_fg_color (gc, &gcolor);
8615
if (container->details->label_gcs [idx]) {
8616
g_object_unref (container->details->label_gcs [idx]);
8619
container->details->label_gcs [idx] = gc;
8402
container->details->label_colors[idx] = *color;
8623
8406
setup_label_gcs (NautilusIconContainer *container)
8625
EelBackground *background;
8626
8408
GtkWidget *widget;
8627
GdkColor *light_info_color, *dark_info_color;
8628
guint light_info_value, dark_info_value;
8629
gboolean frame_text;
8409
GtkStyleContext *style;
8632
8412
if (!gtk_widget_get_realized (GTK_WIDGET (container)))
8637
8417
g_assert (NAUTILUS_IS_ICON_CONTAINER (container));
8639
background = eel_get_widget_background (GTK_WIDGET (container));
8641
8419
/* read the info colors from the current theme; use a reasonable default if undefined */
8642
gtk_widget_style_get (GTK_WIDGET (container),
8643
"light_info_color", &light_info_color,
8644
"dark_info_color", &dark_info_color,
8646
style = gtk_widget_get_style (widget);
8648
if (light_info_color) {
8649
light_info_value = eel_gdk_color_to_rgb (light_info_color);
8650
gdk_color_free (light_info_color);
8652
light_info_value = DEFAULT_LIGHT_INFO_COLOR;
8655
if (dark_info_color) {
8656
dark_info_value = eel_gdk_color_to_rgb (dark_info_color);
8657
gdk_color_free (dark_info_color);
8659
dark_info_value = DEFAULT_DARK_INFO_COLOR;
8662
setup_gc_with_fg (container, LABEL_COLOR_HIGHLIGHT, eel_gdk_color_to_rgb (&style->text[GTK_STATE_SELECTED]));
8663
setup_gc_with_fg (container, LABEL_COLOR_ACTIVE, eel_gdk_color_to_rgb (&style->text[GTK_STATE_ACTIVE]));
8664
setup_gc_with_fg (container, LABEL_COLOR_PRELIGHT, eel_gdk_color_to_rgb (&style->text[GTK_STATE_PRELIGHT]));
8665
setup_gc_with_fg (container,
8666
LABEL_INFO_COLOR_HIGHLIGHT,
8667
eel_gdk_color_is_dark (&style->base[GTK_STATE_SELECTED]) ? light_info_value : dark_info_value);
8668
setup_gc_with_fg (container,
8669
LABEL_INFO_COLOR_ACTIVE,
8670
eel_gdk_color_is_dark (&style->base[GTK_STATE_ACTIVE]) ? light_info_value : dark_info_value);
8672
/* If NautilusIconContainer::frame_text is set, we can safely
8673
* use the foreground color from the theme, because it will
8674
* always be displayed against the gtk background */
8675
gtk_widget_style_get (widget,
8676
"frame_text", &frame_text,
8679
if (frame_text || !eel_background_is_set(background)) {
8680
setup_gc_with_fg (container, LABEL_COLOR,
8681
eel_gdk_color_to_rgb (&style->text[GTK_STATE_NORMAL]));
8682
setup_gc_with_fg (container,
8684
eel_gdk_color_is_dark (&style->base[GTK_STATE_NORMAL]) ? light_info_value : dark_info_value);
8686
if (container->details->use_drop_shadows || eel_background_is_dark (background)) {
8687
setup_gc_with_fg (container, LABEL_COLOR, 0xEFEFEF);
8688
setup_gc_with_fg (container,
8691
} else { /* converse */
8692
setup_gc_with_fg (container, LABEL_COLOR, 0x000000);
8693
setup_gc_with_fg (container,
8701
update_label_color (EelBackground *background,
8702
NautilusIconContainer *container)
8704
g_assert (EEL_IS_BACKGROUND (background));
8706
setup_label_gcs (container);
8420
style = gtk_widget_get_style_context (widget);
8422
gtk_style_context_get_color (style,
8423
GTK_STATE_FLAG_SELECTED,
8425
setup_gc_with_fg (container, LABEL_COLOR_HIGHLIGHT, &color);
8426
setup_gc_with_fg (container, LABEL_INFO_COLOR_HIGHLIGHT, &color);
8429
gtk_style_context_get_color (style, GTK_STATE_FLAG_ACTIVE, &color);
8430
setup_gc_with_fg (container, LABEL_COLOR_ACTIVE, &color);
8431
setup_gc_with_fg (container, LABEL_INFO_COLOR_ACTIVE, &color);
8433
gtk_style_context_get_color (style, GTK_STATE_FLAG_PRELIGHT, &color);
8434
setup_gc_with_fg (container, LABEL_COLOR_PRELIGHT, &color);
8436
gtk_style_context_get_color (style, GTK_STATE_FLAG_INSENSITIVE, &color);
8437
setup_gc_with_fg (container, LABEL_INFO_COLOR,
8440
if (!nautilus_icon_container_get_is_desktop (container)) {
8441
gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &color);
8442
setup_gc_with_fg (container, LABEL_COLOR, &color);
8446
gdk_rgba_parse (&tmp, "#EFEFEF");
8447
setup_gc_with_fg (container, LABEL_COLOR, &tmp);
8710
8451
/* Return if the icon container is a fixed size */
8786
8521
nautilus_icon_container_theme_changed (gpointer user_data)
8788
8523
NautilusIconContainer *container;
8790
GdkColor *prelight_icon_color, *normal_icon_color;
8791
guchar highlight_alpha, normal_alpha, prelight_alpha;
8524
GtkStyleContext *style;
8793
8527
container = NAUTILUS_ICON_CONTAINER (user_data);
8795
/* load the highlight color */
8796
gtk_widget_style_get (GTK_WIDGET (container),
8797
"highlight_alpha", &highlight_alpha,
8800
style = gtk_widget_get_style (GTK_WIDGET (container));
8802
container->details->highlight_color_rgba =
8803
EEL_RGBA_COLOR_PACK (style->base[GTK_STATE_SELECTED].red >> 8,
8804
style->base[GTK_STATE_SELECTED].green >> 8,
8805
style->base[GTK_STATE_SELECTED].blue >> 8,
8807
container->details->active_color_rgba =
8808
EEL_RGBA_COLOR_PACK (style->base[GTK_STATE_ACTIVE].red >> 8,
8809
style->base[GTK_STATE_ACTIVE].green >> 8,
8810
style->base[GTK_STATE_ACTIVE].blue >> 8,
8813
/* load the prelight icon color */
8814
gtk_widget_style_get (GTK_WIDGET (container),
8815
"prelight_icon_color", &prelight_icon_color,
8818
if (prelight_icon_color) {
8819
container->details->prelight_icon_color_rgba =
8820
EEL_RGBA_COLOR_PACK (prelight_icon_color->red >> 8,
8821
prelight_icon_color->green >> 8,
8822
prelight_icon_color->blue >> 8,
8824
} else { /* if not defined by rc, set to default value */
8825
container->details->prelight_icon_color_rgba =
8826
EEL_RGBA_COLOR_PACK (style->base[GTK_STATE_PRELIGHT].red >> 8,
8827
style->base[GTK_STATE_PRELIGHT].green >> 8,
8828
style->base[GTK_STATE_PRELIGHT].blue >> 8,
8833
/* load the normal icon color */
8834
gtk_widget_style_get (GTK_WIDGET (container),
8835
"normal_icon_color", &normal_icon_color,
8838
if (normal_icon_color) {
8839
container->details->normal_icon_color_rgba =
8840
EEL_RGBA_COLOR_PACK (normal_icon_color->red >> 8,
8841
normal_icon_color->green >> 8,
8842
normal_icon_color->blue >> 8,
8844
} else { /* if not defined by rc, set to default value */
8845
container->details->normal_icon_color_rgba =
8846
EEL_RGBA_COLOR_PACK (style->base[GTK_STATE_NORMAL].red >> 8,
8847
style->base[GTK_STATE_NORMAL].green >> 8,
8848
style->base[GTK_STATE_NORMAL].blue >> 8,
8853
/* load the normal color */
8854
gtk_widget_style_get (GTK_WIDGET (container),
8855
"normal_alpha", &normal_alpha,
8858
container->details->normal_color_rgba =
8859
EEL_RGBA_COLOR_PACK (style->base[GTK_STATE_NORMAL].red >> 8,
8860
style->base[GTK_STATE_NORMAL].green >> 8,
8861
style->base[GTK_STATE_NORMAL].blue >> 8,
8865
/* load the prelight color */
8866
gtk_widget_style_get (GTK_WIDGET (container),
8867
"prelight_alpha", &prelight_alpha,
8870
container->details->prelight_color_rgba =
8871
EEL_RGBA_COLOR_PACK (style->base[GTK_STATE_PRELIGHT].red >> 8,
8872
style->base[GTK_STATE_PRELIGHT].green >> 8,
8873
style->base[GTK_STATE_PRELIGHT].blue >> 8,
8528
style = gtk_widget_get_style_context (GTK_WIDGET (container));
8530
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &color);
8531
container->details->highlight_color_rgba = color;
8533
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color);
8534
container->details->active_color_rgba = color;
8536
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_PRELIGHT, &color);
8537
container->details->prelight_color_rgba = color;
8539
gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color);
8540
container->details->normal_color_rgba = color;
8877
8542
setup_label_gcs (container);