Add option to require control click to sort episodes.

This avoids accidental sorting when trying to select the top episode.

Requested by Fourhundred Thecat on mailing list, but is also an issue
I've run into many times.
This commit is contained in:
auouymous 2021-08-05 04:40:53 -06:00
parent 016cde21bb
commit 5ec9b60e3c
3 changed files with 22 additions and 5 deletions

View File

@ -209,6 +209,10 @@
<attribute name="action">win.viewAlwaysShowNewEpisodes</attribute>
<attribute name="label" translatable="yes">Always show New Episodes</attribute>
</item>
<item>
<attribute name="action">win.viewCtrlClickToSortEpisodes</attribute>
<attribute name="label" translatable="yes">Require control click to sort episodes</attribute>
</item>
</section>
<submenu id="menuViewColumns">
<attribute name="label" translatable="yes">Visible columns</attribute>

View File

@ -169,6 +169,7 @@ defaults = {
'view_mode': 1,
'columns': int('110', 2), # bitfield of visible columns
'always_show_new': True,
'ctrl_click_to_sort': False,
},
'download_list': {

View File

@ -271,6 +271,11 @@ class gPodder(BuilderWidget, dbus.service.Object):
action.connect('activate', self.on_item_view_always_show_new_episodes_toggled)
g.add_action(action)
action = Gio.SimpleAction.new_stateful(
'viewCtrlClickToSortEpisodes', None, GLib.Variant.new_boolean(self.config.ui.gtk.episode_list.ctrl_click_to_sort))
action.connect('activate', self.on_item_view_ctrl_click_to_sort_episodes_toggled)
g.add_action(action)
action = Gio.SimpleAction.new_stateful(
'searchAlwaysVisible', None, GLib.Variant.new_boolean(self.config.ui.gtk.search_always_visible))
action.connect('activate', self.on_item_view_search_always_visible_toggled)
@ -808,11 +813,13 @@ class gPodder(BuilderWidget, dbus.service.Object):
(column.get_sort_order() is Gtk.SortType.ASCENDING)
def on_episode_list_header_clicked(self, button, event):
if event.button != 3:
return False
if self.episode_columns_menu is not None:
self.episode_columns_menu.popup(None, None, None, None, event.button, event.time)
if event.button == 1:
# Require control click to sort episodes, when enabled
if self.config.ui.gtk.episode_list.ctrl_click_to_sort and (event.state & Gdk.ModifierType.CONTROL_MASK) == 0:
return True
elif event.button == 3:
if self.episode_columns_menu is not None:
self.episode_columns_menu.popup(None, None, None, None, event.button, event.time)
return False
@ -3195,6 +3202,11 @@ class gPodder(BuilderWidget, dbus.service.Object):
self.config.ui.gtk.episode_list.always_show_new = not state
action.set_state(GLib.Variant.new_boolean(not state))
def on_item_view_ctrl_click_to_sort_episodes_toggled(self, action, param):
state = action.get_state()
self.config.ui.gtk.episode_list.ctrl_click_to_sort = not state
action.set_state(GLib.Variant.new_boolean(not state))
def on_item_view_search_always_visible_toggled(self, action, param):
state = action.get_state()
self.config.ui.gtk.search_always_visible = not state