From df0369a3774af9793549a5febccc2f735ec2a8b1 Mon Sep 17 00:00:00 2001 From: Andrey Izman Date: Wed, 8 Jan 2025 03:37:42 +0200 Subject: [PATCH] Avoiding duplicate custom columns --- TelegramEntry.py | 2 +- TelegramSource.py | 18 ++++++++++++------ rhythmbox-telegram.py | 6 ------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/TelegramEntry.py b/TelegramEntry.py index c8c1888..d35ad4e 100644 --- a/TelegramEntry.py +++ b/TelegramEntry.py @@ -26,7 +26,7 @@ class TelegramEntryType(RB.RhythmDBEntryType): } def __init__(self, plugin): - RB.RhythmDBEntryType.__init__(self, name='TelegramEntryType') + RB.RhythmDBEntryType.__init__(self, name='telegram', save_to_disk=False) self.source = None self.plugin = plugin self.shell = plugin.shell diff --git a/TelegramSource.py b/TelegramSource.py index 9e8f069..794d8a1 100644 --- a/TelegramSource.py +++ b/TelegramSource.py @@ -49,8 +49,10 @@ def __init__(self, source): entry_view.append_column_custom(column, _("Format"), "tg-format", empty_cb, None, None) visible_columns = entry_view.get_property("visible-columns") - visible_columns.append('tg-format') - entry_view.set_property("visible-columns", visible_columns) + + if 'tg-format' not in visible_columns: + visible_columns.append('tg-format') + entry_view.set_property("visible-columns", visible_columns) def data_func(self, column, cell, model, iter, *data): # noqa entry = model.get_value(iter, 0) @@ -79,8 +81,10 @@ def __init__(self, source): entry_view.append_column_custom(column, _("Size"), "tg-size", empty_cb, None, None) visible_columns = entry_view.get_property("visible-columns") - visible_columns.append('tg-size') - entry_view.set_property("visible-columns", visible_columns) + + if 'tg-size' not in visible_columns: + visible_columns.append('tg-size') + entry_view.set_property("visible-columns", visible_columns) def data_func(self, column, cell, model, iter, *data): # noqa entry = model.get_value(iter, 0) @@ -127,8 +131,10 @@ def __init__(self, source): entry_view.append_column_custom(column, ' ', "tg-state", empty_cb, None, None) visible_columns = entry_view.get_property("visible-columns") - visible_columns.append('tg-state') - entry_view.set_property("visible-columns", visible_columns) + + if 'tg-state' not in visible_columns: + visible_columns.append('tg-state') + entry_view.set_property("visible-columns", visible_columns) def activate(self): if not self.timeout_id: diff --git a/rhythmbox-telegram.py b/rhythmbox-telegram.py index fad3cf1..27c0754 100644 --- a/rhythmbox-telegram.py +++ b/rhythmbox-telegram.py @@ -197,7 +197,6 @@ def delete_display_pages(self, permanent=False): self.sources = {} def do_reload_display_pages(self): - print('reload_display_pages()') selected = json.loads(self.settings[KEY_CHANNELS]) if self.connected else [] if self.connected and selected: @@ -251,15 +250,10 @@ def register_source(self, chat_id, name, visibility): def do_deactivate(self): print('Telegram plugin deactivating') - # shell = self.object - # shell.props.shell_player.disconnect(self.pec_id) - # self.db.entry_delete_by_type(self.entry_type) - # self.db.commit() self.delete_display_pages(True) self.db = None def playing_entry_changed(self, sp, entry): - print(entry) self.source.playing_entry_changed(entry) def file_manager_action_cb(self, action, parameter):