Merge lp:~sara.ribeiro/gtg/userdoc into lp:~gtg/gtg/old-trunk

Proposed by Sara Ribeiro on 2014-03-09
Status: Merged
Merged at revision: 1364
Proposed branch: lp:~sara.ribeiro/gtg/userdoc
Merge into: lp:~gtg/gtg/old-trunk
Diff against target: 240 lines (+79/-10)
8 files modified
CHANGELOG (+1/-0)
GTG/gtk/backends_dialog.ui (+1/-1)
GTG/gtk/backends_dialog/__init__.py (+8/-4)
GTG/gtk/editor/editor.py (+4/-0)
GTG/gtk/help.py (+53/-0)
GTG/gtk/plugins.py (+5/-1)
GTG/gtk/plugins.ui (+3/-3)
GTG/gtk/preferences.py (+4/-1)
To merge this branch: bzr merge lp:~sara.ribeiro/gtg/userdoc
Reviewer Review Type Date Requested Status
Izidor Matušov Needs Fixing on 2014-03-09
Nimit Shah 2014-03-09 Needs Fixing on 2014-03-09
Review via email: mp+210071@code.launchpad.net

Description of the change

Fix for bug #1027604: Deeper integeration of userdoc

To post a comment you must log in.
Nimit Shah (nimit-svnit) wrote :
Download full text (8.1 KiB)

Hi Sara,
You need to make some small fixes:

=== modified file 'CHANGELOG'

> --- CHANGELOG 2014-03-05 19:25:18 +0000
> +++ CHANGELOG 2014-03-09 03:03:28 +0000
> @@ -19,6 +19,7 @@
> * Fix for bug #1286493 : GTG cannot connect to RTM, by Pawan Hegde
> * Fix for bug #1288011 : More intuitive title label for tasks, by
> Sara Ribeiro
> * Fix for bug #316922 : Have a link to the parent(s) in the task
> editor, by Parth Panchal
> + * Fix for bug #1027604: Deeper integeration of userdoc, by Sara
> Ribeiro
>
> 2013-11-24 Getting Things GNOME! 0.3.1
> * Fix for bug #1024473: Have 'Show Main Window' in notification area,
> by Antonio Roquentin
>
> === modified file 'GTG/gtk/backends_dialog.ui'
> --- GTG/gtk/backends_dialog.ui 2013-09-04 17:48:19 +0000
> +++ GTG/gtk/backends_dialog.ui 2014-03-09 03:03:28 +0000
> @@ -151,7 +151,7 @@
> <property name="can_focus">False</property>
> <property name="layout_style">edge</property>
> <child>
> - <object class="GtkButton" id="button1">
> + <object class="GtkButton" id="sync_help">
> <property name="label">gtk-help</property>
> <property name="visible">True</property>
> <property name="can_focus">True</property>
>
> === modified file 'GTG/gtk/backends_dialog/__init__.py'
> --- GTG/gtk/backends_dialog/__init__.py 2013-11-25 02:37:46 +0000
> +++ GTG/gtk/backends_dialog/__init__.py 2014-03-09 03:03:28 +0000
> @@ -72,6 +72,7 @@
> self._load_widgets_from_builder(builder)
> # Load and setup other widgets
> self.dialog.set_title(_("Synchronization Services - %s" %
> info.NAME))
> +
>
Remove this extra line

> self._create_widgets_for_add_panel()
> self._create_widgets_for_conf_panel()
> self._setup_signal_connections(builder)
> @@ -199,6 +200,13 @@
> }
> builder.connect_signals(signals)
>
> + # adding F1 as a shortcut for Help
> + agr = Gtk.AccelGroup()
> + self.dialog.add_accel_group(agr)
> + widget = builder.get_object("sync_help")
> + key, modifier = Gtk.accelerator_parse('F1')
> + widget.add_accelerator("activate", agr, key, modifier,
> Gtk.AccelFlags.VISIBLE)
> +
> def _configure_icon_theme(self):
> '''
> Inform gtk on the location of the backends icons (which is in
>
> === modified file 'GTG/gtk/editor/editor.py'
> --- GTG/gtk/editor/editor.py 2014-03-05 19:25:18 +0000
> +++ GTG/gtk/editor/editor.py 2014-03-09 03:03:28 +0000
> @@ -24,10 +24,12 @@
> The rest is the logic of the widget: date changing widgets, buttons, ...
> """
> import time
> +from webbrowser import open as openurl
>
> from gi.repository import Gtk, Gdk, Pango
>
> from GTG import _, ngettext
> +from GTG import info
> from GTG.gtk.editor import GnomeConfig
> from GTG.gtk.editor.taskview import TaskView
> from GTG.core.plugins.engine import PluginEngine
> @@ -201,6 +203,10 @@
> key, modifier = Gtk.accelerator_parse('<Control>w')
> agr.connect(key, modifier, Gtk.AccelFlags.VISIBLE, self.close)
>
> + # F...

Read more...

Nimit Shah (nimit-svnit) wrote :

Hi Sara,
Please check my mail for the small readability related issues that you need to rectify.

review: Needs Fixing
Izidor Matušov (izidor) wrote :

I like the change and have a proposal to make it even better! What about extracting the code you added into a separate module, something like GTG.gtk.help?

Why?

 - less duplicated code
 - add more abstraction: I want the documentation for this dialog be this URI
 - it would be easy to modify way how to open/display help

The use can be as easy as this:

<code>
from GTG.gtk.help import register_help
register_help(self.dialog, 'preferences')
</code>

Implementation will be the code you copy pasted (pseudo code):

<code>
def show_help(help_url, *args):
   openurl(help_url)
   return True

def register_help(widget, help_addr):
   full_help_addr = construct_help_addr(help_addr)

   # Code for adding accel group here
</code>

review: Needs Fixing
lp:~sara.ribeiro/gtg/userdoc updated on 2014-03-11
1366. By Sara Ribeiro on 2014-03-09

Removed blank lines

1367. By Sara Ribeiro on 2014-03-09

Solve merge conflict

1368. By Sara Ribeiro on 2014-03-11

Created a separate Help module for better abstraction

1369. By Sara Ribeiro on 2014-03-11

Solve merge conflict

1370. By Sara Ribeiro on 2014-03-11

Removed blank lines

Sara Ribeiro (sara.ribeiro) wrote :

I made the modifications you guys suggested. Can you please review again? Thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CHANGELOG'
2--- CHANGELOG 2014-03-10 03:37:32 +0000
3+++ CHANGELOG 2014-03-11 04:25:45 +0000
4@@ -21,6 +21,7 @@
5 * Fix for bug #316922 : Have a link to the parent(s) in the task editor, by Parth Panchal
6 * Fix for bug #1287259 : pep8ify the codebase, by Izidor Matušov
7 * Rework of test-suite, by Izidor Matušov
8+ * Fix for bug #1027604: Deeper integeration of userdoc, by Sara Ribeiro
9
10 2013-11-24 Getting Things GNOME! 0.3.1
11 * Fix for bug #1024473: Have 'Show Main Window' in notification area, by Antonio Roquentin
12
13=== modified file 'GTG/gtk/backends_dialog.ui'
14--- GTG/gtk/backends_dialog.ui 2013-09-04 17:48:19 +0000
15+++ GTG/gtk/backends_dialog.ui 2014-03-11 04:25:45 +0000
16@@ -151,7 +151,7 @@
17 <property name="can_focus">False</property>
18 <property name="layout_style">edge</property>
19 <child>
20- <object class="GtkButton" id="button1">
21+ <object class="GtkButton" id="sync_help">
22 <property name="label">gtk-help</property>
23 <property name="visible">True</property>
24 <property name="can_focus">True</property>
25
26=== modified file 'GTG/gtk/backends_dialog/__init__.py'
27--- GTG/gtk/backends_dialog/__init__.py 2013-11-25 02:37:46 +0000
28+++ GTG/gtk/backends_dialog/__init__.py 2014-03-11 04:25:45 +0000
29@@ -28,8 +28,6 @@
30
31 from gi.repository import Gtk
32
33-from webbrowser import open as openurl
34-
35 from GTG.gtk import ViewConfig
36 from GTG.core import CoreConfig
37 from GTG.gtk.backends_dialog.backendstree import BackendsTree
38@@ -40,6 +38,7 @@
39 from GTG import _
40 from GTG.backends.genericbackend import GenericBackend
41 from GTG import info
42+from GTG.gtk import help
43
44
45 class BackendsDialog(object):
46@@ -76,6 +75,7 @@
47 self._create_widgets_for_conf_panel()
48 self._setup_signal_connections(builder)
49 self._create_widgets_for_treeview()
50+ help.add_help_shortcut(self.dialog, "sync")
51
52 ########################################
53 ### INTERFACE WITH THE VIEWMANAGER #####
54@@ -194,8 +194,7 @@
55 'on_BackendsDialog_delete_event': self.on_close,
56 'on_close_button_clicked': self.on_close,
57 'on_remove_button_clicked': self.on_remove_button,
58- 'on_help_button_clicked': lambda w:
59- openurl("help:gtg/gtg-add-sync"),
60+ 'on_help_button_clicked': self.on_help,
61 }
62 builder.connect_signals(signals)
63
64@@ -227,6 +226,11 @@
65 ########################################
66 ### EVENT HANDLING #####################
67 ########################################
68+ def on_help(cls, widget):
69+ """ Open help for syncronization services """
70+ help.show_help("sync")
71+ return True
72+
73 def on_backend_selected(self, backend_id):
74 '''
75 When a backend in the treeview gets selected, show
76
77=== modified file 'GTG/gtk/editor/editor.py'
78--- GTG/gtk/editor/editor.py 2014-03-09 12:59:59 +0000
79+++ GTG/gtk/editor/editor.py 2014-03-11 04:25:45 +0000
80@@ -35,6 +35,7 @@
81 from GTG.core.task import Task
82 from GTG.tools.dates import Date
83 from GTG.gtk.editor.calendar import GTGCalendar
84+from GTG.gtk.help import add_help_shortcut
85
86
87 class TaskEditor(object):
88@@ -201,6 +202,9 @@
89 key, modifier = Gtk.accelerator_parse('<Control>w')
90 agr.connect(key, modifier, Gtk.AccelFlags.VISIBLE, self.close)
91
92+ # F1 shows help
93+ add_help_shortcut(self.window, "editor")
94+
95 # Ctrl-N creates a new task
96 key, modifier = Gtk.accelerator_parse('<Control>n')
97 agr.connect(key, modifier, Gtk.AccelFlags.VISIBLE, self.new_task)
98
99=== added file 'GTG/gtk/help.py'
100--- GTG/gtk/help.py 1970-01-01 00:00:00 +0000
101+++ GTG/gtk/help.py 2014-03-11 04:25:45 +0000
102@@ -0,0 +1,53 @@
103+# -*- coding: utf-8 -*-
104+# -----------------------------------------------------------------------------
105+# Getting Things GNOME! - a personal organizer for the GNOME desktop
106+# Copyright (c) 2008-2013 - Lionel Dricot & Bertrand Rousseau
107+#
108+# This program is free software: you can redistribute it and/or modify it under
109+# the terms of the GNU General Public License as published by the Free Software
110+# Foundation, either version 3 of the License, or (at your option) any later
111+# version.
112+#
113+# This program is distributed in the hope that it will be useful, but WITHOUT
114+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
115+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
116+# details.
117+#
118+# You should have received a copy of the GNU General Public License along with
119+# this program. If not, see <http://www.gnu.org/licenses/>.
120+# -----------------------------------------------------------------------------
121+
122+""" This file contains Help related funcions for displaying user documentation.
123+It allows you to:
124+ - setup F1 as a help shortcut
125+ - display the documentation help for a given subject (plugins, sync, ...)
126+"""
127+
128+from gi.repository import Gtk
129+from webbrowser import open as openurl
130+
131+from GTG import info
132+
133+
134+def construct_help_addr(help_addr=None):
135+ """ Return the url help address for a specific subject
136+ (default: general help) """
137+ return info.HELP_URI + {
138+ "plugins": "/gtg-plugins",
139+ "sync": "/gtg-add-sync",
140+ }.get(help_addr, "")
141+
142+def show_help(help_addr):
143+ """ Open a specif help page for a given subject """
144+ help_url = construct_help_addr(help_addr)
145+ openurl(help_url)
146+ return True
147+
148+def add_help_shortcut(widget, help_addr):
149+ """ Add F1 as a shortcut for help """
150+ agr = Gtk.AccelGroup()
151+ widget.add_accel_group(agr)
152+ key, modifier = Gtk.accelerator_parse('F1')
153+ # use dummy variables for lambda
154+ agr.connect(key, modifier, Gtk.AccelFlags.VISIBLE,
155+ lambda a,b,c,d: show_help(help_addr))
156
157=== modified file 'GTG/gtk/plugins.py'
158--- GTG/gtk/plugins.py 2014-03-09 12:59:59 +0000
159+++ GTG/gtk/plugins.py 2014-03-11 04:25:45 +0000
160@@ -26,6 +26,7 @@
161 from GTG.core.plugins import GnomeConfig
162 from GTG.core.plugins.engine import PluginEngine
163 from GTG.gtk import ViewConfig
164+from GTG.gtk import help
165
166 # columns in PluginsDialog.plugin_store
167 PLUGINS_COL_ID = 0
168@@ -144,6 +145,8 @@
169 self.plugin_about = builder.get_object("PluginAboutDialog")
170 self.plugin_depends = builder.get_object('PluginDepends')
171
172+ help.add_help_shortcut(self.dialog, "plugins")
173+
174 self.pengine = PluginEngine()
175 # plugin config initiation
176 if self.pengine.get_plugins():
177@@ -241,7 +244,8 @@
178
179 @classmethod
180 def on_help(cls, widget):
181- """ In future, this will open help for plugins """
182+ """ Open help for plugins """
183+ help.show_help("plugins")
184 return True
185
186 def on_plugin_toggle(self, widget, path):
187
188=== modified file 'GTG/gtk/plugins.ui'
189--- GTG/gtk/plugins.ui 2013-09-04 17:48:19 +0000
190+++ GTG/gtk/plugins.ui 2014-03-11 04:25:45 +0000
191@@ -83,16 +83,16 @@
192 <object class="GtkButtonBox" id="dialog-action_area5">
193 <property name="visible">True</property>
194 <property name="can_focus">False</property>
195- <property name="layout_style">end</property>
196+ <property name="layout_style">edge</property>
197 <child>
198 <object class="GtkButton" id="plugins_help">
199 <property name="label">gtk-help</property>
200 <property name="can_focus">True</property>
201 <property name="receives_default">True</property>
202- <property name="no_show_all">True</property>
203+ <property name="visible">True</property>
204 <property name="use_action_appearance">False</property>
205 <property name="use_stock">True</property>
206- <signal name="released" handler="on_plugins_help" swapped="no"/>
207+ <signal name="clicked" handler="on_plugins_help" swapped="no"/>
208 </object>
209 <packing>
210 <property name="expand">False</property>
211
212=== modified file 'GTG/gtk/preferences.py'
213--- GTG/gtk/preferences.py 2014-01-14 16:36:35 +0000
214+++ GTG/gtk/preferences.py 2014-03-11 04:25:45 +0000
215@@ -29,6 +29,7 @@
216 from GTG import _
217 from GTG import info
218 from GTG.gtk import ViewConfig
219+from GTG.gtk import help
220
221 AUTOSTART_DIRECTORY = os.path.join(xdg_config_home, "autostart")
222 AUTOSTART_FILE = "gtg.desktop"
223@@ -91,6 +92,7 @@
224 self.shortcut_button = builder.get_object("shortcut_button")
225
226 self.shortcut = ShortcutWidget(builder)
227+ help.add_help_shortcut(self.dialog, "preferences")
228
229 self.fontbutton = builder.get_object("fontbutton")
230 editor_font = self.config.get("font_name")
231@@ -149,7 +151,8 @@
232
233 @classmethod
234 def on_help(cls, widget):
235- """ In future, this will open help for preferences """
236+ """ Open help for preferences """
237+ help.show_help("preferences")
238 return True
239
240 @classmethod

Subscribers

People subscribed via source and target branches

to status/vote changes: