Skip to content

Commit

Permalink
Fix #1055
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed Dec 8, 2023
1 parent d6ad587 commit 5ccb8ef
Show file tree
Hide file tree
Showing 14 changed files with 97 additions and 188 deletions.
2 changes: 0 additions & 2 deletions config.vala.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ namespace Constants {
public const string TODOIST_CLIENT_SECRET = "a86dfeb12139459da3e5e2a8c197c678";
public const string TODOIST_SCOPE = "data:read_write,data:delete,project:delete";
public const string PROFILE = @PROFILE@;
public const int ACTIVE = 1;
public const int INACTIVE = 0;
public const int UPDATE_TIMEOUT = 1500;
public const int DESTROY_TIMEOUT = 750;
public const int DRAG_TIMEOUT = 225;
Expand Down
5 changes: 5 additions & 0 deletions data/io.github.alainm23.planify.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@
<enum id="io.github.alainm23.planify.start-week">
<value nick="Sunday" value="0" />
<value nick="Monday" value="1" />
<value nick="Tuesday" value="2" />
<value nick="Wednesday" value="3" />
<value nick="Thursday" value="4" />
<value nick="Friday" value="5" />
<value nick="Saturday" value="6" />
</enum>

<enum id="io.github.alainm23.planify.new-tasks-position">
Expand Down
2 changes: 1 addition & 1 deletion quick-add/Objects/BaseObject.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Objects.BaseObject : GLib.Object {
public signal void deleted ();
public signal void updated ();

public uint update_timeout_id { get; set; default = Constants.INACTIVE; }
public uint update_timeout_id { get; set; default = 0; }

string _id_string;
public string id_string {
Expand Down
8 changes: 4 additions & 4 deletions quick-add/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 = Constants.INACTIVE; }
public int priority { get; set; default = 0; }

public string priority_icon {
get {
Expand Down Expand Up @@ -74,8 +74,8 @@ public class Objects.Item : Objects.BaseObject {
}
}

public int child_order { get; set; default = Constants.INACTIVE; }
public int day_order { get; set; default = Constants.INACTIVE; }
public int child_order { get; set; default = 0; }
public int day_order { get; set; default = 0; }
public bool checked { get; set; default = false; }
public bool is_deleted { get; set; default = false; }
public bool collapsed { get; set; default = false; }
Expand Down Expand Up @@ -195,7 +195,7 @@ public class Objects.Item : Objects.BaseObject {
builder.add_string_value (Util.get_default ().get_encode_text (description));

builder.set_member_name ("priority");
if (priority == Constants.INACTIVE) {
if (priority == 0) {
builder.add_int_value (Constants.PRIORITY_4);
} else {
builder.add_int_value (priority);
Expand Down
4 changes: 2 additions & 2 deletions quick-add/Services/Database.vala
Original file line number Diff line number Diff line change
Expand Up @@ -341,10 +341,10 @@ public class Services.Database : GLib.Object {

private void set_parameter_bool (Sqlite.Statement? stmt, string par, bool val) {
int par_position = stmt.bind_parameter_index (par);
stmt.bind_int (par_position, val ? Constants.ACTIVE : Constants.INACTIVE);
stmt.bind_int (par_position, val ? 1 : 0);
}

private bool get_parameter_bool (Sqlite.Statement stmt, int col) {
return stmt.column_int (col) == Constants.ACTIVE;
return stmt.column_int (col) == 1;
}
}
144 changes: 26 additions & 118 deletions src/Dialogs/Preferences/PreferencesWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ public class Dialogs.Preferences.PreferencesWindow : Adw.PreferencesWindow {
var start_week_model = new Gtk.StringList (null);
start_week_model.append (_("Sunday"));
start_week_model.append (_("Monday"));
start_week_model.append (_("Tuesday"));
start_week_model.append (_("Wednesday"));
start_week_model.append (_("Thursday"));
start_week_model.append (_("Friday"));
start_week_model.append (_("Saturday"));

var start_week_row = new Adw.ComboRow ();
start_week_row.title = _("Start of the week");
Expand Down Expand Up @@ -274,7 +279,6 @@ public class Dialogs.Preferences.PreferencesWindow : Adw.PreferencesWindow {

var content_clamp = new Adw.Clamp () {
maximum_size = 600,
margin_top = 24,
margin_start = 24,
margin_end = 24,
margin_bottom = 24
Expand All @@ -289,15 +293,11 @@ public class Dialogs.Preferences.PreferencesWindow : Adw.PreferencesWindow {
};
scrolled_window.child = content_clamp;

var main_content = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
vexpand = true,
hexpand = true
};

main_content.append (settings_header);
main_content.append (scrolled_window);
var toolbar_view = new Adw.ToolbarView ();
toolbar_view.add_top_bar (settings_header);
toolbar_view.content = scrolled_window;

var page = new Adw.NavigationPage (main_content, "general");
var page = new Adw.NavigationPage (toolbar_view, "general");

sort_projects_row.notify["selected"].connect (() => {
Services.Settings.get_default ().settings.set_enum ("projects-sort-by", (int) sort_projects_row.selected);
Expand Down Expand Up @@ -439,7 +439,6 @@ public class Dialogs.Preferences.PreferencesWindow : Adw.PreferencesWindow {

var content_clamp = new Adw.Clamp () {
maximum_size = 600,
margin_top = 24,
margin_start = 24,
margin_end = 24
};
Expand Down Expand Up @@ -631,22 +630,18 @@ public class Dialogs.Preferences.PreferencesWindow : Adw.PreferencesWindow {

var content_clamp = new Adw.Clamp () {
maximum_size = 600,
margin_top = 24,
margin_start = 24,
margin_end = 24
margin_end = 24,
margin_top = 12
};

content_clamp.child = content_box;

var main_content = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
vexpand = true,
hexpand = true
};

main_content.append (settings_header);
main_content.append (content_clamp);
var toolbar_view = new Adw.ToolbarView ();
toolbar_view.add_top_bar (settings_header);
toolbar_view.content = content_clamp;

var page = new Adw.NavigationPage (main_content, "account");
var page = new Adw.NavigationPage (toolbar_view, "account");

var todoist_switch_gesture = new Gtk.GestureClick ();
todoist_switch_gesture.set_button (1);
Expand Down Expand Up @@ -713,7 +708,7 @@ public class Dialogs.Preferences.PreferencesWindow : Adw.PreferencesWindow {
});

google_tasks_button.clicked.connect (() => {
push_subpage (get_google_view ());

});

inbox_project_row.notify["selected"].connect (() => {
Expand Down Expand Up @@ -758,7 +753,6 @@ public class Dialogs.Preferences.PreferencesWindow : Adw.PreferencesWindow {

var content_clamp = new Adw.Clamp () {
maximum_size = 600,
margin_top = 24,
margin_start = 24,
margin_end = 24
};
Expand Down Expand Up @@ -797,96 +791,14 @@ public class Dialogs.Preferences.PreferencesWindow : Adw.PreferencesWindow {
hexpand = true
};

main_content.append (settings_header);
main_content.append (user_box);
main_content.append (content_clamp);

var page = new Adw.NavigationPage (main_content, "todoist");

settings_header.back_activated.connect (() => {
pop_subpage ();
});

sync_server_row.notify["active"].connect (() => {
Services.Settings.get_default ().settings.set_boolean ("todoist-sync-server", sync_server_switch.active);
});

return page;
}

private Adw.NavigationPage get_google_view () {
var settings_header = new Widgets.SettingsHeader (_("Google Tasks"));

var avatar = new Adw.Avatar (84, Services.Settings.get_default ().settings.get_string ("google-user-name"), true);

var file = File.new_for_path (Util.get_default ().get_avatar_path ("google-user"));
if (file.query_exists ()) {
// todoist_avatar.set_loadable_icon (new FileIcon (file));
}

var user_label = new Gtk.Label (Services.Settings.get_default ().settings.get_string ("google-user-name")) {
margin_top = 12
};
user_label.add_css_class ("title-1");

var email_label = new Gtk.Label (Services.Settings.get_default ().settings.get_string ("todoist-user-email"));
email_label.add_css_class (Granite.STYLE_CLASS_DIM_LABEL);

var user_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
margin_top = 64
};
user_box.append (avatar);
user_box.append (user_label);
user_box.append (email_label);

var default_group = new Adw.PreferencesGroup ();

var content_clamp = new Adw.Clamp () {
maximum_size = 400,
margin_top = 24,
margin_start = 24,
margin_end = 24
};

content_clamp.child = default_group;

var sync_server_switch = new Gtk.Switch () {
valign = Gtk.Align.CENTER,
active = Services.Settings.get_default ().settings.get_boolean ("todoist-sync-server")
};

var sync_server_row = new Adw.ActionRow ();
sync_server_row.title = _("Sync Server");
sync_server_row.subtitle = _("Activate this setting so that Planner automatically synchronizes with your Todoist account every 15 minutes.");
sync_server_row.set_activatable_widget (sync_server_switch);
sync_server_row.add_suffix (sync_server_switch);

var last_sync_date = new GLib.DateTime.from_iso8601 (
Services.Settings.get_default ().settings.get_string ("todoist-last-sync"), new GLib.TimeZone.local ()
);

var last_sync_label = new Gtk.Label (Util.get_default ().get_relative_date_from_date (
last_sync_date
));

var last_sync_row = new Adw.ActionRow ();
last_sync_row.activatable = false;
last_sync_row.title = _("Last Sync");
last_sync_row.add_suffix (last_sync_label);

default_group.add (sync_server_row);
default_group.add (last_sync_row);

var main_content = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
vexpand = true,
hexpand = true
};

main_content.append (settings_header);
main_content.append (user_box);
main_content.append (content_clamp);
var toolbar_view = new Adw.ToolbarView ();
toolbar_view.add_top_bar (settings_header);
toolbar_view.content = main_content;

var page = new Adw.NavigationPage (main_content, "google");
var page = new Adw.NavigationPage (toolbar_view, "todoist");

settings_header.back_activated.connect (() => {
pop_subpage ();
Expand Down Expand Up @@ -940,22 +852,18 @@ public class Dialogs.Preferences.PreferencesWindow : Adw.PreferencesWindow {

var content_clamp = new Adw.Clamp () {
maximum_size = 400,
margin_top = 24,
margin_start = 24,
margin_end = 24
margin_end = 24,
margin_top = 12
};

content_clamp.child = content_box;

var main_content = new Gtk.Box (Gtk.Orientation.VERTICAL, 0) {
vexpand = true,
hexpand = true
};

main_content.append (settings_header);
main_content.append (content_clamp);
var toolbar_view = new Adw.ToolbarView ();
toolbar_view.add_top_bar (settings_header);
toolbar_view.content = content_clamp;

var page = new Adw.NavigationPage (main_content, "quick-add");
var page = new Adw.NavigationPage (toolbar_view, "quick-add");

copy_button.clicked.connect (() => {
Gdk.Clipboard clipboard = Gdk.Display.get_default ().get_clipboard ();
Expand Down
2 changes: 1 addition & 1 deletion src/Objects/BaseObject.vala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class Objects.BaseObject : GLib.Object {
public signal void deleted ();
public signal void updated ();

public uint update_timeout_id { get; set; default = Constants.INACTIVE; }
public uint update_timeout_id { get; set; default = 0; }

string _id_string;
public string id_string {
Expand Down
10 changes: 5 additions & 5 deletions src/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 = Constants.INACTIVE; }
public int priority { get; set; default = 0; }

// Tmp
public bool activate_name_editable { get; set; default = false; }
Expand Down Expand Up @@ -77,8 +77,8 @@ public class Objects.Item : Objects.BaseObject {
}
}

public int child_order { get; set; default = Constants.INACTIVE; }
public int day_order { get; set; default = Constants.INACTIVE; }
public int child_order { get; set; default = 0; }
public int day_order { get; set; default = 0; }
public bool checked { get; set; default = false; }
public bool is_deleted { get; set; default = false; }
public bool collapsed { get; set; default = false; }
Expand Down Expand Up @@ -617,7 +617,7 @@ public class Objects.Item : Objects.BaseObject {
builder.add_string_value (Util.get_default ().get_encode_text (description));

builder.set_member_name ("priority");
if (priority == Constants.INACTIVE) {
if (priority == 0) {
builder.add_int_value (Constants.PRIORITY_4);
} else {
builder.add_int_value (priority);
Expand Down Expand Up @@ -694,7 +694,7 @@ public class Objects.Item : Objects.BaseObject {
builder.add_string_value (Util.get_default ().get_encode_text (description));

builder.set_member_name ("priority");
if (priority == Constants.INACTIVE) {
if (priority == 0) {
builder.add_int_value (Constants.PRIORITY_4);
} else {
builder.add_int_value (priority);
Expand Down
2 changes: 1 addition & 1 deletion src/Objects/Label.vala
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

public class Objects.Label : Objects.BaseObject {
public string color { get; set; default = ""; }
public int item_order { get; set; default = Constants.INACTIVE; }
public int item_order { get; set; default = 0; }
public bool is_deleted { get; set; default = false; }
public bool is_favorite { get; set; default = false; }
public BackendType backend_type { get; set; default = BackendType.NONE; }
Expand Down
6 changes: 3 additions & 3 deletions src/Objects/Reminder.vala
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
public class Objects.Reminder : Objects.BaseObject {
public int64 notify_uid { get; set; default = Constants.INACTIVE; }
public int64 notify_uid { get; set; default = 0; }
public string item_id { get; set; default = ""; }
public string service { get; set; default = ""; }
public Objects.DueDate due { get; set; default = new Objects.DueDate (); }
public int mm_offset { get; set; default = Constants.INACTIVE; }
public int is_deleted { get; set; default = Constants.INACTIVE; }
public int mm_offset { get; set; default = 0; }
public int is_deleted { get; set; default = 0; }

Objects.Item? _item;
public Objects.Item item {
Expand Down
4 changes: 2 additions & 2 deletions src/Services/Database.vala
Original file line number Diff line number Diff line change
Expand Up @@ -2014,11 +2014,11 @@ public class Services.Database : GLib.Object {

private void set_parameter_bool (Sqlite.Statement? stmt, string par, bool val) {
int par_position = stmt.bind_parameter_index (par);
stmt.bind_int (par_position, val ? Constants.ACTIVE : Constants.INACTIVE);
stmt.bind_int (par_position, val ? 1 : 0);
}

private bool get_parameter_bool (Sqlite.Statement stmt, int col) {
return stmt.column_int (col) == Constants.ACTIVE;
return stmt.column_int (col) == 1;
}

Json.Parser parser;
Expand Down
Loading

0 comments on commit 5ccb8ef

Please sign in to comment.