jun7 / rox-filer

ROX file manager
24 stars 6 forks source link

Custom time/date format #219

Closed JakeSFR closed 3 years ago

JakeSFR commented 3 years ago

Hey Jun,

I've added an option to set custom time/date format for Properties window and extra details view:

xscreenshot-20210519T145807

Here's the patch:

diff -ur rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_old/ROX-Filer/Options.xml rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_new/ROX-Filer/Options.xml
--- rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_old/ROX-Filer/Options.xml    2020-08-01 10:35:21.000000000 +0200
+++ rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_new/ROX-Filer/Options.xml    2021-05-19 14:55:43.182801662 +0200
@@ -41,6 +41,8 @@
        If this is on then files which have one or more extended attributes set will have an emblem added to indicate this.</toggle>
    <toggle name='hide_root_msg' label="Hide the message bar Running as user 'root'">
        This hides the bar even with the command-line option -u, --user if user is the root.</toggle>
+   <entry name='time_format' label="Time and date format">
+       Set time and date format for Properties window and extra details view.</entry>
    </frame>

     <section title='New Window'>
diff -ur rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_old/ROX-Filer/src/filer.c rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_new/ROX-Filer/src/filer.c
--- rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_old/ROX-Filer/src/filer.c    2020-08-01 10:35:21.000000000 +0200
+++ rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_new/ROX-Filer/src/filer.c    2021-05-19 14:55:43.184801662 +0200
@@ -248,6 +248,7 @@
    option_add_int(&o_bottom_gap, "bottom_gap", 0);
    option_add_int(&o_auto_move, "auto_move", TRUE);
    option_add_int(&o_disable_pointer_warp, "disable_pointer_warp", FALSE);
+   option_add_string(&o_time_format, "time_format", COMPACT_TIME_FORMAT);
    option_add_int(&o_fast_font_calc, "fast_font_calc", TRUE);

    option_add_notify(filer_options_changed);
Only in rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_new/ROX-Filer/src: filer.c.orig
diff -ur rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_old/ROX-Filer/src/filer.h rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_new/ROX-Filer/src/filer.h
--- rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_old/ROX-Filer/src/filer.h    2020-08-01 10:35:21.000000000 +0200
+++ rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_new/ROX-Filer/src/filer.h    2021-05-19 14:55:43.184801662 +0200
@@ -158,6 +158,7 @@
 extern Option      o_fast_font_calc;
 extern Option      o_window_link;
 extern Option      o_scroll_speed;
+extern Option      o_time_format;
 extern gint        fw_font_height;
 extern gint        fw_font_widths[0x7f];
 extern gint        fw_font_widthsb[0x7f];
diff -ur rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_old/ROX-Filer/src/support.c rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_new/ROX-Filer/src/support.c
--- rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_old/ROX-Filer/src/support.c  2020-08-01 10:35:21.000000000 +0200
+++ rox-filer-df7a6b65bee08d9a7a6dae8433186e23dc4ea0c8_new/ROX-Filer/src/support.c  2021-05-19 14:55:43.185801662 +0200
@@ -55,6 +55,8 @@
 /* Static prototypes */
 static void MD5Transform(guint32 buf[4], guint32 const in[16]);

+Option o_time_format;
+
 /****************************************************************
  *         EXTERNAL INTERFACE          *
  ****************************************************************/
@@ -601,7 +603,7 @@
    if (tms == NULL)
        return g_strdup("(invalid time)");

-        if (strftime(time_buf, sizeof(time_buf), COMPACT_TIME_FORMAT, tms) == 0)
+        if (strftime(time_buf, sizeof(time_buf), o_time_format.value, tms) == 0)
        time_buf[0]= 0;

    return to_utf8(time_buf);

There are 2 minor issues, though:

xscreenshot-20210519T144814

I'm not sure how to fix these (other than increasing the buffer, in the first one) and not sure if the way I did it is good enough either. Anyway, what do you think about it?

jun7 commented 3 years ago

I found a following commit on my fork of rox. https://github.com/jun7/literocks/commit/8f0a3e9ef6e65f3ba998bca35ae9dcfc9eda1c12 (infobox is Properties window) So I think, separate Properties window's date is good. Which is the problem came from? Both that Properties window and details view?

jun7 commented 3 years ago

Hmm separating Properties window's date is complex for users. "Set time and date format for Properties window and extra details view." is good enough.

JakeSFR commented 3 years ago

I found a following commit on my fork of rox. jun7/literocks@8f0a3e9 (infobox is Properties window)

So, if I understand correctly, that commit separates time formats for Properties and Details View? That's interesting, I wouldn't mind that in ROX. But yeah, it could confuse some users...

Which is the problem came from? Both that Properties window and details view?

The problem is that I don't like the compact time format (I prefer, e.g. '%Y-%m-%d %T'), but @step- does. :) So, the best compromise was to make it customizable.

Hmm separating Properties window's date is complex for users. "Set time and date format for Properties window and extra details view." is good enough.

Ok, so am I supposed to make a PR? The code's good?

jun7 commented 3 years ago

It is good that the option is in display.c/h .

Ok, so am I supposed to make a PR? The code's good?

Good!

JakeSFR commented 3 years ago

It is good that the option is in display.c/h .

Ok, so am I supposed to make a PR? The code's good?

Good!

I'm getting some mixed signals. ;) Correct me if I'm wrong, but you wanted me to move that option from filer.c/h to display.c/h before I make the PR? If so, I've done it. I also increased the buffer from 32 to 64, just in case somebody's gonna use some really long format. Here's the PR: https://github.com/jun7/rox-filer/pull/220

Cheers!

jun7 commented 3 years ago

If so

Yes. Thank you for reporting!

jun7 commented 3 years ago

I fixed the overlap. thank you!

JakeSFR commented 3 years ago

I fixed the overlap. thank you!

Oh, that really great! Works perfect. Many thanks!