From 3ec224ea9f829802730ba9926e70232f6b00a26e Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Fri, 10 Mar 2000 17:39:28 +0000 Subject: [PATCH] r208: Added Bernard Jungen's patch: - Dates are displayed in a more RISC OS like format. - (Scanning) is shown in the titlebar during scans. - Option to only display one window per directory. - User and group names displayed in the Full Info view. - Home directory stored centrally. - Open Parent in the root does nothing. - Errors in options are only reported once. - File does chdir() if -b isn't possible. --- ROX-Filer/src/dir.c | 10 +++ ROX-Filer/src/dir.h | 3 +- ROX-Filer/src/filer.c | 183 +++++++++++++++++++++++++++++++++++++++--------- ROX-Filer/src/filer.h | 2 +- ROX-Filer/src/main.c | 5 +- ROX-Filer/src/main.h | 1 + ROX-Filer/src/menu.c | 37 ++++++---- ROX-Filer/src/options.c | 8 ++- ROX-Filer/src/run.c | 6 +- ROX-Filer/src/support.c | 68 +++++++++++++----- ROX-Filer/src/support.h | 2 + ROX-Filer/src/type.c | 3 +- 12 files changed, 254 insertions(+), 74 deletions(-) diff --git a/ROX-Filer/src/dir.c b/ROX-Filer/src/dir.c index 4a99e7a8..a17659de 100644 --- a/ROX-Filer/src/dir.c +++ b/ROX-Filer/src/dir.c @@ -258,6 +258,8 @@ static void init_for_scan(Directory *dir) static void start_scanning(Directory *dir, char *pathname) { + GList *next; + if (dir->dir_handle) { /* We are already scanning */ @@ -286,6 +288,14 @@ static void start_scanning(Directory *dir, char *pathname) init_for_scan(dir); dir->idle = gtk_idle_add((GtkFunction) idle_callback, dir); + + /* Let all the filer windows know we're scanning */ + for (next = dir->users; next; next = next->next) + { + DirUser *user = (DirUser *) next->data; + + user->callback(dir, DIR_START_SCAN, NULL, user->data); + } } static gint notify_timeout(gpointer data) diff --git a/ROX-Filer/src/dir.h b/ROX-Filer/src/dir.h index 8357816e..f777db1e 100644 --- a/ROX-Filer/src/dir.h +++ b/ROX-Filer/src/dir.h @@ -13,7 +13,8 @@ #include typedef enum { - DIR_END_SCAN, /* Remove busy cursor */ + DIR_START_SCAN, /* Set 'scanning' indicator */ + DIR_END_SCAN, /* Clear 'scanning' indicator */ DIR_ADD, /* Add the listed items to the display */ DIR_REMOVE, /* Remove listed items from display */ DIR_UPDATE, /* Redraw these items */ diff --git a/ROX-Filer/src/filer.c b/ROX-Filer/src/filer.c index 94a2b647..7ab8c7d3 100644 --- a/ROX-Filer/src/filer.c +++ b/ROX-Filer/src/filer.c @@ -81,6 +81,7 @@ static void update_options(); static void set_options(); static void save_options(); static char *filer_single_click(char *data); +static char *filer_unique_windows(char *data); static char *filer_menu_on_2(char *data); static char *filer_new_window_on_1(char *data); static char *filer_toolbar(char *data); @@ -112,6 +113,8 @@ static GtkWidget *toggle_single_click; static gboolean o_new_window_on_1 = FALSE; /* Button 1 => New window */ static GtkWidget *toggle_new_window_on_1; static GtkWidget *toggle_menu_on_2; +static GtkWidget *toggle_unique_filer_windows; +static gboolean o_unique_filer_windows = FALSE; /* Static prototypes */ static void attach(FilerWindow *filer_window); @@ -172,6 +175,7 @@ static void update_display(Directory *dir, DirAction action, GPtrArray *items, FilerWindow *filer_window); +static void set_scanning_display(FilerWindow *filer_window, gboolean scanning); static void shrink_width(FilerWindow *filer_window); static gboolean may_rescan(FilerWindow *filer_window, gboolean warning); static void open_item(Collection *collection, @@ -179,6 +183,9 @@ static void open_item(Collection *collection, gpointer user_data); static gboolean minibuffer_show_cb(FilerWindow *filer_window); static void set_autoselect(FilerWindow *filer_window, guchar *leaf); +static FilerWindow *find_filer_window(char *path); +static void filer_set_title(FilerWindow *filer_window); +static gboolean exists(FilerWindow *filer_window); static GdkAtom xa_string; enum @@ -198,6 +205,7 @@ void filer_init() option_register("filer_new_window_on_1", filer_new_window_on_1); option_register("filer_menu_on_2", filer_menu_on_2); option_register("filer_single_click", filer_single_click); + option_register("filer_unique_windows", filer_unique_windows); option_register("filer_toolbar", filer_toolbar); option_register("filer_display_style", filer_display_style); option_register("filer_sort_by", filer_sort_by); @@ -289,6 +297,9 @@ static void update_display(Directory *dir, if_deleted, items); break; + case DIR_START_SCAN: + set_scanning_display(filer_window, TRUE); + break; case DIR_END_SCAN: if (filer_window->window->window) gdk_window_set_cursor( @@ -301,6 +312,7 @@ static void update_display(Directory *dir, collection_set_cursor_item(collection, 0); filer_window->had_cursor = FALSE; } + set_scanning_display(filer_window, FALSE); break; case DIR_UPDATE: for (i = 0; i < items->len; i++) @@ -319,8 +331,10 @@ static void attach(FilerWindow *filer_window) { gdk_window_set_cursor(filer_window->window->window, busy_cursor); collection_clear(filer_window->collection); + filer_window->scanning = TRUE; dir_attach(filer_window->directory, (DirCallback) update_display, filer_window); + filer_set_title(filer_window); } static void detach(FilerWindow *filer_window) @@ -616,33 +630,31 @@ static void draw_string(GtkWidget *widget, x, y, string, strlen(string)); } - + /* Return a string (valid until next call) giving details * of this item. */ char *details(DirItem *item) { - mode_t m = item->mode; - static GString *buf = NULL; - static char time_buf[32]; + mode_t m = item->mode; + static GString *buf = NULL; + if (!buf) buf = g_string_new(NULL); - if (strftime(time_buf, sizeof(time_buf), - "%d-%b-%Y %T", localtime(&item->mtime)) == 0) - time_buf[0]= 0; - - g_string_sprintf(buf, "%s%s %s %s", + g_string_sprintf(buf, "%s %s %8s %8s %s %s", item->flags & ITEM_FLAG_APPDIR? "App " : - S_ISDIR(m) ? "Dir " : - S_ISCHR(m) ? "Char " : - S_ISBLK(m) ? "Blck " : - S_ISLNK(m) ? "Link " : - S_ISSOCK(m) ? "Sock " : - S_ISFIFO(m) ? "Pipe " : "File ", + S_ISDIR(m) ? "Dir " : + S_ISCHR(m) ? "Char" : + S_ISBLK(m) ? "Blck" : + S_ISLNK(m) ? "Link" : + S_ISSOCK(m) ? "Sock" : + S_ISFIFO(m) ? "Pipe" : "File", pretty_permissions(m), + user_name(item->uid), + group_name(item->gid), format_size_aligned(item->size), - time_buf); + pretty_time(&item->mtime)); return buf->str; } @@ -1194,7 +1206,7 @@ static void toolbar_refresh_clicked(GtkWidget *widget, static void toolbar_home_clicked(GtkWidget *widget, FilerWindow *filer_window) { - filer_change_to(filer_window, getenv("HOME"), NULL); + filer_change_to(filer_window, home_dir, NULL); } static void toolbar_up_clicked(GtkWidget *widget, FilerWindow *filer_window) @@ -1234,15 +1246,25 @@ void change_to_parent(FilerWindow *filer_window) void filer_change_to(FilerWindow *filer_window, char *path, char *from) { char *from_dup; + char *real_path = pathdup(path); + if (o_unique_filer_windows) + { + FilerWindow *fw; + + fw = find_filer_window(real_path); + if (fw && fw != filer_window) + gtk_widget_destroy(fw->window); + } + from_dup = from && *from ? g_strdup(from) : NULL; detach(filer_window); g_free(filer_window->path); - filer_window->path = pathdup(path); + filer_window->path = real_path; filer_window->directory = g_fscache_lookup(dir_cache, - filer_window->path); + filer_window->path); if (filer_window->directory) { g_free(filer_window->auto_select); @@ -1251,8 +1273,7 @@ void filer_change_to(FilerWindow *filer_window, char *path, char *from) || filer_window->had_cursor; filer_window->auto_select = from_dup; - gtk_window_set_title(GTK_WINDOW(filer_window->window), - filer_window->path); + filer_set_title(filer_window); collection_set_cursor_item(filer_window->collection, -1); attach(filer_window); @@ -1396,10 +1417,32 @@ FilerWindow *filer_opendir(char *path, PanelType panel_type) {"text/uri-list", 0, TARGET_URI_LIST}, {"STRING", 0, TARGET_STRING}, }; + char *real_path; + + real_path = pathdup(path); + + if (o_unique_filer_windows && panel_type == PANEL_NO) + { + FilerWindow *fw; + + fw = find_filer_window(real_path); + + if (fw) + { + /* TODO: this should bring the window to the front + * at the same coordinates. + */ + gtk_widget_hide(fw->window); + gtk_widget_show(fw->window); + g_free(real_path); + return fw; + } + } filer_window = g_new(FilerWindow, 1); filer_window->minibuffer = NULL; - filer_window->path = pathdup(path); + filer_window->path = real_path; + filer_window->scanning = FALSE; filer_window->had_cursor = FALSE; filer_window->auto_select = NULL; @@ -1425,8 +1468,7 @@ FilerWindow *filer_opendir(char *path, PanelType panel_type) filer_window->display_style = UNKNOWN_STYLE; filer_window->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_title(GTK_WINDOW(filer_window->window), - filer_window->path); + filer_set_title(filer_window); collection = collection_new(NULL); gtk_object_set_data(GTK_OBJECT(collection), @@ -1564,6 +1606,26 @@ FilerWindow *filer_opendir(char *path, PanelType panel_type) return filer_window; } +static gint clear_scanning_display(FilerWindow *filer_window) +{ + if (exists(filer_window)) + filer_set_title(filer_window); + return FALSE; +} + +static void set_scanning_display(FilerWindow *filer_window, gboolean scanning) +{ + if (scanning == filer_window->scanning) + return; + filer_window->scanning = scanning; + + if (scanning) + filer_set_title(filer_window); + else + gtk_timeout_add(300, (GtkFunction) clear_scanning_display, + filer_window); +} + static GtkWidget *create_toolbar(FilerWindow *filer_window) { GtkWidget *frame, *box; @@ -1672,6 +1734,10 @@ static GtkWidget *create_options() gtk_check_button_new_with_label("Single-click nagivation"); gtk_box_pack_start(GTK_BOX(vbox), toggle_single_click, FALSE, TRUE, 0); + toggle_unique_filer_windows = + gtk_check_button_new_with_label("Unique windows"); + gtk_box_pack_start(GTK_BOX(vbox), toggle_unique_filer_windows, FALSE, TRUE, 0); + hbox = gtk_hbox_new(FALSE, 4); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); @@ -1709,6 +1775,8 @@ static void update_options() collection_menu_button == 2 ? 1 : 0); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_single_click), o_single_click); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_unique_filer_windows), + o_unique_filer_windows); gtk_option_menu_set_history(GTK_OPTION_MENU(menu_toolbar), o_toolbar); update_options_label(); @@ -1728,6 +1796,10 @@ static void set_options() o_single_click = gtk_toggle_button_get_active( GTK_TOGGLE_BUTTON(toggle_single_click)); + + o_unique_filer_windows = gtk_toggle_button_get_active( + GTK_TOGGLE_BUTTON(toggle_unique_filer_windows)); + collection_single_click = o_single_click ? TRUE : FALSE; menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(menu_toolbar)); @@ -1759,6 +1831,7 @@ static void save_options() option_write("filer_menu_on_2", collection_menu_button == 2 ? "1" : "0"); option_write("filer_single_click", o_single_click ? "1" : "0"); + option_write("filer_unique_windows", o_unique_filer_windows ? "1" : "0"); option_write("filer_display_style", style_to_name()); option_write("filer_sort_by", sort_fn_to_name()); option_write("filer_toolbar", o_toolbar == TOOLBAR_NONE ? "None" : @@ -1786,6 +1859,12 @@ static char *filer_single_click(char *data) return NULL; } +static char *filer_unique_windows(char *data) +{ + o_unique_filer_windows = atoi(data) != 0; + return NULL; +} + static char *filer_display_style(char *data) { if (g_strcasecmp(data, "Large Icons") == 0) @@ -1859,6 +1938,27 @@ void full_refresh(void) mount_update(TRUE); } +/* See whether a filer window with a given path already exists */ +static FilerWindow *find_filer_window(char *path) +{ + GList *next = all_filer_windows; + + while (next) + { + FilerWindow *filer_window = (FilerWindow *) next->data; + + if (filer_window->panel_type == PANEL_NO + && strcmp(path, filer_window->path) == 0) + { + return filer_window; + } + + next = next->next; + } + + return NULL; +} + /* This path has been mounted/umounted - update all dirs */ void filer_check_mounted(char *path) { @@ -1889,20 +1989,21 @@ void filer_check_mounted(char *path) */ static gboolean minibuffer_show_cb(FilerWindow *filer_window) { - GList *next = all_filer_windows; + if (exists(filer_window)) + minibuffer_show(filer_window); + return FALSE; +} - while (next) +static gboolean exists(FilerWindow *filer_window) +{ + GList *next; + + for (next = all_filer_windows; next; next = next->next) { FilerWindow *fw = (FilerWindow *) next->data; - if (fw == filer_window) - { - minibuffer_show(filer_window); - break; - } - - next = next->next; + return TRUE; } return FALSE; @@ -1936,3 +2037,19 @@ static void set_autoselect(FilerWindow *filer_window, guchar *leaf) filer_window->auto_select = g_strdup(leaf); } + +static void filer_set_title(FilerWindow *filer_window) +{ + if (filer_window->scanning) + { + guchar *title; + + title = g_strdup_printf("%s (Scanning)", filer_window->path); + gtk_window_set_title(GTK_WINDOW(filer_window->window), + title); + g_free(title); + } + else + gtk_window_set_title(GTK_WINDOW(filer_window->window), + filer_window->path); +} diff --git a/ROX-Filer/src/filer.h b/ROX-Filer/src/filer.h index 1d7ba835..0bca1064 100644 --- a/ROX-Filer/src/filer.h +++ b/ROX-Filer/src/filer.h @@ -39,13 +39,13 @@ typedef enum struct _FilerWindow { GtkWidget *window; + gboolean scanning; /* State of the 'scanning' indicator */ char *path; /* pathname */ Collection *collection; gboolean temp_item_selected; gboolean show_hidden; FilerFlags flags; PanelType panel_type; - time_t m_time; /* m-time at last scan */ int (*sort_fn)(const void *a, const void *b); DisplayStyle display_style; diff --git a/ROX-Filer/src/main.c b/ROX-Filer/src/main.c index e688a46e..2b90905d 100644 --- a/ROX-Filer/src/main.c +++ b/ROX-Filer/src/main.c @@ -58,6 +58,7 @@ uid_t euid; gid_t egid; int ngroups; /* Number of supplemental groups */ gid_t *supplemental_groups = NULL; +char *home_dir; #define VERSION "ROX-Filer 0.1.16\n" \ "Copyright (C) 1999 Thomas Leonard.\n" \ @@ -159,6 +160,8 @@ int main(int argc, char **argv) GList *panel_dirs = NULL; GList *panel_sides = NULL; + home_dir = g_get_home_dir(); + gtk_init(&argc, &argv); while (1) @@ -250,7 +253,7 @@ int main(int argc, char **argv) } if (optind == argc && !panel_dirs) - filer_opendir(getenv("HOME"), PANEL_NO); + filer_opendir(home_dir, PANEL_NO); else { int i = optind; diff --git a/ROX-Filer/src/main.h b/ROX-Filer/src/main.h index 909ae2bc..7b266fc3 100644 --- a/ROX-Filer/src/main.h +++ b/ROX-Filer/src/main.h @@ -18,6 +18,7 @@ extern uid_t euid; extern gid_t egid; extern int ngroups; /* Number of supplemental groups */ extern gid_t *supplemental_groups; +extern char *home_dir; /* Prototypes */ int main(int argc, char **argv); diff --git a/ROX-Filer/src/menu.c b/ROX-Filer/src/menu.c index 5122f3df..3cc91bbb 100644 --- a/ROX-Filer/src/menu.c +++ b/ROX-Filer/src/menu.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include @@ -890,27 +889,21 @@ static void show_file_info(gpointer data, guint action, GtkWidget *widget) label = gtk_label_new("Change time:"); gtk_misc_set_alignment(GTK_MISC(label), 1, .5); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); - g_string_sprintf(gstring, "%s", ctime(&info.st_ctime)); - g_string_truncate(gstring, gstring->len - 1); - label = gtk_label_new(gstring->str); + label = gtk_label_new(pretty_time(&info.st_ctime)); gtk_misc_set_alignment(GTK_MISC(label), 0, .5); gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 2, 3); label = gtk_label_new("Modify time:"); gtk_misc_set_alignment(GTK_MISC(label), 1, .5); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); - g_string_sprintf(gstring, "%s", ctime(&info.st_mtime)); - g_string_truncate(gstring, gstring->len - 1); - label = gtk_label_new(gstring->str); + label = gtk_label_new(pretty_time(&info.st_mtime)); gtk_misc_set_alignment(GTK_MISC(label), 0, .5); gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 3, 4); label = gtk_label_new("Access time:"); gtk_misc_set_alignment(GTK_MISC(label), 1, .5); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 4, 5); - g_string_sprintf(gstring, "%s", ctime(&info.st_atime)); - g_string_truncate(gstring, gstring->len - 1); - label = gtk_label_new(gstring->str); + label = gtk_label_new(pretty_time(&info.st_atime)); gtk_misc_set_alignment(GTK_MISC(label), 0, .5); gtk_table_attach_defaults(GTK_TABLE(table), label, 1, 2, 4, 5); @@ -983,7 +976,8 @@ static void show_file_info(gpointer data, guint action, GtkWidget *widget) #ifdef FILE_B_FLAG argv[2] = path; #else - argv[1] = path; + argv[1] = file->leafname; + chdir(window_with_focus->path); #endif if (execvp(argv[0], argv)) fprintf(stderr, "execvp() error: %s\n", @@ -1154,10 +1148,27 @@ static void xterm_here(gpointer data, guint action, GtkWidget *widget) static void open_parent(gpointer data, guint action, GtkWidget *widget) { + char *copy; + char *slash; + g_return_if_fail(window_with_focus != NULL); - filer_opendir(make_path(window_with_focus->path, "/..")->str, - PANEL_NO); + if (window_with_focus->path[0] == '/' + && window_with_focus->path[1] == '\0') + return; /* Already in the root */ + + copy = g_strdup(window_with_focus->path); + slash = strrchr(copy, '/'); + + if (slash) + { + *slash = '\0'; + filer_opendir(*copy ? copy : "/", PANEL_NO); + } + else + g_warning("No / in directory path!\n"); + + g_free(copy); } static void open_parent_same(gpointer data, guint action, GtkWidget *widget) diff --git a/ROX-Filer/src/options.c b/ROX-Filer/src/options.c index 688f3850..451e9e07 100644 --- a/ROX-Filer/src/options.c +++ b/ROX-Filer/src/options.c @@ -153,6 +153,7 @@ void parse_file(char *path, ParseFunc *parse_line) { char *data; long length; + gboolean seen_error = FALSE; if (load_file(path, &data, &length)) { @@ -168,7 +169,7 @@ void parse_file(char *path, ParseFunc *parse_line) error = parse_line(line); - if (error) + if (error && !seen_error) { GString *message; @@ -179,12 +180,13 @@ void parse_file(char *path, ParseFunc *parse_line) "This may be due to upgrading from " "a previous version of ROX-Filer. " "Open the Options window and click " - "on Save.", + "on Save.\n" + "Further errors will be ignored.", line_number, error); delayed_error("ROX-Filer", message->str); g_string_free(message, TRUE); - break; + seen_error = TRUE; } if (!eol) diff --git a/ROX-Filer/src/run.c b/ROX-Filer/src/run.c index 9095ef7d..3b23142f 100644 --- a/ROX-Filer/src/run.c +++ b/ROX-Filer/src/run.c @@ -59,7 +59,7 @@ void run_app(char *path) apprun = g_string_new(path); argv[0] = g_string_append(apprun, "/AppRun")->str; - if (!spawn_full(argv, getenv("HOME"))) + if (!spawn_full(argv, home_dir)) report_error("ROX-Filer", "Failed to fork() child process"); g_string_free(apprun, TRUE); @@ -103,7 +103,7 @@ void run_with_files(char *path, GSList *uri_list) argv[argc++] = NULL; - if (!spawn_full(argv, getenv("HOME"))) + if (!spawn_full(argv, home_dir)) delayed_error("ROX-Filer", "Failed to fork() child process"); } @@ -144,7 +144,7 @@ void run_with_data(char *path, gpointer data, gulong length) break; case 0: /* We are the child */ - chdir(getenv("HOME")); + chdir(home_dir); dup2(to_error_log, STDERR_FILENO); close_on_exec(STDERR_FILENO, FALSE); if (dup2(fds[0], 0) == -1) diff --git a/ROX-Filer/src/support.c b/ROX-Filer/src/support.c index cc648739..960321d0 100644 --- a/ROX-Filer/src/support.c +++ b/ROX-Filer/src/support.c @@ -33,12 +33,16 @@ #include #include #include +#include #include #include "main.h" #include "support.h" +static GHashTable *uid_hash = NULL; /* UID -> User name */ +static GHashTable *gid_hash = NULL; /* GID -> Group name */ + /* Static prototypes */ @@ -141,33 +145,45 @@ void debug_free_string(void *data) char *user_name(uid_t uid) { - struct passwd *passwd; - GString *tmp; char *retval; + + if (!uid_hash) + uid_hash = g_hash_table_new(NULL, NULL); + + retval = g_hash_table_lookup(uid_hash, (gpointer) uid); + + if (!retval) + { + struct passwd *passwd; + + passwd = getpwuid(uid); + retval = passwd ? g_strdup(passwd->pw_name) + : g_strdup_printf("[%d]", (int) uid); + g_hash_table_insert(uid_hash, (gpointer) uid, retval); + } - passwd = getpwuid(uid); - if (passwd) - return passwd->pw_name; - tmp = g_string_new(NULL); - g_string_sprintf(tmp, "[%d]", (int) uid); - retval = tmp->str; - g_string_free(tmp, FALSE); return retval; } char *group_name(gid_t gid) { - struct group *group; - GString *tmp; char *retval; - group = getgrgid(gid); - if (group) - return group->gr_name; - tmp = g_string_new(NULL); - g_string_sprintf(tmp, "[%d]", (int) gid); - retval = tmp->str; - g_string_free(tmp, FALSE); + if (!gid_hash) + gid_hash = g_hash_table_new(NULL, NULL); + + retval = g_hash_table_lookup(gid_hash, (gpointer) gid); + + if (!retval) + { + struct group *group; + + group = getgrgid(gid); + retval = group ? g_strdup(group->gr_name) + : g_strdup_printf("[%d]", (int) gid); + g_hash_table_insert(gid_hash, (gpointer) gid, retval); + } + return retval; } @@ -385,3 +401,19 @@ void set_blocking(int fd, gboolean blocking) if (fcntl(fd, F_SETFL, blocking ? 0 : O_NONBLOCK)) g_warning("fcntl() failed: %s\n", g_strerror(errno)); } + +/* Format this time nicely. The result is a pointer to a static buffer, + * valid until the next call. + */ +char *pretty_time(time_t *time) +{ + static char time_buf[32]; + + if (strftime(time_buf, sizeof(time_buf), + TIME_FORMAT, localtime(time)) == 0) + time_buf[0]= 0; + + return time_buf; +} + + diff --git a/ROX-Filer/src/support.h b/ROX-Filer/src/support.h index 06237e05..478c08a8 100644 --- a/ROX-Filer/src/support.h +++ b/ROX-Filer/src/support.h @@ -12,6 +12,7 @@ #include #define PRETTY_SIZE_LIMIT 4096 +#define TIME_FORMAT "%T %d %b %Y" char *pathdup(char *path); GString *make_path(char *dir, char *leaf); @@ -29,5 +30,6 @@ gint applicable(uid_t uid, gid_t gid); char *get_local_path(char *uri); void close_on_exec(int fd, gboolean close); void set_blocking(int fd, gboolean blocking); +char *pretty_time(time_t *time); #endif /* _SUPPORT_H */ diff --git a/ROX-Filer/src/type.c b/ROX-Filer/src/type.c index 843772c1..48d2d50a 100644 --- a/ROX-Filer/src/type.c +++ b/ROX-Filer/src/type.c @@ -30,6 +30,7 @@ #include #include "string.h" +#include "main.h" #include "filer.h" #include "pixmaps.h" #include "run.h" @@ -223,7 +224,7 @@ gboolean type_open(char *path, MIME_type *type) else argv[0] = open; - if (!spawn_full(argv, getenv("HOME"))) + if (!spawn_full(argv, home_dir)) { report_error("ROX-Filer", "Failed to fork() child process"); -- 2.11.4.GIT