Adding plugin files to version control system.
[bluehi] / plugins / canola-bluehi / bluehi / ui.py
diff --git a/plugins/canola-bluehi/bluehi/ui.py b/plugins/canola-bluehi/bluehi/ui.py
new file mode 100755 (executable)
index 0000000..48ebacc
--- /dev/null
@@ -0,0 +1,92 @@
+"""
+Project: BlueHi: A plugin for Canola
+File name: ui.py
+
+Description: This software was developed in Zagaia Project
+
+Copyright (C) 2009
+    Antonio R. de C. Junior  <brankinhu@gmail.com>
+    Henry Miller M. Bilby <henrymiller.engenheiro@gmail.com>
+    Mauricio Figueiredo <mauricio.figueiredo@fucapi.br>
+    Samuel de Oliveira Fagundes <sf.oliveira@gmail.com>
+
+    This program is free software; you can redistribute it and/or modify 
+    it under the terms of the GNU General Public License as published by 
+    the Free Software Foundation; either version 2 of the License, or 
+    (at your option) any later version.
+    
+    This program is distributed in the hope that it will be useful, but 
+    WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
+    or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
+    for more details.
+    
+    You should have received a copy of the GNU General Public License along 
+    with this program; if not, write to the Free Software Foundation, Inc., 
+    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+"""
+from terra.core.manager import Manager
+from model import FileFolder, BrowseByFolder
+
+manager = Manager()
+WaitNotifyController = manager.get_class("Model/WaitNotify")
+YesNoDialogModel = manager.get_class("Model/YesNoDialog")
+BaseListController = manager.get_class("Controller/Folder")
+BaseRowRenderer = manager.get_class("Widget/RowRenderer")
+ResizableRowRenderer = manager.get_class("Widget/ResizableRowRenderer")
+
+"""Manager list devices"""
+class DeviceListController(BaseListController):
+    """
+    This class is controller for class MainFolder, BluetoothDeviceFolder
+    and BluetoothListDevice.
+    """
+    terra_type = "Controller/Folder/Task/Apps/Bluetooth"
+
+    def __init__(self, model, canvas, parent):
+        BaseListController.__init__(self, model, canvas, parent)
+        self.model.callback_notify = self._show_notify
+
+    def _show_notify(self, err):
+        """Popup a modal with a notify message."""
+        self.parent.show_notify(err)
+
+    def cb_on_clicked(self,view, index):
+        model=self.model.children[index]
+        BaseListController.cb_on_clicked(self, view, index)
+
+class DiretorioListController(BaseListController):
+    terra_type = "Controller/Folder/Task/Apps/Bluetooth/Choice"
+
+    def __init__(self, model, canvas, parent):
+        BaseListController.__init__(self, model, canvas, parent)
+        self.vmodel = None
+        self.model.callback_notify = self._show_notify
+
+    def _show_notify(self, err):
+        """Popup a modal with a notify message."""
+        self.parent.show_notify(err)
+
+    def _show_notify_conf(self, msg):
+        def confirme(dialog, ok):
+            if ok:
+                self.loading()
+
+        self.parent.show_notify(YesNoDialogModel("%s" % msg, confirme))
+
+    def loading(self):
+        def wait(value, ok):
+            self.model.send(self.vmodel.name)
+        self.parent.show_notify(WaitNotifyController("Sending file...", 5, wait))
+
+    def cb_on_clicked(self, view, index):
+        self.vmodel=self.model.children[index]
+
+        if type(self.vmodel) is FileFolder:
+            self._show_notify_conf("Do you want to send this file?\n%s"\
+                    % self.vmodel.name)
+            return
+
+        if type(self.vmodel) is BrowseByFolder:
+            BaseListController.cb_on_clicked(self, view, index)
+            return
+