Exemple #1
0
	def _on_row_activated(self, treeview, path, column):
		iter = self._model.get_iter(path)
		name = self._model.get_value(iter, 0)
		c = self._setting[name]
		if not c.readonly:
			value = None
			if c.name in engine_map.keys() + ['main.download', 
				'display.embedded', 'display.roller', 'display.gosd', 'display.single',
				'display.gosd.animations', 'display.gosd.avoid_panels',
				'display.gosd.drop_shadow', 'display.gosd.hide_on_hover']:
				self._on_bool_set(c, iter)
			elif c.name in ['display.embedded.foreground', 'display.embedded.background',
				'display.roller.foreground', 'display.roller.background', 'display.roller.highlight',
				'display.single.foreground', 'display.single.background', 'display.single.highlight',
				'display.gosd.color']:
				self._on_color_set(c, iter)
			elif c.name in ['display.embedded.font', 'display.roller.font', 'display.gosd.font', 'display.single.font']:
				self._on_font_set(c, iter)
			elif c.name == 'main.directory':
				self._on_directory_set(c, iter)
			elif c.name in ['main.file_pattern', 'display.gosd.vpos', 'display.gosd.halignment']:
				self._on_combo_set(c, iter)
			elif c.name in ['display.roller.opacity', 'display.single.opacity']:
				self._on_scale_set(c, iter)
		return
Exemple #2
0
 def _on_row_activated(self, treeview, path, column):
     iter = self._model.get_iter(path)
     name = self._model.get_value(iter, 0)
     c = self._setting[name]
     if not c.readonly:
         value = None
         if c.name in engine_map.keys() + [
                 'main.download', 'display.embedded', 'display.roller',
                 'display.gosd', 'display.single',
                 'display.gosd.animations', 'display.gosd.avoid_panels',
                 'display.gosd.drop_shadow', 'display.gosd.hide_on_hover'
         ]:
             self._on_bool_set(c, iter)
         elif c.name in [
                 'display.embedded.foreground',
                 'display.embedded.background', 'display.roller.foreground',
                 'display.roller.background', 'display.roller.highlight',
                 'display.single.foreground', 'display.single.background',
                 'display.single.highlight', 'display.gosd.color'
         ]:
             self._on_color_set(c, iter)
         elif c.name in [
                 'display.embedded.font', 'display.roller.font',
                 'display.gosd.font', 'display.single.font'
         ]:
             self._on_font_set(c, iter)
         elif c.name == 'main.directory':
             self._on_directory_set(c, iter)
         elif c.name in [
                 'main.file_pattern', 'display.gosd.vpos',
                 'display.gosd.halignment'
         ]:
             self._on_combo_set(c, iter)
         elif c.name in [
                 'display.roller.opacity', 'display.single.opacity'
         ]:
             self._on_scale_set(c, iter)
     return
Exemple #3
0
	def __init__(self):
		gtk.Dialog.__init__(self, title = _('Preferences'), flags = gtk.DIALOG_NO_SEPARATOR)
		self._setting = {}
		for name in engine_map.keys():
			self._setting[name] = Config(name, '/apps/rhythmbox/plugins/RBLyrics/%s' % name, 'True', False)
		self._setting['display.gosd'] = Config('display.gosd', '/apps/rhythmbox/plugins/RBLyrics/display.gosd', 'True', False)
		self._setting['display.gosd.animations'] = Config('display.gosd.animations', '/apps/rhythmbox/plugins/RBLyrics/display.gosd.animations', 'False', False)
		self._setting['display.gosd.avoid_panels'] = Config('display.gosd.avoid_panels', '/apps/rhythmbox/plugins/RBLyrics/display.gosd.avoid_panels', 'True', False)
		self._setting['display.gosd.drop_shadow'] = Config('display.gosd.drop_shadow', '/apps/rhythmbox/plugins/RBLyrics/display.gosd.drop_shadow', 'False', False)
		self._setting['display.gosd.hide_on_hover'] = Config('display.gosd.hide_on_hover', '/apps/rhythmbox/plugins/RBLyrics/display.gosd.hide_on_hover', 'True', False)
		self._setting['display.gosd.font'] = Config('display.gosd.font', '/apps/rhythmbox/plugins/RBLyrics/display.gosd.font', '16', False)
		self._setting['display.gosd.color'] = Config('display.gosd.color', '/apps/rhythmbox/plugins/RBLyrics/display.gosd.color', '#FF0080', False)
		self._setting['display.gosd.vpos'] = Config('display.gosd.vpos', '/apps/rhythmbox/plugins/RBLyrics/display.gosd.vpos', 'top', False)
		self._setting['display.gosd.halignment'] = Config('display.gosd.halignment', '/apps/rhythmbox/plugins/RBLyrics/display.gosd.halignment', 'center', False)
		self._setting['display.embedded'] = Config('display.embedded', '/apps/rhythmbox/plugins/RBLyrics/display.embedded', 'True', False)
		self._setting['display.embedded.font'] = Config('display.embedded.font', '/apps/rhythmbox/plugins/RBLyrics/display.embedded.font', '13', False)
		self._setting['display.embedded.foreground'] = Config('display.embedded.foreground', '/apps/rhythmbox/plugins/RBLyrics/display.embedded.foreground', '#FF0080', False)
		self._setting['display.embedded.background'] = Config('display.embedded.background', '/apps/rhythmbox/plugins/RBLyrics/display.embedded.background', '#EDECEB', False)
		self._setting['display.roller'] = Config('display.roller', '/apps/rhythmbox/plugins/RBLyrics/display.roller', 'True', False)
		self._setting['display.roller.window'] = Config('display.roller.window', '/apps/rhythmbox/plugins/RBLyrics/display.roller.window', '0,0,%d,%d' % (gtk.gdk.screen_width()/4, gtk.gdk.screen_height()/4), True)
		self._setting['display.roller.opacity'] = Config('display.roller.opacity', '/apps/rhythmbox/plugins/RBLyrics/display.roller.opacity', '100', False)
		self._setting['display.roller.font'] = Config('display.roller.font', '/apps/rhythmbox/plugins/RBLyrics/display.roller.font', '14', False)
		self._setting['display.roller.foreground'] = Config('display.roller.foreground', '/apps/rhythmbox/plugins/RBLyrics/display.roller.foreground', '#FF0080', False)
		self._setting['display.roller.highlight'] = Config('display.roller.highlight', '/apps/rhythmbox/plugins/RBLyrics/display.roller.highlight', '#00FF00', False)
		self._setting['display.roller.background'] = Config('display.roller.background', '/apps/rhythmbox/plugins/RBLyrics/display.roller.background', '#000000', False)
		self._setting['display.single'] = Config('display.single', '/apps/rhythmbox/plugins/RBLyrics/display.single', 'True', False)
		self._setting['display.single.window'] = Config('display.single.window', '/apps/rhythmbox/plugins/RBLyrics/display.single.window', '0,0,%d,%d' % (gtk.gdk.screen_width()/4, 1), True)
		self._setting['display.single.opacity'] = Config('display.single.opacity', '/apps/rhythmbox/plugins/RBLyrics/display.single.opacity', '100', False)
		self._setting['display.single.font'] = Config('display.single.font', '/apps/rhythmbox/plugins/RBLyrics/display.single.font', '14', False)
		self._setting['display.single.foreground'] = Config('display.single.foreground', '/apps/rhythmbox/plugins/RBLyrics/display.single.foreground', '#FF0080', False)
		self._setting['display.single.highlight'] = Config('display.single.highlight', '/apps/rhythmbox/plugins/RBLyrics/display.single.highlight', '#00FF00', False)
		self._setting['display.single.background'] = Config('display.single.background', '/apps/rhythmbox/plugins/RBLyrics/display.single.background', '#000000', False)
		self._setting['main.download'] = Config('main.download', '/apps/rhythmbox/plugins/RBLyrics/main.download', 'True', False)
		self._setting['main.directory'] = Config('main.directory', '/apps/rhythmbox/plugins/RBLyrics/main.directory', os.path.expanduser('~/lyrics'), False)
		self._setting['main.file_pattern'] = Config('main.file_pattern', '/apps/rhythmbox/plugins/RBLyrics/main.file_pattern', LRC_PATH_TEMPLATE[0], False)
		# init dialog widgets
		self.connect('delete-event', self._on_delete_event)
		self.set_default_size(640, 480)
		self._model = gtk.ListStore(str, str, str, str, int, str)
		names = self._setting.keys()
		names.sort()
		for n in names:
			c = self._setting[n]
			if c.value != c.default:
				weight = pango.WEIGHT_BOLD
			else:
				weight = pango.WEIGHT_NORMAL
			if c.readonly:
				color = '#A9A9A9'
			else:
				color = '#000000'
			self._model.append([c.name, _(c.name), c.value, _(c.value), weight, color])
		#
		treeview = gtk.TreeView(self._model)
		treeview.set_rules_hint(True)
		cell = gtk.CellRendererText()
		vc = gtk.TreeViewColumn(_('Name'), cell, text = 1, weight = 4)
		vc.set_sort_column_id(0)
		treeview.append_column(vc)
		cell = gtk.CellRendererText()
		vc = gtk.TreeViewColumn(_('Value'), cell, text = 3, weight = 4, foreground = 5)
		treeview.append_column(vc)
		treeview.connect('row-activated', self._on_row_activated)
		scroll = gtk.ScrolledWindow()
		scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
		scroll.add_with_viewport(treeview)
		self.get_content_area().add(scroll)
		self.get_content_area().show_all()
		#
		btnrestore = gtk.Button(_('Restore'))
		icon = gtk.Image()
		icon.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON)
		btnrestore.set_image(icon)
		btnrestore.connect('released', self._on_btnrestore_released)
		self.get_action_area().pack_end(btnrestore, False, False)
		#
		btnclose = gtk.Button(_('Close'))
		icon = gtk.Image()
		icon.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_BUTTON)
		btnclose.set_image(icon)
		btnclose.connect('released', self._on_btnclose_released)
		self.get_action_area().pack_end(btnclose, False, False)
		self.get_action_area().show_all()
		#
		self._watcher = []
		self._dlgcolor = None
		self._dlgfont = None
		self._dlgdirectory = None
		self._dlgcombo = None
		self._dlgscale = None
		return
Exemple #4
0
 def __init__(self):
     gtk.Dialog.__init__(self,
                         title=_('Preferences'),
                         flags=gtk.DIALOG_NO_SEPARATOR)
     self._setting = {}
     for name in engine_map.keys():
         self._setting[name] = Config(
             name, '/apps/rhythmbox/plugins/RBLyrics/%s' % name, 'True',
             False)
     self._setting['display.gosd'] = Config(
         'display.gosd', '/apps/rhythmbox/plugins/RBLyrics/display.gosd',
         'True', False)
     self._setting['display.gosd.animations'] = Config(
         'display.gosd.animations',
         '/apps/rhythmbox/plugins/RBLyrics/display.gosd.animations',
         'False', False)
     self._setting['display.gosd.avoid_panels'] = Config(
         'display.gosd.avoid_panels',
         '/apps/rhythmbox/plugins/RBLyrics/display.gosd.avoid_panels',
         'True', False)
     self._setting['display.gosd.drop_shadow'] = Config(
         'display.gosd.drop_shadow',
         '/apps/rhythmbox/plugins/RBLyrics/display.gosd.drop_shadow',
         'False', False)
     self._setting['display.gosd.hide_on_hover'] = Config(
         'display.gosd.hide_on_hover',
         '/apps/rhythmbox/plugins/RBLyrics/display.gosd.hide_on_hover',
         'True', False)
     self._setting['display.gosd.font'] = Config(
         'display.gosd.font',
         '/apps/rhythmbox/plugins/RBLyrics/display.gosd.font', '16', False)
     self._setting['display.gosd.color'] = Config(
         'display.gosd.color',
         '/apps/rhythmbox/plugins/RBLyrics/display.gosd.color', '#FF0080',
         False)
     self._setting['display.gosd.vpos'] = Config(
         'display.gosd.vpos',
         '/apps/rhythmbox/plugins/RBLyrics/display.gosd.vpos', 'top', False)
     self._setting['display.gosd.halignment'] = Config(
         'display.gosd.halignment',
         '/apps/rhythmbox/plugins/RBLyrics/display.gosd.halignment',
         'center', False)
     self._setting['display.embedded'] = Config(
         'display.embedded',
         '/apps/rhythmbox/plugins/RBLyrics/display.embedded', 'True', False)
     self._setting['display.embedded.font'] = Config(
         'display.embedded.font',
         '/apps/rhythmbox/plugins/RBLyrics/display.embedded.font', '13',
         False)
     self._setting['display.embedded.foreground'] = Config(
         'display.embedded.foreground',
         '/apps/rhythmbox/plugins/RBLyrics/display.embedded.foreground',
         '#FF0080', False)
     self._setting['display.embedded.background'] = Config(
         'display.embedded.background',
         '/apps/rhythmbox/plugins/RBLyrics/display.embedded.background',
         '#EDECEB', False)
     self._setting['display.roller'] = Config(
         'display.roller',
         '/apps/rhythmbox/plugins/RBLyrics/display.roller', 'True', False)
     self._setting['display.roller.window'] = Config(
         'display.roller.window',
         '/apps/rhythmbox/plugins/RBLyrics/display.roller.window',
         '0,0,%d,%d' %
         (gtk.gdk.screen_width() / 4, gtk.gdk.screen_height() / 4), True)
     self._setting['display.roller.opacity'] = Config(
         'display.roller.opacity',
         '/apps/rhythmbox/plugins/RBLyrics/display.roller.opacity', '100',
         False)
     self._setting['display.roller.font'] = Config(
         'display.roller.font',
         '/apps/rhythmbox/plugins/RBLyrics/display.roller.font', '14',
         False)
     self._setting['display.roller.foreground'] = Config(
         'display.roller.foreground',
         '/apps/rhythmbox/plugins/RBLyrics/display.roller.foreground',
         '#FF0080', False)
     self._setting['display.roller.highlight'] = Config(
         'display.roller.highlight',
         '/apps/rhythmbox/plugins/RBLyrics/display.roller.highlight',
         '#00FF00', False)
     self._setting['display.roller.background'] = Config(
         'display.roller.background',
         '/apps/rhythmbox/plugins/RBLyrics/display.roller.background',
         '#000000', False)
     self._setting['display.single'] = Config(
         'display.single',
         '/apps/rhythmbox/plugins/RBLyrics/display.single', 'True', False)
     self._setting['display.single.window'] = Config(
         'display.single.window',
         '/apps/rhythmbox/plugins/RBLyrics/display.single.window',
         '0,0,%d,%d' % (gtk.gdk.screen_width() / 4, 1), True)
     self._setting['display.single.opacity'] = Config(
         'display.single.opacity',
         '/apps/rhythmbox/plugins/RBLyrics/display.single.opacity', '100',
         False)
     self._setting['display.single.font'] = Config(
         'display.single.font',
         '/apps/rhythmbox/plugins/RBLyrics/display.single.font', '14',
         False)
     self._setting['display.single.foreground'] = Config(
         'display.single.foreground',
         '/apps/rhythmbox/plugins/RBLyrics/display.single.foreground',
         '#FF0080', False)
     self._setting['display.single.highlight'] = Config(
         'display.single.highlight',
         '/apps/rhythmbox/plugins/RBLyrics/display.single.highlight',
         '#00FF00', False)
     self._setting['display.single.background'] = Config(
         'display.single.background',
         '/apps/rhythmbox/plugins/RBLyrics/display.single.background',
         '#000000', False)
     self._setting['main.download'] = Config(
         'main.download', '/apps/rhythmbox/plugins/RBLyrics/main.download',
         'True', False)
     self._setting['main.directory'] = Config(
         'main.directory',
         '/apps/rhythmbox/plugins/RBLyrics/main.directory',
         os.path.expanduser('~/lyrics'), False)
     self._setting['main.file_pattern'] = Config(
         'main.file_pattern',
         '/apps/rhythmbox/plugins/RBLyrics/main.file_pattern',
         LRC_PATH_TEMPLATE[0], False)
     # init dialog widgets
     self.connect('delete-event', self._on_delete_event)
     self.set_default_size(640, 480)
     self._model = gtk.ListStore(str, str, str, str, int, str)
     names = self._setting.keys()
     names.sort()
     for n in names:
         c = self._setting[n]
         if c.value != c.default:
             weight = pango.WEIGHT_BOLD
         else:
             weight = pango.WEIGHT_NORMAL
         if c.readonly:
             color = '#A9A9A9'
         else:
             color = '#000000'
         self._model.append(
             [c.name, _(c.name), c.value,
              _(c.value), weight, color])
     #
     treeview = gtk.TreeView(self._model)
     treeview.set_rules_hint(True)
     cell = gtk.CellRendererText()
     vc = gtk.TreeViewColumn(_('Name'), cell, text=1, weight=4)
     vc.set_sort_column_id(0)
     treeview.append_column(vc)
     cell = gtk.CellRendererText()
     vc = gtk.TreeViewColumn(_('Value'),
                             cell,
                             text=3,
                             weight=4,
                             foreground=5)
     treeview.append_column(vc)
     treeview.connect('row-activated', self._on_row_activated)
     scroll = gtk.ScrolledWindow()
     scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     scroll.add_with_viewport(treeview)
     self.get_content_area().add(scroll)
     self.get_content_area().show_all()
     #
     btnrestore = gtk.Button(_('Restore'))
     icon = gtk.Image()
     icon.set_from_stock(gtk.STOCK_REFRESH, gtk.ICON_SIZE_BUTTON)
     btnrestore.set_image(icon)
     btnrestore.connect('released', self._on_btnrestore_released)
     self.get_action_area().pack_end(btnrestore, False, False)
     #
     btnclose = gtk.Button(_('Close'))
     icon = gtk.Image()
     icon.set_from_stock(gtk.STOCK_CLOSE, gtk.ICON_SIZE_BUTTON)
     btnclose.set_image(icon)
     btnclose.connect('released', self._on_btnclose_released)
     self.get_action_area().pack_end(btnclose, False, False)
     self.get_action_area().show_all()
     #
     self._watcher = []
     self._dlgcolor = None
     self._dlgfont = None
     self._dlgdirectory = None
     self._dlgcombo = None
     self._dlgscale = None
     return