From b00e384c1b803409e6658c19fee5c4ab03983c40 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Fri, 31 May 2002 13:13:43 +0000 Subject: [PATCH] r1542: Option to switch automatically between Large and Small icons (Stephen Watson). --- ROX-Filer/Help/Changes | 1 + ROX-Filer/Help/TODO | 2 ++ ROX-Filer/Options.xml | 2 ++ ROX-Filer/src/display.c | 8 ++++---- ROX-Filer/src/filer.c | 43 +++++++++++++++++++++++++++++++++++++++---- 5 files changed, 48 insertions(+), 8 deletions(-) diff --git a/ROX-Filer/Help/Changes b/ROX-Filer/Help/Changes index 04bc797c..3d1961fb 100644 --- a/ROX-Filer/Help/Changes +++ b/ROX-Filer/Help/Changes @@ -4,6 +4,7 @@ 31-May-2002 ~~~~~~~~~~~ +Option to switch automatically between Large and Small icons (Stephen Watson). Bugfix: Default icon for iconified windows wasn't found (Jimmy Olgeni). Bugfix: Sometimes the SOAP message sent to a running process got displayed. diff --git a/ROX-Filer/Help/TODO b/ROX-Filer/Help/TODO index fd216020..c9419503 100644 --- a/ROX-Filer/Help/TODO +++ b/ROX-Filer/Help/TODO @@ -23,6 +23,8 @@ rox -b Small Changing the pinboard font doesn't realign the icons. +Dirs in /proc which have no access permission keep bringing up error boxes. + FEATURES FOR 1.3 Edit MIME-Info database. diff --git a/ROX-Filer/Options.xml b/ROX-Filer/Options.xml index aa63b6d9..f7b4407f 100644 --- a/ROX-Filer/Options.xml +++ b/ROX-Filer/Options.xml @@ -28,6 +28,8 @@ The filer will resize windows whenever it seems useful (that is, when changing directory or display style). The largest size, as a percentage of the screen size, that the auto-resizer will resize a window to. + If this is on then filer windows will change from Large icons to Small when showing a new directory with lots of files. + If the directory contains this many items them it will be shown using Small Icons, otherwise Large Icons will be used. Use single letters instead of words for Scanning, All and Thumbs indicators in the titlebar. diff --git a/ROX-Filer/src/display.c b/ROX-Filer/src/display.c index 82715eb3..94326c76 100644 --- a/ROX-Filer/src/display.c +++ b/ROX-Filer/src/display.c @@ -79,7 +79,6 @@ Option o_display_show_hidden; Option o_display_show_thumbs; Option o_display_inherit_options; - /* GC for drawing colour filenames */ static GdkGC *type_gc = NULL; @@ -157,8 +156,9 @@ void display_init() option_add_int(&o_small_width, "display_small_width", 250); option_add_int(&o_display_show_hidden, "display_show_hidden", FALSE); option_add_int(&o_display_show_thumbs, "display_show_thumbs", FALSE); - option_add_int(&o_display_inherit_options,"display_inherit_options", - FALSE); + option_add_int(&o_display_inherit_options, + "display_inherit_options", FALSE); + option_add_notify(options_changed); } @@ -237,7 +237,7 @@ void calc_size(FilerWindow *filer_window, CollectionItem *colitem, if (view->image) pix_width = view->image->width; else - pix_width = HUGE_WIDTH * 3 / 2; + pix_width = ICON_WIDTH; *width = MAX(pix_width, view->name_width) + 4; *height = view->name_height + ICON_HEIGHT + 2; } diff --git a/ROX-Filer/src/filer.c b/ROX-Filer/src/filer.c index 16d23765..d01fbbf1 100644 --- a/ROX-Filer/src/filer.c +++ b/ROX-Filer/src/filer.c @@ -111,6 +111,7 @@ static void set_selection_state(FilerWindow *collection, gboolean normal); static void filer_next_thumb(GObject *window, const gchar *path); static void start_thumb_scanning(FilerWindow *filer_window); static void filer_options_changed(void); +static void set_style_by_number_of_items(FilerWindow *filer_window); static GdkCursor *busy_cursor = NULL; static GdkCursor *crosshair = NULL; @@ -118,8 +119,9 @@ static GdkCursor *crosshair = NULL; /* Indicates whether the filer's display is different to the machine it * is actually running on. */ -static gboolean not_local=FALSE; +static gboolean not_local = FALSE; +static Option o_filer_change_size, o_filer_change_size_num; static Option o_filer_size_limit, o_short_flag_names; Option o_filer_auto_resize, o_unique_filer_windows; @@ -136,6 +138,9 @@ void filer_init(void) option_add_int(&o_short_flag_names, "filer_short_flag_names", FALSE); + option_add_int(&o_filer_change_size, "filer_change_size", TRUE); + option_add_int(&o_filer_change_size_num, "filer_change_size_num", 30); + option_add_notify(filer_options_changed); busy_cursor = gdk_cursor_new(GDK_WATCH); @@ -394,6 +399,7 @@ static gint open_filer_window(FilerWindow *filer_window) if (!GTK_WIDGET_VISIBLE(filer_window->window)) { + set_style_by_number_of_items(filer_window); filer_window_autosize(filer_window, TRUE); gtk_widget_show(filer_window->window); } @@ -1189,6 +1195,9 @@ void filer_change_to(FilerWindow *filer_window, collection_set_cursor_item(filer_window->collection, -1); attach(filer_window); + + set_style_by_number_of_items(filer_window); + if (o_filer_auto_resize.int_value == RESIZE_ALWAYS) filer_window_autosize(filer_window, TRUE); @@ -1401,9 +1410,9 @@ FilerWindow *filer_opendir(const char *path, FilerWindow *src_win) * collection->number_of_items may be valid after the call to * attach() returns). * - * BUT, if the directory was not in the cache (because it hadn't been - * opened it before) then the cached dir will be empty and nothing gets - * added until a while later when some entries are actually available. + * If the directory was not in the cache (because it hadn't been + * opened it before) then the types and icons for the entries are + * not know, but the list of names is. */ attach(filer_window); @@ -2422,3 +2431,29 @@ static void filer_options_changed(void) } } } + +/* Change to Large or Small icons depending on the number of items + * in the directory, subject to options. + */ +static void set_style_by_number_of_items(FilerWindow *filer_window) +{ + int n; + + g_return_if_fail(filer_window != NULL); + + if (!o_filer_change_size.int_value) + return; /* Don't auto-set style */ + + if (filer_window->display_style != LARGE_ICONS && + filer_window->display_style != SMALL_ICONS) + return; /* Only change between these two styles */ + + n = filer_window->collection->number_of_items; + + if (n >= o_filer_change_size_num.int_value) + display_set_layout(filer_window, SMALL_ICONS, + filer_window->details_type); + else + display_set_layout(filer_window, LARGE_ICONS, + filer_window->details_type); +} -- 2.11.4.GIT