GTG

Merge lp://staging/~bryce/gtg/gtg-refactor-browser-cleanup into lp://staging/~gtg/gtg/gtg-refactor

Proposed by Bryce Harrington
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~bryce/gtg/gtg-refactor-browser-cleanup
Merge into: lp://staging/~gtg/gtg/gtg-refactor
Diff against target: 419 lines (+64/-99)
3 files modified
GTG/core/plugins/api.py (+3/-3)
GTG/taskbrowser/browser.py (+41/-76)
GTG/taskbrowser/taskbrowser.glade (+20/-20)
To merge this branch: bzr merge lp://staging/~bryce/gtg/gtg-refactor-browser-cleanup
Reviewer Review Type Date Requested Status
Lionel Dricot (community) Approve
Review via email: mp+20326@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Bryce Harrington (bryce) wrote :

This branch does some minor refactoring to make widget naming more consistent, and to simplify the accelerator code.

Now that the major gtg-refactoring work is finished, maybe this is a good time to merge this work.

Revision history for this message
Lionel Dricot (ploum-deactivatedaccount) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'GTG/core/plugins/api.py'
2--- GTG/core/plugins/api.py 2010-02-28 13:09:34 +0000
3+++ GTG/core/plugins/api.py 2010-03-01 00:28:15 +0000
4@@ -110,7 +110,7 @@
5
6 @param item: The gtk.MenuItem that is going to be added.
7 """
8- widget = self.__builder.get_object('menu_plugin')
9+ widget = self.__builder.get_object('plugin_mi')
10 if widget:
11 widget.show_all()
12 widget.get_submenu().append(item)
13@@ -125,7 +125,7 @@
14 fails.
15 """
16 try:
17- wi = self.__builder.get_object('menu_plugin')
18+ wi = self.__builder.get_object('plugin_mi')
19 if wi:
20 menu = wi.get_submenu()
21 menu.remove(item)
22@@ -352,7 +352,7 @@
23
24 @return: The about dialog.
25 """
26- wi = self.__builder.get_object("aboutdialog1")
27+ wi = self.__builder.get_object("about_dialog")
28 if wi:
29 return wi
30 else:
31
32=== modified file 'GTG/taskbrowser/browser.py'
33--- GTG/taskbrowser/browser.py 2010-02-28 16:12:59 +0000
34+++ GTG/taskbrowser/browser.py 2010-03-01 00:28:15 +0000
35@@ -191,19 +191,22 @@
36 def _init_widget_aliases(self):
37 self.window = self.builder.get_object("MainWindow")
38 self.tagpopup = self.builder.get_object("TagContextMenu")
39- self.nonworkviewtag_checkbox = self.builder.get_object("nonworkviewtag")
40+ self.nonworkviewtag_cb = self.builder.get_object("nonworkviewtag")
41 self.taskpopup = self.builder.get_object("TaskContextMenu")
42 self.defertopopup = self.builder.get_object("DeferToContextMenu")
43- self.ctaskpopup = \
44- self.builder.get_object("ClosedTaskContextMenu")
45+ self.ctaskpopup = self.builder.get_object("ClosedTaskContextMenu")
46 self.editbutton = self.builder.get_object("edit_b")
47- self.donebutton = self.builder.get_object("mark_as_done_b")
48+ self.edit_mi = self.builder.get_object("edit_mi")
49+ self.donebutton = self.builder.get_object("done_b")
50+ self.done_mi = self.builder.get_object("done_mi")
51 self.deletebutton = self.builder.get_object("delete_b")
52+ self.delete_mi = self.builder.get_object("delete_mi")
53 self.newtask = self.builder.get_object("new_task_b")
54 self.newsubtask = self.builder.get_object("new_subtask_b")
55- self.dismissbutton = self.builder.get_object("dismiss")
56- self.about = self.builder.get_object("aboutdialog1")
57- self.edit_mi = self.builder.get_object("edit_mi")
58+ self.new_subtask_mi = self.builder.get_object("new_subtask_mi")
59+ self.dismissbutton = self.builder.get_object("dismiss_b")
60+ self.dismiss_mi = self.builder.get_object("dismiss_mi")
61+ self.about = self.builder.get_object("about_dialog")
62 self.main_pane = self.builder.get_object("main_pane")
63 self.menu_view_workview = self.builder.get_object("view_workview")
64 self.toggle_workview = self.builder.get_object("workview_toggle")
65@@ -390,71 +393,34 @@
66 self.tag_modelsort.set_sort_column_id(\
67 tagtree.COL_ID, gtk.SORT_ASCENDING)
68
69+ def _add_accelerator_for_widget(self, agr, name, accel):
70+ widget = self.builder.get_object(name)
71+ key, mod = gtk.accelerator_parse(accel)
72+ widget.add_accelerator("activate", agr, key, mod, gtk.ACCEL_VISIBLE)
73+
74 def _init_accelerators(self):
75 agr = gtk.AccelGroup()
76 self.builder.get_object("MainWindow").add_accel_group(agr)
77
78- view_sidebar = self.builder.get_object("view_sidebar")
79- key, mod = gtk.accelerator_parse("F9")
80- view_sidebar.add_accelerator("activate", agr, key, mod,\
81- gtk.ACCEL_VISIBLE)
82-
83- file_quit = self.builder.get_object("file_quit")
84- key, mod = gtk.accelerator_parse("<Control>q")
85- file_quit.add_accelerator("activate", agr, key, mod, gtk.ACCEL_VISIBLE)
86-
87- edit_undo = self.builder.get_object("edit_undo")
88- key, mod = gtk.accelerator_parse("<Control>z")
89- edit_undo.add_accelerator("activate", agr, key, mod, gtk.ACCEL_VISIBLE)
90-
91- edit_redo = self.builder.get_object("edit_redo")
92- key, mod = gtk.accelerator_parse("<Control>y")
93- edit_redo.add_accelerator("activate", agr, key, mod, gtk.ACCEL_VISIBLE)
94-
95- new_task_mi = self.builder.get_object("new_task_mi")
96- key, mod = gtk.accelerator_parse("<Control>n")
97- new_task_mi.add_accelerator("activate", agr, key, mod,\
98- gtk.ACCEL_VISIBLE)
99-
100- self.new_subtask_mi = self.builder.get_object("new_subtask_mi")
101- key, mod = gtk.accelerator_parse("<Control><Shift>n")
102- self.new_subtask_mi.add_accelerator("activate", agr, key, mod,\
103- gtk.ACCEL_VISIBLE)
104+ self._add_accelerator_for_widget(agr, "view_sidebar", "F9")
105+ self._add_accelerator_for_widget(agr, "file_quit", "<Control>q")
106+ self._add_accelerator_for_widget(agr, "edit_undo", "<Control>z")
107+ self._add_accelerator_for_widget(agr, "edit_redo", "<Control>y")
108+ self._add_accelerator_for_widget(agr, "new_task_mi", "<Control>n")
109+ self._add_accelerator_for_widget(agr, "new_subtask_mi", "<Control><Shift>n")
110+ self._add_accelerator_for_widget(agr, "done_mi", "<Control>d")
111+ self._add_accelerator_for_widget(agr, "dismiss_mi", "<Control>i")
112+ self._add_accelerator_for_widget(agr, "delete_mi", "Cancel")
113+ self._add_accelerator_for_widget(agr, "tcm_addtag", "<Control>t")
114+ self._add_accelerator_for_widget(agr, "view_closed", "<Control>F9")
115
116 edit_button = self.builder.get_object("edit_b")
117 key, mod = gtk.accelerator_parse("<Control>e")
118- edit_button.add_accelerator("clicked", agr, key, mod,\
119- gtk.ACCEL_VISIBLE)
120-
121- quickadd_field = self.builder.get_object('quickadd_field')
122- key, mod = gtk.accelerator_parse('<Control>l')
123- quickadd_field.add_accelerator(
124- 'grab-focus', agr, key, mod, gtk.ACCEL_VISIBLE)
125-
126- self.mark_done_mi = self.builder.get_object('mark_done_mi')
127- key, mod = gtk.accelerator_parse('<Control>d')
128- self.mark_done_mi.add_accelerator(
129- 'activate', agr, key, mod, gtk.ACCEL_VISIBLE)
130-
131- self.dismiss_mi = self.builder.get_object('task_dismiss')
132- key, mod = gtk.accelerator_parse('<Control>i')
133- self.dismiss_mi.add_accelerator(
134- 'activate', agr, key, mod, gtk.ACCEL_VISIBLE)
135-
136- self.delete_mi = self.builder.get_object('delete_mi')
137- key, mod = gtk.accelerator_parse('Cancel')
138- self.delete_mi.add_accelerator(
139- 'activate', agr, key, mod, gtk.ACCEL_VISIBLE)
140-
141- addtag_button = self.builder.get_object('tcm_addtag')
142- key, mod = gtk.accelerator_parse('<Control>t')
143- addtag_button.add_accelerator('activate', agr, key, mod, \
144- gtk.ACCEL_VISIBLE)
145-
146- addtag_button = self.builder.get_object('view_closed')
147- key, mod = gtk.accelerator_parse('<Control>F9')
148- addtag_button.add_accelerator('activate', agr, key, mod, \
149- gtk.ACCEL_VISIBLE)
150+ edit_button.add_accelerator("clicked", agr, key, mod, gtk.ACCEL_VISIBLE)
151+
152+ quickadd_field = self.builder.get_object("quickadd_field")
153+ key, mod = gtk.accelerator_parse("<Control>l")
154+ quickadd_field.add_accelerator("grab-focus", agr, key, mod, gtk.ACCEL_VISIBLE)
155
156 def _init_tag_list(self):
157 self.tag_list_model = gtk.ListStore(gobject.TYPE_STRING)
158@@ -900,8 +866,8 @@
159 #fact we should have a TagPropertiesEditor (like for project) Also,
160 #color change should be immediate. There's no reason for a Ok/Cancel
161 self.set_target_cursor()
162- dialog = gtk.ColorSelectionDialog('Choose color')
163- colorsel = dialog.colorsel
164+ color_dialog = gtk.ColorSelectionDialog('Choose color')
165+ colorsel = color_dialog.colorsel
166 colorsel.connect("color_changed", self.on_color_changed)
167
168 # Get previous color
169@@ -914,7 +880,7 @@
170 colorsel.set_previous_color(colorspec)
171 colorsel.set_current_color(colorspec)
172 init_color = colorsel.get_current_color()
173- response = dialog.run()
174+ response = color_dialog.run()
175 # Check response and set color if required
176 if response != gtk.RESPONSE_OK and init_color:
177 strcolor = gtk.color_selection_palette_to_string([init_color])
178@@ -923,7 +889,7 @@
179 t.set_attribute("color", strcolor)
180 self.reset_cursor()
181 self.task_tv.refresh()
182- dialog.destroy()
183+ color_dialog.destroy()
184
185 def on_resetcolor_activate(self, widget):
186 self.set_target_cursor()
187@@ -1140,10 +1106,9 @@
188 def on_nonworkviewtag_toggled(self, widget):
189 self.set_target_cursor()
190 tags = self.get_selected_tags()[0]
191- nonworkview_item = self.nonworkviewtag_checkbox
192 #We must inverse because the tagstore has True
193 #for tasks that are not in workview (and also convert to string)
194- toset = str(not nonworkview_item.get_active())
195+ toset = str(not self.nonworkview_cb.get_active())
196 if len(tags) > 0:
197 tags[0].set_attribute("nonworkview", toset)
198 if self.priv['workview']:
199@@ -1265,7 +1230,7 @@
200 apply_to_subtasks.set_active(False)
201 tag_entry.set_completion(self.tag_completion)
202 tag_entry.grab_focus()
203- addtag_dialog = self.builder.get_object("TaskAddTag")
204+ addtag_dialog = self.builder.get_object("addtag_dialog")
205 addtag_dialog.run()
206 addtag_dialog.hide()
207 self.tids_to_addtag = None
208@@ -1274,7 +1239,7 @@
209
210 def on_addtag_confirm(self, widget):
211 tag_entry = self.builder.get_object("tag_entry")
212- addtag_dialog = self.builder.get_object("TaskAddTag")
213+ addtag_dialog = self.builder.get_object("addtag_dialog")
214 apply_to_subtasks = self.builder.get_object("apply_to_subtasks")
215 addtag_error = False
216 entry_text = tag_entry.get_text()
217@@ -1410,7 +1375,7 @@
218 #Only if something is selected in the closed task list
219 #And we change the status of the Done/dismiss button
220 update_button(self.donebutton, settings_done)
221- update_menu_item(self.mark_done_mi, settings_done)
222+ update_menu_item(self.done_mi, settings_done)
223 update_button(self.dismissbutton, settings_dismiss)
224 update_menu_item(self.dismiss_mi, settings_dismiss)
225 if selection.count_selected_rows() > 0:
226@@ -1429,7 +1394,7 @@
227 self.builder.get_object(
228 "ctcm_undismiss").set_sensitive(False)
229 update_button(self.donebutton, settings_undone)
230- update_menu_item(self.mark_done_mi, settings_undone)
231+ update_menu_item(self.done_mi, settings_undone)
232 self.update_buttons_sensitivity()
233
234 def on_task_cursor_changed(self, selection=None):
235@@ -1470,7 +1435,7 @@
236 self.closed_selection.count_selected_rows() > 0
237 self.edit_mi.set_sensitive(enable)
238 self.new_subtask_mi.set_sensitive(enable)
239- self.mark_done_mi.set_sensitive(enable)
240+ self.done_mi.set_sensitive(enable)
241 self.dismiss_mi.set_sensitive(enable)
242 self.delete_mi.set_sensitive(enable)
243 self.donebutton.set_sensitive(enable)
244
245=== modified file 'GTG/taskbrowser/taskbrowser.glade'
246--- GTG/taskbrowser/taskbrowser.glade 2010-02-28 15:01:04 +0000
247+++ GTG/taskbrowser/taskbrowser.glade 2010-03-01 00:28:15 +0000
248@@ -59,12 +59,12 @@
249 </object>
250 </child>
251 <child>
252- <object class="GtkSeparatorMenuItem" id="separatormenuitem10">
253+ <object class="GtkSeparatorMenuItem" id="separator_1">
254 <property name="visible">True</property>
255 </object>
256 </child>
257 <child>
258- <object class="GtkImageMenuItem" id="mark_done_mi">
259+ <object class="GtkImageMenuItem" id="done_mi">
260 <property name="label" translatable="yes">Mark as _Done</property>
261 <property name="visible">True</property>
262 <property name="sensitive">False</property>
263@@ -76,7 +76,7 @@
264 </object>
265 </child>
266 <child>
267- <object class="GtkImageMenuItem" id="task_dismiss">
268+ <object class="GtkImageMenuItem" id="dismiss_mi">
269 <property name="label" translatable="yes">D_ismiss</property>
270 <property name="visible">True</property>
271 <property name="sensitive">False</property>
272@@ -99,7 +99,7 @@
273 </object>
274 </child>
275 <child>
276- <object class="GtkSeparatorMenuItem" id="menuitem2">
277+ <object class="GtkSeparatorMenuItem" id="separator_2">
278 <property name="visible">True</property>
279 </object>
280 </child>
281@@ -142,10 +142,10 @@
282 </object>
283 </child>
284 <child>
285- <object class="GtkSeparatorMenuItem" id="menuitem1"/>
286+ <object class="GtkSeparatorMenuItem" id="separator_3"/>
287 </child>
288 <child>
289- <object class="GtkImageMenuItem" id="mi_edit_preferences">
290+ <object class="GtkImageMenuItem" id="edit_preferences_mi">
291 <property name="label">gtk-preferences</property>
292 <property name="visible">True</property>
293 <property name="use_underline">True</property>
294@@ -175,7 +175,7 @@
295 </object>
296 </child>
297 <child>
298- <object class="GtkSeparatorMenuItem" id="separator1">
299+ <object class="GtkSeparatorMenuItem" id="separator_4">
300 <property name="visible">True</property>
301 </object>
302 </child>
303@@ -189,7 +189,7 @@
304 </object>
305 </child>
306 <child>
307- <object class="GtkSeparatorMenuItem" id="separatormenuitem1">
308+ <object class="GtkSeparatorMenuItem" id="separator_5">
309 <property name="visible">True</property>
310 </object>
311 </child>
312@@ -230,7 +230,7 @@
313 </object>
314 </child>
315 <child>
316- <object class="GtkMenuItem" id="menu_plugin">
317+ <object class="GtkMenuItem" id="plugin_mi">
318 <property name="label" translatable="yes">_Plugins</property>
319 <property name="use_underline">True</property>
320 <child type="submenu">
321@@ -241,7 +241,7 @@
322 </object>
323 </child>
324 <child>
325- <object class="GtkMenuItem" id="menuitem4">
326+ <object class="GtkMenuItem" id="help_mi">
327 <property name="visible">True</property>
328 <property name="label" translatable="yes">_Help</property>
329 <property name="use_underline">True</property>
330@@ -337,7 +337,7 @@
331 </packing>
332 </child>
333 <child>
334- <object class="GtkSeparatorToolItem" id="toolbutton2">
335+ <object class="GtkSeparatorToolItem" id="separator_6">
336 <property name="visible">True</property>
337 </object>
338 <packing>
339@@ -346,7 +346,7 @@
340 </packing>
341 </child>
342 <child>
343- <object class="GtkToolButton" id="mark_as_done_b">
344+ <object class="GtkToolButton" id="done_b">
345 <property name="visible">True</property>
346 <property name="sensitive">False</property>
347 <property name="is_important">True</property>
348@@ -360,7 +360,7 @@
349 </packing>
350 </child>
351 <child>
352- <object class="GtkToolButton" id="dismiss">
353+ <object class="GtkToolButton" id="dismiss_b">
354 <property name="visible">True</property>
355 <property name="sensitive">False</property>
356 <property name="label" translatable="yes">Dismiss</property>
357@@ -385,7 +385,7 @@
358 </packing>
359 </child>
360 <child>
361- <object class="GtkSeparatorToolItem" id="toolbutton1">
362+ <object class="GtkSeparatorToolItem" id="separator_7">
363 <property name="visible">True</property>
364 </object>
365 <packing>
366@@ -512,7 +512,7 @@
367 </packing>
368 </child>
369 <child>
370- <object class="GtkButton" id="button1">
371+ <object class="GtkButton" id="quickadd_b">
372 <property name="label">gtk-add</property>
373 <property name="visible">True</property>
374 <property name="can_focus">True</property>
375@@ -622,7 +622,7 @@
376 </object>
377 </child>
378 </object>
379- <object class="GtkAboutDialog" id="aboutdialog1">
380+ <object class="GtkAboutDialog" id="about_dialog">
381 <property name="border_width">5</property>
382 <property name="title" translatable="yes">About GTG!</property>
383 <property name="resizable">False</property>
384@@ -687,7 +687,7 @@
385 </object>
386 </child>
387 <child>
388- <object class="GtkSeparatorMenuItem" id="separatormenuitem3">
389+ <object class="GtkSeparatorMenuItem" id="separator_8">
390 <property name="visible">True</property>
391 </object>
392 </child>
393@@ -732,7 +732,7 @@
394 </object>
395 </child>
396 <child>
397- <object class="GtkSeparatorMenuItem" id="separatormenuitem5">
398+ <object class="GtkSeparatorMenuItem" id="separator_9">
399 <property name="visible">True</property>
400 </object>
401 </child>
402@@ -807,7 +807,7 @@
403 </object>
404 </child>
405 <child>
406- <object class="GtkSeparatorMenuItem" id="separatormenuitem4">
407+ <object class="GtkSeparatorMenuItem" id="separator_10">
408 <property name="visible">True</property>
409 </object>
410 </child>
411@@ -901,7 +901,7 @@
412 <property name="yalign">0.47999998927116394</property>
413 <property name="stock">gtk-revert-to-saved</property>
414 </object>
415- <object class="GtkDialog" id="TaskAddTag">
416+ <object class="GtkDialog" id="addtag_dialog">
417 <property name="border_width">5</property>
418 <property name="title" translatable="yes">Add a Tag...</property>
419 <property name="window_position">center-on-parent</property>

Subscribers

People subscribed via source and target branches

to all changes: