nowfocus 0.5.6__py3-none-any.whl → 0.5.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
nowfocus/settings.py CHANGED
@@ -94,11 +94,13 @@ class SettingsWindow(Gtk.Window):
94
94
 
95
95
 
96
96
 
97
- def __init__(self, parent=None, **kwargs):
97
+ def __init__(self, parent=None, page_number=0, **kwargs):
98
98
  self.app = parent #NOTE: This doesn't look like it will work when called from task_window...
99
99
  Gtk.Window.__init__(self, title="Settings")
100
- self.set_border_width(15)
100
+ self.set_border_width(0)
101
101
  self.set_position(position=1)
102
+ self.set_default_size(-1,800)
103
+
102
104
  self.connect("destroy", self.on_close)
103
105
 
104
106
  self.notebook = Gtk.Notebook()
@@ -106,15 +108,17 @@ class SettingsWindow(Gtk.Window):
106
108
 
107
109
 
108
110
 
109
-
110
-
111
- # Settings
111
+ # Settings page
112
112
  row = 0
113
113
  grid = Gtk.Grid()
114
114
  grid.set_row_spacing(10)
115
115
  grid.set_column_spacing(10)
116
- self.notebook.append_page(grid,Gtk.Label('Settings'))
116
+ grid.set_border_width(15)
117
+ settings_page = Gtk.Box()
118
+ settings_scroller = self.scroll_box(settings_page)
119
+ settings_scroller.add(grid)
117
120
 
121
+ self.notebook.append_page(settings_page,Gtk.Label('Settings'))
118
122
 
119
123
  grid.attach(Gtk.Box(border_width=10),0,(row:=row+1),5,1) # Spacer
120
124
 
@@ -129,9 +133,11 @@ class SettingsWindow(Gtk.Window):
129
133
 
130
134
  grid.attach(self.settings_updater('todolist_refresh_interval', 3, 'SpinButton',"(hours)"),0,(row:=row+1),5,1)
131
135
 
132
-
133
136
  # grid.attach(self.settings_updater('invoice_hourly_rate', 33, 'SpinButton',""),0,(row:=row+1),5,1)
134
137
 
138
+ grid.attach(self.settings_updater('default_list_for_new_tasks', 'List that was last added to', 'ComboBoxText',"", options = ['List that was last added to','Most recently used list']),0,(row:=row+1),5,1)
139
+
140
+
135
141
  grid.attach(self.settings_updater('hours_search_timeframe', 'auto', 'ComboBoxText',"\nDefault timetracking range for hours shown in main window and invoicing", options = list(hours_search_timeframes().keys())),0,(row:=row+1),5,1)
136
142
 
137
143
  grid.attach(self.settings_updater('prompts', None, 'TextView',""),0,(row:=row+1),5,1)
@@ -143,13 +149,18 @@ class SettingsWindow(Gtk.Window):
143
149
 
144
150
 
145
151
 
152
+
153
+ connectors_page = Gtk.Box()
154
+ self.notebook.append_page(connectors_page,Gtk.Label('Todolists and Time Trackers'))
155
+ connectors_scroller = self.scroll_box(connectors_page)
156
+
157
+ # TODO: perhaps use a scroller for each connector category instead of one big one
146
158
  row = 0
147
159
  grid = Gtk.Grid()
160
+ connectors_scroller.add(grid)
148
161
  grid.set_row_spacing(10)
149
162
  grid.set_column_spacing(10)
150
- grid.set_border_width(10)
151
-
152
- self.notebook.append_page(grid,Gtk.Label('Todolists and Time Trackers'))
163
+ grid.set_border_width(15)
153
164
 
154
165
  sub_head = Gtk.Label()
155
166
  sub_head.set_markup("<b>Todo Lists</b>")
@@ -227,11 +238,13 @@ class SettingsWindow(Gtk.Window):
227
238
 
228
239
 
229
240
  # Task Commands notebook page
230
- self.task_commands_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
231
- self.notebook.append_page(self.task_commands_box,Gtk.Label('Task Commands'))
241
+ self.task_commands_page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
242
+ self.notebook.append_page(self.task_commands_page,Gtk.Label('Task Commands'))
243
+
244
+ self.task_commands_box = self.scroll_box(self.task_commands_page)
245
+ self.task_commands_box.set_border_width(15)
232
246
 
233
247
  self.boxes['task_commands_outer'] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
234
- # self.boxes['task_commands_outer'] = self.scroll_box()
235
248
  self.task_commands_box.add(self.boxes['task_commands_outer'])
236
249
 
237
250
  # Gets replaced when commands are loaded
@@ -248,19 +261,22 @@ class SettingsWindow(Gtk.Window):
248
261
 
249
262
 
250
263
 
264
+
265
+
266
+
251
267
  # Time Targets notebook page
252
- self.targets_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
253
- self.notebook.append_page(self.targets_box, Gtk.Label('Time Targets'))
268
+ self.targets_page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
254
269
 
255
- self.boxes['lists_time_targets_outer'] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
256
- # self.targets_box.add(self.boxes['lists_time_targets_outer'])
270
+ self.notebook.append_page(self.targets_page, Gtk.Label('Time Targets'))
257
271
 
258
-
259
- # self.boxes['test'] = self.scroll_box(None ,300)
260
- # self.targets_box.add(self.boxes['test'])
272
+ self.targets_scroller = self.scroll_box(self.targets_page ,300)
261
273
 
262
- # self.boxes['lists_time_targets_outer'] = self.scroll_box(None ,300)
274
+ self.targets_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
275
+ self.targets_box.set_border_width(15)
276
+
277
+ self.targets_scroller.add(self.targets_box)
263
278
 
279
+ self.boxes['lists_time_targets_outer'] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
264
280
 
265
281
  self.targets_box.add(self.boxes['lists_time_targets_outer'])
266
282
 
@@ -268,13 +284,6 @@ class SettingsWindow(Gtk.Window):
268
284
  # Gets replaced when targets are loaded
269
285
  self.boxes['lists_time_targets_inner'] = Gtk.Box()
270
286
  self.boxes['lists_time_targets_outer'].add(self.boxes['lists_time_targets_inner'])
271
-
272
- # separator = Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL)
273
- # self.boxes['lists_time_targets_outer'].pack_start(separator, True, True, 0)
274
-
275
- # test_button = Gtk.Button(label="test")
276
- # self.boxes['lists_time_targets_inner'].add(test_button)
277
-
278
287
 
279
288
  self.show_time_targets('lists')
280
289
 
@@ -286,6 +295,7 @@ class SettingsWindow(Gtk.Window):
286
295
 
287
296
  self.boxes['tasks_time_targets_outer'] = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
288
297
  self.targets_box.add(self.boxes['tasks_time_targets_outer'])
298
+
289
299
  # Gets replaced when targets are loaded
290
300
  self.boxes['tasks_time_targets_inner'] = Gtk.Box()
291
301
  self.boxes['tasks_time_targets_outer'].add(self.boxes['tasks_time_targets_inner'])
@@ -308,6 +318,7 @@ class SettingsWindow(Gtk.Window):
308
318
 
309
319
  # Sessions notebook page
310
320
  self.sessions_page = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=5)
321
+ self.sessions_page.set_border_width(15)
311
322
 
312
323
  self.notebook.append_page(self.sessions_page,Gtk.Label('Sessions'))
313
324
 
@@ -336,8 +347,9 @@ class SettingsWindow(Gtk.Window):
336
347
 
337
348
  self.SessionEditDialog = SessionEditDialog # passed to show_sessions
338
349
 
339
-
350
+ print('set_current_page',page_number)
340
351
  self.show_all()
352
+ self.notebook.set_current_page(page_number)
341
353
 
342
354
 
343
355
 
@@ -434,7 +446,7 @@ class SettingsWindow(Gtk.Window):
434
446
  checkbutton.set_label("Error: '"+str(id)+"' didn't match anything " )
435
447
  else:
436
448
  # print('Show time target',item_data)
437
- checkbutton.set_label(item_data['label']+": "+str(data['type'])+ " "+str(data['value'])+" minutes per "+str(data['within_value'])+" "+str(data['within_unit']) )
449
+ checkbutton.set_label(item_data['label']+" \n"+str(data['type'])+ " "+str(data['value'])+" minutes per "+str(data['within_value'])+" "+str(data['within_unit']) )
438
450
  checkbutton.set_active(data['status'])
439
451
 
440
452
  # checkbutton.connect("toggled", print, checkbutton.get_active())
@@ -476,9 +488,9 @@ class SettingsWindow(Gtk.Window):
476
488
 
477
489
  task_data = db_get_item_by_id(id,"tasks")
478
490
  if not task_data:
479
- checkbutton.set_label("Error: '"+str(id)+"' task missing "+str(command_data['command']))
491
+ checkbutton.set_label("Error: '"+str(id)+"' task missing \n"+str(command_data['command']))
480
492
  else:
481
- checkbutton.set_label(task_data['extended_label']+" "+str(command_data['command']) )
493
+ checkbutton.set_label(task_data['extended_label']+" \n"+str(command_data['command']) )
482
494
  checkbutton.set_active(command_data['status'])
483
495
 
484
496
  checkbutton.connect("toggled", update_user_setting, conf.user['task_commands'][id], 'status', checkbutton.get_active)
@@ -923,7 +935,7 @@ class EditAddConnectorDialog(Gtk.Dialog):
923
935
 
924
936
 
925
937
  if key in ['file']:
926
- self.entries[key] = Gtk.FileChooserButton(title="Select Todo File")
938
+ self.entries[key] = Gtk.FileChooserButton(title="Select "+connector_category+" file")
927
939
  self.entries[key].set_action(Gtk.FileChooserAction.OPEN)
928
940
 
929
941
  else:
nowfocus/task_window.py CHANGED
@@ -36,7 +36,7 @@ class TaskWindow(Gtk.Window):
36
36
  # TaskWindow._instance.present()
37
37
  # return None
38
38
  except Exception as e:
39
- dbg("TaskWindow._instance exception",e,s='taskwindow')
39
+ dbg("TaskWindow._instance exception",e=e ,s='taskwindow')
40
40
 
41
41
  TaskWindow._instance = self
42
42
 
@@ -197,7 +197,7 @@ class TaskWindow(Gtk.Window):
197
197
  self.buttons_box.add(openable_button)
198
198
 
199
199
  except Exception as e:
200
- dbg("error adding todo connector open() to task window ",e, s='taskwindow')
200
+ dbg("error adding todo connector open() to task window ",e=e , s='taskwindow')
201
201
 
202
202
  self.new_task_button = Gtk.Button(label="New Task")
203
203
  self.new_task_button.set_property("tooltip-text","Add a new task (Ctrl + N)")
@@ -521,7 +521,7 @@ class TaskWindow(Gtk.Window):
521
521
 
522
522
 
523
523
  except Exception as e:
524
- utils.dbg("Error adding task to list"+ str(t['extended_label']), t, e, l=0, s='taskwindow')
524
+ utils.dbg("Error adding task to list"+ str(t['extended_label']), t, e=e, l=0, s='taskwindow')
525
525
  return False
526
526
 
527
527
 
nowfocus/upgrade.py ADDED
@@ -0,0 +1,106 @@
1
+ import conf
2
+ from utils import *
3
+ # from pkg_resources import parse_version
4
+
5
+
6
+ def do_upgrades(app):
7
+ db_schema_version = get_system_db_value('db_schema_version')
8
+
9
+ if db_schema_version == '0.2':
10
+
11
+ db_query("ALTER TABLE lists DROP COLUMN status")
12
+ db_query("ALTER TABLE tasks DROP COLUMN status")
13
+
14
+ db_query("ALTER TABLE lists ADD COLUMN status INTEGER DEFAULT 1")
15
+ db_query("ALTER TABLE tasks ADD COLUMN status INTEGER DEFAULT 1")
16
+
17
+ db_query("REPLACE INTO system(field, value) VALUES('db_schema_version', '0.3')")
18
+
19
+ db_schema_version = '0.3'
20
+
21
+
22
+ if db_schema_version == '0.3':
23
+ db_query("ALTER TABLE sessions ADD COLUMN timetracker TEXT")
24
+ db_query("ALTER TABLE sessions ADD COLUMN notes TEXT")
25
+ db_query("REPLACE INTO system(field, value) VALUES('db_schema_version', '0.4')")
26
+ print('adding timetracker column to session table')
27
+
28
+ for todolist_id, todo in conf.user['todolists'].items():
29
+ db_query("UPDATE sessions SET timetracker = ? WHERE todolist = ?",(todo['timetracker'],todolist_id) )
30
+
31
+ db_schema_version = '0.4'
32
+
33
+ if db_schema_version == '0.4':
34
+ dbg('Schema Update from', db_schema_version, 'to 0.5',l=-1)
35
+
36
+ print('Adding priority column to session table')
37
+
38
+ db_query("ALTER TABLE sessions ADD COLUMN priority INTEGER DEFAULT 0")
39
+
40
+
41
+ db_query("REPLACE INTO system(field, value) VALUES('db_schema_version', '0.5')")
42
+
43
+ db_schema_version = '0.5'
44
+
45
+ if db_schema_version == '0.5':
46
+ dbg('Schema Update from', db_schema_version, 'to 0.5.6',l=-1)
47
+
48
+ from install import copy_desktop_integration_files
49
+ copy_desktop_integration_files()
50
+
51
+ db_schema_version = "0.5.6"
52
+ set_system_db_value("db_schema_version",db_schema_version)
53
+
54
+ if db_schema_version == '0.5.6':
55
+ dbg('Schema Update from', db_schema_version, 'to 0.5.9',l=-1)
56
+
57
+ for session in db_query("SELECT DISTINCT task_id, extended_label FROM sessions"):
58
+ t = db_get_item_by_id(session['task_id'],dgb_error_level_for_failure=3)
59
+ if t and t['priority'] > 0:
60
+ print("setting",session['extended_label']," session priority to ",t['priority'] )
61
+
62
+ db_query("UPDATE sessions SET priority = ? WHERE task_id = ?",(t['priority'],session['task_id']))
63
+
64
+ print("Total hours priority sessions",round(divide(db_query("SELECT SUM(duration) as total FROM sessions WHERE priority > 0")[0]['total'],3600),2))
65
+
66
+ db_schema_version = "0.5.9"
67
+ set_system_db_value("db_schema_version",db_schema_version)
68
+ # if db_schema_version == 0.5:
69
+ # db_query("ALTER TABLE tasks ADD COLUMN tags TEXT DEFAULT '{}'")
70
+ # db_query("REPLACE INTO system(field, value) VALUES('db_schema_version', '0.5')")
71
+ # db_schema_version = 0.6
72
+
73
+
74
+ dbg('db_schema_version updated to', db_schema_version,s='db')
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+
84
+
85
+
86
+
87
+
88
+ # update time_target format
89
+ # for id, tt in user['time_targets']['lists'].items():
90
+ # if 'within_value' not in tt:
91
+ # print("Updating time target to new format ",tt)
92
+ # tt['within_value'] = tt['num_days']
93
+ # tt['within_unit'] = 'days'
94
+ # print(tt)
95
+ # if 'status' not in tt:
96
+ # tt['status'] = True
97
+
98
+
99
+ # for id, tt in user['time_targets']['tasks'].items():
100
+ # if 'within_value' not in tt:
101
+ # print("Updating time target to new format ",tt)
102
+ # tt['within_value'] = tt['num_days']
103
+ # tt['within_unit'] = 'days'
104
+ # print(tt)
105
+ # if 'status' not in tt:
106
+ # tt['status'] = True