Skip to content

Commit

Permalink
Merge pull request #1407 from alainm23/develop
Browse files Browse the repository at this point in the history
Prepare release 4.11.0
  • Loading branch information
alainm23 authored Aug 27, 2024
2 parents 291633a + f9fe95b commit 350903a
Show file tree
Hide file tree
Showing 132 changed files with 8,865 additions and 6,106 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@

<a href="https://flathub.org/apps/details/io.github.alainm23.planify" rel="noreferrer noopener" target="_blank"><img loading="lazy" draggable="false" width='240' alt='Download on Flathub' src='https://dl.flathub.org/assets/badges/flathub-badge-en.png' /></a>

<a href="https://snapcraft.io/planify">
<!-- <a href="https://snapcraft.io/planify">
<img alt="Get it from the Snap Store" src="https://snapcraft.io/static/images/badges/en/snap-store-black.svg" loading="lazy" width='240' draggable="false"/>
</a>
</a> -->

## 🛠 Compile

Expand Down
1 change: 0 additions & 1 deletion build-aux/io.github.alainm23.planify.Devel.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"--share=network",
"--socket=fallback-x11",
"--socket=wayland",
"--filesystem=home",
"--talk-name=org.gnome.evolution.dataserver.Calendar8",
"--talk-name=org.gnome.evolution.dataserver.Sources5",
"--talk-name=io.github.alainm23.planify",
Expand Down
22 changes: 22 additions & 0 deletions core/Constants.vala
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
* Copyright © 2023 Alain M. (https://github.com/alainm23/planify)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* Authored by: Alain M. <[email protected]>
*/

namespace Constants {
public const string TODOIST_CLIENT_ID = "b0dd7d3714314b1dbbdab9ee03b6b432";
public const string TODOIST_CLIENT_SECRET = "a86dfeb12139459da3e5e2a8c197c678";
Expand All @@ -20,6 +41,7 @@ namespace Constants {
public const string LIBERAPAY_URL = "https://liberapay.com/Alain/";
public const string KOFI_URL = "https://ko-fi.com/alainm23";
public const string MATRIX_URL = "https://matrix.to/#/#useplanify:matrix.org";
public const string MASTODON_URL = "https://mastodon.social/@planifyapp";
public const bool SHOW_WHATSNEW = false;
public const bool BLOCK_PAST_DAYS = false;
}
56 changes: 52 additions & 4 deletions core/Enum.vala
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,8 @@ public enum CalDAVType {
public enum FilterItemType {
PRIORITY = 0,
LABEL = 1,
DUE_DATE = 2;
DUE_DATE = 2,
SECTION = 3;

public string to_string () {
switch (this) {
Expand All @@ -460,6 +461,9 @@ public enum FilterItemType {

case DUE_DATE:
return "due-date";

case SECTION:
return "section";

default:
assert_not_reached ();
Expand All @@ -477,6 +481,9 @@ public enum FilterItemType {
case DUE_DATE:
return _("Due Date");

case SECTION:
return _("Section");

default:
assert_not_reached ();
}
Expand All @@ -493,6 +500,9 @@ public enum FilterItemType {
case DUE_DATE:
return "month-symbolic";

case SECTION:
return "arrow3-right-symbolic";

default:
assert_not_reached ();
}
Expand Down Expand Up @@ -598,7 +608,10 @@ public enum ObjectEventKeyType {
DUE,
PRIORITY,
LABELS,
PINNED;
PINNED,
CHECKED,
PROJECT,
SECTION;

public static ObjectEventKeyType parse (string value) {
switch (value) {
Expand All @@ -620,6 +633,15 @@ public enum ObjectEventKeyType {
case "pinned":
return ObjectEventKeyType.PINNED;

case "checked":
return ObjectEventKeyType.CHECKED;

case "project":
return ObjectEventKeyType.PROJECT;

case "section":
return ObjectEventKeyType.SECTION;

default:
assert_not_reached ();
}
Expand Down Expand Up @@ -652,6 +674,32 @@ public enum ObjectEventKeyType {
}

public enum LabelPickerType {
SELECT,
FILTER
FILTER_AND_CREATE,
FILTER_ONLY
}

public enum ItemPriority {
HIGHT = 4,
MEDIUM = 3,
LOW = 2,
NONE = 1;

public static ItemPriority parse (string value) {
switch (value) {
case "p1":
return ItemPriority.HIGHT;

case "p2":
return ItemPriority.MEDIUM;

case "p3":
return ItemPriority.LOW;

case "p4":
return ItemPriority.NONE;

default:
return ItemPriority.NONE;
}
}
}
4 changes: 4 additions & 0 deletions core/Layouts/HeaderItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,10 @@ public class Layouts.HeaderItem : Adw.Bin {
);
}

~HeaderItem () {
print ("Destroying Layouts.HeaderItem\n");
}

construct {
header_label = new Gtk.Label (null) {
halign = Gtk.Align.START,
Expand Down
4 changes: 4 additions & 0 deletions core/Objects/DueDate.vala
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ public class Objects.DueDate : GLib.Object {

return _datetime;
}

set {
date = Utils.Datetime.get_todoist_datetime_format (value);
}
}

GLib.DateTime _end_datetime;
Expand Down
2 changes: 1 addition & 1 deletion core/Objects/Filters/FilterItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Objects.Filters.FilterItem : GLib.Object {
public string id {
get {
_id = filter_type.to_string () + "-" + value;
if (filter_type == FilterItemType.DUE_DATE) {
if (filter_type == FilterItemType.DUE_DATE || filter_type == FilterItemType.SECTION) {
_id = filter_type.to_string ();
}

Expand Down
100 changes: 90 additions & 10 deletions core/Objects/Item.vala
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,14 @@ public class Objects.Item : Objects.BaseObject {
}
}

Gee.ArrayList<Objects.Item> _items_uncomplete;
public Gee.ArrayList<Objects.Item> items_uncomplete {
get {
_items_uncomplete = Services.Store.instance ().get_subitems_uncomplete (this);
return _items_uncomplete;
}
}

Gee.ArrayList<Objects.Reminder> _reminders;
public Gee.ArrayList<Objects.Reminder> reminders {
get {
Expand All @@ -272,10 +280,7 @@ public class Objects.Item : Objects.BaseObject {
Gee.ArrayList<Objects.Attachment> _attachments;
public Gee.ArrayList<Objects.Attachment> attachments {
get {
if (_attachments == null) {
_attachments = Services.Store.instance ().get_attachments_by_item (this);
}

_attachments = Services.Store.instance ().get_attachments_by_item (this);
return _attachments;
}
}
Expand All @@ -289,6 +294,7 @@ public class Objects.Item : Objects.BaseObject {
public signal void collapsed_change ();
public signal void attachment_added (Objects.Attachment attachment);
public signal void attachment_deleted (Objects.Attachment attachment);
public signal void pin_updated ();

public Item.from_json (Json.Node node) {
id = node.get_object ().get_string_member ("id");
Expand Down Expand Up @@ -459,11 +465,11 @@ public class Objects.Item : Objects.BaseObject {
checked = true;
string completed = Util.find_string_value ("COMPLETED", data);
if (completed != "") {
completed_at = Utils.Datetime.get_format_date (
completed_at = Utils.Datetime.get_date_only (
Utils.Datetime.ical_to_date_time_local (new ICal.Time.from_string (completed))
).to_string ();
} else {
completed_at = Utils.Datetime.get_format_date (new GLib.DateTime.now_local ()).to_string ();
completed_at = Utils.Datetime.get_date_only (new GLib.DateTime.now_local ()).to_string ();
}
} else {
checked = false;
Expand Down Expand Up @@ -542,11 +548,11 @@ public class Objects.Item : Objects.BaseObject {
checked = true;
string completed = Util.find_string_value ("COMPLETED", data);
if (completed != "") {
completed_at = Utils.Datetime.get_format_date (
completed_at = Utils.Datetime.get_date_only (
Utils.Datetime.ical_to_date_time_local (new ICal.Time.from_string (completed))
).to_string ();
} else {
completed_at = Utils.Datetime.get_format_date (new GLib.DateTime.now_local ()).to_string ();
completed_at = Utils.Datetime.get_date_only (new GLib.DateTime.now_local ()).to_string ();
}
} else {
checked = false;
Expand Down Expand Up @@ -793,6 +799,39 @@ public class Objects.Item : Objects.BaseObject {
}
}

public void update_pin (bool _pinned) {
if (_pinned && project.items_pinned.size + 1 > 3) {
Services.EventBus.get_default ().send_toast (
Util.get_default ().create_toast (
_("Up to 3 tasks can be pinned and they will appear at the top of the project page"),
3
)
);

return;
}

pinned = _pinned;
_update_pin ();
}

private void _update_pin () {
if (project.source_type == SourceType.CALDAV) {
loading = true;
Services.CalDAV.Core.get_default ().add_task.begin (this, true, (obj, res) => {
HttpResponse response = Services.CalDAV.Core.get_default ().add_task.end (res);

if (response.status) {
Services.Store.instance ().update_item_pin (this);
}

loading = false;
});
} else {
Services.Store.instance ().update_item_pin (this);
}
}

public Objects.Reminder? add_reminder_if_not_exists (Objects.Reminder reminder, bool insert_db = true) {
Objects.Reminder? return_value = null;
lock (_reminders) {
Expand Down Expand Up @@ -1541,7 +1580,7 @@ public class Objects.Item : Objects.BaseObject {
this.section_id = _section_id;
this.parent_id = "";

Services.Store.instance ().move_item (this);
Services.Store.instance ().move_item (this, old_section_id, old_parent_id);
Services.EventBus.get_default ().item_moved (this, old_project_id, old_section_id, old_parent_id);
Services.EventBus.get_default ().drag_n_drop_active (old_project_id, false);
Services.EventBus.get_default ().send_toast (
Expand Down Expand Up @@ -1579,8 +1618,13 @@ public class Objects.Item : Objects.BaseObject {
return text;
}

public void update_due (GLib.DateTime? datetime) {
public void update_date (GLib.DateTime? datetime) {
due.date = datetime == null ? "" : Utils.Datetime.get_todoist_datetime_format (datetime);
update_due (due);
}

public void update_due (Objects.DueDate duedate) {
due.date = duedate.date;

if (Services.Settings.get_default ().get_boolean ("automatic-reminders-enabled") && has_time) {
remove_all_relative_reminders ();
Expand Down Expand Up @@ -1639,4 +1683,40 @@ public class Objects.Item : Objects.BaseObject {
}
}
}

public async HttpResponse complete_item (bool old_checked) {
HttpResponse response = new HttpResponse ();

if (project.source_type == SourceType.LOCAL) {
Services.Store.instance ().complete_item (this, old_checked);
response.status = true;

return response;
}

loading = true;

if (project.source_type == SourceType.TODOIST) {
response = yield Services.Todoist.get_default ().complete_item (this);
} else {
response = yield Services.CalDAV.Core.get_default ().complete_item (this);
}

loading = false;

if (response.status) {
bool complete_subitems = project.source_type != SourceType.CALDAV;
Services.Store.instance ().complete_item (this, old_checked, complete_subitems);
if (project.source_type == SourceType.CALDAV) {
foreach (Objects.Item subitem in Services.Store.instance ().get_subitems (this)) {
subitem.checked = checked;
subitem.completed_at = completed_at;

subitem.complete_item (old_checked);
}
}
}

return response;
}
}
26 changes: 26 additions & 0 deletions core/Objects/Label.vala
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,30 @@ public class Objects.Label : Objects.BaseObject {

return generator.to_data (null);
}

public void delete_label (Gtk.Window window) {
var dialog = new Adw.AlertDialog (
_("Delete Label %s".printf (name)),
_("This can not be undone")
);

dialog.add_response ("cancel", _("Cancel"));
dialog.add_response ("delete", _("Delete"));
dialog.set_response_appearance ("delete", Adw.ResponseAppearance.DESTRUCTIVE);
dialog.present (window);

dialog.response.connect ((response) => {
if (response == "delete") {
if (source_type == SourceType.TODOIST) {
loading = true;
Services.Todoist.get_default ().delete.begin (this, (obj, res) => {
Services.Todoist.get_default ().delete.end (res);
Services.Store.instance ().delete_label (this);
});
} else {
Services.Store.instance ().delete_label (this);
}
}
});
}
}
6 changes: 5 additions & 1 deletion core/Objects/ObjectEvent.vala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ public class Objects.ObjectEvent : GLib.Object {
return "tag-outline-symbolic";
} else if (object_key == ObjectEventKeyType.PINNED) {
return "pin-symbolic";
}
} else if (object_key == ObjectEventKeyType.CHECKED) {
return "check-round-outline-symbolic";
} else if (object_key == ObjectEventKeyType.SECTION || object_key == ObjectEventKeyType.PROJECT) {
return "arrow3-right-symbolic";
}
}

return "plus-large-symbolic";
Expand Down
Loading

0 comments on commit 350903a

Please sign in to comment.