/usr/lib/python2.7/dist-packages/radiotray/PluginConfiguration.py is in radiotray 0.7.3-5ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | ##########################################################################
# Copyright 2009 Carlos Ribeiro
#
# This file is part of Radio Tray
#
# Radio Tray is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 1 of the License, or
# (at your option) any later version.
#
# Radio Tray is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Radio Tray. If not, see <http://www.gnu.org/licenses/>.
#
##########################################################################
import sys
try:
import gi
gi.require_version("Gtk", "3.0")
except:
pass
try:
from gi.repository import Gtk
#import Gtk.glade
from gi.repository import GObject
GObject.threads_init()
import os
from lib import utils
from lib.common import APP_ICON_ON
except Exception as e:
print e
import logging
class PluginConfiguration(object):
def __init__(self, pluginManager, cfgProvider):
self.pluginManager = pluginManager
self.cfgProvider = cfgProvider
self.log = logging.getLogger('radiotray')
# load glade and get gui objects
gladefile = utils.load_ui_file("configPlugins.glade")
self.wTree = gladefile
self.window = self.wTree.get_object("dialog1")
self.list = self.wTree.get_object("treeview1")
# set icon
self.window.set_icon_from_file(APP_ICON_ON)
# load plugin data
liststore = self.load_data()
self.list.set_model(liststore)
# config plugins view
cell1 = Gtk.CellRendererToggle()
cell1.set_property('activatable', True)
cell1.set_activatable(True)
cell1.set_property('mode', Gtk.CellRendererMode.ACTIVATABLE)
cell1.connect( 'toggled', self.on_toggle, liststore )
tvcolumn1 = Gtk.TreeViewColumn(_('Active'), cell1)
tvcolumn1.add_attribute( cell1, "active", 0)
cell2 = Gtk.CellRendererText()
tvcolumn2 = Gtk.TreeViewColumn(_('Name'), cell2, text=1)
self.list.append_column(tvcolumn1)
self.list.append_column(tvcolumn2)
if (self.window):
dic = { "on_close_clicked" : self.on_close_clicked}
self.wTree.connect_signals(self)
self.window.show()
def load_data(self):
self.activePlugins = self.cfgProvider.getConfigList('active_plugins')
# if plugins == None:
# self.cfgProvider.setConfigValue('active_plugins'
liststore = Gtk.ListStore(GObject.TYPE_BOOLEAN, GObject.TYPE_STRING)
plugins = self.pluginManager.getPlugins()
for p in plugins:
if p.name in self.activePlugins:
liststore.append([True, p.name])
else:
liststore.append([False, p.name])
return liststore
def on_toggle(self, cell, path, model):
model[path][0] = not model[path][0]
name = model[path][1]
self.log.debug('Setting ' + model[path][1] + ' to ' + str(model[path][0]))
self.log.debug(self.activePlugins)
if(model[path][0] == True):
self.log.debug('apppend %s', name)
self.activePlugins.append(name)
self.pluginManager.activatePlugin(name)
else:
self.log.debug('remove %s', name)
self.activePlugins.remove(name)
self.pluginManager.deactivatePlugin(name)
self.log.debug(self.activePlugins)
def on_close_clicked(self, widget):
self.cfgProvider.setConfigList('active_plugins', self.activePlugins)
self.window.destroy()
|