Skip to content

Commit 736c9d3

Browse files
authored
Merge pull request #1190 from alainm23/develop
Develop
2 parents 99b7012 + 5dca1f5 commit 736c9d3

File tree

249 files changed

+1034
-7897
lines changed

Some content is hidden

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

249 files changed

+1034
-7897
lines changed
-6.42 MB
Binary file not shown.

build-aux/io.github.alainm23.planify.Devel.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,4 @@
162162
]
163163
}
164164
]
165-
}
165+
}

core/Layouts/HeaderItem.vala

Lines changed: 20 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,8 @@ public class Layouts.HeaderItem : Adw.Bin {
6666
private Gtk.Label name_label;
6767
private Gtk.Label placeholder_label;
6868
private Gtk.ListBox listbox;
69-
private Gtk.Grid content_grid;
69+
private Adw.Bin content_grid;
7070
private Gtk.Box action_box;
71-
private Gtk.Revealer action_revealer;
7271
private Gtk.Revealer content_revealer;
7372
private Gtk.Revealer separator_revealer;
7473
public signal void add_activated ();
@@ -92,18 +91,6 @@ public class Layouts.HeaderItem : Adw.Bin {
9291
}
9392
}
9493

95-
public bool card {
96-
set {
97-
if (value) {
98-
content_grid.add_css_class ("card");
99-
content_grid.add_css_class ("sidebar-card");
100-
} else {
101-
content_grid.remove_css_class ("card");
102-
content_grid.remove_css_class ("sidebar-card");
103-
}
104-
}
105-
}
106-
10794
public bool separator_space {
10895
set {
10996
if (value) {
@@ -120,17 +107,27 @@ public class Layouts.HeaderItem : Adw.Bin {
120107
}
121108
}
122109

123-
public bool box_shadow {
110+
public bool listbox_no_margin {
124111
set {
125112
if (value) {
126-
content_grid.remove_css_class ("sidebar-card");
113+
listbox.margin_top = 0;
114+
listbox.margin_bottom = 0;
115+
listbox.margin_start = 0;
116+
listbox.margin_end = 0;
127117
}
128118
}
129119
}
130120

131-
public bool listbox_no_margin {
121+
public bool card {
132122
set {
133123
if (value) {
124+
listbox.css_classes = { "boxed-list" };
125+
listbox.margin_top = 3;
126+
listbox.margin_bottom = 3;
127+
listbox.margin_start = 3;
128+
listbox.margin_end = 3;
129+
} else {
130+
listbox.css_classes = { };
134131
listbox.margin_top = 0;
135132
listbox.margin_bottom = 0;
136133
listbox.margin_start = 0;
@@ -154,33 +151,25 @@ public class Layouts.HeaderItem : Adw.Bin {
154151
name_label.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL);
155152

156153
listbox = new Gtk.ListBox () {
157-
hexpand = true,
158-
margin_top = 3,
159-
margin_start = 3,
160-
margin_end = 3,
161-
margin_bottom = 3
154+
hexpand = true
162155
};
163156

164157
listbox.set_placeholder (get_placeholder ());
165158
listbox.add_css_class ("bg-transparent");
166159

167-
content_grid = new Gtk.Grid () {
168-
margin_end = 3
160+
content_grid = new Adw.Bin () {
161+
child = listbox
169162
};
170163

171-
content_grid.add_css_class ("card");
172-
content_grid.add_css_class ("sidebar-card");
173-
content_grid.attach (listbox, 0, 0, 1, 1);
174-
175-
action_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
164+
action_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) {
176165
hexpand = true,
177166
halign = END
178167
};
179168

180169
var header_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
181170
hexpand = true,
182171
margin_start = 6,
183-
margin_end = 3
172+
margin_end = 6
184173
};
185174

186175
header_box.append (name_label);
@@ -199,9 +188,7 @@ public class Layouts.HeaderItem : Adw.Bin {
199188

200189
var content_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
201190
hexpand = true,
202-
margin_start = 3,
203-
margin_top = 3,
204-
margin_bottom = 3
191+
margin_top = 3
205192
};
206193

207194
content_box.append (header_box);

core/Objects/BaseObject.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ public class Objects.BaseObject : GLib.Object {
121121
public string icon_name {
122122
get {
123123
if (this is Objects.Today) {
124-
return "planner-today";
124+
return "star-outline-thick-symbolic";
125125
} else if (this is Objects.Scheduled) {
126-
return "planner-scheduled";
126+
return "month-symbolic";
127127
} else if (this is Objects.Pinboard) {
128-
return "planner-pin-tack";
128+
return "pin-symbolic";
129129
} else {
130130
return "";
131131
}

core/Objects/Item.vala

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,12 @@ public class Objects.Item : Objects.BaseObject {
384384
patch_from_vtodo (data, _ics);
385385

386386
var categories = Util.find_string_value ("CATEGORIES", data);
387+
print ("categories: %s\n".printf (categories));
387388
check_labels (get_labels_maps_from_caldav (categories));
388389
}
389390

390391
public void patch_from_vtodo (string data, string _ics) {
392+
ECal.Component ecal = new ECal.Component.from_string (data);
391393
ICal.Component ical = new ICal.Component.from_string (data);
392394

393395
id = ical.get_uid ();
@@ -522,10 +524,8 @@ public class Objects.Item : Objects.BaseObject {
522524
private Gee.ArrayList<Objects.Label> get_caldav_categories (string categories) {
523525
Gee.ArrayList<Objects.Label> return_value = new Gee.ArrayList<Objects.Label> ();
524526

525-
// string _categories = categories.replace ("\\,", ";");
526527
string[] categories_list = categories.split (",");
527528
foreach (unowned string category in categories_list) {
528-
// string category = str.replace (";", ",");
529529
Objects.Label label = Services.Database.get_default ().get_label_by_name (category, true, BackendType.CALDAV);
530530
if (label != null) {
531531
return_value.add (label);
@@ -575,6 +575,15 @@ public class Objects.Item : Objects.BaseObject {
575575
Objects.Label label = Services.Database.get_default ().get_label_by_name (category, true, BackendType.CALDAV);
576576
if (label != null) {
577577
return_value [label.id] = label;
578+
} else {
579+
label = new Objects.Label ();
580+
label.id = Util.get_default ().generate_id (label);
581+
label.color = Util.get_default ().get_random_color ();
582+
label.name = category;
583+
label.backend_type = BackendType.CALDAV;
584+
if (Services.Database.get_default ().insert_label (label)) {
585+
return_value [label.id] = label;
586+
}
578587
}
579588
}
580589

@@ -1163,8 +1172,6 @@ public class Objects.Item : Objects.BaseObject {
11631172
ical.add_property (new ICal.Property.categories (get_labels_names (labels)));
11641173
}
11651174

1166-
stdout.printf ("%s\n", ical.as_ical_string ());
1167-
11681175
return "%s%s%s".printf (
11691176
"BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//Planify App (https://github.com/alainm23/planify)\n",
11701177
ical.as_ical_string (),

core/Objects/Project.vala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,14 +320,14 @@ public class Objects.Project : Objects.BaseObject {
320320
backend_type = BackendType.CALDAV;
321321
}
322322

323-
public void update_from_xml (GXml.DomElement element) {
323+
public void update_from_xml (GXml.DomElement element, bool update_sync_token = true) {
324324
GXml.DomElement propstat = element.get_elements_by_tag_name ("d:propstat").get_element (0);
325325
GXml.DomElement prop = propstat.get_elements_by_tag_name ("d:prop").get_element (0);
326326
name = get_content (prop.get_elements_by_tag_name ("d:displayname").get_element (0));
327327
color = get_content (prop.get_elements_by_tag_name ("x1:calendar-color").get_element (0));
328328

329329
GXml.DomHTMLCollection sync_token_collection = prop.get_elements_by_tag_name ("d:sync-token");
330-
if (sync_token_collection.length > 0) {
330+
if (update_sync_token && sync_token_collection.length > 0) {
331331
sync_id = get_content (sync_token_collection.get_element (0));
332332
}
333333
}

core/QuickAdd.vala

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public class Layouts.QuickAdd : Adw.Bin {
5454
content_entry = new Gtk.Entry () {
5555
hexpand = true,
5656
placeholder_text = _("To-do name"),
57-
css_classes = { "flat" }
57+
css_classes = { "flat", "font-bold" }
5858
};
5959

6060
var content_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) {
@@ -79,7 +79,8 @@ public class Layouts.QuickAdd : Adw.Bin {
7979
description_textview.remove_css_class ("view");
8080

8181
item_labels = new Widgets.ItemLabels (item) {
82-
margin_start = 12
82+
margin_start = 6,
83+
top_margin = 12
8384
};
8485

8586
schedule_button = new Widgets.ScheduleButton ();
@@ -90,9 +91,7 @@ public class Layouts.QuickAdd : Adw.Bin {
9091
label_button.backend_type = item.project.backend_type;
9192

9293
var action_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 12) {
93-
margin_start = 3,
94-
margin_top = 6,
95-
margin_bottom = 3
94+
margin_top = 6
9695
};
9796

9897
var action_box_right = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
@@ -122,7 +121,7 @@ public class Layouts.QuickAdd : Adw.Bin {
122121
quick_add_content.append (action_box);
123122

124123
// Alert Box
125-
var error_icon = new Widgets.DynamicIcon.from_icon_name ("dialog-warning-symbolic");
124+
var error_icon = new Gtk.Image.from_icon_name ("dialog-warning-symbolic");
126125
var error_label = new Gtk.Label ("Error de casa");
127126

128127
var error_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
@@ -141,7 +140,7 @@ public class Layouts.QuickAdd : Adw.Bin {
141140
valign = Gtk.Align.CENTER,
142141
halign = Gtk.Align.CENTER,
143142
popover = build_context_menu_popover (),
144-
child = new Widgets.DynamicIcon.from_icon_name ("dots-vertical"),
143+
icon_name = "view-more-symbolic",
145144
css_classes = { "flat" }
146145
};
147146

@@ -159,7 +158,7 @@ public class Layouts.QuickAdd : Adw.Bin {
159158
var footer_content = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 6) {
160159
hexpand = true,
161160
margin_bottom = 12,
162-
margin_start = 6,
161+
margin_start = 12,
163162
margin_end = 12
164163
};
165164

@@ -197,17 +196,14 @@ public class Layouts.QuickAdd : Adw.Bin {
197196
transition_type = Gtk.StackTransitionType.CROSSFADE
198197
};
199198

200-
added_image = new Gtk.Image ();
201-
added_image.gicon = new ThemedIcon ("planner-completed");
202-
added_image.pixel_size = 64;
203-
204-
var added_label = new Gtk.Label (_("To-do added"));
199+
added_image = new Gtk.Image.from_icon_name ("check-round-outline-symbolic") {
200+
pixel_size = 64
201+
};
205202

206-
var added_box = new Gtk.Box (VERTICAL, 0);
203+
var added_box = new Gtk.Box (VERTICAL, 6);
207204
added_box.halign = Gtk.Align.CENTER;
208205
added_box.valign = Gtk.Align.CENTER;
209206
added_box.append (added_image);
210-
added_box.append (added_label);
211207

212208
main_stack.add_named (main_content, "main");
213209
main_stack.add_named (warning_box, "warning");

core/Services/CalDAV.vala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ public class Services.CalDAV : GLib.Object {
583583
Services.Database.get_default ().insert_project (project);
584584
yield get_all_tasks_by_tasklist (project);
585585
} else {
586-
project.update_from_xml (element);
586+
project.update_from_xml (element, false);
587587
Services.Database.get_default ().update_project (project);
588588
}
589589
} else if (is_deleted_calendar (element)) {
@@ -610,10 +610,15 @@ public class Services.CalDAV : GLib.Object {
610610
var username = Services.Settings.get_default ().settings.get_string ("caldav-username");
611611

612612
var url = "%s/remote.php/dav/calendars/%s/%s".printf (server_url, username, project.id);
613+
print ("URL: %s\n".printf (url));
613614
var message = new Soup.Message ("REPORT", url);
614615
yield set_credential (message);
615616
message.set_request_body_from_bytes ("application/xml", new Bytes ((SYNC_TOKEN_REQUEST.printf (project.sync_id)).data));
616617

618+
if (project.sync_id == "") {
619+
return;
620+
}
621+
617622
try {
618623
GLib.Bytes stream = yield session.send_and_read_async (message, GLib.Priority.HIGH, null);
619624

@@ -631,13 +636,14 @@ public class Services.CalDAV : GLib.Object {
631636
}
632637
} else {
633638
string vtodo = yield get_vtodo_by_url (project.id, ics);
639+
634640
ICal.Component ical = new ICal.Component.from_string (vtodo);
635641
Objects.Item? item = Services.Database.get_default ().get_item (ical.get_uid ());
636642

637-
if (item != null) {
643+
if (item != null) {
638644
string old_project_id = item.project_id;
639645
string old_parent_id = item.parent_id;
640-
646+
641647
item.update_from_vtodo (vtodo, ics);
642648
item.project_id = project.id;
643649
Services.Database.get_default ().update_item (item);
@@ -874,7 +880,6 @@ public class Services.CalDAV : GLib.Object {
874880

875881

876882
var url = "%s/remote.php/dav/calendars/%s/%s/%s".printf (server_url, username, item.project.id, item.ics);
877-
print ("url: %s\n".printf (url));
878883
var message = new Soup.Message ("DELETE", url);
879884
yield set_credential (message);
880885

core/Services/Database.vala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,11 @@ public class Services.Database : GLib.Object {
406406
return return_value;
407407
}
408408

409-
public Gee.ArrayList<Objects.Project> get_subprojects (Objects.Project p) {
409+
public Gee.ArrayList<Objects.Project> get_subprojects (Objects.Project _project) {
410410
Gee.ArrayList<Objects.Project> return_value = new Gee.ArrayList<Objects.Project> ();
411411
lock (_projects) {
412412
foreach (var project in projects) {
413-
if (project.parent_id == p.id) {
413+
if (project.parent_id == _project.id) {
414414
return_value.add (project);
415415
}
416416
}
@@ -595,15 +595,15 @@ public class Services.Database : GLib.Object {
595595
set_parameter_str (stmt, "$id", project.id);
596596

597597
if (stmt.step () == Sqlite.DONE) {
598-
foreach (Objects.Section section in project.sections) {
598+
foreach (Objects.Section section in get_sections_by_project (project)) {
599599
delete_section (section);
600600
}
601601

602-
foreach (Objects.Item item in project.items) {
602+
foreach (Objects.Item item in get_items_by_project (project)) {
603603
delete_item (item);
604604
}
605605

606-
foreach (Objects.Project subproject in project.subprojects) {
606+
foreach (Objects.Project subproject in get_subprojects (project)) {
607607
delete_project (subproject);
608608
}
609609

core/Services/EventBus.vala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,7 @@ public class Services.EventBus : Object {
8080
public signal void item_added_successfully ();
8181

8282
// Navigate
83+
public signal void open_item (Objects.Item item);
8384
public signal void push_item (Objects.Item item);
85+
public signal void close_item ();
8486
}

0 commit comments

Comments
 (0)