Skip to content

Commit

Permalink
Avoiding duplicate custom columns
Browse files Browse the repository at this point in the history
  • Loading branch information
mervick committed Jan 8, 2025
1 parent 307aebc commit df0369a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion TelegramEntry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 12 additions & 6 deletions TelegramSource.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 0 additions & 6 deletions rhythmbox-telegram.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit df0369a

Please sign in to comment.