[Syncropated-commits] r154 - trunk/src

zimmerle at garage.maemo.org zimmerle at garage.maemo.org
Mon Jan 29 22:44:39 EET 2007


Author: zimmerle
Date: 2007-01-29 22:44:39 +0200 (Mon, 29 Jan 2007)
New Revision: 154

Added:
   trunk/src/Preferences.py
Log:
first Preferences.py import

Added: trunk/src/Preferences.py
===================================================================
--- trunk/src/Preferences.py	2007-01-29 18:48:20 UTC (rev 153)
+++ trunk/src/Preferences.py	2007-01-29 20:44:39 UTC (rev 154)
@@ -0,0 +1,142 @@
+# Preferences.py
+#
+#  Copyright (c) 2006 INdT (Instituto Nokia de Technologia)
+#
+#  Author: Felipe Zimmerle <felipe at zimmerle.org>
+#          Kenneth Rohde Christiansen <kenneth.christiansen at gmail.com>
+#
+#  This program 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 2 of the
+#  License, or (at your option) any later version.
+#
+#  This program 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 this program; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+#  USA
+
+import gobject
+import gtk
+
+from Logger import Logger
+from Icons import Icons
+from Configuration import Configuration
+from Utils import Utils
+from LocalMusicManager import LocalMusicManager
+from FileTree import FileTree
+
+log = Logger()
+icons = Icons()
+utils = Utils()
+config = Configuration()
+
+
+class Preferences(object):
+	"""
+	Preferences dialog.
+
+	"""
+
+	__instance = None
+	glade = None
+
+	def __new__(cls):
+		"""
+		Preferences is a singleton.
+
+		"""
+		if cls.__instance == None:
+			cls.__instance = super(cls, Preferences).__new__(cls)
+
+		return cls.__instance
+
+	def __init__(self):
+		log.debug("Preferences :: Initializing...")
+
+		if self.glade == None:
+			self.glade = gtk.glade.XML(
+				utils.get_glade_fullpath('syncropated_preferences.glade')
+				)
+			self.preferences_window = self.glade.get_widget('preferences')
+			self.preferences_window.set_deletable(False)
+
+			self.glade.get_widget('audio_choose_folders_button').connect('clicked', 
+				self.open_choose_folders_button, 'audio')
+			self.glade.get_widget('photo_choose_folders_button').connect('clicked', 
+				self.open_choose_folders_button, 'photo')
+			#cls.glade.get_widget('video_choose_folders_button').connect('clicked', 
+				#cls.open_choose_folders_button, 'video')
+
+			self.glade.get_widget('preferences_close').connect('clicked', 
+				self.preferences_close)
+
+			self.thumbnail_size_hscale = self.glade.get_widget('thumbnail_size')
+			self.thumbnail_size_hscale.set_value(
+				int(config.getValue('iconview_thumbnail_width')))
+	                self.thumbnail_size_hscale.connect('value_changed',
+				self.cb_thumbnail_size_changed)
+
+
+	def open_choose_folders_button(self, button, type):
+		"""
+		Open 'Choose folder' dialog
+
+		"""
+		log.info('Preferences :: Opening choose folder... Type..: ' + str(type))
+		fileTree = FileTree(type)
+
+	def start(self):
+		"""
+		Start the preferences dialog 
+
+		"""
+		log.debug("Preferences :: Starting... : " + str(self))
+
+		self.preferences_window.hide()
+
+		## Check the visualisation buttons
+		for i in LocalMusicManager.OPTIONAL_TREEVIEW_COLUMNS:
+			bnt = self.glade.get_widget(i[0])
+			log.debug('Preferences :: Button: ' + str(i[0]) + ' - ' + str(bnt))
+			if bnt != None:
+				bnt.connect('toggled', self.audio_button_toggled, i[0])
+				bnt.set_active(config.getValue(i[0]) == str(True))
+
+		self.preferences_window.show()
+
+
+	def preferences_close(self, bnt):
+		"""
+		Hide the Preferences dialog.
+
+		"""
+		self.preferences_window.hide()
+
+	def cb_thumbnail_size_changed(self, blah):
+ 		"""
+		Callback to change the value of the thumbnail size.
+
+		"""
+		x = round(self.thumbnail_size_hscale.get_value())
+		x = int(x)
+		x = str(x)
+                config.setValue('iconview_thumbnail_height', x)
+                config.setValue('iconview_thumbnail_width', x)
+
+
+	def audio_button_toggled(self, button, button_name):
+		"""
+		Change the value of the view able music informations.
+
+		"""
+		log.debug('Preferences :: An Audio toggle clicked: ' + str(button))
+		log.debug('Preferences :: The button name  is: ' + str(button_name))
+		log.debug('Preferences :: The button value is: ' + str(button.get_active()))
+		config.setValue(button_name, str(button.get_active()))
+
+



More information about the Syncropated-commits mailing list