Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Support for multiple sync sources #1376

Merged
merged 18 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

### ☁️ Support for Todoist:

- Synchronize your Projects, Task and Sections thanks to Todoist.
- Support for Todoist offline: Work without an internet connection and when everything is reconnected it will be synchronized.
- Planify not created by, affiliated with, or supported by Doist
- Synchronize your Projects, Tasks, and Sections thanks to Todoist.
- Support for Todoist offline: Work without an internet connection; when everything is reconnected, it will be synchronized.
- Planify is not created by, affiliated with, or supported by Doist

### 💎️ Other features:

Expand All @@ -49,6 +49,8 @@

You'll need the following dependencies:

* vala
* meson
* gtk4
* libadwaita

Expand All @@ -69,17 +71,15 @@ Planify follows the [GNOME Code of Conduct](https://conduct.gnome.org/).

- **Be friendly.** Use welcoming and inclusive language.
- **Be empathetic.** Be respectful of differing viewpoints and experiences.
- **Be respectful.** When we disagree, we do so in a polite and constructive
manner.
- **Be considerate.** Remember that decisions are often a difficult choice
between competing priorities.
- **Be respectful.** When we disagree, we do so politely and constructively.
- **Be considerate.** Remember that decisions are often difficult when competing priorities are involved.
- **Be patient and generous.** If someone asks for help it is because they need
it.
- **Try to be concise.** Read the discussion before commenting.


## Support
If you like Planify and you want to support its development, consider supporting via [Patreon](https://www.patreon.com/alainm23), [PayPal](https://www.paypal.me/alainm23) or [Liberapay](https://liberapay.com/Alain)
If you like Planify and want to support its development, consider supporting via [Patreon](https://www.patreon.com/alainm23), [PayPal](https://www.paypal.me/alainm23) or [Liberapay](https://liberapay.com/Alain)

### Bitcoin
`
Expand Down
2 changes: 1 addition & 1 deletion core/Constants.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ namespace Constants {
public const string TODOIST_CLIENT_ID = "b0dd7d3714314b1dbbdab9ee03b6b432";
public const string TODOIST_CLIENT_SECRET = "a86dfeb12139459da3e5e2a8c197c678";
public const string TODOIST_SCOPE = "data:read_write,data:delete,project:delete";
public const string BACKUP_VERSION = "1.0";
public const string BACKUP_VERSION = "2.0";
public const int UPDATE_TIMEOUT = 1500;
public const int DESTROY_TIMEOUT = 750;
public const int SYNC_TIMEOUT = 2500;
Expand Down
69 changes: 64 additions & 5 deletions core/Enum.vala
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,7 @@ public enum FilterType {
}
}

public enum BackendType {
ALL,
public enum SourceType {
NONE,
LOCAL,
TODOIST,
Expand All @@ -155,9 +154,6 @@ public enum BackendType {

public string to_string () {
switch (this) {
case ALL:
return "all";

case NONE:
return "none";

Expand All @@ -177,6 +173,25 @@ public enum BackendType {
assert_not_reached ();
}
}

public static SourceType parse (string value) {
switch (value) {
case "local":
return SourceType.LOCAL;

case "todoist":
return SourceType.TODOIST;

case "google-tasks":
return SourceType.GOOGLE_TASKS;

case "caldav":
return SourceType.CALDAV;

default:
return SourceType.NONE;
}
}
}

public enum PaneType {
Expand Down Expand Up @@ -333,6 +348,45 @@ public enum CalDAVType {
assert_not_reached ();
}
}

public string title () {
switch (this) {
case NEXTCLOUD:
return _("Nextcloud");

case RADICALE:
return _("Radicale");

default:
assert_not_reached ();
}
}

public static CalDAVType parse_index (uint value) {
switch (value) {
case 0:
return CalDAVType.NEXTCLOUD;

case 1:
return CalDAVType.RADICALE;

default:
return CalDAVType.NEXTCLOUD;
}
}

public static CalDAVType parse (string value) {
switch (value) {
case "nextcloud":
return CalDAVType.NEXTCLOUD;

case "radicale":
return CalDAVType.RADICALE;

default:
return CalDAVType.NEXTCLOUD;
}
}
}

public enum FilterItemType {
Expand Down Expand Up @@ -539,4 +593,9 @@ public enum ObjectEventKeyType {
assert_not_reached ();
}
}
}

public enum LabelPickerType {
SELECT,
FILTER
}
56 changes: 47 additions & 9 deletions core/Layouts/HeaderItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,21 @@ public class Layouts.HeaderItem : Adw.Bin {

set {
_header_title = value;
name_label.label = _header_title;
name_label.visible = value != null;
header_label.label = _header_title;
header_label.visible = value != null;
}
}

public string _subheader_title;
public string subheader_title {
get {
return _subheader_title;
}

set {
_subheader_title = value;
subheader_label.label = _subheader_title;
subheader_revealer.reveal_child = value != "";
}
}

Expand Down Expand Up @@ -63,7 +76,9 @@ public class Layouts.HeaderItem : Adw.Bin {
}
}

private Gtk.Label name_label;
private Gtk.Label header_label;
private Gtk.Label subheader_label;
private Gtk.Revealer subheader_revealer;
private Gtk.Label placeholder_label;
private Gtk.ListBox listbox;
private Adw.Bin content_grid;
Expand Down Expand Up @@ -135,6 +150,12 @@ public class Layouts.HeaderItem : Adw.Bin {
}
}
}

public int listbox_margin_top {
set {
listbox.margin_top = value;
}
}

public HeaderItem (string? header_title = null) {
Object (
Expand All @@ -143,12 +164,29 @@ public class Layouts.HeaderItem : Adw.Bin {
}

construct {
name_label = new Gtk.Label (null) {
halign = Gtk.Align.START
header_label = new Gtk.Label (null) {
halign = Gtk.Align.START,
ellipsize = Pango.EllipsizeMode.END
};

header_label.add_css_class ("h4");
header_label.add_css_class ("heading");

subheader_label = new Gtk.Label (null) {
halign = Gtk.Align.START,
css_classes = { "caption", "dim-label" }
};

name_label.add_css_class ("h4");
name_label.add_css_class ("heading");
subheader_revealer = new Gtk.Revealer () {
transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN,
child = subheader_label
};

var header_label_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
valign = Gtk.Align.CENTER
};
header_label_box.append (header_label);
header_label_box.append (subheader_revealer);

listbox = new Gtk.ListBox () {
hexpand = true,
Expand All @@ -173,11 +211,11 @@ public class Layouts.HeaderItem : Adw.Bin {
margin_end = 6
};

header_box.append (name_label);
header_box.append (header_label_box);
header_box.append (action_box);

var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) {
margin_top = 3,
margin_top = 6,
margin_start = 3,
margin_bottom = 3
};
Expand Down
10 changes: 2 additions & 8 deletions core/Objects/Attachment.vala
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,14 @@ public class Objects.Attachment : GLib.Object {
Objects.Item? _item;
public Objects.Item item {
get {
_item = Services.Database.get_default ().get_item (item_id);
_item = Services.Store.instance ().get_item (item_id);
return _item;
}

set {
_item = value;
}
}

construct {
deleted.connect (() => {
Services.Database.get_default ().attachment_deleted (this);
});
}

public string to_string () {
return """
Expand All @@ -68,7 +62,7 @@ public class Objects.Attachment : GLib.Object {
}

public void delete () {
Services.Database.get_default ().delete_attachment (this);
Services.Store.instance ().delete_attachment (this);
}

public Objects.Attachment duplicate () {
Expand Down
44 changes: 39 additions & 5 deletions core/Objects/BaseObject.vala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class Objects.BaseObject : GLib.Object {
public string name { get; set; default = ""; }
public string keywords { get; set; default = ""; }
public string icon_name { get; set; default = ""; }

public signal void deleted ();
public signal void updated (string update_id = "");
public signal void archived ();
Expand Down Expand Up @@ -175,15 +176,48 @@ public class Objects.BaseObject : GLib.Object {
get {
if (this is Objects.Item) {
return "child_order";
} else if (this is Objects.Section) {
}

if (this is Objects.Section) {
return "section_order";
} else if (this is Objects.Project) {
}

if (this is Objects.Project) {
return "child_order";
} else if (this is Objects.Label) {
}

if (this is Objects.Label) {
return "item_order";
} else {
return "";
}

return "";
}
}

Objects.Source? _source;
public Objects.Source source {
get {
if (this is Objects.Project) {
return ((Objects.Project) this).source;
}

if (this is Objects.Section) {
return ((Objects.Section) this).project.source;
}

if (this is Objects.Item) {
return ((Objects.Item) this).project.source;
}

if (this is Objects.Label) {
return ((Objects.Label) this).source;
}

if (this is Objects.Reminder) {
return ((Objects.Reminder) this).item.project.source;
}

return _source;
}
}

Expand Down
22 changes: 11 additions & 11 deletions core/Objects/Filters/Completed.vala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class Objects.Filters.Completed : Objects.BaseObject {
public int count {
get {
if (_count == null) {
_count = Services.Database.get_default ().get_items_completed ().size;
_count = Services.Store.instance ().get_items_completed ().size;
}

return _count;
Expand All @@ -52,28 +52,28 @@ public class Objects.Filters.Completed : Objects.BaseObject {
icon_name = "check-round-outline-symbolic";
view_id = FilterType.COMPLETED.to_string ();

Services.Database.get_default ().item_added.connect (() => {
_count = Services.Database.get_default ().get_items_completed ().size;
Services.Store.instance ().item_added.connect (() => {
_count = Services.Store.instance ().get_items_completed ().size;
count_updated ();
});

Services.Database.get_default ().item_deleted.connect (() => {
_count = Services.Database.get_default ().get_items_completed ().size;
Services.Store.instance ().item_deleted.connect (() => {
_count = Services.Store.instance ().get_items_completed ().size;
count_updated ();
});

Services.Database.get_default ().item_updated.connect (() => {
_count = Services.Database.get_default ().get_items_completed ().size;
Services.Store.instance ().item_updated.connect (() => {
_count = Services.Store.instance ().get_items_completed ().size;
count_updated ();
});

Services.Database.get_default ().item_archived.connect (() => {
_count = Services.Database.get_default ().get_items_completed ().size;
Services.Store.instance ().item_archived.connect (() => {
_count = Services.Store.instance ().get_items_completed ().size;
count_updated ();
});

Services.Database.get_default ().item_unarchived.connect (() => {
_count = Services.Database.get_default ().get_items_completed ().size;
Services.Store.instance ().item_unarchived.connect (() => {
_count = Services.Store.instance ().get_items_completed ().size;
count_updated ();
});
}
Expand Down
Loading
Loading