gtg team mailing list archive
-
gtg team
-
Mailing list archive
-
Message #03742
[Merge] lp:~nimit-svnit/gtg/gtk-clean into lp:gtg
Nimit Shah has proposed merging lp:~nimit-svnit/gtg/gtk-clean into lp:gtg.
Requested reviews:
Gtg developers (gtg)
For more details, see:
https://code.launchpad.net/~nimit-svnit/gtg/gtk-clean/+merge/139257
Pep8ification of GTG/gtk folder
--
https://code.launchpad.net/~nimit-svnit/gtg/gtk-clean/+merge/139257
Your team Gtg developers is requested to review the proposed merge of lp:~nimit-svnit/gtg/gtk-clean into lp:gtg.
=== modified file 'GTG/gtk/backends_dialog/__init__.py'
--- GTG/gtk/backends_dialog/__init__.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/backends_dialog/__init__.py 2012-12-11 16:39:32 +0000
@@ -81,7 +81,6 @@
########################################
### INTERFACE WITH THE VIEWMANAGER #####
########################################
-
def activate(self):
'''Shows this window, refreshing the current view'''
self.dialog.show_all()
@@ -103,7 +102,6 @@
########################################
### HELPER FUNCTIONS ###################
########################################
-
def get_requester(self):
'''
Helper function: returns the requester.
@@ -134,7 +132,7 @@
'''
Helper function to switch between panels.
- @param panel_name: the name of the wanted panel. Choose between
+ @param panel_name: the name of the wanted panel. Choose between
"configuration" or "add"
'''
if panel_name == "configuration":
@@ -169,7 +167,6 @@
########################################
### WIDGETS AND SIGNALS ################
########################################
-
def _load_widgets_from_glade(self, builder):
'''
Loads widgets from the glade file
@@ -178,11 +175,11 @@
'''
builder.add_from_file(ViewConfig.BACKENDS_GLADE_FILE)
widgets = {
- 'dialog' : 'backends_dialog',
- 'treeview_window' : 'treeview_window',
- 'central_pane' : 'central_pane',
- 'add_button' : 'add_button',
- 'remove_button' : 'remove_button',
+ 'dialog': 'backends_dialog',
+ 'treeview_window': 'treeview_window',
+ 'central_pane': 'central_pane',
+ 'add_button': 'add_button',
+ 'remove_button': 'remove_button',
}
for attr, widget in widgets.iteritems():
setattr(self, attr, builder.get_object(widget))
@@ -213,7 +210,7 @@
def _create_widgets_for_treeview(self):
'''
- Creates the widgets for the lateral treeview displaying the
+ Creates the widgets for the lateral treeview displaying the
backends the user has added
'''
self.backends_tv = BackendsTree(self)
@@ -230,7 +227,6 @@
########################################
### EVENT HANDLING #####################
########################################
-
def on_backend_selected(self, backend_id):
'''
When a backend in the treeview gets selected, show
@@ -282,7 +278,7 @@
# pylint: disable-msg=W0613
def on_remove_button(self, widget = None, data = None):
'''
- When the remove button is pressed, a confirmation dialog is shown,
+ When the remove button is pressed, a confirmation dialog is shown,
and if the answer is positive, the backend is deleted.
'''
backend_id = self.backends_tv.get_selected_backend_id()
@@ -299,7 +295,7 @@
_("Do you really want to remove the '%s' "
"synchronization service?") % \
backend.get_human_name())
- response = dialog.run()
+ response = dialog.run()
dialog.destroy()
if response == gtk.RESPONSE_YES:
#delete the backend and remove it from the lateral treeview
=== modified file 'GTG/gtk/backends_dialog/addpanel.py'
--- GTG/gtk/backends_dialog/addpanel.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/backends_dialog/addpanel.py 2012-12-11 16:39:32 +0000
@@ -25,11 +25,10 @@
class AddPanel(gtk.VBox):
- '''
+ '''
A VBox filled with gtk widgets to let the user choose a new backend.
'''
-
def __init__(self, backends_dialog):
'''
Constructor, just initializes the gtk widgets
@@ -111,7 +110,7 @@
def _fill_bottom_hbox(self, hbox):
'''
- Helper function to fill and hbox with a buttonbox, featuring
+ Helper function to fill and hbox with a buttonbox, featuring
and ok and cancel buttons.
@param hbox: the gtk.HBox to fill
=== modified file 'GTG/gtk/backends_dialog/backendscombo.py'
--- GTG/gtk/backends_dialog/backendscombo.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/backends_dialog/backendscombo.py 2012-12-11 16:39:32 +0000
@@ -22,18 +22,17 @@
from GTG.backends import BackendFactory
-
class BackendsCombo(gtk.ComboBoxEntry):
'''
A combobox listing all the available backends types
'''
-
+
COLUMN_NAME = 0 #unique name for the backend type. It's never
# displayed, it's used to find which backend has
# been selected
COLUMN_HUMAN_NAME = 1 #human friendly name (which is localized).
- COLUMN_ICON = 2
+ COLUMN_ICON = 2
def __init__(self, backends_dialog):
'''
=== modified file 'GTG/gtk/backends_dialog/backendstree.py'
--- GTG/gtk/backends_dialog/backendstree.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/backends_dialog/backendstree.py 2012-12-11 16:39:32 +0000
@@ -24,7 +24,6 @@
from GTG.backends.backendsignals import BackendSignals
-
class BackendsTree(gtk.TreeView):
'''
gtk.TreeView that shows the currently loaded backends.
@@ -43,7 +42,7 @@
@param backends_dialog: a reference to the dialog in which this is
loaded
'''
- super(BackendsTree,self).__init__()
+ super(BackendsTree, self).__init__()
self.dialog = backendsdialog
self.req = backendsdialog.get_requester()
self._init_liststore()
@@ -60,7 +59,9 @@
# 1, put default backend on top
# 2, sort backends by human name
backends = list(self.req.get_all_backends(disabled = True))
- backends = sorted(backends, key=lambda backend:(not backend.is_default(), backend.get_human_name()))
+ backends = sorted(backends,
+ key=lambda backend: (not backend.is_default(),
+ backend.get_human_name()))
for backend in backends:
self.add_backend(backend)
@@ -101,7 +102,6 @@
])
self.backendid_to_iter[backend.get_id()] = backend_iter
-
def on_backend_state_changed(self, sender, backend_id):
'''
Signal callback executed when a backend is enabled/disabled.
@@ -129,8 +129,8 @@
self.liststore[b_path][self.COLUMN_TAGS] = new_tags
def _get_markup_for_tags(self, tag_names):
- '''Given a list of tags names, generates the pango markup to render that
- list with the tag colors used in GTG
+ '''Given a list of tags names, generates the pango markup to render
+ that list with the tag colors used in GTG
@param tag_names: the list of the tags (strings)
@return str: the pango markup string
@@ -141,7 +141,6 @@
tags_txt = get_colored_tags_markup(self.req, tag_names)
return "<small>" + tags_txt + "</small>"
-
def remove_backend(self, backend_id):
''' Removes a backend from the treeview, and selects the first (to show
something in the configuration panel
@@ -220,8 +219,8 @@
'''
Helper function to get the selected path
- @return gtk.TreePath : returns exactly one path for the selected object or
- None
+ @return gtk.TreePath : returns exactly one path for the selected object
+ or None
'''
selection = self.get_selection()
if selection:
=== modified file 'GTG/gtk/backends_dialog/configurepanel.py'
--- GTG/gtk/backends_dialog/configurepanel.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/backends_dialog/configurepanel.py 2012-12-11 16:39:32 +0000
@@ -27,11 +27,10 @@
class ConfigurePanel(gtk.VBox):
- '''
+ '''
A VBox that lets you configure a backend
'''
-
def __init__(self, backends_dialog):
'''
Constructor, creating all the gtk widgets
@@ -56,7 +55,7 @@
self.refresh_sync_status)
_signals.connect(_signals.BACKEND_SYNC_STARTED, self.on_sync_started)
_signals.connect(_signals.BACKEND_SYNC_ENDED, self.on_sync_ended)
-
+
def _create_widgets(self):
'''
This function fills this Vbox with widgets
@@ -118,7 +117,7 @@
def set_backend(self, backend_id):
'''Changes the backend to configure, refreshing this view.
-
+
@param backend_id: the id of the backend to configure
'''
self.backend = self.dialog.get_requester().get_backend(backend_id)
@@ -139,7 +138,7 @@
markup = "<big><big><big><b>%s</b></big></big></big>" % \
self.backend.get_human_name()
self.human_name_label.set_markup(markup)
-
+
def refresh_sync_button(self):
'''
Refreshes the state of the button that enables the backend
@@ -173,7 +172,7 @@
'''
self.refresh_sync_button()
self.refresh_sync_status_label()
-
+
def on_sync_button_clicked(self, sender):
'''
Signal callback when a backend is enabled/disabled via the UI button
@@ -222,7 +221,7 @@
'''
Enables/disables the gtk.Spinner, while showing/hiding it at the same
time
-
+
@param active: True if the spinner should spin
'''
self.should_spinner_be_shown = active
@@ -234,4 +233,3 @@
self.spinner.hide()
if isinstance(self.spinner, gtk.Spinner):
self.spinner.stop()
-
=== modified file 'GTG/gtk/backends_dialog/parameters_ui/__init__.py'
--- GTG/gtk/backends_dialog/parameters_ui/__init__.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/backends_dialog/parameters_ui/__init__.py 2012-12-11 16:39:32 +0000
@@ -37,7 +37,6 @@
from GTG.gtk.backends_dialog.parameters_ui.pathui import PathUI
-
class ParametersUI(gtk.VBox):
'''
Given a bakcend, this gtk.VBox populates itself with all the necessary
@@ -63,59 +62,50 @@
{"title": _("Import tags"), \
"anybox_text": _("All tags"), \
"somebox_text": _("Just these tags:"), \
- "parameter_name": "import-tags"}) \
- ),\
+ "parameter_name": "import-tags"})),
("attached-tags", self.UI_generator(ImportTagsUI, \
{"title": _("Tags to sync"), \
"anybox_text": _("All tasks"), \
"somebox_text": _("Tasks with these tags:"), \
- "parameter_name": "attached-tags"}) \
- ),\
+ "parameter_name": "attached-tags"})),
("path", self.UI_generator(PathUI)), \
("username", self.UI_generator(TextUI, \
{"description": _("Username"),
- "parameter_name": "username"})
- ), \
- ("password" , self.UI_generator(PasswordUI)), \
- ("period" , self.UI_generator(PeriodUI)), \
+ "parameter_name": "username"})),
+ ("password", self.UI_generator(PasswordUI)), \
+ ("period", self.UI_generator(PeriodUI)), \
("service-url", self.UI_generator(TextUI, \
{"description": _("Service URL"), \
- "parameter_name": "service-url"}) \
- ),\
+ "parameter_name": "service-url"})),
("import-from-replies", self.UI_generator(CheckBoxUI, \
{"text": _("Import tasks from @ replies " + \
"directed to you"), \
- "parameter": "import-from-replies"}) \
- ),\
+ "parameter": "import-from-replies"})),
("import-from-direct-messages", self.UI_generator(CheckBoxUI, \
{"text": _("Import tasks from direct messages"), \
- "parameter": "import-from-direct-messages"}) \
- ),\
+ "parameter": "import-from-direct-messages"})),
("import-from-my-tweets", self.UI_generator(CheckBoxUI, \
{"text": _("Import tasks from your tweets"), \
- "parameter": "import-from-my-tweets"}) \
- ),\
+ "parameter": "import-from-my-tweets"})),\
("import-bug-tags", self.UI_generator(CheckBoxUI, \
- {"text": _("Tag your GTG tasks with the bug tags"), \
- "parameter": "import-bug-tags"}) \
- ),\
+ {"text": _("Tag your GTG tasks with the bug tags"),\
+ "parameter": "import-bug-tags"})),\
("tag-with-project-name", self.UI_generator(CheckBoxUI, \
{"text": _("Tag your GTG tasks with the project "
"targeted by the bug"), \
- "parameter": "tag-with-project-name"}) \
- ),\
- )
+ "parameter": "tag-with-project-name"})), )
+
def UI_generator(self, param_type, special_arguments = {}):
'''A helper function to build a widget type from a template.
- It passes to the created widget generator a series of common parameters,
- plus the ones needed to specialize the given template
+ It passes to the created widget generator a series of common
+ parameters, plus the ones needed to specialize the given template
@param param_type: the template to specialize
@param special_arguments: the arguments used for this particular widget
generator.
- @return function: return a widget generator, not a widget. the widget can
- be obtained by calling widget_generator(backend)
+ @return function: return a widget generator, not a widget. the widget
+ can be obtained by calling widget_generator(backend)
'''
return lambda backend: param_type(req = self.req, \
backend = backend, \
@@ -147,6 +137,7 @@
Saves all the parameters at their current state (the user may have
modified them)
'''
+
def _commit_changes(child):
child.commit_changes()
self.foreach(_commit_changes)
=== modified file 'GTG/gtk/backends_dialog/parameters_ui/checkboxui.py'
--- GTG/gtk/backends_dialog/parameters_ui/checkboxui.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/backends_dialog/parameters_ui/checkboxui.py 2012-12-11 16:39:32 +0000
@@ -20,13 +20,11 @@
import gtk
-
class CheckBoxUI(gtk.HBox):
'''
It's a widget displaying a simple checkbox, with some text to explain its
meaning
'''
-
def __init__(self, req, backend, width, text, parameter):
'''
@@ -35,8 +33,8 @@
@param req: a Requester
@param backend: a backend object
@param width: the width of the gtk.Label object
- @param parameter: the backend parameter this checkbox should display and
- modify
+ @param parameter: the backend parameter this checkbox should display
+ and modify
'''
super(CheckBoxUI, self).__init__()
self.backend = backend
@@ -47,11 +45,12 @@
def _populate_gtk(self, width):
'''Creates the checkbox and the related label
-
+
@param width: the width of the gtk.Label object
'''
self.checkbutton =gtk.CheckButton(label = self.text)
- self.checkbutton.set_active(self.backend.get_parameters()[self.parameter])
+ self.checkbutton.set_active(
+ self.backend.get_parameters()[self.parameter])
self.checkbutton.connect("toggled", self.on_modified)
self.pack_start(self.checkbutton, False)
=== modified file 'GTG/gtk/backends_dialog/parameters_ui/importtagsui.py'
--- GTG/gtk/backends_dialog/parameters_ui/importtagsui.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/backends_dialog/parameters_ui/importtagsui.py 2012-12-11 16:39:32 +0000
@@ -22,13 +22,11 @@
from GTG.backends.genericbackend import GenericBackend
-
class ImportTagsUI(gtk.VBox):
'''
It's a widget displaying a couple of radio buttons, a label and a textbox
to let the user change the attached tags (or imported)
'''
-
def __init__(self, req, backend, width, title, anybox_text, somebox_text, \
parameter_name):
@@ -132,4 +130,3 @@
self.some_tags_radio.connect("toggled", self.on_changed)
self.all_tags_radio.connect("toggled", self.on_changed)
self.tags_entry.connect("changed", self.on_changed)
-
=== modified file 'GTG/gtk/backends_dialog/parameters_ui/passwordui.py'
--- GTG/gtk/backends_dialog/parameters_ui/passwordui.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/backends_dialog/parameters_ui/passwordui.py 2012-12-11 16:39:32 +0000
@@ -22,10 +22,8 @@
from GTG import _
-
class PasswordUI(gtk.HBox):
'''Widget displaying a gtk.Label and a textbox to input a password'''
-
def __init__(self, req, backend, width):
'''Creates the gtk widgets and loads the current password in the text
@@ -44,7 +42,7 @@
def _populate_gtk(self, width):
'''Creates the text box and the related label
-
+
@param width: the width of the gtk.Label object
'''
password_label = gtk.Label(_("Password:"))
@@ -70,7 +68,8 @@
def commit_changes(self):
'''Saves the changes to the backend parameter ('password')'''
- self.backend.set_parameter('password', self.password_textbox.get_text())
+ self.backend.set_parameter('password',
+ self.password_textbox.get_text())
def on_password_modified(self, sender):
''' Signal callback, executed when the user edits the password.
@@ -81,4 +80,3 @@
'''
if self.backend.is_enabled() and not self.backend.is_default():
self.req.set_backend_enabled(self.backend.get_id(), False)
-
=== modified file 'GTG/gtk/backends_dialog/parameters_ui/pathui.py'
--- GTG/gtk/backends_dialog/parameters_ui/pathui.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/backends_dialog/parameters_ui/pathui.py 2012-12-11 16:39:32 +0000
@@ -23,13 +23,10 @@
from GTG import _
-
-
class PathUI(gtk.HBox):
'''Gtk widgets to show a path in a textbox, and a button to bring up a
filesystem explorer to modify that path (also, a label to describe those)
'''
-
def __init__(self, req, backend, width):
'''
@@ -46,7 +43,7 @@
def _populate_gtk(self, width):
'''Creates the gtk.Label, the textbox and the button
-
+
@param width: the width of the gtk.Label object
'''
label = gtk.Label(_("Filename:"))
@@ -78,7 +75,7 @@
'''
if self.backend.is_enabled() and not self.backend.is_default():
self.req.set_backend_enabled(self.backend.get_id(), False)
-
+
def on_button_clicked(self, sender):
'''Shows the filesystem explorer to choose a new file
@@ -93,9 +90,11 @@
gtk.RESPONSE_OK))
self.chooser.set_default_response(gtk.RESPONSE_OK)
#set default file as the current self.path
- self.chooser.set_current_name(os.path.basename(self.textbox.get_text()))
- self.chooser.set_current_folder(os.path.dirname(self.textbox.get_text()))
-
+ self.chooser.set_current_name(os.path.basename(
+ self.textbox.get_text()))
+ self.chooser.set_current_folder(os.path.dirname(
+ self.textbox.get_text()))
+
#filter files
afilter = gtk.FileFilter()
afilter.set_name("All files")
=== modified file 'GTG/gtk/backends_dialog/parameters_ui/periodui.py'
--- GTG/gtk/backends_dialog/parameters_ui/periodui.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/backends_dialog/parameters_ui/periodui.py 2012-12-11 16:39:32 +0000
@@ -22,11 +22,9 @@
from GTG import _, ngettext
-
class PeriodUI(gtk.HBox):
'''A widget to change the frequency of a backend synchronization
'''
-
def __init__(self, req, backend, width):
'''
@@ -45,7 +43,7 @@
def _populate_gtk(self, width):
'''Creates the gtk widgets
-
+
@param width: the width of the gtk.Label object
'''
period_label = gtk.Label(_("Check for new tasks every"))
=== modified file 'GTG/gtk/backends_dialog/parameters_ui/textui.py'
--- GTG/gtk/backends_dialog/parameters_ui/textui.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/backends_dialog/parameters_ui/textui.py 2012-12-11 16:39:32 +0000
@@ -20,11 +20,9 @@
import gtk
-
class TextUI(gtk.HBox):
'''A widget to display a simple textbox and a label to describe its content
'''
-
def __init__(self, req, backend, width, description, parameter_name):
'''
@@ -44,7 +42,7 @@
def _populate_gtk(self, width):
'''Creates the gtk widgets
-
+
@param width: the width of the gtk.Label object
'''
label = gtk.Label("%s:" % self.description)
=== modified file 'GTG/gtk/browser/__init__.py'
--- GTG/gtk/browser/__init__.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/browser/__init__.py 2012-12-11 16:39:32 +0000
@@ -29,24 +29,26 @@
class GnomeConfig:
current_rep = os.path.dirname(os.path.abspath(__file__))
- GLADE_FILE = os.path.join(current_rep, "taskbrowser.glade")
- MODIFYTAGS_GLADE_FILE = os.path.join(current_rep, "modifytags_dialog.glade")
- TAGEDITOR_GLADE_FILE = os.path.join(current_rep, "tageditor.glade")
+ GLADE_FILE = os.path.join(current_rep, "taskbrowser.glade")
+ MODIFYTAGS_GLADE_FILE = os.path.join(current_rep,
+ "modifytags_dialog.glade")
+ TAGEDITOR_GLADE_FILE = os.path.join(current_rep, "tageditor.glade")
- MARK_DONE = _("Mark as Done")
- MARK_DONE_TOOLTIP = _("Mark the selected task as done")
- MARK_UNDONE = _("Mark as not Done")
- MARK_UNDONE_TOOLTIP = _("Mark the selected task as to be done")
- MARK_DISMISS = _("Dismiss")
- MARK_DISMISS_TOOLTIP = _("Mark the task as not to be done anymore")
- MARK_UNDISMISS = _("Undismiss")
- MARK_UNDISMISS_TOOLTIP = _("Mark the selected task as to be done")
- DELETE_TOOLTIP = _("Permanently remove the selected task")
- EDIT_TOOLTIP = _("Edit the selected task")
- NEW_TASK_TOOLTIP = _("Create a new task")
- NEW_SUBTASK_TOOLTIP = _("Create a new subtask")
+ MARK_DONE = _("Mark as Done")
+ MARK_DONE_TOOLTIP = _("Mark the selected task as done")
+ MARK_UNDONE = _("Mark as not Done")
+ MARK_UNDONE_TOOLTIP = _("Mark the selected task as to be done")
+ MARK_DISMISS = _("Dismiss")
+ MARK_DISMISS_TOOLTIP = _("Mark the task as not to be done anymore")
+ MARK_UNDISMISS = _("Undismiss")
+ MARK_UNDISMISS_TOOLTIP = _("Mark the selected task as to be done")
+ DELETE_TOOLTIP = _("Permanently remove the selected task")
+ EDIT_TOOLTIP = _("Edit the selected task")
+ NEW_TASK_TOOLTIP = _("Create a new task")
+ NEW_SUBTASK_TOOLTIP = _("Create a new subtask")
WORKVIEW_TOGGLE_TOOLTIP = _("Display only the currently actionable tasks")
- TAG_IN_WORKVIEW_TOGG = _("Hide this tag from the workview")
+ TAG_IN_WORKVIEW_TOGG = _("Hide this tag from the workview")
TAG_NOTIN_WORKVIEW_TOGG = _("Show this tag in the workview")
- QUICKADD_ENTRY_TOOLTIP = _("You can create, open or filter your tasks here")
- QUICKADD_ICON_TOOLTIP = _("Clear")
+ QUICKADD_ENTRY_TOOLTIP = _("You can create, open or filter your tasks \
+ here")
+ QUICKADD_ICON_TOOLTIP = _("Clear")
=== modified file 'GTG/gtk/browser/custominfobar.py'
--- GTG/gtk/browser/custominfobar.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/browser/custominfobar.py 2012-12-11 16:39:32 +0000
@@ -25,7 +25,6 @@
from GTG.tools.networkmanager import is_connection_up
-
class CustomInfoBar(gtk.InfoBar):
'''
A gtk.InfoBar specialized for displaying errors and requests for
@@ -33,9 +32,10 @@
'''
- AUTHENTICATION_MESSAGE = _("The <b>%s</b> synchronization service cannot login with the "
- "supplied authentication data and has been"
- " disabled. To retry the login, re-enable the service.")
+ AUTHENTICATION_MESSAGE = _("The <b>%s</b> synchronization service cannot "
+ "login with the supplied authentication data "
+ "and has been disabled. To retry the login, "
+ "re-enable the service.")
NETWORK_MESSAGE = _("Due to a network problem, I cannot contact "
"the <b>%s</b> synchronization service.")
@@ -92,8 +92,8 @@
'''
Sets this infobar to show an error to the user
- @param error_code: the code of the error to show. Error codes are listed
- in BackendSignals
+ @param error_code: the code of the error to show. Error codes are
+ listed in BackendSignals
'''
self._populate()
self.connect("response", self._on_error_response)
@@ -102,7 +102,8 @@
if error_code == BackendSignals.ERRNO_AUTHENTICATION:
self.set_message_type(gtk.MESSAGE_ERROR)
self.label.set_markup(self.AUTHENTICATION_MESSAGE % backend_name)
- self.add_button(_('Configure synchronization service'), gtk.RESPONSE_ACCEPT)
+ self.add_button(_('Configure synchronization service'),
+ gtk.RESPONSE_ACCEPT)
self.add_button(_('Ignore'), gtk.RESPONSE_CLOSE)
elif error_code == BackendSignals.ERRNO_NETWORK:
@@ -112,7 +113,7 @@
self.label.set_markup(self.NETWORK_MESSAGE % backend_name)
#FIXME: use gtk stock button instead
self.add_button(_('Ok'), gtk.RESPONSE_CLOSE)
-
+
elif error_code == BackendSignals.ERRNO_DBUS:
self.set_message_type(gtk.MESSAGE_WARNING)
self.label.set_markup(self.DBUS_MESSAGE % backend_name)
@@ -206,5 +207,5 @@
'''
text = self.text_box.get_text()
self.dialog.destroy()
- threading.Thread(target = getattr(self.backend, self.callback),
+ threading.Thread(target = getattr(self.backend, self.callback),
args = ("set_text", text)).start()
=== modified file 'GTG/gtk/browser/simple_color_selector.py'
--- GTG/gtk/browser/simple_color_selector.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/browser/simple_color_selector.py 2012-12-11 16:39:32 +0000
@@ -40,10 +40,12 @@
"#CE5C00", "#C4A000", "#BABDB6", "#2E3436",
]
-BUTTON_WIDTH = 36
+BUTTON_WIDTH = 36
BUTTON_HEIGHT = 24
-class SimpleColorSelectorPaletteItem(gtk.DrawingArea): # pylint: disable-msg=R0904,C0301
+
+class SimpleColorSelectorPaletteItem(gtk.DrawingArea):
+# pylint: disable-msg=R0904,C0301
"""An item of the color selecctor palette"""
def __init__(self, color=None):
@@ -61,7 +63,7 @@
alloc = self.get_allocation()
alloc_w, alloc_h = alloc[2], alloc[3]
# Drawing context
- cr_ctxt = self.window.cairo_create() # pylint: disable-msg=E1101
+ cr_ctxt = self.window.cairo_create() # pylint: disable-msg=E1101
gdkcontext = gtk.gdk.CairoContext(cr_ctxt)
# Draw rectangle
@@ -93,13 +95,12 @@
gdkcontext.stroke()
gdkcontext.set_source_rgba(0, 0, 0, 0.50)
gdkcontext.set_line_width(3.0)
- gdkcontext.move_to(pos_x , pos_y+size/2)
+ gdkcontext.move_to(pos_x, pos_y+size/2)
gdkcontext.line_to(pos_x+size/2, pos_y+size)
- gdkcontext.line_to(pos_x+size , pos_y)
+ gdkcontext.line_to(pos_x+size, pos_y)
gdkcontext.stroke()
### callbacks ###
-
def on_expose(self, widget, params): # pylint: disable-msg=W0613
"""Callback: redraws the widget when it is exposed"""
self.__draw()
@@ -109,7 +110,6 @@
self.__draw()
### PUBLIC IF ###
-
def set_color(self, color):
"""Defines the widget color"""
self.color = color
@@ -125,8 +125,8 @@
class SimpleColorSelector(gtk.VBox): # pylint: disable-msg=R0904,C0301
- """Widget displaying a palette of colors, possibly with a button allowing to
- define new colors."""
+ """Widget displaying a palette of colors, possibly with a button allowing
+ to define new colors."""
def __init__(self, width=9, colors=None, custom_colors=None):
gtk.VBox.__init__(self)
@@ -281,7 +281,6 @@
color_dialog.destroy()
# public IF
-
def has_color(self, col):
"""Returns True if the color is already present"""
return col in self.colors or col in self.custom_colors
=== modified file 'GTG/gtk/browser/treeview_factory.py'
--- GTG/gtk/browser/treeview_factory.py 2012-12-02 12:25:37 +0000
+++ GTG/gtk/browser/treeview_factory.py 2012-12-11 16:39:32 +0000
@@ -32,6 +32,7 @@
from GTG.gtk import colors
from GTG.tools.dates import Date
+
class TreeviewFactory():
def __init__(self, requester, config):
@@ -54,7 +55,6 @@
#############################
#Functions for tasks columns
################################
-
def _has_hidden_subtask(self, task):
#not recursive
display_count = self.mainview.node_n_children(task.get_id())
@@ -79,7 +79,8 @@
search_parent = self.req.get_tag(CoreConfig.SEARCH_TAG)
for search_tag in search_parent.get_children():
tag = self.req.get_tag(search_tag)
- match = search_filter(node, parse_search_query(tag.get_attribute('query')))
+ match = search_filter(node,
+ parse_search_query(tag.get_attribute('query')))
if match and search_tag not in tags:
tags.append(tag)
@@ -101,11 +102,12 @@
str_format = "<b>%s</b>"
if self._has_hidden_subtask(node):
str_format = "<span color='%s'>%s</span>"\
- % (self.unactive_color, str_format)
+ % (self.unactive_color, str_format)
title = str_format % saxutils.escape(node.get_title())
if node.get_status() == Task.STA_ACTIVE:
- count = self.mainview.node_n_children(node.get_id(), recursive=True)
+ count = self.mainview.node_n_children(node.get_id(),
+ recursive=True)
if count != 0:
title += " (%s)" % count
elif node.get_status() == Task.STA_DISMISSED:
@@ -182,7 +184,8 @@
else:
return -1*s
- if sort == 0: # Group tasks with the same tag together for visual cleanness
+ if sort == 0:
+ # Group tasks with the same tag together for visual cleanness
t1_tags = task1.get_tags_name()
t1_tags.sort()
t2_tags = task2.get_tags_name()
@@ -216,7 +219,8 @@
return ""
else:
toreturn = node.get_active_tasks_count()
- return "<span color='%s'>%s</span>" %(self.unactive_color, toreturn)
+ return "<span color='%s'>%s</span>" %(self.unactive_color,
+ toreturn)
def is_tag_separator_filter(self, tag):
return tag.get_attribute('special') == 'sep'
@@ -415,7 +419,6 @@
desc[col_name] = col
return desc
-
def build_task_treeview(self, tree, desc):
treeview = TreeView(tree, desc)
#Now that the treeview is done, we can polish
=== modified file 'GTG/gtk/colors.py'
--- GTG/gtk/colors.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/colors.py 2012-12-11 16:39:32 +0000
@@ -21,6 +21,7 @@
#Take list of Tags and give the background color that should be applied
#The returned color might be None (in which case, the default is used)
+
def background_color(tags, bgcolor = None):
if not bgcolor:
bgcolor = gtk.gdk.color_parse("#FFFFFF")
@@ -32,27 +33,28 @@
blue = 0
for my_tag in tags:
my_color_str = my_tag.get_attribute("color")
- if my_color_str :
+ if my_color_str:
my_color = gtk.gdk.color_parse(my_color_str)
color_count = color_count + 1
- red = red + my_color.red
+ red = red + my_color.red
green = green + my_color.green
- blue = blue + my_color.blue
+ blue = blue + my_color.blue
if color_count != 0:
- red = int(red / color_count)
- green = int(green / color_count)
- blue = int(blue / color_count)
+ red = int(red / color_count)
+ green = int(green / color_count)
+ blue = int(blue / color_count)
brightness = (red+green+blue) / 3.0
target_brightness = (bgcolor.red+bgcolor.green+bgcolor.blue)/3.0
-
+
alpha = (1-abs(brightness-target_brightness)/65535.0)/2.0
red = int(red*alpha + bgcolor.red*(1-alpha))
green = int(green*alpha + bgcolor.green*(1-alpha))
blue = int(blue*alpha + bgcolor.blue*(1-alpha))
-
+
my_color = gtk.gdk.Color(red, green, blue).to_string()
return my_color
+
def get_colored_tag_markup(req, tag_name, html = False):
'''
Given a tag name, returns a string containing the markup to color the
@@ -74,6 +76,7 @@
else:
return tag_name
+
def get_colored_tags_markup(req, tag_names):
'''
Calls get_colored_tag_markup for each tag_name in tag_names
=== modified file 'GTG/gtk/manager.py'
--- GTG/gtk/manager.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/manager.py 2012-12-11 16:39:32 +0000
@@ -32,7 +32,7 @@
import GTG
from GTG.gtk.delete_dialog import DeletionUI
from GTG.gtk.browser.browser import TaskBrowser
-from GTG.gtk.editor.editor import TaskEditor
+from GTG.gtk.editor.editor import TaskEditor
from GTG.gtk.preferences import PreferencesDialog
from GTG.gtk.plugins import PluginsDialog
from GTG.gtk.dbuswrapper import DBusTaskWrapper
@@ -46,7 +46,7 @@
class Manager(object):
-
+
############## init #####################################################
def __init__(self, req):
@@ -54,12 +54,12 @@
self.config_obj = self.req.get_global_config()
self.config = self.config_obj.conf_dict
self.task_config = self.config_obj.task_conf_dict
-
+
# Editors
- self.opened_task = {} # This is the list of tasks that are already
+ self.opened_task = {} # This is the list of tasks that are already
# opened in an editor of course it's empty
# right now
-
+
self.browser = None
self.__start_browser_hidden = False
self.gtk_terminate = False #if true, the gtk main is not started
@@ -67,21 +67,21 @@
# if true, closing the last window doesn't quit GTG
# (GTG lives somewhere else without GUI, e.g. notification area)
self.daemon_mode = False
-
+
#Shared clipboard
self.clipboard = clipboard.TaskClipboard(self.req)
#Browser (still hidden)
self.browser = TaskBrowser(self.req, self)
-
+
self.__init_plugin_engine()
-
+
if not self.__start_browser_hidden:
self.show_browser()
-
+
#Deletion UI
self.delete_dialog = None
-
+
#Preferences and Backends windows
# Initialize dialogs
self.preferences = PreferencesDialog(self.req)
@@ -90,11 +90,11 @@
# Tag Editor
self.tag_editor_dialog = None
-
+
#DBus
DBusTaskWrapper(self.req, self)
Log.debug("Manager initialization finished")
-
+
def __init_plugin_engine(self):
self.pengine = PluginEngine(GTG.PLUGIN_DIR)
# initializes the plugin api class
@@ -109,9 +109,8 @@
plugin.enabled = plugin.module_name in plugins_enabled
# initializes and activates each plugin (that is enabled)
self.pengine.activate_plugins()
-
+
############## Browser #################################################
-
def open_browser(self):
if not self.browser:
self.browser = TaskBrowser(self.req, self)
@@ -120,24 +119,24 @@
#FIXME : the browser should not be the center of the universe.
# In fact, we should build a system where view can register themselves
# as "stay_alive" views. As long as at least one "stay_alive" view
- # is registered, gtg keeps running. It quit only when the last
+ # is registered, gtg keeps running. It quit only when the last
# "stay_alive view" is closed (and then unregistered).
# Currently, the browser is our only "stay_alive" view.
- def close_browser(self,sender=None):
+ def close_browser(self, sender=None):
self.hide_browser()
#may take a while to quit
self.quit()
- def hide_browser(self,sender=None):
+ def hide_browser(self, sender=None):
self.browser.hide()
- def iconify_browser(self,sender=None):
+ def iconify_browser(self, sender=None):
self.browser.iconify()
- def show_browser(self,sender=None):
+ def show_browser(self, sender=None):
self.browser.show()
-
- def is_browser_visible(self,sender=None):
+
+ def is_browser_visible(self, sender=None):
return self.browser.is_visible()
def get_browser(self):
@@ -153,7 +152,6 @@
self.daemon_mode = in_daemon_mode
################# Task Editor ############################################
-
def get_opened_editors(self):
'''
Returns a dict of task_uid -> TaskEditor, one for each opened editor
@@ -192,13 +190,13 @@
def close_task(self, tid):
# When an editor is closed, it should de-register itself.
if tid in self.opened_task:
- #the following line has the side effect of removing the
+ #the following line has the side effect of removing the
# tid key in the opened_task dictionary.
editor = self.opened_task[tid]
if editor:
del self.opened_task[tid]
#we have to remove the tid from opened_task first
- #else, it close_task would be called once again
+ #else, it close_task would be called once again
#by editor.close
editor.close()
if tid in self.config["browser"]["opened_tasks"]:
@@ -210,12 +208,12 @@
'''
checking if we need to shut down the whole GTG (if no window is open)
'''
- if not self.daemon_mode and not self.is_browser_visible() and not self.opened_task:
+ if not self.daemon_mode and not self.is_browser_visible() and \
+ not self.opened_task:
#no need to live"
self.quit()
-
+
################ Others dialog ############################################
-
def open_edit_backends(self, sender = None, backend_id = None):
if not self.edit_backends_dialog:
self.edit_backends_dialog = BackendsDialog(self.req)
@@ -231,7 +229,7 @@
def configure_plugins(self):
self.plugins.activate()
-
+
def ask_delete_tasks(self, tids):
if not self.delete_dialog:
self.delete_dialog = DeletionUI(self.req)
@@ -252,7 +250,6 @@
self.tag_editor_dialog.hide()
### URIS ###################################################################
-
def open_uri_list(self, unused, uri_list):
'''
Open the Editor windows of the tasks associated with the uris given.
@@ -264,9 +261,9 @@
#if no window was opened, we just quit
self.check_quit_condition()
-
+
### MAIN ###################################################################
- def main(self, once_thru = False, uri_list = []):
+ def main(self, once_thru = False, uri_list = []):
if uri_list:
#before opening the requested tasks, we make sure that all of them
#are loaded.
@@ -282,16 +279,16 @@
else:
gtk.main()
return 0
-
- def quit(self,sender=None):
+
+ def quit(self, sender=None):
gtk.main_quit()
#save opened tasks and their positions.
open_task = []
- for otid in self.opened_task.keys():
+ for otid in self.opened_task.keys():
open_task.append(otid)
self.opened_task[otid].close()
self.config["browser"]["opened_tasks"] = open_task
-
+
# adds the plugin settings to the conf
#FIXME: this code is replicated in the preference window.
if len(self.pengine.plugins) > 0:
@@ -302,4 +299,3 @@
[p.module_name for p in self.pengine.get_plugins("enabled")]
# plugins are deactivated
self.pengine.deactivate_plugins()
-
=== modified file 'GTG/gtk/preferences.py'
--- GTG/gtk/preferences.py 2012-11-25 19:19:44 +0000
+++ GTG/gtk/preferences.py 2012-12-11 16:39:32 +0000
@@ -108,7 +108,7 @@
'on_PreferencesDialog_delete_event':
self.on_close,
'on_fontbutton_font_set':
- self.on_font_change,
+ self.on_font_change,
})
def _refresh_preferences_store(self):
@@ -164,6 +164,6 @@
self.config.set("bg_color_enable", not curstate)
self._refresh_task_browser()
- def on_font_change(self,widget):
+ def on_font_change(self, widget):
""" Set a new font for editor """
- self.config.set("font_name", self.fontbutton.get_font_name())
+ self.config.set("font_name", self.fontbutton.get_font_name())