Skip to content

Commit 5831965

Browse files
committed
open files, notify file loads
1 parent 9994816 commit 5831965

File tree

5 files changed

+26
-18
lines changed

5 files changed

+26
-18
lines changed

data/net.hemish.kaar.desktop.in

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[Desktop Entry]
22
Name=Kaar
33
Comment=todo.txt based To-Do app
4-
Exec=kaar
4+
Exec=kaar %F
55
Icon=net.hemish.kaar
66
Terminal=false
77
Type=Application

src/blp/tab.blp

+15-13
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,21 @@ template $TabChild: Gtk.Box {
1111
name: "main";
1212

1313
child: Gtk.Overlay {
14-
Gtk.ScrolledWindow {
15-
Adw.ClampScrollable {
16-
Gtk.ListView list_view {
17-
margin-start: 4;
18-
margin-end: 4;
19-
20-
styles [
21-
"background"
22-
]
23-
24-
vexpand: true;
14+
Adw.ToastOverlay toast_overlay{
15+
child: Gtk.ScrolledWindow {
16+
Adw.ClampScrollable {
17+
Gtk.ListView list_view {
18+
margin-start: 4;
19+
margin-end: 4;
20+
21+
styles [
22+
"background"
23+
]
24+
25+
vexpand: true;
26+
}
2527
}
26-
}
28+
};
2729
}
2830

2931
[overlay]
@@ -41,10 +43,10 @@ template $TabChild: Gtk.Box {
4143

4244
Gtk.StackPage {
4345
name: "status";
46+
4447
child: Adw.StatusPage {
4548
title: _("No Tasks Here");
4649
icon-name: "view-list-symbolic";
47-
4850
};
4951
}
5052
}

src/preferences.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ class KaarPreferencesDialog(Adw.PreferencesDialog):
3636
priority_down_button: Gtk.Button = Gtk.Template.Child()
3737
priority_list_box: Gtk.ListBox = Gtk.Template.Child()
3838
pango_markup: Adw.SwitchRow = Gtk.Template.Child()
39-
autoreload_info_button: Gtk.Button = Gtk.Template.Child()
39+
40+
# TODO: figure out a way to show information about file monitor
41+
#autoreload_info_button: Gtk.Button = Gtk.Template.Child()
4042

4143
def __init__(self, settings: Gio.Settings, **kwargs):
4244
super().__init__(**kwargs)
@@ -73,7 +75,7 @@ def __init__(self, settings: Gio.Settings, **kwargs):
7375
row.set_name(self.settings.get_string(converter(i)))
7476
row.set_title(self.settings.get_string(converter(i)))
7577

76-
self.autoreload_info_button.connect("clicked", self.show_info_file_monitor)
78+
#self.autoreload_info_button.connect("clicked", self.show_info_file_monitor)
7779

7880

7981
def on_priority_changer_button_up(self, *args):

src/tab.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class TabChild(Gtk.Box):
2020
list_view: Gtk.ListView = Gtk.Template.Child()
2121
progress_bar: Gtk.ProgressBar = Gtk.Template.Child()
2222
tab_stack: Gtk.Stack = Gtk.Template.Child()
23+
toast_overlay: Adw.ToastOverlay = Gtk.Template.Child()
2324
##############################################
2425

2526
file: str
@@ -153,6 +154,9 @@ def reload_file(self, *args):
153154
if done:
154155
for task in TodoTxtParser(task_type=TodoTask).parse(contents):
155156
self.list_store.append(task)
157+
toast = Adw.Toast.new(_("File Loaded"))
158+
toast.set_timeout(1)
159+
self.toast_overlay.add_toast(toast)
156160
except Exception as e:
157161
print(e)
158162

@@ -196,6 +200,7 @@ def save_if_required(self):
196200

197201
def monitor(self):
198202
self.file_monitor = self.file_obj.monitor(flags=Gio.FileMonitorFlags.NONE, cancellable=None)
203+
self.file_monitor.set_rate_limit(2000)
199204
self.file_monitor.connect("changed", self.on_file_changed_externally)
200205

201206
def unmonitor(self):
@@ -214,7 +219,6 @@ def on_file_changed_externally(self, *args):
214219
dialog.set_close_response("no")
215220
dialog.set_default_response("reload")
216221

217-
# TODO: add a toast to notify user that file was auto reloaded
218222
def on_response(*args):
219223
if args[1] == "reload":
220224
self.reload_file()

src/window.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def new_task(self, *args):
205205
tabchild.list_store.append(task)
206206

207207
# FIXME: Scroll and select newly added task
208-
#self.props.active_window.list_view.scroll_to(, Gtk.ListScrollFlags.SELECT)
208+
#self.props.active_window.list_viewscroll_to(, Gtk.ListScrollFlags.SELECT)
209209

210210
# Auto set the mode to edit on blank task
211211
task.mode = 'edit'

0 commit comments

Comments
 (0)