Skip to content

Commit 115c4b8

Browse files
committed
fix #1257
1 parent e11719a commit 115c4b8

File tree

14 files changed

+190
-209
lines changed

14 files changed

+190
-209
lines changed

core/Enum.vala

Lines changed: 74 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -102,43 +102,99 @@ public enum FilterType {
102102

103103
public string to_string () {
104104
switch (this) {
105-
case TODAY:
106-
return "today";
105+
case INBOX:
106+
return "inbox";
107107

108-
case INBOX:
109-
return "inbox";
108+
case TODAY:
109+
return "today";
110110

111-
case SCHEDULED:
112-
return "scheduled";
111+
case SCHEDULED:
112+
return "scheduled";
113113

114-
case PINBOARD:
115-
return "pinboard";
114+
case PINBOARD:
115+
return "pinboard";
116116

117-
case LABELS:
118-
return "labels";
117+
case LABELS:
118+
return "labels";
119119

120-
case COMPLETED:
121-
return "completed";
120+
case COMPLETED:
121+
return "completed";
122122

123-
default:
124-
assert_not_reached ();
125-
}
123+
default:
124+
assert_not_reached ();
125+
}
126126
}
127127

128128
public string get_name () {
129129
switch (this) {
130-
case TODAY:
131-
return _("Today");
132-
133130
case INBOX:
134131
return _("Inbox");
135132

133+
case TODAY:
134+
return _("Today");
135+
136136
case SCHEDULED:
137137
return _("Scheduled");
138138

139139
case PINBOARD:
140140
return _("Pinboard");
141141

142+
case LABELS:
143+
return _("Labels");
144+
145+
case COMPLETED:
146+
return _("Completed");
147+
148+
default:
149+
assert_not_reached ();
150+
}
151+
}
152+
153+
public string get_icon () {
154+
switch (this) {
155+
case INBOX:
156+
return "mailbox-symbolic";
157+
158+
case TODAY:
159+
return "star-outline-thick-symbolic";
160+
161+
case SCHEDULED:
162+
return "month-symbolic";
163+
164+
case PINBOARD:
165+
return "pin-symbolic";
166+
167+
case LABELS:
168+
return "tag-outline-symbolic";
169+
170+
case COMPLETED:
171+
return "check-round-outline-symbolic";
172+
173+
default:
174+
assert_not_reached ();
175+
}
176+
}
177+
178+
public string get_color () {
179+
switch (this) {
180+
case INBOX:
181+
return "#3584e4";
182+
183+
case TODAY:
184+
return "#33d17a";
185+
186+
case SCHEDULED:
187+
return "#9141ac";
188+
189+
case PINBOARD:
190+
return "#ed333b";
191+
192+
case LABELS:
193+
return "#986a44";
194+
195+
case COMPLETED:
196+
return "#ff7800";
197+
142198
default:
143199
assert_not_reached ();
144200
}

core/Objects/Project.vala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,6 @@ public class Objects.Project : Objects.BaseObject {
262262

263263
item_deleted.connect ((item) => {
264264
_project_count = update_project_count ();
265-
print ("Count: %d\n".printf (_project_count));
266-
267265
_percentage = update_percentage ();
268266
project_count_updated ();
269267
});

core/Services/CalDAV/Core.vala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ public class Services.CalDAV.Core : GLib.Object {
5757
Services.CalDAV.Providers.Base provider = providers_map.get (caldav_type.to_string ());
5858

5959
string url = provider.get_server_url (server_url, username, password);
60-
print ("Server URL: %s\n".printf (url));
6160

6261
if (Services.Store.instance ().source_caldav_exists (url, username)) {
6362
response.error_code = 409;
@@ -156,7 +155,6 @@ public class Services.CalDAV.Core : GLib.Object {
156155
Services.CalDAV.Providers.Base provider = providers_map.get (source.caldav_data.caldav_type.to_string ());
157156

158157
var url = provider.get_all_taskslist_url (source.caldav_data.server_url, source.caldav_data.username);
159-
print ("Server URL: %s\n".printf (url));
160158

161159
var message = new Soup.Message ("PROPFIND", url);
162160
message.request_headers.append ("Authorization", "Basic %s".printf (source.caldav_data.credentials));

core/Services/Todoist.vala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ public class Services.Todoist : GLib.Object {
11681168
private void print_root (Json.Node root) {
11691169
Json.Generator generator = new Json.Generator ();
11701170
generator.set_root (root);
1171-
print (generator.to_data (null) + "\n");
1171+
debug (generator.to_data (null) + "\n");
11721172
}
11731173

11741174
public string get_delete_json (string id, string type, string uuid) {

meson_options.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
option('tracing', type: 'boolean', value: false, description: 'add extra debugging information')
2-
option('profile', type: 'combo', choices: ['default', 'development'], value: 'default')
2+
option('profile', type: 'combo', choices: ['default', 'development'], value: 'development')

src/Layouts/FilterPaneRow.vala

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -41,26 +41,25 @@ public class Layouts.FilterPaneRow : Gtk.FlowBoxChild {
4141
add_css_class ("card");
4242
add_css_class ("filter-pane-row");
4343

44-
title_image = new Gtk.Image () {
44+
title_image = new Gtk.Image.from_icon_name (filter_type.get_icon ()) {
4545
margin_start = 3
4646
};
4747

48-
title_label = new Gtk.Label (null) {
48+
title_label = new Gtk.Label (filter_type.get_name ()) {
4949
hexpand = true,
5050
halign = Gtk.Align.START,
51-
margin_start = 3
51+
margin_start = 3,
52+
css_classes = { "font-bold" },
53+
ellipsize = Pango.EllipsizeMode.END
5254
};
53-
title_label.ellipsize = Pango.EllipsizeMode.END;
54-
title_label.add_css_class ("font-bold");
5555

5656
count_label = new Gtk.Label (null) {
5757
hexpand = true,
5858
halign = Gtk.Align.END,
59-
margin_end = 3
59+
margin_end = 3,
60+
css_classes = { "font-bold" }
6061
};
6162

62-
count_label.add_css_class ("font-bold");
63-
6463
var count_revealer = new Gtk.Revealer () {
6564
transition_type = Gtk.RevealerTransitionType.CROSSFADE,
6665
child = count_label
@@ -80,13 +79,11 @@ public class Layouts.FilterPaneRow : Gtk.FlowBoxChild {
8079
main_grid.attach (title_label, 0, 1, 2, 2);
8180

8281
child = main_grid;
83-
build_filter_data ();
82+
Util.get_default ().set_widget_color (filter_type.get_color (), this);
8483
Services.Settings.get_default ().settings.bind ("show-tasks-count", count_revealer, "reveal_child", GLib.SettingsBindFlags.DEFAULT);
8584

8685
var select_gesture = new Gtk.GestureClick ();
87-
select_gesture.set_button (1);
8886
add_controller (select_gesture);
89-
9087
select_gesture.pressed.connect (() => {
9188
Services.EventBus.get_default ().pane_selected (PaneType.FILTER, filter_type.to_string ());
9289
});
@@ -108,34 +105,6 @@ public class Layouts.FilterPaneRow : Gtk.FlowBoxChild {
108105
});
109106
}
110107

111-
private void build_filter_data () {
112-
if (filter_type == FilterType.TODAY) {
113-
title_label.label = _("Today");
114-
title_image.icon_name = "star-outline-thick-symbolic";
115-
Util.get_default ().set_widget_color ("#33d17a", this);
116-
} else if (filter_type == FilterType.INBOX) {
117-
title_label.label = _("Inbox");
118-
title_image.icon_name = "mailbox-symbolic";
119-
Util.get_default ().set_widget_color ("#3584e4", this);
120-
} else if (filter_type == FilterType.SCHEDULED) {
121-
title_label.label = _("Scheduled");
122-
title_image.icon_name = "month-symbolic";
123-
Util.get_default ().set_widget_color ("#9141ac", this);
124-
} else if (filter_type == FilterType.PINBOARD) {
125-
title_label.label = _("Pinboard");
126-
title_image.icon_name = "pin-symbolic";
127-
Util.get_default ().set_widget_color ("#ed333b", this);
128-
} else if (filter_type == FilterType.LABELS) {
129-
title_label.label = _("Labels");
130-
title_image.icon_name = "tag-outline-symbolic";
131-
Util.get_default ().set_widget_color ("#986a44", this);
132-
} else if (filter_type == FilterType.COMPLETED) {
133-
title_label.label = _("Completed");
134-
title_image.icon_name = "check-round-outline-symbolic";
135-
Util.get_default ().set_widget_color ("#ff7800", this);
136-
}
137-
}
138-
139108
private void update_count_label (int count) {
140109
count_label.label = count <= 0 ? "" : count.to_string ();
141110
}
@@ -182,8 +151,7 @@ public class Layouts.FilterPaneRow : Gtk.FlowBoxChild {
182151
}
183152

184153
public int item_order () {
185-
var views_order = Services.Settings.get_default ().settings.get_strv ("views-order-visible");
186-
return find_index (views_order, filter_type.to_string ());
154+
return find_index (Services.Settings.get_default ().settings.get_strv ("views-order-visible"), filter_type.to_string ());
187155
}
188156

189157
public bool active () {

src/Layouts/HeaderBar.vala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,8 @@ public class Layouts.HeaderBar : Adw.Bin {
124124
back_activated ();
125125
});
126126

127-
Services.Settings.get_default ().settings.changed.connect ((key) => {
128-
if (key == "slim-mode") {
129-
update_sidebar_icon ();
130-
}
127+
Services.Settings.get_default ().settings.changed["slim-mode"].connect (() => {
128+
update_sidebar_icon ();
131129
});
132130
}
133131

src/Layouts/ItemRow.vala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -669,11 +669,8 @@ public class Layouts.ItemRow : Layouts.ItemBase {
669669
update_labels (labels);
670670
});
671671

672-
Services.Settings.get_default ().settings.changed.connect ((key) => {
673-
if (key == "underline-completed-tasks" || key == "clock-format") {
674-
update_request ();
675-
}
676-
});
672+
Services.Settings.get_default ().settings.changed["underline-completed-tasks"].connect (update_request);
673+
Services.Settings.get_default ().settings.changed["clock-format"].connect (update_request);
677674

678675
var menu_handle_gesture = new Gtk.GestureClick ();
679676
menu_handle_gesture.set_button (3);

src/Layouts/Sidebar.vala

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,6 @@ public class Layouts.Sidebar : Adw.Bin {
3535
public Gee.HashMap <string, Layouts.ProjectRow> favorites_hashmap = new Gee.HashMap <string, Layouts.ProjectRow> ();
3636
public Gee.HashMap <string, Layouts.SidebarSourceRow> sources_hashmap = new Gee.HashMap <string, Layouts.SidebarSourceRow> ();
3737

38-
public Sidebar () {
39-
Object ();
40-
}
41-
4238
construct {
4339
filters_flow = new Gtk.FlowBox () {
4440
homogeneous = true,
@@ -69,9 +65,7 @@ public class Layouts.Sidebar : Adw.Bin {
6965
tooltip_markup = Util.get_default ().markup_accel_tooltip (_("Go to Pinboard"), "Ctrl+P")
7066
};
7167

72-
completed_filter = new Layouts.FilterPaneRow (FilterType.COMPLETED) {
73-
// tooltip_markup = Util.get_default ().markup_accel_tooltip (_("Go to Completed"), "Ctrl+P")
74-
};
68+
completed_filter = new Layouts.FilterPaneRow (FilterType.COMPLETED);
7569

7670
filters_flow.append (inbox_filter);
7771
filters_flow.append (today_filter);
@@ -81,22 +75,16 @@ public class Layouts.Sidebar : Adw.Bin {
8175
filters_flow.append (completed_filter);
8276

8377
favorites_header = new Layouts.HeaderItem (_("Favorites")) {
84-
margin_top = 12
78+
margin_top = 12,
79+
placeholder_message = _("No favorites available. Create one by clicking on the '+' button")
8580
};
86-
favorites_header.placeholder_message = _("No favorites available. Create one by clicking on the '+' button");
8781

8882
sources_listbox = new Gtk.ListBox () {
8983
hexpand = true,
9084
valign = Gtk.Align.START,
9185
css_classes = { "listbox-background" }
9286
};
9387

94-
sources_listbox.set_sort_func ((child1, child2) => {
95-
int item1 = ((Layouts.SidebarSourceRow) child1).source.child_order;
96-
int item2 = ((Layouts.SidebarSourceRow) child2).source.child_order;
97-
return item1 - item2;
98-
});
99-
10088
var whats_new_icon = new Gtk.Image.from_icon_name ("star-outline-thick-symbolic") {
10189
css_classes = { "gift-animation" }
10290
};
@@ -151,13 +139,16 @@ public class Layouts.Sidebar : Adw.Bin {
151139

152140
child = scrolled_window;
153141

154-
Services.Settings.get_default ().settings.changed.connect ((key) => {
155-
if (key == "views-order-visible") {
156-
filters_flow.invalidate_sort ();
157-
filters_flow.invalidate_filter ();
158-
}
142+
sources_listbox.set_sort_func ((child1, child2) => {
143+
int item1 = ((Layouts.SidebarSourceRow) child1).source.child_order;
144+
int item2 = ((Layouts.SidebarSourceRow) child2).source.child_order;
145+
return item1 - item2;
146+
});
147+
148+
Services.Settings.get_default ().settings.changed["views-order-visible"].connect (() => {
149+
filters_flow.invalidate_sort ();
150+
filters_flow.invalidate_filter ();
159151
});
160-
161152

162153
filters_flow.set_sort_func ((child1, child2) => {
163154
int item1 = ((Layouts.FilterPaneRow) child1).item_order ();

src/Layouts/SidebarSourceRow.vala

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,8 @@ public class Layouts.SidebarSourceRow : Gtk.ListBoxRow {
145145
}
146146
});
147147

148-
Services.Settings.get_default ().settings.changed.connect ((key) => {
149-
if (key == "projects-sort-by" || key == "projects-ordered") {
150-
update_projects_sort ();
151-
}
152-
});
148+
Services.Settings.get_default ().settings.changed["projects-sort-by"].connect (update_projects_sort);
149+
Services.Settings.get_default ().settings.changed["projects-ordered"].connect (update_projects_sort);
153150
}
154151

155152
public void hide_destroy () {

0 commit comments

Comments
 (0)