Subject: [PATCH] Journal documents volume button

From: Martin Abente <[email-masked]>
Date: Fri, 25 Jun 2010 09:40:17 -0400

Simplified version of Jorge Saldivar's patch. Add a new volume toolbar
button for xdg-user-dir DOCUMENTS directory.
---
 src/jarabe/journal/volumestoolbar.py |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/src/jarabe/journal/volumestoolbar.py b/src/jarabe/journal/volumestoolbar.py
index a245b1f..448e228 100644
--- a/src/jarabe/journal/volumestoolbar.py
+++ b/src/jarabe/journal/volumestoolbar.py
@@ -21,6 +21,7 @@ import gobject
 import gio
 import gtk
 import gconf
+import subprocess
 
 from sugar.graphics.radiotoolbutton import RadioToolButton
 from sugar.graphics.palette import Palette
@@ -53,6 +54,7 @@ class VolumesToolbar(gtk.Toolbar):
         self.connect('destroy', self.__destroy_cb)
 
         self.setup_xs_button()
+        self.setup_documents_button()
         gobject.idle_add(self._set_up_volumes)
 
     def __destroy_cb(self, widget):
@@ -75,6 +77,18 @@ class VolumesToolbar(gtk.Toolbar):
             self.insert(xs_button, position)
             self.show()
 
+    def setup_documents_button(self):
+        button = DocumentsButton()
+        button.props.group = self._volume_buttons[0]
+        button.set_palette(Palette(_('Documents')))
+        button.connect('toggled', self._button_toggled_cb)
+        button.show()
+
+        position = len(self._volume_buttons) - 1
+        self.insert(button, position)
+        self._volume_buttons.append(button)
+        self.show()
+
     def _set_up_volumes(self):
         volume_monitor = gio.volume_monitor_get()
         self._mount_added_hid = \
@@ -211,3 +225,19 @@ class XSButton(RadioToolButton):
 
     def _button_toggled_cb(self):
         pass
+
+class DocumentsButton(BaseButton):
+    def __init__(self):
+        self.__mount_directory_path = subprocess.Popen(["xdg-user-dir", "DOCUMENTS"], stdout=subprocess.PIPE).stdout.read().strip()
+
+        BaseButton.__init__(self, mount_point=self.__mount_directory_path)
+
+        self.props.named_icon = 'drive'
+
+        client = gconf.client_get_default()
+        color = XoColor(client.get_string('/desktop/sugar/user/color'))
+        self.props.xo_color = color
+
+    def get_mount_point(self):
+        return self.__mount_directory_path
+
-- 
1.6.0.4