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

Release 4.3 #1082

Merged
merged 12 commits into from
Dec 19, 2023
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
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"mesonbuild.configureOnOpen": false
}
1 change: 1 addition & 0 deletions config.vala.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ namespace Build {
public const string INSTALL_PREFIX = @PREFIX@;
public const string DATADIR = @DATADIR@;
public const string PROFILE = @PROFILE@;
public const string LOCALEDIR = @LOCALEDIR@;
}
1 change: 1 addition & 0 deletions core/Constants.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +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 int UPDATE_TIMEOUT = 1500;
public const int DESTROY_TIMEOUT = 750;
public const int DRAG_TIMEOUT = 225;
Expand Down
6 changes: 3 additions & 3 deletions core/Enum.vala
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public enum FilterType {
SCHEDULED = 2,
PINBOARD = 3,
LABEL = 4,
FILTER = 5;
LABELS = 5;

public string to_string () {
switch (this) {
Expand All @@ -91,8 +91,8 @@ public enum FilterType {
case LABEL:
return "label";

case FILTER:
return "filter";
case LABELS:
return "labels";

default:
assert_not_reached ();
Expand Down
41 changes: 38 additions & 3 deletions src/Layouts/HeaderItem.vala → core/Layouts/HeaderItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ public class Layouts.HeaderItem : Adw.Bin {
set {
_header_title = value;
name_label.label = _header_title;
name_label.visible = value != null;
}
}

Expand Down Expand Up @@ -116,6 +117,33 @@ public class Layouts.HeaderItem : Adw.Bin {
}
}
}

public bool separator_lines {
set {
if (value) {
listbox.add_css_class ("separator-lines");
}
}
}

public bool box_shadow {
set {
if (value) {
content_grid.remove_css_class ("sidebar-card");
}
}
}

public bool listbox_no_margin {
set {
if (value) {
listbox.margin_top = 0;
listbox.margin_bottom = 0;
listbox.margin_start = 0;
listbox.margin_end = 0;
}
}
}

public HeaderItem (string? header_title = null) {
Object (
Expand All @@ -132,19 +160,22 @@ public class Layouts.HeaderItem : Adw.Bin {
name_label.add_css_class (Granite.STYLE_CLASS_SMALL_LABEL);

listbox = new Gtk.ListBox () {
hexpand = true
hexpand = true,
margin_top = 3,
margin_bottom = 3,
margin_start = 3,
margin_end = 3
};

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

content_grid = new Gtk.Grid () {
margin_end = 1
margin_end = 3
};

content_grid.add_css_class ("card");
content_grid.add_css_class ("sidebar-card");
content_grid.add_css_class ("padding-3");
content_grid.attach (listbox, 0, 0, 1, 1);

action_box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0) {
Expand Down Expand Up @@ -241,6 +272,10 @@ public class Layouts.HeaderItem : Adw.Bin {
listbox.append (widget);
}

public void insert_child (Gtk.Widget widget, int position) {
listbox.insert (widget, position);
}

public void add_widget_end (Gtk.Widget widget) {
action_box.append (widget);
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class Objects.Priority : Objects.BaseObject {

construct {
name = Util.get_default ().get_priority_title (priority);
keywords = "%s;%s".printf (_("priority"), "p" + priority.to_string ());
keywords = Util.get_default ().get_priority_keywords (priority);

Services.Database.get_default ().item_added.connect (() => {
_count = Services.Database.get_default ().get_items_by_priority (priority, false).size;
Expand Down
File renamed without changes.
File renamed without changes.
52 changes: 37 additions & 15 deletions src/Objects/Item.vala → core/Objects/Item.vala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class Objects.Item : Objects.BaseObject {
public string project_id { get; set; default = ""; }
public string parent_id { get; set; default = ""; }

public int priority { get; set; default = 0; }
public int priority { get; set; default = Constants.PRIORITY_4; }

public bool activate_name_editable { get; set; default = false; }

Expand Down Expand Up @@ -85,7 +85,7 @@ public class Objects.Item : Objects.BaseObject {
public bool pinned { get; set; default = false; }
public string pinned_icon {
get {
return pinned ? "planner-pinned-activated" : "planner-pinned";
return pinned ? "planner-pin-tack" : "planner-pinned";
}
}

Expand Down Expand Up @@ -205,6 +205,7 @@ public class Objects.Item : Objects.BaseObject {
public signal void reminder_added (Objects.Reminder reminder);
public signal void reminder_deleted (Objects.Reminder reminder);
public signal void loading_changed (bool value);

construct {
deleted.connect (() => {
Idle.add (() => {
Expand All @@ -220,6 +221,27 @@ public class Objects.Item : Objects.BaseObject {
update_local_labels (get_labels_from_json (node));
}

public Item.from_import_json (Json.Node node) {
id = node.get_object ().get_string_member ("id");
content = node.get_object ().get_string_member ("content");
description = node.get_object ().get_string_member ("description");
added_at = node.get_object ().get_string_member ("added_at");
completed_at = node.get_object ().get_string_member ("completed_at");
updated_at = node.get_object ().get_string_member ("updated_at");
section_id = node.get_object ().get_string_member ("section_id");
project_id = node.get_object ().get_string_member ("project_id");
parent_id = node.get_object ().get_string_member ("parent_id");
priority = (int32) node.get_object ().get_int_member ("priority");
child_order = (int32) node.get_object ().get_int_member ("child_order");
checked = node.get_object ().get_boolean_member ("checked");
is_deleted = node.get_object ().get_boolean_member ("is_deleted");
day_order = (int32) node.get_object ().get_int_member ("day_order");
due.update_from_json (Services.Database.get_default ().get_due_parameter (node.get_object ().get_string_member ("due")));
collapsed = node.get_object ().get_boolean_member ("collapsed");
pinned = node.get_object ().get_boolean_member ("pinned");
update_local_labels (get_labels_from_json (node));
}

public void update_labels_from_json (Json.Node node) {
update_labels_async (get_labels_from_json (node));
}
Expand Down Expand Up @@ -641,8 +663,6 @@ public class Objects.Item : Objects.BaseObject {
Json.Generator generator = new Json.Generator ();
Json.Node root = builder.get_root ();
generator.set_root (root);

print ("%s\n".printf (generator.to_data (null)));
return generator.to_data (null);
}

Expand Down Expand Up @@ -670,7 +690,7 @@ public class Objects.Item : Objects.BaseObject {
}
}

if (section_id != "") {
if (parent_id != "") {
builder.set_member_name ("parent_id");
if (Services.Database.get_default ().curTempIds_exists (parent_id)) {
builder.add_string_value (Services.Database.get_default ().get_temp_id (parent_id));
Expand Down Expand Up @@ -705,12 +725,14 @@ public class Objects.Item : Objects.BaseObject {
builder.add_null_value ();
}

// builder.set_member_name ("labels");
// builder.begin_array ();
// foreach (Objects.ItemLabel item_label in labels.values) {
// builder.add_string_value (item_label.label.name);
// }
// builder.end_array ();
builder.set_member_name ("labels");
builder.begin_array ();
foreach (Objects.ItemLabel item_label in labels.values) {
if (item_label.label.backend_type == BackendType.TODOIST) {
builder.add_string_value (item_label.label.name);
}
}
builder.end_array ();
builder.end_object ();

Json.Generator generator = new Json.Generator ();
Expand Down Expand Up @@ -777,9 +799,9 @@ public class Objects.Item : Objects.BaseObject {

if (project.backend_type == BackendType.TODOIST) {
Services.Todoist.get_default ().add.begin (new_item, (obj, res) => {
string? id = Services.Todoist.get_default ().add.end (res);
if (id != null) {
new_item.id = id;
TodoistResponse response = Services.Todoist.get_default ().add.end (res);
if (response.status) {
new_item.id = response.data;
insert_duplicate (new_item);
}
});
Expand Down Expand Up @@ -810,7 +832,7 @@ public class Objects.Item : Objects.BaseObject {
public void delete_item () {
if (project.backend_type == BackendType.TODOIST) {
Services.Todoist.get_default ().delete.begin (this, (obj, res) => {
if (Services.Todoist.get_default ().delete.end (res)) {
if (Services.Todoist.get_default ().delete.end (res).status) {
Services.Database.get_default ().delete_item (this);
}
});
Expand Down
File renamed without changes.
59 changes: 9 additions & 50 deletions src/Objects/Label.vala → core/Objects/Label.vala
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ public class Objects.Label : Objects.BaseObject {
backend_type = BackendType.TODOIST;
}

public Label.from_import_json (Json.Node node) {
id = node.get_object ().get_string_member ("id");
name = node.get_object ().get_string_member ("name");
color = node.get_object ().get_string_member ("color");
backend_type = Util.get_default ().get_backend_type_by_text (node.get_object ().get_string_member ("backend_type"));
is_deleted = node.get_object ().get_boolean_member ("is_deleted");
is_favorite = node.get_object ().get_boolean_member ("is_favorite");
}

public void update_from_json (Json.Node node) {
name = node.get_object ().get_string_member ("name");

Expand Down Expand Up @@ -175,54 +184,4 @@ public class Objects.Label : Objects.BaseObject {

return generator.to_data (null);
}

public void delete (bool confirm = true) {
// if (!confirm) {
// if (todoist) {
// Planify.todoist.delete.begin (this, (obj, res) => {
// Planify.todoist.delete.end (res);
// Services.Database.get_default ().delete_label (this);
// });
// } else {
// Services.Database.get_default ().delete_label (this);
// }

// return;
// }

// var message_dialog = new Dialogs.MessageDialog (
// _("Delete label"),
// _("Are you sure you want to delete <b>%s</b>?".printf (Util.get_default ().get_dialog_text (short_name))),
// "dialog-warning"
// );
// message_dialog.add_default_action (_("Cancel"), Gtk.ResponseType.CANCEL);
// message_dialog.show_all ();

// var remove_button = new Widgets.LoadingButton (
// LoadingButtonType.LABEL, _("Delete")) {
// hexpand = true
// };
// remove_button.get_style_context ().add_class (Gtk.STYLE_CLASS_DESTRUCTIVE_ACTION);
// remove_button.get_style_context ().add_class ("border-radius-6");
// message_dialog.add_action_widget (remove_button, Gtk.ResponseType.ACCEPT);

// message_dialog.default_action.connect ((response) => {
// if (response == Gtk.ResponseType.ACCEPT) {
// if (todoist) {
// remove_button.is_loading = true;
// Planify.todoist.delete.begin (this, (obj, res) => {
// Planify.todoist.delete.end (res);
// Services.Database.get_default ().delete_label (this);
// remove_button.is_loading = false;
// message_dialog.hide_destroy ();
// });
// } else {
// Services.Database.get_default ().delete_label (this);
// message_dialog.hide_destroy ();
// }
// } else {
// message_dialog.hide_destroy ();
// }
// });
}
}
Loading
Loading