GTG

Merge lp:~gtg/gtg/not-today into lp:~gtg/gtg/old-trunk

Proposed by Lionel Dricot
Status: Merged
Merged at revision: 1259
Proposed branch: lp:~gtg/gtg/not-today
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 165 lines (+125/-0)
4 files modified
GTG/core/plugins/api.py (+18/-0)
GTG/plugins/not-today.gtg-plugin (+9/-0)
GTG/plugins/not_today/__init__.py (+23/-0)
GTG/plugins/not_today/not_today.py (+75/-0)
To merge this branch: bzr merge lp:~gtg/gtg/not-today
Reviewer Review Type Date Requested Status
Izidor Matušov code,run Approve
Review via email: mp+140427@code.launchpad.net

Description of the change

This introduces a new plugin "not today". The plugin only add a new button in the main GTG window, marked as "do it tomorrow". The button change the start date of selected active tasks to tomorrow.

New plugins API introduced with this merge :

get_selected (which returns the selected tasks)
set_selection_changed_callback (which allows you to set a callback called each time the selection is changed in the
browser)

To post a comment you must log in.
lp:~gtg/gtg/not-today updated
1263. By Lionel Dricot

allow string to be translated

Revision history for this message
Izidor Matušov (izidor) wrote :

Awesome plugin :)

review: Approve (code,run)

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 2012-11-25 19:19:44 +0000
3+++ GTG/core/plugins/api.py 2012-12-18 13:12:24 +0000
4@@ -49,6 +49,7 @@
5 """
6 self.__requester = requester
7 self.__view_manager = view_manager
8+ self.selection_changed_callback = None
9 if taskeditor:
10 self.__ui = taskeditor
11 self.__builder = self.__ui.get_builder()
12@@ -59,6 +60,11 @@
13 self.__builder = self.__ui.get_builder()
14 self.__toolbar = self.__builder.get_object('task_toolbar')
15 self.__task_id = None
16+ self.__view_manager.browser.selection.connect("changed",self.__selection_changed)
17+
18+ def __selection_changed(self,selection):
19+ if self.selection_changed_callback:
20+ self.selection_changed_callback(selection)
21
22 #=== Accessor methods ========================================================
23 def is_editor(self):
24@@ -96,6 +102,18 @@
25 Returns a Browser or an Editor
26 '''
27 return self.__ui
28+
29+ def get_selected(self):
30+ '''
31+ Returns the selected tasks in the browser or the task ID if the editor
32+ '''
33+ if self.is_editor():
34+ return self.__task_id
35+ else:
36+ return self.__view_manager.browser.get_selected_tasks()
37+
38+ def set_active_selection_changed_callback(self, func):
39+ self.selection_changed_callback = func
40
41 #=== Changing the UI =========================================================
42 def add_menu_item(self, item):
43
44=== added file 'GTG/plugins/not-today.gtg-plugin'
45--- GTG/plugins/not-today.gtg-plugin 1970-01-01 00:00:00 +0000
46+++ GTG/plugins/not-today.gtg-plugin 2012-12-18 13:12:24 +0000
47@@ -0,0 +1,9 @@
48+[GTG Plugin]
49+Module=not_today
50+Name=Not Today
51+Short-description="Mark task as not to do today"
52+Description="""Move the start date of tasks you don't want to do today to tomorrow."""
53+Authors=Lionel Dricot <lionel@ploum.net>
54+Version=0.1
55+Enabled=False
56+Dependencies=
57
58=== added directory 'GTG/plugins/not_today'
59=== added file 'GTG/plugins/not_today/__init__.py'
60--- GTG/plugins/not_today/__init__.py 1970-01-01 00:00:00 +0000
61+++ GTG/plugins/not_today/__init__.py 2012-12-18 13:12:24 +0000
62@@ -0,0 +1,23 @@
63+# -*- coding: utf-8 -*-
64+# Copyright (c) 2012 - Lionel Dricot <lionel@ploum.net>
65+
66+# This program is free software: you can redistribute it and/or modify it under
67+# the terms of the GNU General Public License as published by the Free Software
68+# Foundation, either version 3 of the License, or (at your option) any later
69+# version.
70+#
71+# This program is distributed in the hope that it will be useful, but WITHOUT
72+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
73+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
74+# details.
75+#
76+# You should have received a copy of the GNU General Public License along with
77+# this program. If not, see <http://www.gnu.org/licenses/>.
78+
79+""" Not today pluging"""
80+
81+from GTG.plugins.not_today.not_today import notToday
82+
83+#suppress pyflakes warning (given by make lint)
84+if False :
85+ notToday()
86
87=== added file 'GTG/plugins/not_today/not_today.py'
88--- GTG/plugins/not_today/not_today.py 1970-01-01 00:00:00 +0000
89+++ GTG/plugins/not_today/not_today.py 2012-12-18 13:12:24 +0000
90@@ -0,0 +1,75 @@
91+# -*- coding: utf-8 -*-
92+# Copyright (c) 2012 - Lionel Dricot <lionel@ploum.net>
93+
94+# This program is free software: you can redistribute it and/or modify it under
95+# the terms of the GNU General Public License as published by the Free Software
96+# Foundation, either version 3 of the License, or (at your option) any later
97+# version.
98+#
99+# This program is distributed in the hope that it will be useful, but WITHOUT
100+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
101+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
102+# details.
103+#
104+# You should have received a copy of the GNU General Public License along with
105+# this program. If not, see <http://www.gnu.org/licenses/>.
106+
107+import gtk
108+from GTG.tools.dates import Date
109+from GTG import _
110+
111+class notToday:
112+
113+ def __init__(self):
114+ self.plugin_api = None
115+ self.menu_entry = None
116+ self.tb_button = None
117+
118+ def activate(self, plugin_api):
119+ self.plugin_api = plugin_api
120+ self.req = self.plugin_api.get_requester()
121+ self._init_gtk()
122+ self.plugin_api.set_active_selection_changed_callback(self.selection_changed)
123+
124+ def deactivate(self, plugin_api): # pylint: disable-msg=W0613
125+ """ Removes the gtk widgets before quitting """
126+ self._gtk_deactivate()
127+
128+
129+ def mark_not_today(self,button):
130+ start_date = Date.parse("tomorrow")
131+ for tid in self.plugin_api.get_selected():
132+ task = self.req.get_task(tid)
133+ task.set_start_date(start_date)
134+
135+ def selection_changed(self,selection):
136+ if selection.count_selected_rows() > 0:
137+ self.tb_button.set_sensitive(True)
138+ else:
139+ self.tb_button.set_sensitive(False)
140+
141+
142+## GTK FUNCTIONS ##############################################################
143+ def _init_gtk(self):
144+ """ Initialize all the GTK widgets """
145+
146+ self.tb_button = gtk.ToolButton()
147+ self.tb_button.set_sensitive(False)
148+ self.tb_button.set_icon_name("document-revert")
149+ self.tb_button.set_is_important(True)
150+ self.tb_button.set_label(_("Do it tomorrow"))
151+ self.tb_button.connect('clicked', self.mark_not_today)
152+ self.tb_button.show()
153+ self.plugin_api.add_toolbar_item(self.tb_button)
154+
155+
156+
157+ def _gtk_deactivate(self):
158+ """ Remove Toolbar Button and Menu item for this plugin """
159+ if self.menu_entry:
160+ self.plugin_api.remove_menu_item(self.menu_item)
161+ self.menu_entry = False
162+
163+ if self.toolbar_entry:
164+ self.plugin_api.remove_toolbar_item(self.tb_button)
165+ self.toolbar_entry = False

Subscribers

People subscribed via source and target branches

to status/vote changes: