Subject: [Tecnologia] [sugar 3/4] Modify a few lines of volumnestoolber to allow it mount a directory

From: "Jorge (jasg) Saldivar" <[email-masked]>
Date: Fri, 21 May 2010 17:18:14 -0400

From: Jorge Saldivar <jorge@jorge-laptop.(none)>

Signed-off-by: Jorge Saldivar Galli <[email-masked]>

---

--- a/src/jarabe/journal/volumestoolbar.py.orig	2010-05-23 20:28:37.000000000 -0400
+++ b/src/jarabe/journal/volumestoolbar.py	2010-05-23 20:28:55.000000000 -0400
@@ -30,6 +30,9 @@ from sugar.graphics.xocolor import XoCol
 from jarabe.journal import model
 from jarabe.view.palettes import VolumePalette
 
+MOUNT_DIRECTORY_PATH = '/desktop/sugar/journal/mount-directory-path'
+MOUNT_DIRECTORY_VALUE = '/desktop/sugar/journal/mount-directory-value'
+
 class VolumesToolbar(gtk.Toolbar):
     __gtype_name__ = 'VolumesToolbar'
 
@@ -51,25 +54,29 @@ class VolumesToolbar(gtk.Toolbar):
         button.show()
         self._volume_buttons = [button]
 
-        button = DirectoryButton()
-        button.props.group = self._volume_buttons[0]
-        button.set_palette(Palette(_('Directory GNOME')))
-        button.connect('toggled', self._button_toggled_cb)
-        self.insert(button, 1)
-        button.show()
-        self._volume_buttons.append(button)
-
         self.connect('destroy', self.__destroy_cb)
 
         gobject.idle_add(self._set_up_volumes)
-	
+
+        client = gconf.client_get_default()        
+        mount_directory = client.get_string(MOUNT_DIRECTORY_VALUE) or 'False'
+        if mount_directory == 'True':           
+            button = DirectoryButton()
+            button.props.group = self._volume_buttons[0]
+            button.set_palette(Palette(_('Directory') + ' ' + str(button.get_mount_point())))
+            button.connect('toggled', self._button_toggled_cb)
+            position = self.get_item_index(self._volume_buttons[-1]) + 1            
+            self.insert(button, position)
+            button.show()
+            self._volume_buttons.append(button)
+            self.show()
 
     def __destroy_cb(self, widget):
         volume_monitor = gio.volume_monitor_get()
         volume_monitor.disconnect(self._mount_added_hid)
         volume_monitor.disconnect(self._mount_removed_hid)
 
-    def _set_up_volumes(self):
+    def _set_up_volumes(self):        
         volume_monitor = gio.volume_monitor_get()
         self._mount_added_hid = \
                 volume_monitor.connect('mount-added', self.__mount_added_cb)
@@ -79,7 +86,6 @@ class VolumesToolbar(gtk.Toolbar):
         for mount in volume_monitor.get_mounts():
             self._add_button(mount)
 
-
     def __mount_added_cb(self, volume_monitor, mount):
         self._add_button(mount)
 
@@ -192,12 +198,15 @@ class JournalButton(BaseButton):
 
 class DirectoryButton(BaseButton):
     def __init__(self):
-        BaseButton.__init__(self, mount_point=os.environ['HOME'])
-        #BaseButton.__init__(self, mount_point="/tmp/hola")
+        client = gconf.client_get_default()
+        self.__mount_directory_path = client.get_string(MOUNT_DIRECTORY_PATH) or os.environ['HOME']
+        BaseButton.__init__(self, mount_point=self.__mount_directory_path)
 
 	    #self.props.active = False
         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.7.0.4