Skip to content

Commit

Permalink
fix #1257
Browse files Browse the repository at this point in the history
  • Loading branch information
alainm23 committed Jul 30, 2024
1 parent e11719a commit 115c4b8
Show file tree
Hide file tree
Showing 14 changed files with 190 additions and 209 deletions.
92 changes: 74 additions & 18 deletions core/Enum.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
}
Expand Down
2 changes: 0 additions & 2 deletions core/Objects/Project.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
});
Expand Down
2 changes: 0 additions & 2 deletions core/Services/CalDAV/Core.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion core/Services/Todoist.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion meson_options.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
option('tracing', type: 'boolean', value: false, description: 'add extra debugging information')
option('profile', type: 'combo', choices: ['default', 'development'], value: 'default')
option('profile', type: 'combo', choices: ['default', 'development'], value: 'development')
50 changes: 9 additions & 41 deletions src/Layouts/FilterPaneRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 ());
});
Expand All @@ -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 ();
}
Expand Down Expand Up @@ -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 () {
Expand Down
6 changes: 2 additions & 4 deletions src/Layouts/HeaderBar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 ();
});
}

Expand Down
7 changes: 2 additions & 5 deletions src/Layouts/ItemRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
33 changes: 12 additions & 21 deletions src/Layouts/Sidebar.vala
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,6 @@ public class Layouts.Sidebar : Adw.Bin {
public Gee.HashMap <string, Layouts.ProjectRow> favorites_hashmap = new Gee.HashMap <string, Layouts.ProjectRow> ();
public Gee.HashMap <string, Layouts.SidebarSourceRow> sources_hashmap = new Gee.HashMap <string, Layouts.SidebarSourceRow> ();

public Sidebar () {
Object ();
}

construct {
filters_flow = new Gtk.FlowBox () {
homogeneous = true,
Expand Down Expand Up @@ -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);
Expand All @@ -81,22 +75,16 @@ 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,
valign = Gtk.Align.START,
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" }
};
Expand Down Expand Up @@ -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 ();
Expand Down
7 changes: 2 additions & 5 deletions src/Layouts/SidebarSourceRow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
Loading

0 comments on commit 115c4b8

Please sign in to comment.