From 7e0fbe257af509f7d433e851a2c7edabe1de6d5c Mon Sep 17 00:00:00 2001 From: Alain M Date: Mon, 26 Oct 2020 12:46:38 -0500 Subject: [PATCH] Fix #577 --- ...com.github.alainm23.planner.appdata.xml.in | 10 +++ data/com.github.alainm23.planner.gschema.xml | 17 +++-- meson.build | 2 +- src/Application.vala | 15 +++-- src/Dialogs/Preferences/Preferences.vala | 66 ++++++++++--------- src/Dialogs/ProjectSettings.vala | 8 ++- src/Views/Inbox.vala | 2 +- src/Views/Priority.vala | 2 +- src/Views/Project.vala | 2 +- src/Views/TaskList.vala | 2 +- src/Views/Today.vala | 2 +- src/Widgets/ItemRow.vala | 14 ++-- src/Widgets/SectionRow.vala | 6 +- src/Widgets/Toast.vala | 12 +--- 14 files changed, 93 insertions(+), 67 deletions(-) diff --git a/data/com.github.alainm23.planner.appdata.xml.in b/data/com.github.alainm23.planner.appdata.xml.in index e235a2dfa..50cb11585 100644 --- a/data/com.github.alainm23.planner.appdata.xml.in +++ b/data/com.github.alainm23.planner.appdata.xml.in @@ -46,6 +46,16 @@ com.github.alainm23.planner + + +

Bug fixes and performance improvement

+
    +
  • Github #577 - Fixed recurring tasks.
  • +
  • Updated translations.
  • +
+
+
+

Bug fixes and performance improvement

diff --git a/data/com.github.alainm23.planner.gschema.xml b/data/com.github.alainm23.planner.gschema.xml index b91fd5812..c6d3ee573 100644 --- a/data/com.github.alainm23.planner.gschema.xml +++ b/data/com.github.alainm23.planner.gschema.xml @@ -42,6 +42,11 @@ + + + + + "None" @@ -49,6 +54,12 @@ Choose which items should be counted for the badge on the application icon + + "Bottom" + Choose which items should be counted for the badge on the application icon + Choose which items should be counted for the badge on the application icon + + "Light" @@ -300,11 +311,5 @@ font-scale font-scale - - - -1 - new-tasks-top - new-tasks-top - diff --git a/meson.build b/meson.build index c7873f4be..746e883ea 100644 --- a/meson.build +++ b/meson.build @@ -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') diff --git a/src/Application.vala b/src/Application.vala index 8c3964069..b0f5cf0a6 100644 --- a/src/Application.vala +++ b/src/Application.vala @@ -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, @@ -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 } }; @@ -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; @@ -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 (); @@ -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 list = new List (); - 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); diff --git a/src/Dialogs/Preferences/Preferences.vala b/src/Dialogs/Preferences/Preferences.vala index c4da5dc26..be1b69aae 100644 --- a/src/Dialogs/Preferences/Preferences.vala +++ b/src/Dialogs/Preferences/Preferences.vala @@ -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)); @@ -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; @@ -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); }); @@ -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 list = new List (); + 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); @@ -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; @@ -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; } @@ -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 list = new List (); - 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")); @@ -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); }); diff --git a/src/Dialogs/ProjectSettings.vala b/src/Dialogs/ProjectSettings.vala index e9a38f76d..be2e6ab90 100644 --- a/src/Dialogs/ProjectSettings.vala +++ b/src/Dialogs/ProjectSettings.vala @@ -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; diff --git a/src/Views/Inbox.vala b/src/Views/Inbox.vala index d34ee14cc..cee8ffe23 100644 --- a/src/Views/Inbox.vala +++ b/src/Views/Inbox.vala @@ -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 (); diff --git a/src/Views/Priority.vala b/src/Views/Priority.vala index 2831594ec..a08c383c8 100644 --- a/src/Views/Priority.vala +++ b/src/Views/Priority.vala @@ -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) => { diff --git a/src/Views/Project.vala b/src/Views/Project.vala index 9cf2ee673..6953d30f1 100644 --- a/src/Views/Project.vala +++ b/src/Views/Project.vala @@ -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 diff --git a/src/Views/TaskList.vala b/src/Views/TaskList.vala index 0f0c4f16b..1b264a49f 100644 --- a/src/Views/TaskList.vala +++ b/src/Views/TaskList.vala @@ -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) => { diff --git a/src/Views/Today.vala b/src/Views/Today.vala index a80fdb912..647c86f35 100644 --- a/src/Views/Today.vala +++ b/src/Views/Today.vala @@ -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 diff --git a/src/Widgets/ItemRow.vala b/src/Widgets/ItemRow.vala index 2fb54d81a..0bf8cd9ca 100644 --- a/src/Widgets/ItemRow.vala +++ b/src/Widgets/ItemRow.vala @@ -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 (); @@ -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); @@ -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 { diff --git a/src/Widgets/SectionRow.vala b/src/Widgets/SectionRow.vala index 1a25e4b53..5ee42b5c2 100644 --- a/src/Widgets/SectionRow.vala +++ b/src/Widgets/SectionRow.vala @@ -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 (() => { @@ -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 (() => { @@ -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; diff --git a/src/Widgets/Toast.vala b/src/Widgets/Toast.vala index c4133a8e7..6a2bbd199 100644 --- a/src/Widgets/Toast.vala +++ b/src/Widgets/Toast.vala @@ -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);