r4523: Updated headers:
[rox-filer/dt.git] / ROX-Filer / src / display.c
blob480cdf9a6dacabed96ac2eb49a04507faa397c41
1 /*
2 * ROX-Filer, filer for the ROX desktop project
3 * Copyright (C) 2006, Thomas Leonard and others (see changelog for details).
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
8 * any later version.
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 * more details.
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
20 /* display.c - code for arranging and displaying file items */
22 #include "config.h"
24 #include <stdlib.h>
25 #include <stdio.h>
26 #include <math.h>
27 #include <string.h>
28 #include <errno.h>
29 #include <sys/param.h>
30 #include <unistd.h>
31 #include <time.h>
32 #include <ctype.h>
34 #include <gtk/gtk.h>
35 #include <gdk/gdkx.h>
36 #include <gdk/gdkkeysyms.h>
38 #include "global.h"
40 #include "main.h"
41 #include "filer.h"
42 #include "display.h"
43 #include "support.h"
44 #include "gui_support.h"
45 #include "pixmaps.h"
46 #include "menu.h"
47 #include "dnd.h"
48 #include "run.h"
49 #include "mount.h"
50 #include "type.h"
51 #include "options.h"
52 #include "action.h"
53 #include "minibuffer.h"
54 #include "dir.h"
55 #include "diritem.h"
56 #include "fscache.h"
57 #include "view_iface.h"
59 #define HUGE_WRAP (1.5 * o_large_width.int_value)
61 /* Options bits */
62 static Option o_display_caps_first;
63 static Option o_display_dirs_first;
64 Option o_display_size;
65 Option o_display_details;
66 Option o_display_sort_by;
67 static Option o_large_width;
68 Option o_small_width;
69 Option o_display_show_hidden;
70 Option o_display_show_thumbs;
71 Option o_display_show_headers;
72 Option o_display_show_full_type;
73 Option o_display_inherit_options;
74 static Option o_filer_change_size_num;
75 Option o_vertical_order_small, o_vertical_order_large;
77 /* Static prototypes */
78 static void display_details_set(FilerWindow *filer_window, DetailsType details);
79 static void display_style_set(FilerWindow *filer_window, DisplayStyle style);
80 static void options_changed(void);
81 static char *details(FilerWindow *filer_window, DirItem *item);
82 static void display_set_actual_size_real(FilerWindow *filer_window);
84 /****************************************************************
85 * EXTERNAL INTERFACE *
86 ****************************************************************/
88 void display_init()
90 option_add_int(&o_display_caps_first, "display_caps_first", FALSE);
91 option_add_int(&o_display_dirs_first, "display_dirs_first", FALSE);
92 option_add_int(&o_display_size, "display_icon_size", AUTO_SIZE_ICONS);
93 option_add_int(&o_display_details, "display_details", DETAILS_NONE);
94 option_add_int(&o_display_sort_by, "display_sort_by", SORT_NAME);
95 option_add_int(&o_large_width, "display_large_width", 155);
96 option_add_int(&o_small_width, "display_small_width", 250);
97 option_add_int(&o_display_show_hidden, "display_show_hidden", FALSE);
98 option_add_int(&o_display_show_thumbs, "display_show_thumbs", FALSE);
99 option_add_int(&o_display_show_headers, "display_show_headers", TRUE);
100 option_add_int(&o_display_show_full_type, "display_show_full_type", FALSE);
101 option_add_int(&o_display_inherit_options,
102 "display_inherit_options", FALSE);
103 option_add_int(&o_filer_change_size_num, "filer_change_size_num", 30);
104 option_add_int(&o_vertical_order_small, "vertical_order_small", FALSE);
105 option_add_int(&o_vertical_order_large, "vertical_order_large", FALSE);
107 option_add_notify(options_changed);
110 static void draw_emblem_on_icon(GdkWindow *window, MaskedPixmap *image,
111 int *x, int y)
113 gdk_pixbuf_render_to_drawable_alpha(image->pixbuf,
114 window,
115 0, 0, /* src */
116 *x, y, /* dest */
117 -1, -1,
118 GDK_PIXBUF_ALPHA_FULL, 128, /* (unused) */
119 GDK_RGB_DITHER_NORMAL, 0, 0);
121 *x+=image->width+1;
124 /* Draw this icon (including any symlink or mount symbol) inside the
125 * given rectangle.
127 void draw_huge_icon(GdkWindow *window, GdkRectangle *area,
128 DirItem *item, MaskedPixmap *image, gboolean selected,
129 GdkColor *color)
131 int width, height;
132 int image_x;
133 int image_y;
134 GdkPixbuf *pixbuf;
136 if (!image)
137 return;
139 width = image->huge_width;
140 height = image->huge_height;
141 image_x = area->x + ((area->width - width) >> 1);
142 image_y = MAX(0, area->height - height - 6);
144 pixbuf = selected
145 ? create_spotlight_pixbuf(image->huge_pixbuf, color)
146 : image->huge_pixbuf;
148 gdk_pixbuf_render_to_drawable_alpha(
149 pixbuf,
150 window,
151 0, 0, /* src */
152 image_x, area->y + image_y, /* dest */
153 width, height,
154 GDK_PIXBUF_ALPHA_FULL, 128, /* (unused) */
155 GDK_RGB_DITHER_NORMAL, 0, 0);
157 if (selected)
158 g_object_unref(pixbuf);
160 if (item->flags & ITEM_FLAG_MOUNT_POINT)
162 MaskedPixmap *mp = item->flags & ITEM_FLAG_MOUNTED
163 ? im_mounted
164 : im_unmounted;
165 draw_emblem_on_icon(window, mp, &image_x, area->y + 2);
167 if (item->flags & ITEM_FLAG_SYMLINK)
169 draw_emblem_on_icon(window, im_symlink, &image_x, area->y + 2);
171 if (item->flags & ITEM_FLAG_HAS_XATTR)
173 draw_emblem_on_icon(window, im_xattr, &image_x, area->y + 2);
177 /* Draw this icon (including any symlink or mount symbol) inside the
178 * given rectangle.
180 void draw_large_icon(GdkWindow *window,
181 GdkRectangle *area,
182 DirItem *item,
183 MaskedPixmap *image,
184 gboolean selected,
185 GdkColor *color)
187 int width;
188 int height;
189 int image_x;
190 int image_y;
191 GdkPixbuf *pixbuf;
193 if (!image)
194 return;
196 width = MIN(image->width, ICON_WIDTH);
197 height = MIN(image->height, ICON_HEIGHT);
198 image_x = area->x + ((area->width - width) >> 1);
199 image_y = MAX(0, area->height - height - 6);
201 pixbuf = selected
202 ? create_spotlight_pixbuf(image->pixbuf, color)
203 : image->pixbuf;
205 gdk_pixbuf_render_to_drawable_alpha(
206 pixbuf,
207 window,
208 0, 0, /* src */
209 image_x, area->y + image_y, /* dest */
210 width, height,
211 GDK_PIXBUF_ALPHA_FULL, 128, /* (unused) */
212 GDK_RGB_DITHER_NORMAL, 0, 0);
214 if (selected)
215 g_object_unref(pixbuf);
217 if (item->flags & ITEM_FLAG_MOUNT_POINT)
219 MaskedPixmap *mp = item->flags & ITEM_FLAG_MOUNTED
220 ? im_mounted
221 : im_unmounted;
222 draw_emblem_on_icon(window, mp, &image_x, area->y + 2);
224 if (item->flags & ITEM_FLAG_SYMLINK)
226 draw_emblem_on_icon(window, im_symlink, &image_x, area->y + 2);
228 if (item->flags & ITEM_FLAG_HAS_XATTR)
230 draw_emblem_on_icon(window, im_xattr, &image_x, area->y + 2);
234 void draw_small_icon(GdkWindow *window, GdkRectangle *area,
235 DirItem *item, MaskedPixmap *image, gboolean selected,
236 GdkColor *color)
238 int width, height, image_x, image_y;
239 GdkPixbuf *pixbuf;
241 if (!image)
242 return;
244 if (!image->sm_pixbuf)
245 pixmap_make_small(image);
247 width = MIN(image->sm_width, SMALL_WIDTH);
248 height = MIN(image->sm_height, SMALL_HEIGHT);
249 image_x = area->x + ((area->width - width) >> 1);
250 image_y = MAX(0, SMALL_HEIGHT - image->sm_height);
252 pixbuf = selected
253 ? create_spotlight_pixbuf(image->sm_pixbuf, color)
254 : image->sm_pixbuf;
256 gdk_pixbuf_render_to_drawable_alpha(
257 pixbuf,
258 window,
259 0, 0, /* src */
260 image_x, area->y + image_y, /* dest */
261 width, height,
262 GDK_PIXBUF_ALPHA_FULL, 128, /* (unused) */
263 GDK_RGB_DITHER_NORMAL, 0, 0);
265 if (selected)
266 g_object_unref(pixbuf);
268 if (item->flags & ITEM_FLAG_MOUNT_POINT)
270 MaskedPixmap *mp = item->flags & ITEM_FLAG_MOUNTED
271 ? im_mounted
272 : im_unmounted;
273 draw_emblem_on_icon(window, mp, &image_x, area->y + 2);
275 if (item->flags & ITEM_FLAG_SYMLINK)
277 draw_emblem_on_icon(window, im_symlink, &image_x, area->y + 8);
279 if (item->flags & ITEM_FLAG_HAS_XATTR)
281 draw_emblem_on_icon(window, im_xattr, &image_x, area->y + 8);
285 /* The sort functions aren't called from outside, but they are
286 * passed as arguments to display_set_sort_fn().
289 #define IS_A_DIR(item) (item->base_type == TYPE_DIRECTORY && \
290 !(item->flags & ITEM_FLAG_APPDIR))
292 #define SORT_DIRS \
293 if (o_display_dirs_first.int_value) { \
294 gboolean id1 = IS_A_DIR(i1); \
295 gboolean id2 = IS_A_DIR(i2); \
296 if (id1 && !id2) return -1; \
297 if (id2 && !id1) return 1; \
300 int sort_by_name(const void *item1, const void *item2)
302 const DirItem *i1 = (DirItem *) item1;
303 const DirItem *i2 = (DirItem *) item2;
304 CollateKey *n1 = i1->leafname_collate;
305 CollateKey *n2 = i2->leafname_collate;
306 int retval;
308 SORT_DIRS;
310 retval = collate_key_cmp(n1, n2, o_display_caps_first.int_value);
312 return retval ? retval : strcmp(i1->leafname, i2->leafname);
315 int sort_by_type(const void *item1, const void *item2)
317 const DirItem *i1 = (DirItem *) item1;
318 const DirItem *i2 = (DirItem *) item2;
319 MIME_type *m1, *m2;
321 int diff = i1->base_type - i2->base_type;
323 if (!diff)
324 diff = (i1->flags & ITEM_FLAG_APPDIR)
325 - (i2->flags & ITEM_FLAG_APPDIR);
326 if (diff)
327 return diff > 0 ? 1 : -1;
329 m1 = i1->mime_type;
330 m2 = i2->mime_type;
332 if (m1 && m2)
334 diff = strcmp(m1->media_type, m2->media_type);
335 if (!diff)
336 diff = strcmp(m1->subtype, m2->subtype);
338 else if (m1 || m2)
339 diff = m1 ? 1 : -1;
340 else
341 diff = 0;
343 if (diff)
344 return diff > 0 ? 1 : -1;
346 return sort_by_name(item1, item2);
349 int sort_by_owner(const void *item1, const void *item2)
351 const DirItem *i1 = (DirItem *) item1;
352 const DirItem *i2 = (DirItem *) item2;
353 const gchar *name1;
354 const gchar *name2;
356 if(i1->uid==i2->uid)
357 return sort_by_name(item1, item2);
359 name1=user_name(i1->uid);
360 name2=user_name(i2->uid);
362 return strcmp(name1, name2);
365 int sort_by_group(const void *item1, const void *item2)
367 const DirItem *i1 = (DirItem *) item1;
368 const DirItem *i2 = (DirItem *) item2;
369 const gchar *name1;
370 const gchar *name2;
372 if(i1->gid==i2->gid)
373 return sort_by_name(item1, item2);
375 name1=group_name(i1->gid);
376 name2=group_name(i2->gid);
378 return strcmp(name1, name2);
381 int sort_by_date(const void *item1, const void *item2)
383 const DirItem *i1 = (DirItem *) item1;
384 const DirItem *i2 = (DirItem *) item2;
386 /* SORT_DIRS; -- too confusing! */
388 return i1->mtime < i2->mtime ? -1 :
389 i1->mtime > i2->mtime ? 1 :
390 sort_by_name(item1, item2);
393 int sort_by_size(const void *item1, const void *item2)
395 const DirItem *i1 = (DirItem *) item1;
396 const DirItem *i2 = (DirItem *) item2;
398 SORT_DIRS;
400 return i1->size < i2->size ? -1 :
401 i1->size > i2->size ? 1 :
402 sort_by_name(item1, item2);
405 void display_set_sort_type(FilerWindow *filer_window, SortType sort_type,
406 GtkSortType order)
408 if (filer_window->sort_type == sort_type &&
409 filer_window->sort_order == order)
410 return;
412 filer_window->sort_type = sort_type;
413 filer_window->sort_order = order;
415 view_sort(filer_window->view);
418 /* Change the icon size and style.
419 * force_resize should only be TRUE for new windows.
421 void display_set_layout(FilerWindow *filer_window,
422 DisplayStyle style,
423 DetailsType details,
424 gboolean force_resize)
426 gboolean style_changed = FALSE;
428 g_return_if_fail(filer_window != NULL);
430 if (filer_window->display_style_wanted != style
431 || filer_window->details_type != details)
433 style_changed = TRUE;
436 display_style_set(filer_window, style);
437 display_details_set(filer_window, details);
439 /* Recreate layouts because wrapping may have changed */
440 view_style_changed(filer_window->view, VIEW_UPDATE_NAME);
442 if (force_resize || o_filer_auto_resize.int_value == RESIZE_ALWAYS
443 || (o_filer_auto_resize.int_value == RESIZE_STYLE && style_changed))
445 view_autosize(filer_window->view);
449 /* Set the 'Show Thumbnails' flag for this window */
450 void display_set_thumbs(FilerWindow *filer_window, gboolean thumbs)
452 if (filer_window->show_thumbs == thumbs)
453 return;
455 filer_window->show_thumbs = thumbs;
457 view_style_changed(filer_window->view, VIEW_UPDATE_VIEWDATA);
459 if (!thumbs)
460 filer_cancel_thumbnails(filer_window);
462 filer_set_title(filer_window);
464 filer_create_thumbs(filer_window);
467 void display_update_hidden(FilerWindow *filer_window)
469 filer_detach_rescan(filer_window); /* (updates titlebar) */
471 display_set_actual_size(filer_window, FALSE);
474 /* Set the 'Show Hidden' flag for this window */
475 void display_set_hidden(FilerWindow *filer_window, gboolean hidden)
477 if (filer_window->show_hidden == hidden)
478 return;
481 filer_window->show_hidden = hidden;
483 filer_set_hidden(filer_window, hidden);
485 display_update_hidden(filer_window);
488 void display_set_filter(FilerWindow *filer_window, FilterType type,
489 const gchar *filter_string)
491 if (filer_set_filter(filer_window, type, filter_string))
492 display_update_hidden(filer_window);
496 /* Highlight (wink or cursor) this item in the filer window. If the item
497 * isn't already there but we're scanning then highlight it if it
498 * appears later.
500 void display_set_autoselect(FilerWindow *filer_window, const gchar *leaf)
502 gchar *new;
504 g_return_if_fail(filer_window != NULL);
505 g_return_if_fail(leaf != NULL);
507 new = g_strdup(leaf); /* leaf == old value sometimes */
509 null_g_free(&filer_window->auto_select);
511 if (view_autoselect(filer_window->view, new))
512 g_free(new);
513 else
514 filer_window->auto_select = new;
517 /* Change the icon size (wraps) */
518 void display_change_size(FilerWindow *filer_window, gboolean bigger)
520 DisplayStyle new;
522 g_return_if_fail(filer_window != NULL);
524 switch (filer_window->display_style)
526 case LARGE_ICONS:
527 new = bigger ? HUGE_ICONS : SMALL_ICONS;
528 break;
529 case HUGE_ICONS:
530 if (bigger)
531 return;
532 new = LARGE_ICONS;
533 break;
534 default:
535 if (!bigger)
536 return;
537 new = LARGE_ICONS;
538 break;
541 display_set_layout(filer_window, new, filer_window->details_type,
542 FALSE);
545 ViewData *display_create_viewdata(FilerWindow *filer_window, DirItem *item)
547 ViewData *view;
549 view = g_new(ViewData, 1);
551 view->layout = NULL;
552 view->details = NULL;
553 view->image = NULL;
555 display_update_view(filer_window, item, view, TRUE);
557 return view;
560 /* Set the display style to the desired style. If the desired style
561 * is AUTO_SIZE_ICONS, choose an appropriate size. Also resizes filer
562 * window, if requested.
564 void display_set_actual_size(FilerWindow *filer_window, gboolean force_resize)
566 display_set_layout(filer_window, filer_window->display_style_wanted,
567 filer_window->details_type, force_resize);
571 /****************************************************************
572 * INTERNAL FUNCTIONS *
573 ****************************************************************/
575 static void options_changed(void)
577 GList *next;
579 for (next = all_filer_windows; next; next = next->next)
581 FilerWindow *filer_window = (FilerWindow *) next->data;
582 int flags = 0;
584 if (o_display_dirs_first.has_changed ||
585 o_display_caps_first.has_changed)
586 view_sort(VIEW(filer_window->view));
588 if (o_display_show_headers.has_changed)
589 flags |= VIEW_UPDATE_HEADERS;
591 if (o_large_width.has_changed || o_small_width.has_changed)
592 flags |= VIEW_UPDATE_NAME; /* Recreate PangoLayout */
594 view_style_changed(filer_window->view, flags);
598 /* Return a new string giving details of this item, or NULL if details
599 * are not being displayed. If details are not yet available, return
600 * a string of the right length.
602 static char *details(FilerWindow *filer_window, DirItem *item)
604 mode_t m = item->mode;
605 guchar *buf = NULL;
606 gboolean scanned = item->base_type != TYPE_UNKNOWN;
608 if (filer_window->details_type == DETAILS_NONE)
609 return NULL;
611 if (scanned && item->lstat_errno)
612 buf = g_strdup_printf(_("lstat(2) failed: %s"),
613 g_strerror(item->lstat_errno));
614 else if (filer_window->details_type == DETAILS_TYPE)
616 MIME_type *type = item->mime_type;
618 if (!scanned)
619 return g_strdup("application/octet-stream");
621 buf = g_strdup_printf("%s/%s",
622 type->media_type, type->subtype);
624 else if (filer_window->details_type == DETAILS_TIMES)
626 guchar *ctime, *mtime, *atime;
628 ctime = pretty_time(&item->ctime);
629 mtime = pretty_time(&item->mtime);
630 atime = pretty_time(&item->atime);
632 buf = g_strdup_printf("a[%s] c[%s] m[%s]", atime, ctime, mtime);
633 g_free(ctime);
634 g_free(mtime);
635 g_free(atime);
637 else if (filer_window->details_type == DETAILS_PERMISSIONS)
639 if (!scanned)
640 return g_strdup("---,---,---/--"
641 #ifdef S_ISVTX
643 #endif
644 " 12345678 12345678");
646 buf = g_strdup_printf("%s %-8.8s %-8.8s",
647 pretty_permissions(m),
648 user_name(item->uid),
649 group_name(item->gid));
651 else
653 if (!scanned)
655 if (filer_window->display_style == SMALL_ICONS)
656 return g_strdup("1234M");
657 else
658 return g_strdup("1234 bytes");
661 if (item->base_type != TYPE_DIRECTORY)
663 if (filer_window->display_style == SMALL_ICONS)
664 buf = g_strdup(format_size_aligned(item->size));
665 else
666 buf = g_strdup(format_size(item->size));
668 else
669 buf = g_strdup("-");
672 return buf;
675 /* Note: Call style_changed after this */
676 static void display_details_set(FilerWindow *filer_window, DetailsType details)
678 filer_window->details_type = details;
681 /* Note: Call style_changed after this */
682 static void display_style_set(FilerWindow *filer_window, DisplayStyle style)
684 filer_window->display_style_wanted = style;
685 display_set_actual_size_real(filer_window);
688 /* Each displayed item has a ViewData structure with some cached information
689 * to help quickly draw the item (eg, the PangoLayout). This function updates
690 * this information.
692 void display_update_view(FilerWindow *filer_window,
693 DirItem *item,
694 ViewData *view,
695 gboolean update_name_layout)
697 DisplayStyle style = filer_window->display_style;
698 int w, h;
699 int wrap_width = -1;
700 char *str;
701 static PangoFontDescription *monospace = NULL;
702 PangoAttrList *list = NULL;
704 if (!monospace)
705 monospace = pango_font_description_from_string("monospace");
707 if (view->details)
709 g_object_unref(G_OBJECT(view->details));
710 view->details = NULL;
713 str = details(filer_window, item);
714 if (str)
716 PangoAttrList *details_list;
717 int perm_offset = -1;
719 view->details = gtk_widget_create_pango_layout(
720 filer_window->window, str);
721 g_free(str);
723 pango_layout_set_font_description(view->details, monospace);
724 pango_layout_get_size(view->details, &w, &h);
725 view->details_width = w / PANGO_SCALE;
726 view->details_height = h / PANGO_SCALE;
728 if (filer_window->details_type == DETAILS_PERMISSIONS)
729 perm_offset = 0;
730 if (perm_offset > -1)
732 PangoAttribute *attr;
734 attr = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
736 perm_offset += 4 * applicable(item->uid, item->gid);
737 attr->start_index = perm_offset;
738 attr->end_index = perm_offset + 3;
740 details_list = pango_attr_list_new();
741 pango_attr_list_insert(details_list, attr);
742 pango_layout_set_attributes(view->details,
743 details_list);
747 if (view->image)
749 g_object_unref(view->image);
750 view->image = NULL;
753 if (filer_window->show_thumbs && item->base_type == TYPE_FILE /*&&
754 strcmp(item->mime_type->media_type, "image") == 0*/)
756 const guchar *path;
758 path = make_path(filer_window->real_path, item->leafname);
760 view->image = g_fscache_lookup_full(pixmap_cache, path,
761 FSCACHE_LOOKUP_ONLY_NEW, NULL);
764 if (!view->image)
766 view->image = di_image(item);
767 if (view->image)
768 g_object_ref(view->image);
771 if (view->layout && update_name_layout)
773 g_object_unref(G_OBJECT(view->layout));
774 view->layout = NULL;
777 if (view->layout)
779 /* Do nothing */
781 else if (g_utf8_validate(item->leafname, -1, NULL))
783 view->layout = gtk_widget_create_pango_layout(
784 filer_window->window, item->leafname);
786 else
788 PangoAttribute *attr;
789 gchar *utf8;
791 utf8 = to_utf8(item->leafname);
792 view->layout = gtk_widget_create_pango_layout(
793 filer_window->window, utf8);
794 g_free(utf8);
796 attr = pango_attr_foreground_new(0xffff, 0, 0);
797 attr->start_index = 0;
798 attr->end_index = -1;
799 if (!list)
800 list = pango_attr_list_new();
801 pango_attr_list_insert(list, attr);
804 if (item->flags & ITEM_FLAG_RECENT)
806 PangoAttribute *attr;
808 attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
809 attr->start_index = 0;
810 attr->end_index = -1;
811 if (!list)
812 list = pango_attr_list_new();
813 pango_attr_list_insert(list, attr);
816 if (list)
817 pango_layout_set_attributes(view->layout, list);
819 if (filer_window->details_type == DETAILS_NONE)
821 if (style == HUGE_ICONS)
822 wrap_width = HUGE_WRAP * PANGO_SCALE;
823 else if (style == LARGE_ICONS)
824 wrap_width = o_large_width.int_value * PANGO_SCALE;
827 #ifdef USE_PANGO_WRAP_WORD_CHAR
828 pango_layout_set_wrap(view->layout, PANGO_WRAP_WORD_CHAR);
829 #endif
830 if (wrap_width != -1)
831 pango_layout_set_width(view->layout, wrap_width);
833 pango_layout_get_size(view->layout, &w, &h);
834 view->name_width = w / PANGO_SCALE;
835 view->name_height = h / PANGO_SCALE;
838 /* Sets display_style from display_style_wanted.
839 * See also display_set_actual_size().
841 static void display_set_actual_size_real(FilerWindow *filer_window)
843 DisplayStyle size = filer_window->display_style_wanted;
844 int n;
846 g_return_if_fail(filer_window != NULL);
848 if (size == AUTO_SIZE_ICONS)
850 n = view_count_items(filer_window->view);
852 if (n >= o_filer_change_size_num.int_value)
853 size = SMALL_ICONS;
854 else
855 size = LARGE_ICONS;
858 filer_window->display_style = size;