comparison src/cagou/core/cagou_main.py @ 25:d09bd16dbbe2

code (cagou widget), selector: icons handling + use of new muchoslava icon set
author Goffi <goffi@goffi.org>
date Wed, 10 Aug 2016 01:24:37 +0200
parents c58b522607f4
children 9f9532eb835f
comparison
equal deleted inserted replaced
24:bc15b55a4114 25:d09bd16dbbe2
69 69
70 def __init__(self): 70 def __init__(self):
71 super(Cagou, self).__init__(create_bridge=DBusBridgeFrontend, xmlui=xmlui) 71 super(Cagou, self).__init__(create_bridge=DBusBridgeFrontend, xmlui=xmlui)
72 self._import_kv() 72 self._import_kv()
73 self.app = CagouApp() 73 self.app = CagouApp()
74 media_dir = self.app.media_dir = self.bridge.getConfig("", "media_dir") 74 self.media_dir = self.app.media_dir = self.bridge.getConfig("", "media_dir")
75 self.app.default_avatar = os.path.join(media_dir, "misc/default_avatar.png") 75 self.app.default_avatar = os.path.join(self.media_dir, "misc/default_avatar.png")
76 self._plg_wids = [] # widget plugins 76 self._plg_wids = [] # widget plugins
77 self._import_plugins() 77 self._import_plugins()
78 78
79 def run(self): 79 def run(self):
80 self.app.run() 80 self.app.run()
133 # factory is used to create the instance 133 # factory is used to create the instance
134 # if not found, we use a defaut one with getOrCreateWidget 134 # if not found, we use a defaut one with getOrCreateWidget
135 if 'factory' not in plugin_info: 135 if 'factory' not in plugin_info:
136 plugin_info['factory'] = self._defaultFactory 136 plugin_info['factory'] = self._defaultFactory
137 137
138 # icons
139 for size in ('small', 'medium'):
140 key = u'icon_{}'.format(size)
141 try:
142 path = plugin_info[key]
143 except KeyError:
144 path = C.DEFAULT_WIDGET_ICON.format(media=self.media_dir)
145 else:
146 path = path.format(media=self.media_dir)
147 if not os.path.isfile(path):
148 path = C.DEFAULT_WIDGET_ICON.format(media=self.media_dir)
149 plugin_info[key] = path
150
138 self._plg_wids.append(plugin_info) 151 self._plg_wids.append(plugin_info)
139 if not self._plg_wids: 152 if not self._plg_wids:
140 log.error(_(u"no widget plugin found")) 153 log.error(_(u"no widget plugin found"))
141 return 154 return
142 155