diff --git a/src/TaskModel.vala b/src/TaskModel.vala index 23139e8845..d8a007340f 100644 --- a/src/TaskModel.vala +++ b/src/TaskModel.vala @@ -282,7 +282,7 @@ public class Tasks.TaskModel : Object { return false; } - private string get_collection_backend_name (E.Source source, E.SourceRegistry registry) { + public string get_collection_backend_name (E.Source source, E.SourceRegistry registry) { string? backend_name = null; var collection_source = registry.find_extension (source, E.SOURCE_EXTENSION_COLLECTION); diff --git a/src/Widgets/DateTimePopover.vala b/src/Widgets/DateTimePopover.vala index 131fe1eefd..4acc7fba9c 100644 --- a/src/Widgets/DateTimePopover.vala +++ b/src/Widgets/DateTimePopover.vala @@ -20,6 +20,7 @@ public class Tasks.DateTimePopover : Tasks.EntryPopover { private Gtk.Calendar calendar; private Granite.Widgets.TimePicker timepicker; + private Gtk.Revealer timepicker_revealer; public DateTimePopover () { Object ( @@ -39,6 +40,13 @@ public class Tasks.DateTimePopover : Tasks.EntryPopover { margin_top = 0 }; + timepicker_revealer = new Gtk.Revealer () { + reveal_child = true, + margin = 0 + }; + + timepicker_revealer.add (timepicker); + var today_separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) { margin_bottom = 3, margin_top = 3 @@ -54,7 +62,7 @@ public class Tasks.DateTimePopover : Tasks.EntryPopover { grid.attach (today_button, 0, 0); grid.attach (today_separator, 0, 1); grid.attach (calendar, 0, 2); - grid.attach (timepicker, 0, 3); + grid.attach (timepicker_revealer, 0, 3); grid.show_all (); popover.add (grid); @@ -66,6 +74,10 @@ public class Tasks.DateTimePopover : Tasks.EntryPopover { timepicker.time_changed.connect (on_timepicker_time_changed); } + public void hide_timepicker () { + timepicker_revealer.reveal_child = false; + } + private void on_popover_show () { var selected_datetime = value; if (selected_datetime == null) { diff --git a/src/Widgets/TaskRow.vala b/src/Widgets/TaskRow.vala index 8a16aa836d..6e5be238dc 100644 --- a/src/Widgets/TaskRow.vala +++ b/src/Widgets/TaskRow.vala @@ -75,6 +75,16 @@ public class Tasks.TaskRow : Gtk.ListBoxRow { can_focus = false; created = calcomponent_created (task); + // GTasks tasks only have date on due time, so only show the date + bool is_gtask = false; + E.SourceRegistry? registry = null; + try { + registry = Application.model.get_registry_sync (); + is_gtask = Application.model.get_collection_backend_name (source, registry) == "google"; + } catch (Error e) { + warning ("unable to get the registry, assuming task is not from gtask"); + } + icon = new Gtk.Image.from_icon_name ("list-add-symbolic", Gtk.IconSize.MENU); icon.get_style_context ().add_class (Gtk.STYLE_CLASS_DIM_LABEL); @@ -96,6 +106,10 @@ public class Tasks.TaskRow : Gtk.ListBoxRow { due_datetime_popover = new Tasks.DateTimePopover (); + if (is_gtask) { + due_datetime_popover.hide_timepicker (); + } + due_datetime_popover_revealer = new Gtk.Revealer () { margin_end = 6, reveal_child = false, @@ -113,20 +127,27 @@ public class Tasks.TaskRow : Gtk.ListBoxRow { due_datetime_popover.get_style_context ().add_class ("error"); } - var h24_settings = new GLib.Settings ("org.gnome.desktop.interface"); - var format = h24_settings.get_string ("clock-format"); - - if (is_scheduled_view) { - return _("%s").printf ( - value.format (Granite.DateTime.get_default_time_format (format.contains ("12h"))) - ); - + if (is_gtask) { + if (is_scheduled_view) { + return null; + } else { + return _("%s").printf (Tasks.Util.get_relative_date (value)); + } } else { - ///TRANSLATORS: Represents due date and time of a task, e.g. "Tomorrow at 9:00 AM" - return _("%s at %s").printf ( - Tasks.Util.get_relative_date (value), - value.format (Granite.DateTime.get_default_time_format (format.contains ("12h"))) - ); + var h24_settings = new GLib.Settings ("org.gnome.desktop.interface"); + var format = h24_settings.get_string ("clock-format"); + + if (is_scheduled_view) { + return _("%s").printf ( + value.format (Granite.DateTime.get_default_time_format (format.contains ("12h"))) + ); + } else { + ///TRANSLATORS: Represents due date and time of a task, e.g. "Tomorrow at 9:00 AM" + return _("%s at %s").printf ( + Tasks.Util.get_relative_date (value), + value.format (Granite.DateTime.get_default_time_format (format.contains ("12h"))) + ); + } } });