Skip to content

Commit

Permalink
Fix #577
Browse files Browse the repository at this point in the history
  • Loading branch information
Alain M committed Oct 26, 2020
1 parent f298644 commit 7e0fbe2
Show file tree
Hide file tree
Showing 14 changed files with 93 additions and 67 deletions.
10 changes: 10 additions & 0 deletions data/com.github.alainm23.planner.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@
<binary>com.github.alainm23.planner</binary>
</provides>
​<releases>
<release version="2.5.7" date="2020-10-26">
<description>
<p>Bug fixes and performance improvement</p>
<ul>
<li>Github #577 - Fixed recurring tasks.</li>
<li>Updated translations.</li>
</ul>
</description>
</release>

<release version="2.5.6" date="2020-10-23">
<description>
<p>Bug fixes and performance improvement</p>
Expand Down
17 changes: 11 additions & 6 deletions data/com.github.alainm23.planner.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,24 @@
<value nick="Saturday" value="6" />
</enum>

<enum id="com.github.alainm23.planner.new-tasks-position">
<value nick="Top" value="0" />
<value nick="Bottom" value="-1" />
</enum>

<schema path="/com/github/alainm23/planner/" id="com.github.alainm23.planner" gettext-domain="com.github.alainm23.planner">
<key name="badge-count" enum="com.github.alainm23.planner.badge-count">
<default>"None"</default>
<summary>Choose which items should be counted for the badge on the application icon</summary>
<description>Choose which items should be counted for the badge on the application icon</description>
</key>

<key name="new-tasks-position" enum="com.github.alainm23.planner.new-tasks-position">
<default>"Bottom"</default>
<summary>Choose which items should be counted for the badge on the application icon</summary>
<description>Choose which items should be counted for the badge on the application icon</description>
</key>

<key name="appearance" enum="com.github.alainm23.planner.appearance">
<default>"Light"</default>
<summary></summary>
Expand Down Expand Up @@ -300,11 +311,5 @@
<summary>font-scale</summary>
<description>font-scale</description>
</key>

<key name="new-tasks-top" type="i">
<default>-1</default>
<summary>new-tasks-top</summary>
<description>new-tasks-top</description>
</key>
</schema>
</schemalist>
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project ('com.github.alainm23.planner', 'vala', 'c', version: '2.5.6')
project ('com.github.alainm23.planner', 'vala', 'c', version: '2.5.7')

gnome = import('gnome')
i18n = import('i18n')
Expand Down
15 changes: 10 additions & 5 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class Planner : Gtk.Application {
private static int64 load_project = 0;
private static bool version = false;
private static bool clear_database = false;
private static string lang = "";


public const OptionEntry[] PLANNER_OPTIONS = {
{ "version", 'v', 0, OptionArg.NONE, ref version,
Expand All @@ -52,6 +54,8 @@ public class Planner : Gtk.Application {
"Run the Application in background", null },
{ "load-project", 'l', 0, OptionArg.INT64, ref load_project,
"Open project in separate window", "PROJECT_ID" },
{ "lang", 'n', 0, OptionArg.STRING, ref lang,
"Open Planner in a specific language", "LANG" },
{ null }
};

Expand Down Expand Up @@ -81,9 +85,6 @@ public class Planner : Gtk.Application {
// task_store = new Services.Tasks.Store ();

add_main_option_entries (PLANNER_OPTIONS);

// Set lang
// GLib.Environment.set_variable ("LANGUAGE", "es", true);
}

public static Planner _instance = null;
Expand All @@ -97,6 +98,11 @@ public class Planner : Gtk.Application {
}

protected override void activate () {
// Set lang
if (lang != "") {
GLib.Environment.set_variable ("LANGUAGE", lang, true);
}

if (get_windows ().length () > 0) {
get_windows ().data.present ();
get_windows ().data.show_all ();
Expand Down Expand Up @@ -237,8 +243,7 @@ public class Planner : Gtk.Application {
var dialog = new Widgets.WhatsNew ("com.github.alainm23.planner", _("Planner %s is here, with many design improvements, new features, and more.".printf (Constants.VERSION)));

List<string> list = new List<string> ();
list.append (_("Github #575 - Homepage was fixed."));
list.append (_("Github #336 - The option to change the text size was added."));
list.append (_("Github #577 - Fixed recurring tasks."));
list.append (_("Updated translations."));

dialog.append_notes (_("Bug fixes and performance improvement"), list, 30);
Expand Down
66 changes: 36 additions & 30 deletions src/Dialogs/Preferences/Preferences.vala
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ public class Dialogs.Preferences.Preferences : Gtk.Dialog {
general_grid.add (start_page_item);
general_grid.add (badge_item);
general_grid.add (theme_item);
general_grid.add (task_item);
general_grid.add (backups_item);
// general_grid.add (task_item);
// general_grid.add (backups_item);
general_grid.add (general_item);
general_grid.add (new Gtk.Separator (Gtk.Orientation.HORIZONTAL));

Expand Down Expand Up @@ -364,7 +364,7 @@ public class Dialogs.Preferences.Preferences : Gtk.Dialog {

var new_tasks_position_switch = new Dialogs.Preferences.ItemSwitch (
_("New tasks on top"),
Planner.settings.get_int ("new-tasks-top") == 0
Planner.settings.get_enum ("new-tasks-position") == 0
);
new_tasks_position_switch.margin_top = 12;

Expand Down Expand Up @@ -413,14 +413,13 @@ public class Dialogs.Preferences.Preferences : Gtk.Dialog {

new_tasks_position_switch.activated.connect ((value) => {
if (value) {
Planner.settings.set_int ("new-tasks-top", 0);
Planner.settings.set_enum ("new-tasks-position", 0);
} else {
Planner.settings.set_int ("new-tasks-top", -1);
Planner.settings.set_enum ("new-tasks-position", -1);
}
});

default_priority.activated.connect ((index) => {
print ("%i\n".printf (index));
Planner.settings.set_enum ("default-priority", index);
});

Expand Down Expand Up @@ -531,26 +530,47 @@ public class Dialogs.Preferences.Preferences : Gtk.Dialog {
font_size_scale.set_value (Planner.settings.get_double ("font-scale"));
font_size_scale.add_mark (1, Gtk.PositionType.LEFT, null);
font_size_scale.draw_value = false;
font_size_scale.margin_top = 3;
font_size_scale.margin_bottom = 6;

var font_size_small = new Gtk.Image ();
font_size_small.gicon = new ThemedIcon ("font-x-generic-symbolic");
font_size_small.pixel_size = 16;

font_size_small.margin_start = 12;

var font_size_large = new Gtk.Image ();
font_size_large.gicon = new ThemedIcon ("font-x-generic-symbolic");
font_size_large.pixel_size = 24;
font_size_large.margin_end = 12;

var font_size_grid = new Gtk.Grid ();
font_size_grid.get_style_context ().add_class ("preferences-view");
font_size_grid.column_spacing = 12;
font_size_grid.hexpand = true;
font_size_grid.add (font_size_small);
font_size_grid.add (font_size_scale);
font_size_grid.add (font_size_large);
font_size_grid.valign = Gtk.Align.START;
font_size_grid.margin_start = 12;
font_size_grid.margin_end = 12;

List<string> list = new List<string> ();
list.append ("elementary");
list.append ("Ubuntu");
list.append ("Windows");
list.append ("macOS");
list.append ("Minimize Left");
list.append ("Minimize Right");
list.append ("Close Only Left");
list.append ("Close Only Right");

var button_layout = new Dialogs.Preferences.ItemSelect (
_("Button layout"),
Planner.settings.get_enum ("button-layout"),
list
);
button_layout.margin_top = 12;

var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
main_box.valign = Gtk.Align.START;
main_box.expand = true;

main_box.pack_start (info_box, false, false, 0);
Expand All @@ -567,7 +587,10 @@ public class Dialogs.Preferences.Preferences : Gtk.Dialog {
margin_start = 12,
margin_top = 12
}, false, false, 0);
main_box.pack_start (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), false, true, 0);
main_box.pack_start (font_size_grid);
main_box.pack_start (new Gtk.Separator (Gtk.Orientation.HORIZONTAL), false, true, 0);
main_box.pack_start (button_layout);

if (Planner.settings.get_enum ("appearance") == 0) {
light_radio.active = true;
Expand Down Expand Up @@ -603,6 +626,10 @@ public class Dialogs.Preferences.Preferences : Gtk.Dialog {
Planner.settings.set_double ("font-scale", font_size_scale.get_value ());
});

button_layout.activated.connect ((index) => {
Planner.settings.set_enum ("button-layout", index);
});

return main_box;
}

Expand Down Expand Up @@ -805,23 +832,6 @@ public class Dialogs.Preferences.Preferences : Gtk.Dialog {
run_startup_label.margin_start = 12;
run_startup_label.halign = Gtk.Align.START;

List<string> list = new List<string> ();
list.append ("elementary");
list.append ("Ubuntu");
list.append ("Windows");
list.append ("macOS");
list.append ("Minimize Left");
list.append ("Minimize Right");
list.append ("Close Only Left");
list.append ("Close Only Right");

var button_layout = new Dialogs.Preferences.ItemSelect (
_("Button layout"),
Planner.settings.get_enum ("button-layout"),
list
);
button_layout.margin_top = 12;

// var database_settings = new Dialogs.Preferences.DatabaseSettings ();

var dz_header = new Granite.HeaderLabel (_("Danger zone"));
Expand Down Expand Up @@ -888,10 +898,6 @@ public class Dialogs.Preferences.Preferences : Gtk.Dialog {
stack.visible_child_name = "home";
});

button_layout.activated.connect ((index) => {
Planner.settings.set_enum ("button-layout", index);
});

start_week.activated.connect ((index) => {
Planner.settings.set_enum ("start-week", index);
});
Expand Down
8 changes: 7 additions & 1 deletion src/Dialogs/ProjectSettings.vala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@ public class Dialogs.ProjectSettings : Gtk.Dialog {
width_request = 480;
get_style_context ().add_class ("planner-dialog");
get_style_context ().add_class ("app");


// use_header_bar = 1;
// var header_bar = (Gtk.HeaderBar) get_header_bar ();
// header_bar.get_style_context ().add_class (Gtk.STYLE_CLASS_FLAT);
// header_bar.get_style_context ().add_class ("oauth-dialog");
// header_bar.get_style_context ().add_class ("default-decoration");

name_entry = new Widgets.Entry ();
name_entry.margin_start = 12;
name_entry.margin_end = 12;
Expand Down
2 changes: 1 addition & 1 deletion src/Views/Inbox.vala
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ public class Views.Inbox : Gtk.EventBox {
add (overlay);

magic_button.clicked.connect (() => {
add_new_item (Planner.settings.get_int ("new-tasks-top"));
add_new_item (Planner.settings.get_enum ("new-tasks-position"));
});

build_drag_and_drop ();
Expand Down
2 changes: 1 addition & 1 deletion src/Views/Priority.vala
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public class Views.Priority : Gtk.EventBox {
});

magic_button.clicked.connect (() => {
add_new_item (Planner.settings.get_int ("new-tasks-top"));
add_new_item (Planner.settings.get_enum ("new-tasks-position"));
});

Planner.database.item_added.connect ((item, index) => {
Expand Down
2 changes: 1 addition & 1 deletion src/Views/Project.vala
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ public class Views.Project : Gtk.EventBox {
check_due_date ();

magic_button.clicked.connect (() => {
add_new_item (Planner.settings.get_int ("new-tasks-top"));
add_new_item (Planner.settings.get_enum ("new-tasks-position"));
});

// Check Placeholder view
Expand Down
2 changes: 1 addition & 1 deletion src/Views/TaskList.vala
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ public class Views.TaskList : Gtk.EventBox {
});

magic_button.clicked.connect (() => {
add_new_task (Planner.settings.get_int ("new-tasks-top"));
add_new_task (Planner.settings.get_enum ("new-tasks-position"));
});

Planner.task_store.task_list_modified.connect ((s) => {
Expand Down
2 changes: 1 addition & 1 deletion src/Views/Today.vala
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public class Views.Today : Gtk.EventBox {
build_drag_and_drop ();

magic_button.clicked.connect (() => {
add_new_item (Planner.settings.get_int ("new-tasks-top"));
add_new_item (Planner.settings.get_enum ("new-tasks-position"));
});

// Check Placeholder view
Expand Down
14 changes: 8 additions & 6 deletions src/Widgets/ItemRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,11 @@ public class Widgets.ItemRow : Gtk.ListBoxRow {
activate_menu (false);
});

checked_button.toggled.connect (checked_toggled);
checked_button.button_release_event.connect (() => {
checked_button.active = !checked_button.active;
checked_toggled (checked_button.active);
return Gdk.EVENT_STOP;
});

check_listbox.remove.connect (() => {
check_checklist_separator ();
Expand Down Expand Up @@ -1034,10 +1038,9 @@ public class Widgets.ItemRow : Gtk.ListBoxRow {
});
}

private void checked_toggled () {
if (checked_button.active) {
checked_button.active = false;

private void checked_toggled (bool active) {
checked_button.active = false;
if (active) {
if (item.due_is_recurring == 1) {
GLib.DateTime next_due = Planner.utils.get_next_recurring_due_date (item, +1);

Expand All @@ -1051,7 +1054,6 @@ public class Widgets.ItemRow : Gtk.ListBoxRow {
_("1 task completed"),
Planner.utils.build_undo_object ("item_complete", "item", item.id.to_string (), "", "")
);

main_revealer.reveal_child = false;
}
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/Widgets/SectionRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ public class Widgets.SectionRow : Gtk.ListBoxRow {
});

add_button.clicked.connect (() => {
add_new_item (Planner.settings.get_int ("new-tasks-top"));
add_new_item (Planner.settings.get_enum ("new-tasks-position"));
});

name_entry.changed.connect (() => {
Expand Down Expand Up @@ -908,7 +908,7 @@ public class Widgets.SectionRow : Gtk.ListBoxRow {
menu.show_all ();

add_menu.activate.connect (() => {
add_new_item (Planner.settings.get_int ("new-tasks-top"));
add_new_item (Planner.settings.get_enum ("new-tasks-position"));
});

note_menu.activate.connect (() => {
Expand Down Expand Up @@ -1291,7 +1291,7 @@ public class Widgets.SectionRow : Gtk.ListBoxRow {
grid.show ();

button.clicked.connect (() => {
add_new_item (Planner.settings.get_int ("new-tasks-top"));
add_new_item (Planner.settings.get_enum ("new-tasks-position"));
});

return grid;
Expand Down
12 changes: 2 additions & 10 deletions src/Widgets/Toast.vala
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,11 @@ public class Widgets.Toast : Gtk.Revealer {
var item = Planner.database.get_item_by_id (
int64.parse (Planner.todoist.get_string_member_by_object (query, "object_id"))
);

if (item.id != 0) {
if (Planner.todoist.get_string_member_by_object (query, "type") == "item_delete") {
Planner.database.show_undo_item (item, "item_delete");
} else if (Planner.todoist.get_string_member_by_object (query, "type") == "item_complete") {
item.checked = 0;
item.date_completed = "";

Planner.database.update_item_completed (item);
if (item.is_todoist == 1) {
Planner.todoist.item_uncomplete (item);
}

} else if (Planner.todoist.get_string_member_by_object (query, "type") == "item_complete") {
Planner.database.show_undo_item (item, "item_complete");
} else if (Planner.todoist.get_string_member_by_object (query, "type") == "item_reschedule") {
Planner.database.update_item_recurring_due_date (item, -1);
Expand Down

0 comments on commit 7e0fbe2

Please sign in to comment.