[Sugar-devel] [PATCH shell 2/2] Port Volume palette that has mixed content to new API

Manuel Quiñones manuq at laptop.org
Thu Sep 20 08:51:52 EDT 2012


2012/9/20 Simon Schampijer <simon at schampijer.de>:
> That one looks good as well, please push.

Pushed fixing the typo, thanks,

> Simon
>
>
>
> On 09/20/2012 07:00 AM, Manuel Quiñones wrote:
>>
>> This fixes VolumePalette that is used in the Journal, and in the
>> volume device icon.
>>
>> Had to set the content box (the one passed to set_content) a property
>> of the palette.  Otherwise the "Show Contents" can't be added from the
>> device icon.  Previusly the palette.menu attribute was used for that.
>
>
>
> s/Previusly/Previously
>
>
>
>> Also I had to reorder the "Show Contents" item because pack_end nor
>> pack_start didn't pack it to the correct place.
>>
>> Note that the separator packed after the Remove item is not visible.
>>
>> Signed-off-by: Manuel Quiñones <manuq at laptop.org>
>> ---
>>   extensions/deviceicon/volume.py |  8 +++++---
>>   src/jarabe/view/palettes.py     | 34 +++++++++++++++++++---------------
>>   2 files changed, 24 insertions(+), 18 deletions(-)
>>
>> diff --git a/extensions/deviceicon/volume.py
>> b/extensions/deviceicon/volume.py
>> index 11a8cc9..ec7b2e2 100644
>> --- a/extensions/deviceicon/volume.py
>> +++ b/extensions/deviceicon/volume.py
>> @@ -24,7 +24,8 @@ from gi.repository import GConf
>>
>>   from sugar3.graphics.tray import TrayIcon
>>   from sugar3.graphics.xocolor import XoColor
>> -from sugar3.graphics.menuitem import MenuItem
>> +from sugar3.graphics.palettemenuitem import PaletteMenuItem
>> +from sugar3.graphics.palettemenuitem import PaletteMenuItemSeparator
>>   from sugar3.graphics.icon import Icon
>>
>>   from jarabe.journal import journalactivity
>> @@ -69,7 +70,7 @@ class DeviceView(TrayIcon):
>>           palette = VolumePalette(self._mount)
>>           palette.set_group_id('frame')
>>
>> -        menu_item = MenuItem(_('Show contents'))
>> +        menu_item = PaletteMenuItem(_('Show contents'))
>>           client = GConf.Client.get_default()
>>           color = XoColor(client.get_string('/desktop/sugar/user/color'))
>>           icon = Icon(icon_name=self._icon_name,
>> icon_size=Gtk.IconSize.MENU,
>> @@ -78,7 +79,8 @@ class DeviceView(TrayIcon):
>>           icon.show()
>>
>>           menu_item.connect('activate', self.__show_contents_cb)
>> -        palette.menu.insert(menu_item, 0)
>> +        palette.content_box.pack_start(menu_item, True, True, 0)
>> +        palette.content_box.reorder_child(menu_item, 0)
>>           menu_item.show()
>>
>>           return palette
>> diff --git a/src/jarabe/view/palettes.py b/src/jarabe/view/palettes.py
>> index 50f6c83..35475d0 100644
>> --- a/src/jarabe/view/palettes.py
>> +++ b/src/jarabe/view/palettes.py
>> @@ -216,31 +216,35 @@ class VolumePalette(Palette):
>>           path = mount.get_root().get_path()
>>           self.props.secondary_text = glib.markup_escape_text(path)
>>
>> -        vbox = Gtk.VBox()
>> -        self.set_content(vbox)
>> -        vbox.show()
>> +        self.content_box = Gtk.VBox()
>> +        self.set_content(self.content_box)
>> +        self.content_box.show()
>> +
>> +        menu_item = PaletteMenuItem(pgettext('Volume', 'Remove'))
>> +
>> +        icon = Icon(icon_name='media-eject', icon_size=Gtk.IconSize.MENU)
>> +        menu_item.set_image(icon)
>> +        icon.show()
>> +
>> +        menu_item.connect('activate', self.__unmount_activate_cb)
>> +        self.content_box.pack_start(menu_item, True, True, 0)
>> +        menu_item.show()
>> +
>> +        separator = PaletteMenuItemSeparator()
>> +        self.content_box.pack_start(separator, True, True, 0)
>> +        separator.show()
>>
>>           self._progress_bar = Gtk.ProgressBar()
>> -        vbox.add(self._progress_bar)
>> +        self.content_box.pack_start(self._progress_bar, True, True, 0)
>>           self._progress_bar.show()
>>
>>           self._free_space_label = Gtk.Label()
>>           self._free_space_label.set_alignment(0.5, 0.5)
>> -        vbox.add(self._free_space_label)
>> +        self.content_box.pack_start(self._free_space_label, True, True,
>> 0)
>>           self._free_space_label.show()
>>
>>           self.connect('popup', self.__popup_cb)
>>
>> -        menu_item = MenuItem(pgettext('Volume', 'Remove'))
>> -
>> -        icon = Icon(icon_name='media-eject', icon_size=Gtk.IconSize.MENU)
>> -        menu_item.set_image(icon)
>> -        icon.show()
>> -
>> -        menu_item.connect('activate', self.__unmount_activate_cb)
>> -        self.menu.append(menu_item)
>> -        menu_item.show()
>> -
>>       def __unmount_activate_cb(self, menu_item):
>>           self._mount.unmount(self.__unmount_cb)
>>
>>
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel



-- 
.. manuq ..


More information about the Sugar-devel mailing list