Suppress sub-palettes in radiopalette

This commit is contained in:
Aleksey Lim 2009-07-29 16:15:38 +00:00
parent e5a701a1e6
commit 2655a8ccad
3 changed files with 16 additions and 14 deletions

View File

@ -30,21 +30,21 @@ group = RadioToolButton(
icon_name='document-open', icon_name='document-open',
tooltip='menu.document-open') tooltip='menu.document-open')
group.connect('clicked', lambda button: echo(button)) group.connect('clicked', lambda button: echo(button))
palette.append(group) palette.append(group, 'menu.document-open')
button = RadioToolButton( button = RadioToolButton(
icon_name='document-save', icon_name='document-save',
group=group, group=group,
tooltip='menu.document-save') tooltip='menu.document-save')
button.connect('clicked', lambda button: echo(button)) button.connect('clicked', lambda button: echo(button))
palette.append(button) palette.append(button, 'menu.document-save')
button = RadioToolButton( button = RadioToolButton(
icon_name='document-send', icon_name='document-send',
group=group, group=group,
tooltip='menu.document-send') tooltip='menu.document-send')
button.connect('clicked', lambda button: echo(button)) button.connect('clicked', lambda button: echo(button))
palette.append(button) palette.append(button, 'menu.document-send')
button = RadioMenuButton(palette=palette) button = RadioMenuButton(palette=palette)
toolbar.insert(button, -1) toolbar.insert(button, -1)
@ -57,21 +57,21 @@ group = RadioToolButton(
icon_name='document-open', icon_name='document-open',
tooltip='menu.document-open') tooltip='menu.document-open')
group.connect('clicked', lambda button: echo(button)) group.connect('clicked', lambda button: echo(button))
palette.append(group) palette.append(group, 'menu.document-open')
button = RadioToolButton( button = RadioToolButton(
icon_name='document-save', icon_name='document-save',
group=group, group=group,
tooltip='menu.document-save') tooltip='menu.document-save')
button.connect('clicked', lambda button: echo(button)) button.connect('clicked', lambda button: echo(button))
palette.append(button) palette.append(button, 'menu.document-save')
button = RadioToolButton( button = RadioToolButton(
icon_name='document-send', icon_name='document-send',
group=group, group=group,
tooltip='menu.document-send') tooltip='menu.document-send')
button.connect('clicked', lambda button: echo(button)) button.connect('clicked', lambda button: echo(button))
palette.append(button) palette.append(button, 'menu.document-send')
button = RadioToolsButton(palette=palette) button = RadioToolsButton(palette=palette)
toolbar.insert(button, -1) toolbar.insert(button, -1)

View File

@ -1061,16 +1061,14 @@ def share_button(activity, **kwargs):
palette = RadioPalette() palette = RadioPalette()
private = RadioToolButton( private = RadioToolButton(
icon_name='zoom-home', icon_name='zoom-home')
tooltip=_('Private')) palette.append(private, _('Private'))
palette.append(private)
neighborhood = RadioToolButton( neighborhood = RadioToolButton(
icon_name='zoom-neighborhood', icon_name='zoom-neighborhood',
group=private, group=private)
tooltip=_('My Neighborhood'))
neighborhood.connect('clicked', neighborhood_cb) neighborhood.connect('clicked', neighborhood_cb)
palette.append(neighborhood) palette.append(neighborhood, _('My Neighborhood'))
def update_share(): def update_share():
neighborhood.handler_block_by_func(neighborhood_cb) neighborhood.handler_block_by_func(neighborhood_cb)

View File

@ -88,12 +88,16 @@ class RadioPalette(Palette):
self.top.show() self.top.show()
self.set_content(self.top) self.set_content(self.top)
def append(self, button): def append(self, button, label):
children = self.top.get_children() children = self.top.get_children()
# palette's button should not have sub-palettes
button.palette = None
button.show() button.show()
button.connect('clicked', self.__clicked_cb) button.connect('clicked', self.__clicked_cb)
self.top.pack_start(button, fill=False) self.top.pack_start(button, fill=False)
button.__palette_label = label
if not children: if not children:
self.__clicked_cb(button, True) self.__clicked_cb(button, True)
@ -106,7 +110,7 @@ class RadioPalette(Palette):
if not button.get_active(): if not button.get_active():
return return
self.set_primary_text(button.props.tooltip) self.set_primary_text(button.__palette_label)
if not quiet: if not quiet:
self.popdown(immediate=True) self.popdown(immediate=True)