Skip to content

Commit f3a00a9

Browse files
authored
Merge pull request #1376 from alainm23/develop
Feature: Support for multiple sync sources
2 parents 3771950 + 1ea0d35 commit f3a00a9

File tree

110 files changed

+11313
-9948
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+11313
-9948
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@
2222

2323
### ☁️ Support for Todoist:
2424

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

2929
### 💎️ Other features:
3030

@@ -49,6 +49,8 @@
4949

5050
You'll need the following dependencies:
5151

52+
* vala
53+
* meson
5254
* gtk4
5355
* libadwaita
5456

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

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

8080

8181
## Support
82-
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)
82+
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)
8383

8484
### Bitcoin
8585
`

core/Constants.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ namespace Constants {
22
public const string TODOIST_CLIENT_ID = "b0dd7d3714314b1dbbdab9ee03b6b432";
33
public const string TODOIST_CLIENT_SECRET = "a86dfeb12139459da3e5e2a8c197c678";
44
public const string TODOIST_SCOPE = "data:read_write,data:delete,project:delete";
5-
public const string BACKUP_VERSION = "1.0";
5+
public const string BACKUP_VERSION = "2.0";
66
public const int UPDATE_TIMEOUT = 1500;
77
public const int DESTROY_TIMEOUT = 750;
88
public const int SYNC_TIMEOUT = 2500;

core/Enum.vala

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,7 @@ public enum FilterType {
145145
}
146146
}
147147

148-
public enum BackendType {
149-
ALL,
148+
public enum SourceType {
150149
NONE,
151150
LOCAL,
152151
TODOIST,
@@ -155,9 +154,6 @@ public enum BackendType {
155154

156155
public string to_string () {
157156
switch (this) {
158-
case ALL:
159-
return "all";
160-
161157
case NONE:
162158
return "none";
163159

@@ -177,6 +173,25 @@ public enum BackendType {
177173
assert_not_reached ();
178174
}
179175
}
176+
177+
public static SourceType parse (string value) {
178+
switch (value) {
179+
case "local":
180+
return SourceType.LOCAL;
181+
182+
case "todoist":
183+
return SourceType.TODOIST;
184+
185+
case "google-tasks":
186+
return SourceType.GOOGLE_TASKS;
187+
188+
case "caldav":
189+
return SourceType.CALDAV;
190+
191+
default:
192+
return SourceType.NONE;
193+
}
194+
}
180195
}
181196

182197
public enum PaneType {
@@ -333,6 +348,45 @@ public enum CalDAVType {
333348
assert_not_reached ();
334349
}
335350
}
351+
352+
public string title () {
353+
switch (this) {
354+
case NEXTCLOUD:
355+
return _("Nextcloud");
356+
357+
case RADICALE:
358+
return _("Radicale");
359+
360+
default:
361+
assert_not_reached ();
362+
}
363+
}
364+
365+
public static CalDAVType parse_index (uint value) {
366+
switch (value) {
367+
case 0:
368+
return CalDAVType.NEXTCLOUD;
369+
370+
case 1:
371+
return CalDAVType.RADICALE;
372+
373+
default:
374+
return CalDAVType.NEXTCLOUD;
375+
}
376+
}
377+
378+
public static CalDAVType parse (string value) {
379+
switch (value) {
380+
case "nextcloud":
381+
return CalDAVType.NEXTCLOUD;
382+
383+
case "radicale":
384+
return CalDAVType.RADICALE;
385+
386+
default:
387+
return CalDAVType.NEXTCLOUD;
388+
}
389+
}
336390
}
337391

338392
public enum FilterItemType {
@@ -539,4 +593,9 @@ public enum ObjectEventKeyType {
539593
assert_not_reached ();
540594
}
541595
}
596+
}
597+
598+
public enum LabelPickerType {
599+
SELECT,
600+
FILTER
542601
}

core/Layouts/HeaderItem.vala

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,21 @@ public class Layouts.HeaderItem : Adw.Bin {
3030

3131
set {
3232
_header_title = value;
33-
name_label.label = _header_title;
34-
name_label.visible = value != null;
33+
header_label.label = _header_title;
34+
header_label.visible = value != null;
35+
}
36+
}
37+
38+
public string _subheader_title;
39+
public string subheader_title {
40+
get {
41+
return _subheader_title;
42+
}
43+
44+
set {
45+
_subheader_title = value;
46+
subheader_label.label = _subheader_title;
47+
subheader_revealer.reveal_child = value != "";
3548
}
3649
}
3750

@@ -63,7 +76,9 @@ public class Layouts.HeaderItem : Adw.Bin {
6376
}
6477
}
6578

66-
private Gtk.Label name_label;
79+
private Gtk.Label header_label;
80+
private Gtk.Label subheader_label;
81+
private Gtk.Revealer subheader_revealer;
6782
private Gtk.Label placeholder_label;
6883
private Gtk.ListBox listbox;
6984
private Adw.Bin content_grid;
@@ -135,6 +150,12 @@ public class Layouts.HeaderItem : Adw.Bin {
135150
}
136151
}
137152
}
153+
154+
public int listbox_margin_top {
155+
set {
156+
listbox.margin_top = value;
157+
}
158+
}
138159

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

145166
construct {
146-
name_label = new Gtk.Label (null) {
147-
halign = Gtk.Align.START
167+
header_label = new Gtk.Label (null) {
168+
halign = Gtk.Align.START,
169+
ellipsize = Pango.EllipsizeMode.END
170+
};
171+
172+
header_label.add_css_class ("h4");
173+
header_label.add_css_class ("heading");
174+
175+
subheader_label = new Gtk.Label (null) {
176+
halign = Gtk.Align.START,
177+
css_classes = { "caption", "dim-label" }
148178
};
149179

150-
name_label.add_css_class ("h4");
151-
name_label.add_css_class ("heading");
180+
subheader_revealer = new Gtk.Revealer () {
181+
transition_type = Gtk.RevealerTransitionType.SLIDE_DOWN,
182+
child = subheader_label
183+
};
184+
185+
var header_label_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
186+
valign = Gtk.Align.CENTER
187+
};
188+
header_label_box.append (header_label);
189+
header_label_box.append (subheader_revealer);
152190

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

176-
header_box.append (name_label);
214+
header_box.append (header_label_box);
177215
header_box.append (action_box);
178216

179217
var separator = new Gtk.Separator (Gtk.Orientation.HORIZONTAL) {
180-
margin_top = 3,
218+
margin_top = 6,
181219
margin_start = 3,
182220
margin_bottom = 3
183221
};

core/Objects/Attachment.vala

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,14 @@ public class Objects.Attachment : GLib.Object {
3232
Objects.Item? _item;
3333
public Objects.Item item {
3434
get {
35-
_item = Services.Database.get_default ().get_item (item_id);
35+
_item = Services.Store.instance ().get_item (item_id);
3636
return _item;
3737
}
3838

3939
set {
4040
_item = value;
4141
}
4242
}
43-
44-
construct {
45-
deleted.connect (() => {
46-
Services.Database.get_default ().attachment_deleted (this);
47-
});
48-
}
4943

5044
public string to_string () {
5145
return """
@@ -68,7 +62,7 @@ public class Objects.Attachment : GLib.Object {
6862
}
6963

7064
public void delete () {
71-
Services.Database.get_default ().delete_attachment (this);
65+
Services.Store.instance ().delete_attachment (this);
7266
}
7367

7468
public Objects.Attachment duplicate () {

core/Objects/BaseObject.vala

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class Objects.BaseObject : GLib.Object {
2424
public string name { get; set; default = ""; }
2525
public string keywords { get; set; default = ""; }
2626
public string icon_name { get; set; default = ""; }
27+
2728
public signal void deleted ();
2829
public signal void updated (string update_id = "");
2930
public signal void archived ();
@@ -175,15 +176,48 @@ public class Objects.BaseObject : GLib.Object {
175176
get {
176177
if (this is Objects.Item) {
177178
return "child_order";
178-
} else if (this is Objects.Section) {
179+
}
180+
181+
if (this is Objects.Section) {
179182
return "section_order";
180-
} else if (this is Objects.Project) {
183+
}
184+
185+
if (this is Objects.Project) {
181186
return "child_order";
182-
} else if (this is Objects.Label) {
187+
}
188+
189+
if (this is Objects.Label) {
183190
return "item_order";
184-
} else {
185-
return "";
191+
}
192+
193+
return "";
194+
}
195+
}
196+
197+
Objects.Source? _source;
198+
public Objects.Source source {
199+
get {
200+
if (this is Objects.Project) {
201+
return ((Objects.Project) this).source;
202+
}
203+
204+
if (this is Objects.Section) {
205+
return ((Objects.Section) this).project.source;
206+
}
207+
208+
if (this is Objects.Item) {
209+
return ((Objects.Item) this).project.source;
210+
}
211+
212+
if (this is Objects.Label) {
213+
return ((Objects.Label) this).source;
186214
}
215+
216+
if (this is Objects.Reminder) {
217+
return ((Objects.Reminder) this).item.project.source;
218+
}
219+
220+
return _source;
187221
}
188222
}
189223

core/Objects/Filters/Completed.vala

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class Objects.Filters.Completed : Objects.BaseObject {
3333
public int count {
3434
get {
3535
if (_count == null) {
36-
_count = Services.Database.get_default ().get_items_completed ().size;
36+
_count = Services.Store.instance ().get_items_completed ().size;
3737
}
3838

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

55-
Services.Database.get_default ().item_added.connect (() => {
56-
_count = Services.Database.get_default ().get_items_completed ().size;
55+
Services.Store.instance ().item_added.connect (() => {
56+
_count = Services.Store.instance ().get_items_completed ().size;
5757
count_updated ();
5858
});
5959

60-
Services.Database.get_default ().item_deleted.connect (() => {
61-
_count = Services.Database.get_default ().get_items_completed ().size;
60+
Services.Store.instance ().item_deleted.connect (() => {
61+
_count = Services.Store.instance ().get_items_completed ().size;
6262
count_updated ();
6363
});
6464

65-
Services.Database.get_default ().item_updated.connect (() => {
66-
_count = Services.Database.get_default ().get_items_completed ().size;
65+
Services.Store.instance ().item_updated.connect (() => {
66+
_count = Services.Store.instance ().get_items_completed ().size;
6767
count_updated ();
6868
});
6969

70-
Services.Database.get_default ().item_archived.connect (() => {
71-
_count = Services.Database.get_default ().get_items_completed ().size;
70+
Services.Store.instance ().item_archived.connect (() => {
71+
_count = Services.Store.instance ().get_items_completed ().size;
7272
count_updated ();
7373
});
7474

75-
Services.Database.get_default ().item_unarchived.connect (() => {
76-
_count = Services.Database.get_default ().get_items_completed ().size;
75+
Services.Store.instance ().item_unarchived.connect (() => {
76+
_count = Services.Store.instance ().get_items_completed ().size;
7777
count_updated ();
7878
});
7979
}

0 commit comments

Comments
 (0)