CoverPanel: combine context sort items in submenu

This commit is contained in:
coderkun 2012-07-07 23:31:18 +02:00
parent 6265db2d6e
commit 25083a1b7a

View file

@ -449,34 +449,41 @@ class CoverPanel(Gtk.HPaned):
self._progress_box.pack_start(self._progress_bar, True, False, 0)
# Context Menu
self._cover_grid_menu = Gtk.Menu()
# Sorting
item_sorting = Gtk.MenuItem("Sorting")
item_sorting.show()
self._cover_grid_menu.add(item_sorting)
menu_sorting = Gtk.Menu()
menu_sorting.show()
item_sorting.set_submenu(menu_sorting)
cover_grid_menu_group_sort = None
item = Gtk.RadioMenuItem("Sort by artist")
item = Gtk.RadioMenuItem("by artist")
item.connect('activate', self.cover_grid_menu_sort, mcg.MCGAlbum.SORT_BY_ARTIST)
item.show()
self._cover_grid_menu.add(item)
menu_sorting.add(item)
cover_grid_menu_group_sort = item
item = Gtk.RadioMenuItem(group=cover_grid_menu_group_sort, label="Sort by title")
item = Gtk.RadioMenuItem(group=cover_grid_menu_group_sort, label="by title")
item.set_active(True)
item.connect('activate', self.cover_grid_menu_sort, mcg.MCGAlbum.SORT_BY_TITLE)
item.show()
self._cover_grid_menu.add(item)
item = Gtk.RadioMenuItem(group=cover_grid_menu_group_sort, label="Sort by year")
menu_sorting.add(item)
item = Gtk.RadioMenuItem(group=cover_grid_menu_group_sort, label="by year")
item.connect('activate', self.cover_grid_menu_sort, mcg.MCGAlbum.SORT_BY_YEAR)
item.show()
self._cover_grid_menu.add(item)
menu_sorting.add(item)
item = Gtk.SeparatorMenuItem()
item.show()
self._cover_grid_menu.add(item)
menu_sorting.add(item)
item = Gtk.RadioMenuItem("Ascending")
cover_grid_menu_group_sort_type = item
item.set_active(True)
item.connect('activate', lambda widget: self._cover_grid_model.set_sort_column_id(3, Gtk.SortType.ASCENDING))
item.show()
self._cover_grid_menu.add(item)
menu_sorting.add(item)
item = Gtk.RadioMenuItem(group=cover_grid_menu_group_sort_type, label="Descending")
item.connect('activate', lambda widget: self._cover_grid_model.set_sort_column_id(3, Gtk.SortType.DESCENDING))
item.show()
self._cover_grid_menu.add(item)
menu_sorting.add(item)
self._cover_grid_menu.show()
# Signals