import ConfigParser
import socket
+import gobject
import gtk
import gtk.glade
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"
self._clipboard = gtk.clipboard_get()
self.__window = self._widgetTree.get_widget("mainWindow")
self.__errorDisplay = gtk_toolbox.ErrorDisplay(self._widgetTree)
- self._prefsDialog = gtk_toolbox.PreferencesDialog(self._widgetTree)
+ self._prefsDialog = PreferencesDialog(self._widgetTree)
self._app = None
self._isFullScreen = False
# Setup costly backends
import rtm_view
with gtk_toolbox.gtk_lock():
- rtmView = rtm_view.GtkRtMilk(self._widgetTree, self.__errorDisplay)
+ rtmView = rtm_view.RtmView(self._widgetTree, self.__errorDisplay)
self._todoUIs[rtmView.name()] = rtmView
self._defaultUIName = rtmView.name()