diff --git a/core/Enum.vala b/core/Enum.vala index d7e9ff831..8e630b1da 100644 --- a/core/Enum.vala +++ b/core/Enum.vala @@ -102,43 +102,99 @@ public enum FilterType { public string to_string () { switch (this) { - case TODAY: - return "today"; + case INBOX: + return "inbox"; - case INBOX: - return "inbox"; + case TODAY: + return "today"; - case SCHEDULED: - return "scheduled"; + case SCHEDULED: + return "scheduled"; - case PINBOARD: - return "pinboard"; + case PINBOARD: + return "pinboard"; - case LABELS: - return "labels"; + case LABELS: + return "labels"; - case COMPLETED: - return "completed"; + case COMPLETED: + return "completed"; - default: - assert_not_reached (); - } + default: + assert_not_reached (); + } } public string get_name () { switch (this) { - case TODAY: - return _("Today"); - case INBOX: return _("Inbox"); + case TODAY: + return _("Today"); + case SCHEDULED: return _("Scheduled"); case PINBOARD: return _("Pinboard"); + case LABELS: + return _("Labels"); + + case COMPLETED: + return _("Completed"); + + default: + assert_not_reached (); + } + } + + public string get_icon () { + switch (this) { + case INBOX: + return "mailbox-symbolic"; + + case TODAY: + return "star-outline-thick-symbolic"; + + case SCHEDULED: + return "month-symbolic"; + + case PINBOARD: + return "pin-symbolic"; + + case LABELS: + return "tag-outline-symbolic"; + + case COMPLETED: + return "check-round-outline-symbolic"; + + default: + assert_not_reached (); + } + } + + public string get_color () { + switch (this) { + case INBOX: + return "#3584e4"; + + case TODAY: + return "#33d17a"; + + case SCHEDULED: + return "#9141ac"; + + case PINBOARD: + return "#ed333b"; + + case LABELS: + return "#986a44"; + + case COMPLETED: + return "#ff7800"; + default: assert_not_reached (); } diff --git a/core/Objects/Project.vala b/core/Objects/Project.vala index 9ade26efd..121d55b8b 100644 --- a/core/Objects/Project.vala +++ b/core/Objects/Project.vala @@ -262,8 +262,6 @@ public class Objects.Project : Objects.BaseObject { item_deleted.connect ((item) => { _project_count = update_project_count (); - print ("Count: %d\n".printf (_project_count)); - _percentage = update_percentage (); project_count_updated (); }); diff --git a/core/Services/CalDAV/Core.vala b/core/Services/CalDAV/Core.vala index afd1c3586..d621144b4 100644 --- a/core/Services/CalDAV/Core.vala +++ b/core/Services/CalDAV/Core.vala @@ -57,7 +57,6 @@ public class Services.CalDAV.Core : GLib.Object { Services.CalDAV.Providers.Base provider = providers_map.get (caldav_type.to_string ()); string url = provider.get_server_url (server_url, username, password); - print ("Server URL: %s\n".printf (url)); if (Services.Store.instance ().source_caldav_exists (url, username)) { response.error_code = 409; @@ -156,7 +155,6 @@ public class Services.CalDAV.Core : GLib.Object { Services.CalDAV.Providers.Base provider = providers_map.get (source.caldav_data.caldav_type.to_string ()); var url = provider.get_all_taskslist_url (source.caldav_data.server_url, source.caldav_data.username); - print ("Server URL: %s\n".printf (url)); var message = new Soup.Message ("PROPFIND", url); message.request_headers.append ("Authorization", "Basic %s".printf (source.caldav_data.credentials)); diff --git a/core/Services/Todoist.vala b/core/Services/Todoist.vala index b0e0573d5..5b3ca7d37 100644 --- a/core/Services/Todoist.vala +++ b/core/Services/Todoist.vala @@ -1168,7 +1168,7 @@ public class Services.Todoist : GLib.Object { private void print_root (Json.Node root) { Json.Generator generator = new Json.Generator (); generator.set_root (root); - print (generator.to_data (null) + "\n"); + debug (generator.to_data (null) + "\n"); } public string get_delete_json (string id, string type, string uuid) { diff --git a/meson_options.txt b/meson_options.txt index 494387e9c..5d180579a 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -1,2 +1,2 @@ option('tracing', type: 'boolean', value: false, description: 'add extra debugging information') -option('profile', type: 'combo', choices: ['default', 'development'], value: 'default') \ No newline at end of file +option('profile', type: 'combo', choices: ['default', 'development'], value: 'development') \ No newline at end of file diff --git a/src/Layouts/FilterPaneRow.vala b/src/Layouts/FilterPaneRow.vala index 2a6e2a4b2..b4d22350b 100644 --- a/src/Layouts/FilterPaneRow.vala +++ b/src/Layouts/FilterPaneRow.vala @@ -41,26 +41,25 @@ public class Layouts.FilterPaneRow : Gtk.FlowBoxChild { add_css_class ("card"); add_css_class ("filter-pane-row"); - title_image = new Gtk.Image () { + title_image = new Gtk.Image.from_icon_name (filter_type.get_icon ()) { margin_start = 3 }; - title_label = new Gtk.Label (null) { + title_label = new Gtk.Label (filter_type.get_name ()) { hexpand = true, halign = Gtk.Align.START, - margin_start = 3 + margin_start = 3, + css_classes = { "font-bold" }, + ellipsize = Pango.EllipsizeMode.END }; - title_label.ellipsize = Pango.EllipsizeMode.END; - title_label.add_css_class ("font-bold"); count_label = new Gtk.Label (null) { hexpand = true, halign = Gtk.Align.END, - margin_end = 3 + margin_end = 3, + css_classes = { "font-bold" } }; - count_label.add_css_class ("font-bold"); - var count_revealer = new Gtk.Revealer () { transition_type = Gtk.RevealerTransitionType.CROSSFADE, child = count_label @@ -80,13 +79,11 @@ public class Layouts.FilterPaneRow : Gtk.FlowBoxChild { main_grid.attach (title_label, 0, 1, 2, 2); child = main_grid; - build_filter_data (); + Util.get_default ().set_widget_color (filter_type.get_color (), this); Services.Settings.get_default ().settings.bind ("show-tasks-count", count_revealer, "reveal_child", GLib.SettingsBindFlags.DEFAULT); var select_gesture = new Gtk.GestureClick (); - select_gesture.set_button (1); add_controller (select_gesture); - select_gesture.pressed.connect (() => { Services.EventBus.get_default ().pane_selected (PaneType.FILTER, filter_type.to_string ()); }); @@ -108,34 +105,6 @@ public class Layouts.FilterPaneRow : Gtk.FlowBoxChild { }); } - private void build_filter_data () { - if (filter_type == FilterType.TODAY) { - title_label.label = _("Today"); - title_image.icon_name = "star-outline-thick-symbolic"; - Util.get_default ().set_widget_color ("#33d17a", this); - } else if (filter_type == FilterType.INBOX) { - title_label.label = _("Inbox"); - title_image.icon_name = "mailbox-symbolic"; - Util.get_default ().set_widget_color ("#3584e4", this); - } else if (filter_type == FilterType.SCHEDULED) { - title_label.label = _("Scheduled"); - title_image.icon_name = "month-symbolic"; - Util.get_default ().set_widget_color ("#9141ac", this); - } else if (filter_type == FilterType.PINBOARD) { - title_label.label = _("Pinboard"); - title_image.icon_name = "pin-symbolic"; - Util.get_default ().set_widget_color ("#ed333b", this); - } else if (filter_type == FilterType.LABELS) { - title_label.label = _("Labels"); - title_image.icon_name = "tag-outline-symbolic"; - Util.get_default ().set_widget_color ("#986a44", this); - } else if (filter_type == FilterType.COMPLETED) { - title_label.label = _("Completed"); - title_image.icon_name = "check-round-outline-symbolic"; - Util.get_default ().set_widget_color ("#ff7800", this); - } - } - private void update_count_label (int count) { count_label.label = count <= 0 ? "" : count.to_string (); } @@ -182,8 +151,7 @@ public class Layouts.FilterPaneRow : Gtk.FlowBoxChild { } public int item_order () { - var views_order = Services.Settings.get_default ().settings.get_strv ("views-order-visible"); - return find_index (views_order, filter_type.to_string ()); + return find_index (Services.Settings.get_default ().settings.get_strv ("views-order-visible"), filter_type.to_string ()); } public bool active () { diff --git a/src/Layouts/HeaderBar.vala b/src/Layouts/HeaderBar.vala index db4481003..a4549f9ee 100644 --- a/src/Layouts/HeaderBar.vala +++ b/src/Layouts/HeaderBar.vala @@ -124,10 +124,8 @@ public class Layouts.HeaderBar : Adw.Bin { back_activated (); }); - Services.Settings.get_default ().settings.changed.connect ((key) => { - if (key == "slim-mode") { - update_sidebar_icon (); - } + Services.Settings.get_default ().settings.changed["slim-mode"].connect (() => { + update_sidebar_icon (); }); } diff --git a/src/Layouts/ItemRow.vala b/src/Layouts/ItemRow.vala index da3052f65..d4f27bb3b 100644 --- a/src/Layouts/ItemRow.vala +++ b/src/Layouts/ItemRow.vala @@ -669,11 +669,8 @@ public class Layouts.ItemRow : Layouts.ItemBase { update_labels (labels); }); - Services.Settings.get_default ().settings.changed.connect ((key) => { - if (key == "underline-completed-tasks" || key == "clock-format") { - update_request (); - } - }); + Services.Settings.get_default ().settings.changed["underline-completed-tasks"].connect (update_request); + Services.Settings.get_default ().settings.changed["clock-format"].connect (update_request); var menu_handle_gesture = new Gtk.GestureClick (); menu_handle_gesture.set_button (3); diff --git a/src/Layouts/Sidebar.vala b/src/Layouts/Sidebar.vala index cad869e53..6d85f05b1 100644 --- a/src/Layouts/Sidebar.vala +++ b/src/Layouts/Sidebar.vala @@ -35,10 +35,6 @@ public class Layouts.Sidebar : Adw.Bin { public Gee.HashMap favorites_hashmap = new Gee.HashMap (); public Gee.HashMap sources_hashmap = new Gee.HashMap (); - public Sidebar () { - Object (); - } - construct { filters_flow = new Gtk.FlowBox () { homogeneous = true, @@ -69,9 +65,7 @@ public class Layouts.Sidebar : Adw.Bin { tooltip_markup = Util.get_default ().markup_accel_tooltip (_("Go to Pinboard"), "Ctrl+P") }; - completed_filter = new Layouts.FilterPaneRow (FilterType.COMPLETED) { - // tooltip_markup = Util.get_default ().markup_accel_tooltip (_("Go to Completed"), "Ctrl+P") - }; + completed_filter = new Layouts.FilterPaneRow (FilterType.COMPLETED); filters_flow.append (inbox_filter); filters_flow.append (today_filter); @@ -81,9 +75,9 @@ public class Layouts.Sidebar : Adw.Bin { filters_flow.append (completed_filter); favorites_header = new Layouts.HeaderItem (_("Favorites")) { - margin_top = 12 + margin_top = 12, + placeholder_message = _("No favorites available. Create one by clicking on the '+' button") }; - favorites_header.placeholder_message = _("No favorites available. Create one by clicking on the '+' button"); sources_listbox = new Gtk.ListBox () { hexpand = true, @@ -91,12 +85,6 @@ public class Layouts.Sidebar : Adw.Bin { css_classes = { "listbox-background" } }; - sources_listbox.set_sort_func ((child1, child2) => { - int item1 = ((Layouts.SidebarSourceRow) child1).source.child_order; - int item2 = ((Layouts.SidebarSourceRow) child2).source.child_order; - return item1 - item2; - }); - var whats_new_icon = new Gtk.Image.from_icon_name ("star-outline-thick-symbolic") { css_classes = { "gift-animation" } }; @@ -151,13 +139,16 @@ public class Layouts.Sidebar : Adw.Bin { child = scrolled_window; - Services.Settings.get_default ().settings.changed.connect ((key) => { - if (key == "views-order-visible") { - filters_flow.invalidate_sort (); - filters_flow.invalidate_filter (); - } + sources_listbox.set_sort_func ((child1, child2) => { + int item1 = ((Layouts.SidebarSourceRow) child1).source.child_order; + int item2 = ((Layouts.SidebarSourceRow) child2).source.child_order; + return item1 - item2; + }); + + Services.Settings.get_default ().settings.changed["views-order-visible"].connect (() => { + filters_flow.invalidate_sort (); + filters_flow.invalidate_filter (); }); - filters_flow.set_sort_func ((child1, child2) => { int item1 = ((Layouts.FilterPaneRow) child1).item_order (); diff --git a/src/Layouts/SidebarSourceRow.vala b/src/Layouts/SidebarSourceRow.vala index ba459cff0..7d7369132 100644 --- a/src/Layouts/SidebarSourceRow.vala +++ b/src/Layouts/SidebarSourceRow.vala @@ -145,11 +145,8 @@ public class Layouts.SidebarSourceRow : Gtk.ListBoxRow { } }); - Services.Settings.get_default ().settings.changed.connect ((key) => { - if (key == "projects-sort-by" || key == "projects-ordered") { - update_projects_sort (); - } - }); + Services.Settings.get_default ().settings.changed["projects-sort-by"].connect (update_projects_sort); + Services.Settings.get_default ().settings.changed["projects-ordered"].connect (update_projects_sort); } public void hide_destroy () { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 75c8ede01..740bd7c54 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -153,42 +153,35 @@ public class MainWindow : Adw.ApplicationWindow { } }); - Services.Settings.get_default ().settings.changed.connect ((key) => { - if (key == "system-appearance") { - Services.Settings.get_default ().settings.set_boolean ( - "dark-mode", - granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK - ); - Util.get_default ().update_theme (); - } else if (key == "appearance" || key == "dark-mode") { - Util.get_default ().update_theme (); - } else if (key == "run-in-background") { - // set_hide_on_close (Services.Settings.get_default ().settings.get_boolean ("run-in-background")); - } else if (key == "run-on-startup") { - bool active = Services.Settings.get_default ().settings.get_boolean ("run-on-startup"); - - if (active) { - Planify.instance.ask_for_background.begin (Xdp.BackgroundFlags.AUTOSTART, (obj, res) => { - if (Planify.instance.ask_for_background.end (res)) { - Services.Settings.get_default ().settings.set_boolean ("run-on-startup", true); - } else { - Services.Settings.get_default ().settings.set_boolean ("run-on-startup", false); - } - }); - } else { - Planify.instance.ask_for_background.begin (Xdp.BackgroundFlags.NONE, (obj, res) => { - if (Planify.instance.ask_for_background.end (res)) { - Services.Settings.get_default ().settings.set_boolean ("run-on-startup", false); - } else { - Services.Settings.get_default ().settings.set_boolean ("run-on-startup", false); - } - }); - } - } else if (key == "mobile-mode") { - Services.EventBus.get_default ().mobile_mode = Services.Settings.get_default ().settings.get_boolean ("mobile-mode"); + Services.Settings.get_default ().settings.changed["system-appearance"].connect (() => { + Services.Settings.get_default ().settings.set_boolean ( + "dark-mode", + granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK + ); + Util.get_default ().update_theme (); + }); + + Services.Settings.get_default ().settings.changed["appearance"].connect (Util.get_default ().update_theme); + Services.Settings.get_default ().settings.changed["dark-mode"].connect (Util.get_default ().update_theme); + + Services.Settings.get_default ().settings.changed["run-on-startup"].connect (() => { + bool active = Services.Settings.get_default ().settings.get_boolean ("run-on-startup"); + + if (active) { + Planify.instance.ask_for_background.begin (Xdp.BackgroundFlags.AUTOSTART, (obj, res) => { + Planify.instance.ask_for_background.end (res); + }); + } else { + Planify.instance.ask_for_background.begin (Xdp.BackgroundFlags.NONE, (obj, res) => { + Planify.instance.ask_for_background.end (res); + }); } }); + Services.Settings.get_default ().settings.changed["mobile-mode"].connect (() => { + Services.EventBus.get_default ().mobile_mode = Services.Settings.get_default ().settings.get_boolean ("mobile-mode"); + }); + Services.EventBus.get_default ().pane_selected.connect ((pane_type, id) => { if (pane_type == PaneType.PROJECT) { add_project_view (Services.Store.instance ().get_project (id)); @@ -406,60 +399,51 @@ public class MainWindow : Adw.ApplicationWindow { } public void valid_view_removed (Objects.Project project) { - // Views.Project? project_view; - // project_view = (Views.Project) views_stack.get_child_by_name (project.view_id); - // if (project_view != null) { - // views_stack.remove (project_view); - // go_homepage (); - // } + if (views_stack.visible_page == null) { + return; + } + + if (views_stack.visible_page.child is Views.Project) { + Views.Project? project_view = (Views.Project) views_stack.visible_page.child; + if (project_view != null && project_view.project.id == project.id) { + go_homepage (); + } + } } public void add_task_action (string content = "") { - // if (views_stack.visible_child_name.has_prefix ("project")) { - // Views.Project? project_view = (Views.Project) views_stack.visible_child; - // if (project_view != null) { - // project_view.prepare_new_item (content); - // } - // } else if (views_stack.visible_child_name.has_prefix ("today-view")) { - // Views.Today? today_view = (Views.Today) views_stack.visible_child; - // if (today_view != null) { - // today_view.prepare_new_item (content); - // } - // } else if (views_stack.visible_child_name.has_prefix ("scheduled-view")) { - // Views.Scheduled.Scheduled? scheduled_view = (Views.Scheduled.Scheduled) views_stack.visible_child; - // if (scheduled_view != null) { - // scheduled_view.prepare_new_item (content); - // } - // } else if (views_stack.visible_child_name.has_prefix ("labels-view")) { - // var dialog = new Dialogs.QuickAdd (); - // dialog.update_content (content); - // dialog.present (Planify._instance.main_window); - // } else if (views_stack.visible_child_name.has_prefix ("label-view")) { - // Views.Label? label_view = (Views.Label) views_stack.visible_child; - // if (label_view != null) { - // label_view.prepare_new_item (content); - // } - // } else { - // Views.Filter? filter_view = (Views.Filter) views_stack.visible_child; - // if (filter_view != null) { - // filter_view.prepare_new_item (content); - // } else { - // var dialog = new Dialogs.QuickAdd (); - // dialog.update_content (content); - // dialog.present (Planify._instance.main_window); - // } - // } + if (views_stack.visible_page == null) { + return; + } + + if (views_stack.visible_page.child is Views.Project) { + Views.Project? project_view = (Views.Project) views_stack.visible_page.child; + if (project_view != null) { + project_view.prepare_new_item (content); + } + } else if (views_stack.visible_page.child is Views.Today) { + Views.Today? today_view = (Views.Today) views_stack.visible_page.child; + if (today_view != null) { + today_view.prepare_new_item (content); + } + } else { + var dialog = new Dialogs.QuickAdd (); + dialog.update_content (content); + dialog.present (Planify._instance.main_window); + } } public void new_section_action () { - // if (!views_stack.visible_child_name.has_prefix ("project")) { - // return; - // } - - // Views.Project? project_view = (Views.Project) views_stack.visible_child; - // if (project_view != null) { - // project_view.prepare_new_section (); - // } + if (views_stack.visible_page == null) { + return; + } + + if (views_stack.visible_page.child is Views.Project) { + Views.Project? project_view = (Views.Project) views_stack.visible_page.child; + if (project_view != null) { + project_view.prepare_new_section (); + } + } } private Gtk.Popover build_menu_app () { diff --git a/src/Views/Project/Project.vala b/src/Views/Project/Project.vala index ac6751469..a19f35ef8 100644 --- a/src/Views/Project/Project.vala +++ b/src/Views/Project/Project.vala @@ -227,23 +227,21 @@ public class Views.Project : Adw.Bin { } public void prepare_new_item (string content = "") { - // if (project.is_deck) { - // return; - // } - - // if (view_style == ProjectViewStyle.LIST) { - // Views.List? list_view; - // list_view = (Views.List) view_stack.get_child_by_name (view_style.to_string ()); - // if (list_view != null) { - // list_view.prepare_new_item (content); - // } - // } else { - // Views.Board? board_view; - // board_view = (Views.Board) view_stack.get_child_by_name (view_style.to_string ()); - // if (board_view != null) { - // board_view.prepare_new_item (content); - // } - // } + if (project.is_deck) { + return; + } + + if (view_style == ProjectViewStyle.LIST) { + Views.List? list_view = (Views.List) view_stack.visible_page.child; + if (list_view != null) { + list_view.prepare_new_item (content); + } + } else { + Views.Board? board_view = (Views.Board) view_stack.visible_page.child; + if (board_view != null) { + board_view.prepare_new_item (content); + } + } } private Gtk.Popover build_context_menu_popover () { diff --git a/src/Widgets/EventsList.vala b/src/Widgets/EventsList.vala index b9c854d53..01b9f5dfe 100644 --- a/src/Widgets/EventsList.vala +++ b/src/Widgets/EventsList.vala @@ -105,10 +105,8 @@ public class Widgets.EventsList : Adw.Bin { child = main_revealer; add_events (); - Services.Settings.get_default ().settings.changed.connect ((key) => { - if (key == "calendar-enabled") { - main_revealer.reveal_child = Services.Settings.get_default ().settings.get_boolean ("calendar-enabled"); - } + Services.Settings.get_default ().settings.changed["calendar-enabled"].connect (() => { + main_revealer.reveal_child = Services.Settings.get_default ().settings.get_boolean ("calendar-enabled"); }); } diff --git a/src/Widgets/SubItems.vala b/src/Widgets/SubItems.vala index d8e778dda..ca9005b88 100644 --- a/src/Widgets/SubItems.vala +++ b/src/Widgets/SubItems.vala @@ -278,13 +278,11 @@ public class Widgets.SubItems : Adw.Bin { update_sort (); })] = item_parent.project; - signals_map[Services.Settings.get_default ().settings.changed.connect ((key) => { - if (key == "always-show-completed-subtasks") { - checked_revealer.reveal_child = show_completed; - if (show_completed) { - add_completed_items (); - } - } + signals_map[Services.Settings.get_default ().settings.changed["always-show-completed-subtasks"].connect (() => { + checked_revealer.reveal_child = show_completed; + if (show_completed) { + add_completed_items (); + } })] = Services.Settings.get_default ().settings; signals_map[Services.EventBus.get_default ().expand_all.connect ((project_id, value) => {