#!/usr/bin/python
"""
-@todo Alt Views (Besides task list)
- Map
- Using new api widgets people are developing)
- Integrate GPS w/ fallback to default location
- Use locations for mapping
- Quick search (OR within a property type, and between property types)
- Drop down for multi selecting priority
- Drop down for multi selecting tags
- Drop down for multi selecting locations
- Calendar selector for choosing due date range
@todo Add logging support to make debugging random user issues a lot easier
+@todo See Tasque for UI ideas http://live.gnome.org/Tasque/Screenshots
"""
from __future__ import with_statement
import threading
import warnings
import ConfigParser
+import socket
+import gobject
import gtk
import gtk.glade
import gtk_toolbox
+socket.setdefaulttimeout(10)
+
+
+class PreferencesDialog(object):
+
+ def __init__(self, widgetTree):
+ self._backendList = gtk.ListStore(gobject.TYPE_STRING)
+ self._backendCell = gtk.CellRendererText()
+
+ self._dialog = widgetTree.get_widget("preferencesDialog")
+ self._backendSelector = widgetTree.get_widget("prefsBackendSelector")
+ self._applyButton = widgetTree.get_widget("applyPrefsButton")
+ self._cancelButton = widgetTree.get_widget("cancelPrefsButton")
+
+ self._onApplyId = None
+ self._onCancelId = None
+
+ def enable(self):
+ self._dialog.set_default_size(800, 300)
+ self._onApplyId = self._applyButton.connect("clicked", self._on_apply_clicked)
+ self._onCancelId = self._cancelButton.connect("clicked", self._on_cancel_clicked)
+
+ cell = self._backendCell
+ self._backendSelector.pack_start(cell, True)
+ self._backendSelector.add_attribute(cell, 'text', 0)
+ self._backendSelector.set_model(self._backendList)
+
+ def disable(self):
+ self._applyButton.disconnect(self._onApplyId)
+ self._cancelButton.disconnect(self._onCancelId)
+
+ self._backendList.clear()
+ self._backendSelector.set_model(None)
+
+ def run(self, app, parentWindow = None):
+ if parentWindow is not None:
+ self._dialog.set_transient_for(parentWindow)
+
+ self._backendList.clear()
+ activeIndex = 0
+ for i, (uiName, ui) in enumerate(app.get_uis()):
+ self._backendList.append((uiName, ))
+ if uiName == app.get_default_ui():
+ activeIndex = i
+ self._backendSelector.set_active(activeIndex)
+
+ try:
+ response = self._dialog.run()
+ if response != gtk.RESPONSE_OK:
+ raise RuntimeError("Edit Cancelled")
+ finally:
+ self._dialog.hide()
+
+ backendName = self._backendSelector.get_active_text()
+ app.switch_ui(backendName)
+
+ def _on_apply_clicked(self, *args):
+ self._dialog.response(gtk.RESPONSE_OK)
+
+ def _on_cancel_clicked(self, *args):
+ self._dialog.response(gtk.RESPONSE_CANCEL)
+
+
class DoneIt(object):
__pretty_app_name__ = "DoneIt"
__app_name__ = "doneit"
- __version__ = "0.3.0"
+ __version__ = "0.3.1"
__app_magic__ = 0xdeadbeef
_glade_files = [
_user_settings = "%s/settings.ini" % _user_data
def __init__(self):
+ self._initDone = False
self._todoUIs = {}
self._todoUI = None
self._osso = None
self._clipboard = gtk.clipboard_get()
self.__window = self._widgetTree.get_widget("mainWindow")
self.__errorDisplay = gtk_toolbox.ErrorDisplay(self._widgetTree)
+ self._prefsDialog = PreferencesDialog(self._widgetTree)
self._app = None
self._isFullScreen = False
self._app.add_window(self.__window)
self._widgetTree.get_widget("usernameentry").set_property('hildon-input-mode', 7)
self._widgetTree.get_widget("passwordentry").set_property('hildon-input-mode', 7|(1 << 29))
- self._widgetTree.get_widget("projectsCombo").get_child().set_property('hildon-input-mode', (1 << 4))
gtkMenu = self._widgetTree.get_widget("mainMenubar")
menu = gtk.Menu()
callbackMapping = {
"on_doneit_quit": self._on_close,
- "on_paste": self._on_paste,
"on_about": self._on_about_activate,
}
self._widgetTree.signal_autoconnect(callbackMapping)
# Setup costly backends
import rtm_view
with gtk_toolbox.gtk_lock():
- rtmView = rtm_view.GtkRtMilk(self._widgetTree)
+ rtmView = rtm_view.RtmView(self._widgetTree, self.__errorDisplay)
self._todoUIs[rtmView.name()] = rtmView
- self._defaultUIName = rtmView.name()
+
+ import file_view
+ defaultStoragePath = "%s/data.txt" % self._user_data
+ with gtk_toolbox.gtk_lock():
+ fileView = file_view.FileView(self._widgetTree, self.__errorDisplay, defaultStoragePath)
+ self._todoUIs[fileView.name()] = fileView
+
+ self._defaultUIName = fileView.name()
config = ConfigParser.SafeConfigParser()
config.read(self._user_settings)
with gtk_toolbox.gtk_lock():
self.load_settings(config)
+ self._widgetTree.get_widget("connectMenuItem").connect("activate", lambda *args: self.switch_ui(self._defaultUIName))
+ self._widgetTree.get_widget("preferencesMenuItem").connect("activate", self._on_prefs)
+
+ self._initDone = True
def display_error_message(self, msg):
"""
)
try:
- self._switch_ui(activeUIName)
+ self.switch_ui(activeUIName)
except KeyError, e:
- self._switch_ui(self._defaultUIName)
+ self.switch_ui(self._defaultUIName)
def save_settings(self, config):
"""
for todoUI in self._todoUIs.itervalues():
todoUI.save_settings(config)
- def _switch_ui(self, uiName):
+ def get_uis(self):
+ return (ui for ui in self._todoUIs.iteritems())
+
+ def get_default_ui(self):
+ return self._defaultUIName
+
+ def switch_ui(self, uiName):
"""
@note UI Thread
"""
if status == conic.STATUS_CONNECTED:
self._deviceIsOnline = True
- self._switch_ui(self._defaultUIName)
+ if self._initDone:
+ self.switch_ui(self._defaultUIName)
elif status == conic.STATUS_DISCONNECTED:
self._deviceIsOnline = False
- self._switch_ui(self._fallbackUIName)
+ if self._initDone:
+ self.switch_ui(self._fallbackUIName)
def _on_window_state_change(self, widget, event, *args):
"""
if self._osso is not None:
self._osso.close()
- self._save_settings()
+ if self._initDone:
+ self._save_settings()
finally:
gtk.main_quit()
- def _on_paste(self, *args):
- pass
-
def _on_key_press(self, widget, event, *args):
"""
@note Hildon specific
self.__window.fullscreen()
def _on_logout(self, *args):
+ if not self._initDone:
+ return
+
self._todoUI.logout()
- self._switch_ui(self._fallbackUIName)
+ self.switch_ui(self._fallbackUIName)
+
+ def _on_prefs(self, *args):
+ if not self._initDone:
+ return
+
+ self._prefsDialog.enable()
+ try:
+ self._prefsDialog.run(self)
+ finally:
+ self._prefsDialog.disable()
def _on_about_activate(self, *args):
dlg = gtk.AboutDialog()
dlg.set_version(self.__version__)
dlg.set_copyright("Copyright 2008 - LGPL")
dlg.set_comments("")
- dlg.set_website("")
- dlg.set_authors([""])
+ dlg.set_website("http://doneit.garage.maemo.org")
+ dlg.set_authors(["Ed Page"])
dlg.run()
dlg.destroy()