Skip to content

Commit b00edf9

Browse files
authored
Add compact dateformat mode (#2646)
1 parent cda7466 commit b00edf9

4 files changed

Lines changed: 20 additions & 1 deletion

File tree

data/schemas/io.elementary.files.gschema.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
<value value="0" nick="iso"/>
2121
<value value="1" nick="locale"/>
2222
<value value="2" nick="informal"/>
23+
<value value="3" nick="compact"/>
2324
</enum>
2425
<enum id="windowstate">
2526
<value value="0" nick="normal"/>

libcore/Enums.vala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ namespace Files {
258258
public enum DateFormatMode {
259259
ISO,
260260
LOCALE,
261-
INFORMAL;
261+
INFORMAL,
262+
COMPACT;
262263

263264
public string to_string () {
264265
switch (this) {
@@ -269,6 +270,9 @@ namespace Files {
269270
return _("Locale");
270271
case INFORMAL:
271272
return _("Informal");
273+
case COMPACT:
274+
///TRANSLATORS Adjective applied to datetime format
275+
return _("Compact");
272276
default:
273277
assert_not_reached ();
274278
}

libcore/FileUtils.vala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,9 @@ namespace Files.FileUtils {
632632
return dt.format ("%c");
633633
case DateFormatMode.ISO:
634634
return dt.format ("%Y-%m-%d %H:%M:%S");
635+
case DateFormatMode.COMPACT :
636+
var locale_format_string = Posix.nl_langinfo (D_FMT);
637+
return dt.format (string.join (" ", locale_format_string.down (), "%H:%M"));
635638
default:
636639
return get_informal_date_time (dt);
637640
}

src/View/Widgets/AppMenu.vala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,8 @@ public class Files.AppMenu : Gtk.Popover {
121121
locale_button.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUITEM);
122122
var informal_button = new Gtk.RadioButton.with_label_from_widget (iso_button, DateFormatMode.INFORMAL.to_string ());
123123
informal_button.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUITEM);
124+
var compact_button = new Gtk.RadioButton.with_label_from_widget (iso_button, DateFormatMode.COMPACT.to_string ());
125+
compact_button.get_style_context ().add_class (Gtk.STYLE_CLASS_MENUITEM);
124126

125127
var menu_box = new Gtk.Box (VERTICAL, 0) {
126128
margin_bottom = 6
@@ -141,6 +143,7 @@ public class Files.AppMenu : Gtk.Popover {
141143
menu_box.add (iso_button);
142144
menu_box.add (locale_button);
143145
menu_box.add (informal_button);
146+
menu_box.add (compact_button);
144147

145148
menu_box.show_all ();
146149

@@ -167,6 +170,9 @@ public class Files.AppMenu : Gtk.Popover {
167170
case DateFormatMode.INFORMAL:
168171
informal_button.active= true;
169172
break;
173+
case DateFormatMode.COMPACT:
174+
compact_button.active= true;
175+
break;
170176
default:
171177
assert_not_reached ();
172178
}
@@ -186,6 +192,11 @@ public class Files.AppMenu : Gtk.Popover {
186192
app_settings.set_enum ("date-format", DateFormatMode.INFORMAL);
187193
}
188194
});
195+
compact_button.toggled.connect (() => {
196+
if (compact_button.active) {
197+
app_settings.set_enum ("date-format", DateFormatMode.COMPACT);
198+
}
199+
});
189200
}
190201

191202
private void set_undo_redo_tooltips () {

0 commit comments

Comments
 (0)