Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/jarabe/journal/volumestoolbar.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/jarabe/journal/volumestoolbar.py')
-rw-r--r--src/jarabe/journal/volumestoolbar.py94
1 files changed, 82 insertions, 12 deletions
diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py
index 94914e6..1f6e3ec 100644
--- a/src/jarabe/journal/volumestoolbar.py
+++ b/src/jarabe/journal/volumestoolbar.py
@@ -37,8 +37,10 @@ from sugar.graphics.palette import Palette
from sugar.graphics.xocolor import XoColor
from sugar import env
+from jarabe.frame.notification import NotificationIcon
from jarabe.journal import model
-from jarabe.view.palettes import JournalVolumePalette, JournalXSPalette
+from jarabe.view.palettes import JournalVolumePalette, JournalXSPalette, RemoteSharePalette
+import jarabe.frame
_JOURNAL_0_METADATA_DIR = '.olpc.store'
@@ -209,6 +211,7 @@ class VolumesToolbar(gtk.Toolbar):
def _set_up_volumes(self):
self._set_up_documents_button()
+ self._set_up_shares_button()
volume_monitor = gio.volume_monitor_get()
self._mount_added_hid = volume_monitor.connect('mount-added',
@@ -219,12 +222,11 @@ class VolumesToolbar(gtk.Toolbar):
for mount in volume_monitor.get_mounts():
self._add_button(mount)
- def _set_up_documents_button(self):
- documents_path = model.get_documents_path()
- if documents_path is not None:
- button = DocumentsButton(documents_path)
+ def _set_up_directory_button(self, dir_path, icon_name, label_text):
+ if dir_path is not None:
+ button = DirectoryButton(dir_path, icon_name)
button.props.group = self._volume_buttons[0]
- label = glib.markup_escape_text(_('Documents'))
+ label = glib.markup_escape_text(label_text)
button.set_palette(Palette(label))
button.connect('toggled', self._button_toggled_cb)
button.show()
@@ -234,6 +236,39 @@ class VolumesToolbar(gtk.Toolbar):
self._volume_buttons.append(button)
self.show()
+ def _set_up_documents_button(self):
+ documents_path = model.get_documents_path()
+ self._set_up_directory_button(documents_path,
+ 'user-documents',
+ _('Documents'))
+
+ def _set_up_shares_button(self):
+ shares_dir_path = '/var/www/web1/web'
+ self._set_up_directory_button(shares_dir_path,
+ 'emblem-neighborhood-shared',
+ _('Shares'))
+
+ def _add_remote_share_button(self, buddy):
+ button = RemoteSharesButton(buddy)
+ button.props.group = self._volume_buttons[0]
+ label = glib.markup_escape_text(_('%s\'s share') % \
+ buddy.props.nick)
+ button.set_palette(RemoteSharePalette(buddy, button))
+ button.connect('toggled', self._button_toggled_cb)
+ button.show()
+
+ position = self.get_item_index(self._volume_buttons[-1]) + 1
+ self.insert(button, position)
+ self._volume_buttons.append(button)
+ self.show()
+
+ frame = jarabe.frame.get_view()
+ notif_icon = NotificationIcon()
+ notif_icon.props.icon_name = 'emblem-neighborhood-shared'
+ notif_icon.props.xo_color = buddy.props.color
+ frame.add_notification(notif_icon,
+ gtk.CORNER_BOTTOM_RIGHT)
+
def __mount_added_cb(self, volume_monitor, mount):
self._add_button(mount)
@@ -271,8 +306,8 @@ class VolumesToolbar(gtk.Toolbar):
def __volume_error_cb(self, button, strerror, severity):
self.emit('volume-error', strerror, severity)
- def _button_toggled_cb(self, button):
- if button.props.active:
+ def _button_toggled_cb(self, button, force_toggle=False):
+ if button.props.active or force_toggle:
self.emit('volume-changed', button.mount_point)
def _unmount_activated_cb(self, menu_item, mount):
@@ -300,6 +335,19 @@ class VolumesToolbar(gtk.Toolbar):
if len(self.get_children()) < 2:
self.hide()
+ def _remove_remote_share_button(self, mount_point):
+ # Here, IP_Address is the mount_point.
+ for button in self.get_children():
+ if type(button) == RemoteSharesButton and \
+ button.mount_point == mount_point:
+ self._volume_buttons.remove(button)
+ self.remove(button)
+ self.get_children()[0].props.active = True
+
+ if len(sel.get_children()) < 2:
+ self.hide()
+ break;
+
def set_active_volume(self, mount):
button = self._get_button_for_mount(mount)
button.props.active = True
@@ -313,6 +361,12 @@ class VolumesToolbar(gtk.Toolbar):
if button.mount_point != mount_point:
button.set_sensitive(sensitive)
+ def get_journal_button(self):
+ return self._volume_buttons[0]
+
+ def get_button_toggled_cb(self):
+ return self._button_toggled_cb
+
class BaseButton(RadioToolButton):
__gsignals__ = {
@@ -427,18 +481,34 @@ class JournalButtonPalette(Palette):
{'free_space': free_space / (1024 * 1024)}
-class DocumentsButton(BaseButton):
+class DirectoryButton(BaseButton):
- def __init__(self, documents_path):
- BaseButton.__init__(self, mount_point=documents_path)
+ def __init__(self, dir_path, icon_name):
+ BaseButton.__init__(self, mount_point=dir_path)
- self.props.named_icon = 'user-documents'
+ self.props.named_icon = icon_name
client = gconf.client_get_default()
color = XoColor(client.get_string('/desktop/sugar/user/color'))
self.props.xo_color = color
+class RemoteSharesButton(BaseButton):
+
+ def __init__(self, buddy):
+ BaseButton.__init__(self, mount_point=buddy.props.ip_address)
+
+ self._buddy = buddy
+ self.props.named_icon = 'emblem-neighborhood-shared'
+ self.props.xo_color = buddy.props.color
+ self._buddy_ip_address = buddy.props.ip_address
+
+ def create_palette(self):
+ palette = RemoteSharePalette(self._buddy)
+ return palette
+
+
+
class XSButton(ToolButton):
def __init__(self):
ToolButton.__init__(self)