openall_time_applet 0.0.32 → 0.0.33
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/glade/win_main.glade +1 -1
- data/gui/trayicon.rb +65 -64
- data/gui/win_main.rb +124 -57
- data/lib/openall_time_applet.rb +8 -5
- data/openall_time_applet.gemspec +2 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.33
|
data/glade/win_main.glade
CHANGED
@@ -142,7 +142,7 @@
|
|
142
142
|
</child>
|
143
143
|
<child>
|
144
144
|
<object class="GtkComboBox" id="cbTask">
|
145
|
-
<property name="width_request">
|
145
|
+
<property name="width_request">280</property>
|
146
146
|
<property name="visible">True</property>
|
147
147
|
<property name="can_focus">False</property>
|
148
148
|
</object>
|
data/gui/trayicon.rb
CHANGED
@@ -5,6 +5,7 @@ class Openall_time_applet::Gui::Trayicon
|
|
5
5
|
def initialize(args)
|
6
6
|
@args = args
|
7
7
|
@debug = @args[:oata].debug
|
8
|
+
@mutex_update_icon = Mutex.new
|
8
9
|
|
9
10
|
@ti = Gtk::StatusIcon.new
|
10
11
|
@ti.signal_connect("popup-menu", &self.method(:on_statusicon_rightclick))
|
@@ -20,68 +21,63 @@ class Openall_time_applet::Gui::Trayicon
|
|
20
21
|
Knj::Thread.new do
|
21
22
|
loop do
|
22
23
|
self.update_icon
|
23
|
-
sleep
|
24
|
+
sleep 30
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
27
28
|
|
28
29
|
#This updates the icon in the system-tray. It draws seconds on the icon, if a timelog is being tracked.
|
29
30
|
def update_icon
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
@mutex_update_icon.synchronize do
|
32
|
+
print "Updating icon.\n" if @debug
|
33
|
+
|
34
|
+
color = Knj::Opts.get("tray_text_color")
|
35
|
+
color = "black" if color.to_s.strip.length <= 0
|
36
|
+
|
37
|
+
if !@args[:oata].timelog_active
|
38
|
+
@ti.file = "../gfx/icon_time_#{color}.png"
|
39
|
+
return nil
|
40
|
+
end
|
41
|
+
|
42
|
+
#Calculate minutes tracked and generate variables.
|
43
|
+
secs = Time.now.to_i - @args[:oata].timelog_active_time.to_i + @args[:oata].timelog_active.time_total
|
44
|
+
text = Knj::Strings.secs_to_human_short_time(secs, :secs => false)
|
45
|
+
|
46
|
+
if text.length <= 2
|
47
|
+
padding_left = 9
|
48
|
+
elsif text.length <= 3
|
49
|
+
padding_left = 4
|
50
|
+
elsif text.length <= 4
|
51
|
+
padding_left = 2
|
52
|
+
else
|
53
|
+
padding_left = 0
|
54
|
+
end
|
55
|
+
|
56
|
+
#Generate image.
|
57
|
+
require "RMagick"
|
58
|
+
canvas = Magick::Image.new(53, 53) do
|
59
|
+
self.background_color = "transparent"
|
60
|
+
self.format = "png"
|
61
|
+
end
|
62
|
+
|
63
|
+
color = "#a1a80a" if color == "green_casalogic"
|
64
|
+
|
65
|
+
gc = Magick::Draw.new
|
66
|
+
gc.fill(color)
|
67
|
+
gc.pointsize = 23
|
68
|
+
gc.text(padding_left, 35, text)
|
69
|
+
gc.draw(canvas)
|
70
|
+
|
71
|
+
tmp_path = "#{Knj::Os.tmpdir}/openall_time_applet_icon.png"
|
72
|
+
canvas.write(tmp_path)
|
73
|
+
canvas.destroy!
|
74
|
+
|
75
|
+
#Set icon for tray.
|
76
|
+
@ti.file = tmp_path
|
77
|
+
|
78
|
+
|
37
79
|
return nil
|
38
80
|
end
|
39
|
-
|
40
|
-
#Calculate minutes tracked and generate variables.
|
41
|
-
secs = Time.now.to_i - @args[:oata].timelog_active_time.to_i + @args[:oata].timelog_active.time_total
|
42
|
-
mins = (secs.to_f / 60.0).floor
|
43
|
-
|
44
|
-
if mins >= 60
|
45
|
-
hours = mins / 60
|
46
|
-
text = "#{Knj::Locales.number_out(hours, 1)}t"
|
47
|
-
else
|
48
|
-
text = "#{Knj::Locales.number_out(mins, 0)}m"
|
49
|
-
end
|
50
|
-
|
51
|
-
if text.length <= 2
|
52
|
-
padding_left = 9
|
53
|
-
elsif text.length <= 3
|
54
|
-
padding_left = 4
|
55
|
-
elsif text.length <= 4
|
56
|
-
padding_left = 2
|
57
|
-
else
|
58
|
-
padding_left = 0
|
59
|
-
end
|
60
|
-
|
61
|
-
#Generate image.
|
62
|
-
require "RMagick"
|
63
|
-
canvas = Magick::Image.new(53, 53) do
|
64
|
-
self.background_color = "transparent"
|
65
|
-
self.format = "png"
|
66
|
-
end
|
67
|
-
|
68
|
-
color = "#a1a80a" if color == "green_casalogic"
|
69
|
-
|
70
|
-
gc = Magick::Draw.new
|
71
|
-
gc.fill(color)
|
72
|
-
gc.pointsize = 23
|
73
|
-
gc.text(padding_left, 35, text)
|
74
|
-
gc.draw(canvas)
|
75
|
-
|
76
|
-
tmp_path = "#{Knj::Os.tmpdir}/openall_time_applet_icon.png"
|
77
|
-
canvas.write(tmp_path)
|
78
|
-
canvas.destroy!
|
79
|
-
|
80
|
-
#Set icon for tray.
|
81
|
-
@ti.file = tmp_path
|
82
|
-
|
83
|
-
|
84
|
-
return nil
|
85
81
|
end
|
86
82
|
|
87
83
|
def on_statusicon_rightclick(tray, button, time)
|
@@ -96,7 +92,7 @@ class Openall_time_applet::Gui::Trayicon
|
|
96
92
|
secs = Time.now.to_i - @args[:oata].timelog_active_time.to_i + timelog.time_total
|
97
93
|
mins = (secs.to_f / 60.0).round(0)
|
98
94
|
|
99
|
-
mi.children[0].markup = "<b>#{_("Stop")}
|
95
|
+
mi.children[0].markup = "<b>#{_("Stop")} #{Knj::Web.html(label)}</b>"
|
100
96
|
mi.signal_connect("activate", &self.method(:on_stopTracking_activate))
|
101
97
|
else
|
102
98
|
mi = Gtk::MenuItem.new(label)
|
@@ -112,15 +108,8 @@ class Openall_time_applet::Gui::Trayicon
|
|
112
108
|
|
113
109
|
#Start-menu-item. Opens main-window, expands treeview and calls the plus-button which adds a new timelog and focuses treeview.
|
114
110
|
start = Gtk::ImageMenuItem.new(Gtk::Stock::NEW)
|
115
|
-
start.children[0].label = _("
|
116
|
-
start.signal_connect(:activate)
|
117
|
-
#Open main-window and focus it.
|
118
|
-
@args[:oata].show_main
|
119
|
-
|
120
|
-
#Get main-window-object.
|
121
|
-
win_main = Knj::Gtk2::Window.get("main")
|
122
|
-
win_main.gui["txtDescr"].grab_focus
|
123
|
-
end
|
111
|
+
start.children[0].label = _("Start new")
|
112
|
+
start.signal_connect(:activate, &self.method(:on_startNew_activate))
|
124
113
|
|
125
114
|
menu.append(Gtk::SeparatorMenuItem.new)
|
126
115
|
menu.append(start)
|
@@ -134,6 +123,18 @@ class Openall_time_applet::Gui::Trayicon
|
|
134
123
|
end
|
135
124
|
end
|
136
125
|
|
126
|
+
def on_startNew_activate(*args)
|
127
|
+
#Stop tracking current timelog (if tracking).
|
128
|
+
@args[:oata].timelog_stop_tracking
|
129
|
+
|
130
|
+
#Open main-window and focus it.
|
131
|
+
@args[:oata].show_main
|
132
|
+
|
133
|
+
#Get main-window-object.
|
134
|
+
win_main = Knj::Gtk2::Window.get("main")
|
135
|
+
win_main.gui["txtDescr"].grab_focus
|
136
|
+
end
|
137
|
+
|
137
138
|
def on_statusicon_leftclick(*args)
|
138
139
|
@args[:oata].show_main
|
139
140
|
end
|
data/gui/win_main.rb
CHANGED
@@ -31,13 +31,7 @@ class Openall_time_applet::Gui::Win_main
|
|
31
31
|
@descr_ec.text_column = 0
|
32
32
|
@gui["txtDescr"].completion = @descr_ec
|
33
33
|
self.reload_descr_completion
|
34
|
-
|
35
|
-
|
36
|
-
@descr_ec.signal_connect("match-selected") do |me, model, iter|
|
37
|
-
text = model.get_value(iter, 0)
|
38
|
-
me.entry.text = text
|
39
|
-
true
|
40
|
-
end
|
34
|
+
@descr_ec.signal_connect("match-selected", &self.method(:on_descr_entrycompletion_selected))
|
41
35
|
|
42
36
|
|
43
37
|
|
@@ -47,7 +41,7 @@ class Openall_time_applet::Gui::Win_main
|
|
47
41
|
init_data = @gui["tvTimelogs"].init([
|
48
42
|
_("ID"),
|
49
43
|
{
|
50
|
-
:title => _("
|
44
|
+
:title => _("Times."),
|
51
45
|
:type => :string,
|
52
46
|
:markup => true,
|
53
47
|
:expand => false
|
@@ -62,7 +56,9 @@ class Openall_time_applet::Gui::Win_main
|
|
62
56
|
:title => _("Description"),
|
63
57
|
:type => :string,
|
64
58
|
:markup => true,
|
65
|
-
:expand => true
|
59
|
+
:expand => true,
|
60
|
+
:wrap_mode => Pango::WRAP_WORD_CHAR,
|
61
|
+
:wrap_width => 160
|
66
62
|
},
|
67
63
|
{
|
68
64
|
:title => _("T-time"),
|
@@ -79,7 +75,9 @@ class Openall_time_applet::Gui::Win_main
|
|
79
75
|
:title => _("T-Descr."),
|
80
76
|
:type => :string,
|
81
77
|
:markup => true,
|
82
|
-
:expand => true
|
78
|
+
:expand => true,
|
79
|
+
:wrap_mode => Pango::WRAP_WORD_CHAR,
|
80
|
+
:wrap_width => 160
|
83
81
|
},
|
84
82
|
{
|
85
83
|
:title => _("Cost"),
|
@@ -92,7 +90,7 @@ class Openall_time_applet::Gui::Win_main
|
|
92
90
|
:expand => false
|
93
91
|
},
|
94
92
|
{
|
95
|
-
:title => _("
|
93
|
+
:title => _("Int."),
|
96
94
|
:type => :toggle,
|
97
95
|
:expand => false
|
98
96
|
},
|
@@ -102,10 +100,30 @@ class Openall_time_applet::Gui::Win_main
|
|
102
100
|
:model => task_ls,
|
103
101
|
:has_entry => false,
|
104
102
|
:markup => true,
|
105
|
-
:expand => true
|
103
|
+
:expand => true,
|
104
|
+
:wrap_mode => Pango::WRAP_WORD_CHAR,
|
105
|
+
:wrap_width => 160
|
106
106
|
}
|
107
107
|
])
|
108
108
|
|
109
|
+
@tv_settings = Gtk2_treeview_settings.new(
|
110
|
+
:id => "win_main_tvTimelogs",
|
111
|
+
:tv => @gui["tvTimelogs"],
|
112
|
+
:col_ids => {
|
113
|
+
0 => :id,
|
114
|
+
1 => :timestamp,
|
115
|
+
2 => :time,
|
116
|
+
3 => :descr,
|
117
|
+
4 => :ttime,
|
118
|
+
5 => :tkm,
|
119
|
+
6 => :tdescr,
|
120
|
+
7 => :cost,
|
121
|
+
8 => :fixed,
|
122
|
+
9 => :int,
|
123
|
+
10 => :task
|
124
|
+
}
|
125
|
+
)
|
126
|
+
|
109
127
|
Knj::Gtk2::Tv.editable_text_renderers_to_model(
|
110
128
|
:ob => @args[:oata].ob,
|
111
129
|
:tv => @gui["tvTimelogs"],
|
@@ -152,7 +170,7 @@ class Openall_time_applet::Gui::Win_main
|
|
152
170
|
10 => {
|
153
171
|
:col => :task_id,
|
154
172
|
:value_callback => lambda{|data|
|
155
|
-
task = @args[:oata].ob.get_by(:Task,
|
173
|
+
task = @args[:oata].ob.get_by(:Task, "title" => data[:value])
|
156
174
|
|
157
175
|
if !task
|
158
176
|
return 0
|
@@ -170,6 +188,10 @@ class Openall_time_applet::Gui::Win_main
|
|
170
188
|
@gui["tvTimelogs"].columns[0].visible = false
|
171
189
|
|
172
190
|
|
191
|
+
#Move the columns around to the right order (the way Jacob wanted them).
|
192
|
+
@gui["tvTimelogs"].move_column_after(@gui["tvTimelogs"].columns[10], @gui["tvTimelogs"].columns[3])
|
193
|
+
|
194
|
+
|
173
195
|
#Connect certain column renderers to the editingStarted-method, so editing can be canceled, if the user tries to edit forbidden data on the active timelog.
|
174
196
|
init_data[:renderers][2].signal_connect_after("editing-started", :time, &self.method(:on_cell_editingStarted))
|
175
197
|
|
@@ -187,19 +209,11 @@ class Openall_time_applet::Gui::Win_main
|
|
187
209
|
|
188
210
|
|
189
211
|
#Update switch-button when active timelog is changed.
|
190
|
-
@event_timelog_active_changed = @args[:oata].events.connect(:timelog_active_changed)
|
191
|
-
self.update_switch_button
|
192
|
-
self.check_rows
|
193
|
-
self.timelog_info_trigger
|
194
|
-
end
|
212
|
+
@event_timelog_active_changed = @args[:oata].events.connect(:timelog_active_changed, &self.method(:on_timelog_active_changed))
|
195
213
|
|
196
214
|
|
197
215
|
#This timeout controls the updating of the timelog-info-frame and the time-counter for the active timelog in the treeview.
|
198
|
-
@timeout_id = Gtk.timeout_add(1000)
|
199
|
-
self.check_rows
|
200
|
-
self.timelog_info_trigger
|
201
|
-
true
|
202
|
-
end
|
216
|
+
@timeout_id = Gtk.timeout_add(1000, &self.method(:timeout_update_sec))
|
203
217
|
|
204
218
|
|
205
219
|
|
@@ -213,7 +227,7 @@ class Openall_time_applet::Gui::Win_main
|
|
213
227
|
iter[1] = 0.to_s
|
214
228
|
|
215
229
|
tasks = [_("Choose:")]
|
216
|
-
@args[:oata].ob.list(:Task,
|
230
|
+
@args[:oata].ob.list(:Task, "orderby" => "title") do |task|
|
217
231
|
iter = task_ls.append
|
218
232
|
iter[0] = task[:title]
|
219
233
|
iter[1] = task.id.to_s
|
@@ -260,6 +274,29 @@ class Openall_time_applet::Gui::Win_main
|
|
260
274
|
_("Sync time")
|
261
275
|
])
|
262
276
|
|
277
|
+
@tv_settings_pt = Gtk2_treeview_settings.new(
|
278
|
+
:id => "win_main_tvTimelogsPrepareTransfer",
|
279
|
+
:tv => @gui["tvTimelogsPrepareTransfer"],
|
280
|
+
:col_ids => {
|
281
|
+
0 => :id,
|
282
|
+
1 => :descr,
|
283
|
+
2 => :timestamp,
|
284
|
+
3 => :time,
|
285
|
+
4 => :ttime,
|
286
|
+
5 => :tkm,
|
287
|
+
6 => :tdescr,
|
288
|
+
7 => :cost,
|
289
|
+
8 => :fixed,
|
290
|
+
9 => :internal,
|
291
|
+
10 => :skip,
|
292
|
+
11 => :task,
|
293
|
+
12 => :sync_time
|
294
|
+
}
|
295
|
+
)
|
296
|
+
|
297
|
+
@gui["tvTimelogsPrepareTransfer"].move_column_after(@gui["tvTimelogsPrepareTransfer"].columns[1], @gui["tvTimelogsPrepareTransfer"].columns[3])
|
298
|
+
@gui["tvTimelogsPrepareTransfer"].move_column_after(@gui["tvTimelogsPrepareTransfer"].columns[11], @gui["tvTimelogsPrepareTransfer"].columns[4])
|
299
|
+
|
263
300
|
#Make columns editable.
|
264
301
|
Knj::Gtk2::Tv.editable_text_renderers_to_model(
|
265
302
|
:ob => @args[:oata].ob,
|
@@ -324,6 +361,30 @@ class Openall_time_applet::Gui::Win_main
|
|
324
361
|
@gui["window"].resize(width, 1)
|
325
362
|
end
|
326
363
|
|
364
|
+
#This is called when an item from the description-entry-completion-menu is selected. This method sets the selected text in the description-entry.
|
365
|
+
def on_descr_entrycompletion_selected(me, model, iter)
|
366
|
+
text = model.get_value(iter, 0)
|
367
|
+
me.entry.text = text
|
368
|
+
return true
|
369
|
+
end
|
370
|
+
|
371
|
+
#This method is called when the active timelog is changed. It calls various events to update the switch-button, update information in treeview and more instantly (instead of waiting for the 1-sec timeout which will seem like a delay).
|
372
|
+
def on_timelog_active_changed(*args)
|
373
|
+
self.update_switch_button
|
374
|
+
self.check_rows
|
375
|
+
self.timelog_info_trigger
|
376
|
+
end
|
377
|
+
|
378
|
+
#This method is called every second in order to update various information when tracking timelogs (stop-button-time, treeview-time and more).
|
379
|
+
def timeout_update_sec
|
380
|
+
#Update various information in the main treeview (time-counter).
|
381
|
+
self.check_rows
|
382
|
+
self.timelog_info_trigger
|
383
|
+
|
384
|
+
#Returns true in order to continue calling this method every second.
|
385
|
+
return true
|
386
|
+
end
|
387
|
+
|
327
388
|
def tv_editable_timestamp_callback(data)
|
328
389
|
if match = data[:value].match(/^\s*(\d+)\s*:\s*(\d+)\s*$/)
|
329
390
|
date = Datet.new
|
@@ -405,21 +466,21 @@ class Openall_time_applet::Gui::Win_main
|
|
405
466
|
tstamp_str = tstamp.strftime("%d/%m")
|
406
467
|
end
|
407
468
|
|
408
|
-
|
409
|
-
timelog.id,
|
410
|
-
timelog[:descr],
|
411
|
-
tstamp_str,
|
412
|
-
timelog.time_as_human,
|
413
|
-
timelog.time_transport_as_human,
|
414
|
-
Knj::Locales.number_out(timelog[:transportlength], 0),
|
415
|
-
timelog.transport_descr_short,
|
416
|
-
Knj::Locales.number_out(timelog[:transportcosts], 2),
|
417
|
-
Knj::Strings.yn_str(timelog[:travelfixed], true, false),
|
418
|
-
Knj::Strings.yn_str(timelog[:workinternal], true, false),
|
419
|
-
Knj::Strings.yn_str(timelog[:sync_need], false, true),
|
420
|
-
timelog.task_name,
|
421
|
-
Knj::Strings.secs_to_human_time_str(count_rounded_time, :secs => false)
|
422
|
-
|
469
|
+
@tv_settings_pt.append(
|
470
|
+
:id => timelog.id,
|
471
|
+
:descr => timelog[:descr],
|
472
|
+
:timestamp => tstamp_str,
|
473
|
+
:time => timelog.time_as_human,
|
474
|
+
:ttime => timelog.time_transport_as_human,
|
475
|
+
:tkm => Knj::Locales.number_out(timelog[:transportlength], 0),
|
476
|
+
:tdescr => timelog.transport_descr_short,
|
477
|
+
:cost => Knj::Locales.number_out(timelog[:transportcosts], 2),
|
478
|
+
:fixed => Knj::Strings.yn_str(timelog[:travelfixed], true, false),
|
479
|
+
:internal => Knj::Strings.yn_str(timelog[:workinternal], true, false),
|
480
|
+
:skip => Knj::Strings.yn_str(timelog[:sync_need], false, true),
|
481
|
+
:task => timelog.task_name,
|
482
|
+
:sync_time => Knj::Strings.secs_to_human_time_str(count_rounded_time, :secs => false)
|
483
|
+
)
|
423
484
|
@timelogs_sync_count += 1
|
424
485
|
end
|
425
486
|
end
|
@@ -503,19 +564,19 @@ class Openall_time_applet::Gui::Win_main
|
|
503
564
|
tstamp_str = tstamp.strftime("%d/%m")
|
504
565
|
end
|
505
566
|
|
506
|
-
@
|
507
|
-
timelog.id,
|
508
|
-
tstamp_str,
|
509
|
-
timelog.time_as_human,
|
510
|
-
Knj::Web.html(timelog[:descr]),
|
511
|
-
timelog.time_transport_as_human,
|
512
|
-
Knj::Locales.number_out(timelog[:transportlength], 0),
|
513
|
-
Knj::Web.html(timelog[:transportdescription]),
|
514
|
-
Knj::Locales.number_out(timelog[:transportcosts], 2),
|
515
|
-
Knj::Strings.yn_str(timelog[:travelfixed], true, false),
|
516
|
-
Knj::Strings.yn_str(timelog[:workinternal], true, false),
|
517
|
-
timelog.task_name
|
518
|
-
|
567
|
+
@tv_settings.append(
|
568
|
+
:id => timelog.id,
|
569
|
+
:timestamp => tstamp_str,
|
570
|
+
:time => timelog.time_as_human,
|
571
|
+
:descr => Knj::Web.html(timelog[:descr]),
|
572
|
+
:ttime => timelog.time_transport_as_human,
|
573
|
+
:tkm => Knj::Locales.number_out(timelog[:transportlength], 0),
|
574
|
+
:tdescr => Knj::Web.html(timelog[:transportdescription]),
|
575
|
+
:cost => Knj::Locales.number_out(timelog[:transportcosts], 2),
|
576
|
+
:fixed => Knj::Strings.yn_str(timelog[:travelfixed], true, false),
|
577
|
+
:int => Knj::Strings.yn_str(timelog[:workinternal], true, false),
|
578
|
+
:task => timelog.task_name
|
579
|
+
)
|
519
580
|
end
|
520
581
|
|
521
582
|
#Reset cache of which rows are set to bold.
|
@@ -578,7 +639,10 @@ class Openall_time_applet::Gui::Win_main
|
|
578
639
|
def timelog_info_trigger
|
579
640
|
if tlog = @args[:oata].timelog_active
|
580
641
|
time_tracked = @args[:oata].timelog_active_time_tracked + tlog.time_total
|
581
|
-
@gui["btnSwitch"].label = "#{_("Stop")} #{Knj::Strings.secs_to_human_short_time(time_tracked)}"
|
642
|
+
@gui["btnSwitch"].label = "#{_("Stop")} (#{Knj::Strings.secs_to_human_short_time(time_tracked)})"
|
643
|
+
|
644
|
+
#Update icon every second while showing main-window, so it looks like stop-button and tray-icon-time is in sync (else tray will only update every 30 sec. which will make it look out of sync, even though it wont be).
|
645
|
+
@args[:oata].ti.update_icon
|
582
646
|
end
|
583
647
|
end
|
584
648
|
|
@@ -657,7 +721,7 @@ class Openall_time_applet::Gui::Win_main
|
|
657
721
|
act_timelog_id = nil
|
658
722
|
end
|
659
723
|
|
660
|
-
rows_bold = [
|
724
|
+
rows_bold = [:timestamp, :time, :descr, :ttime, :tkm, :tdescr, :cost, :task]
|
661
725
|
|
662
726
|
@gui["tvTimelogs"].model.each do |model, path, iter|
|
663
727
|
timelog_id = model.get_value(iter, 0).to_i
|
@@ -667,14 +731,16 @@ class Openall_time_applet::Gui::Win_main
|
|
667
731
|
#Update time tracked.
|
668
732
|
if timelog_id == act_timelog_id
|
669
733
|
secs = act_timelog.time_total + @args[:oata].timelog_active_time_tracked
|
670
|
-
|
734
|
+
col_no = @tv_settings.col_orig_no_for_id(:time)
|
735
|
+
iter[col_no] = "<b>#{Knj::Strings.secs_to_human_time_str(secs, :secs => false)}</b>"
|
671
736
|
bold = true
|
672
737
|
end
|
673
738
|
|
674
739
|
#Set all columns to bold if not already set.
|
675
740
|
if bold and !@bold_rows.key?(iter_id)
|
676
741
|
rows_bold.each do |row_no|
|
677
|
-
|
742
|
+
col_no = @tv_settings.col_orig_no_for_id(row_no)
|
743
|
+
iter[col_no] = "<b>#{model.get_value(iter, col_no)}</b>"
|
678
744
|
end
|
679
745
|
|
680
746
|
@bold_rows[iter_id] = true
|
@@ -711,7 +777,8 @@ class Openall_time_applet::Gui::Win_main
|
|
711
777
|
added_id = timelog.id.to_i
|
712
778
|
|
713
779
|
@gui["tvTimelogs"].model.each do |model, path, iter|
|
714
|
-
|
780
|
+
col_no = @tv_settings.col_no_for_id(:id)
|
781
|
+
timelog_id = model.get_value(iter, col_no).to_i
|
715
782
|
|
716
783
|
if timelog_id == added_id
|
717
784
|
col = @gui["tvTimelogs"].columns[1]
|
data/lib/openall_time_applet.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require "rubygems"
|
3
3
|
|
4
4
|
#For secs-to-human-string (MySQL-format), model-framework, database-framework, options-framework, date-framework and more.
|
5
|
-
gems = ["wref", "datet", "http2", "knjrbfw"]
|
5
|
+
gems = ["wref", "datet", "http2", "knjrbfw", "gtk2_treeview_settings"]
|
6
6
|
gems.each do |gem|
|
7
7
|
fpath = "#{File.dirname(__FILE__)}/../../#{gem}/lib/#{gem}.rb"
|
8
8
|
if File.exists?(fpath)
|
@@ -99,9 +99,7 @@ class Openall_time_applet
|
|
99
99
|
:class_pre => "",
|
100
100
|
:module => Openall_time_applet::Models
|
101
101
|
)
|
102
|
-
@ob.events.connect(:no_name
|
103
|
-
_("not set")
|
104
|
-
end
|
102
|
+
@ob.events.connect(:no_name, &self.method(:objects_no_name))
|
105
103
|
|
106
104
|
@events = Knj::Event_handler.new
|
107
105
|
@events.add_event(:name => :timelog_active_changed)
|
@@ -113,7 +111,7 @@ class Openall_time_applet
|
|
113
111
|
Kernel.at_exit(&self.method(:destroy))
|
114
112
|
|
115
113
|
#Set default-color to "green_casalogic".
|
116
|
-
Knj::Opts.set("tray_text_color", "green_casalogic") if Knj::Opts.get("tray_text_color").to_s.strip.
|
114
|
+
Knj::Opts.set("tray_text_color", "green_casalogic") if Knj::Opts.get("tray_text_color").to_s.strip.empty?
|
117
115
|
|
118
116
|
#Spawn tray-icon.
|
119
117
|
self.spawn_trayicon
|
@@ -128,6 +126,11 @@ class Openall_time_applet
|
|
128
126
|
self.restart_autosync
|
129
127
|
end
|
130
128
|
|
129
|
+
#Called when something doesnt have a name to get a replacement-name in the objects-framework.
|
130
|
+
def objects_no_name(event, classname)
|
131
|
+
return _("not set")
|
132
|
+
end
|
133
|
+
|
131
134
|
#Creates a runfile or sending a command to the running OpenAll-Time-Applet through the Unix-socket.
|
132
135
|
def check_runfile_and_cmds
|
133
136
|
#If run-file exists and the PID within is still running, then send command (if given) and exit.
|
data/openall_time_applet.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{openall_time_applet}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.33"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Kasper Johansen"]
|
12
|
-
s.date = %q{2012-08-
|
12
|
+
s.date = %q{2012-08-08}
|
13
13
|
s.description = %q{Off-line time-tracking for OpenAll with syncing when online.}
|
14
14
|
s.email = %q{k@spernj.org}
|
15
15
|
s.executables = ["OpenAll Timelogging", "openall_time_applet.rb"]
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: openall_time_applet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.33
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Kasper Johansen
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-08 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -209,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
209
|
requirements:
|
210
210
|
- - ">="
|
211
211
|
- !ruby/object:Gem::Version
|
212
|
-
hash: -
|
212
|
+
hash: -2432431753330081145
|
213
213
|
segments:
|
214
214
|
- 0
|
215
215
|
version: "0"
|