[Syncropated-commits] r153 - trunk/src

zimmerle at garage.maemo.org zimmerle at garage.maemo.org
Mon Jan 29 20:48:20 EET 2007


Author: zimmerle
Date: 2007-01-29 20:48:20 +0200 (Mon, 29 Jan 2007)
New Revision: 153

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

Added: trunk/src/Syncropated.py
===================================================================
--- trunk/src/Syncropated.py	2007-01-29 18:20:25 UTC (rev 152)
+++ trunk/src/Syncropated.py	2007-01-29 18:48:20 UTC (rev 153)
@@ -0,0 +1,260 @@
+#!/usr/bin/python
+
+# Syncropated
+#
+#  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 logging
+import sys
+import gtk
+import pygtk
+import gobject
+from gtk import gdk
+from Configuration import Configuration
+# Default configuration values.
+conf = {'watch_files_rescan_time' : '500',
+ 	 'devices_watch_dog_time' : '800',
+   	      'devices_watch_dog' : 'False',
+ 	      'media_audio_paths' : '',
+ 	      'media_photo_paths' : '',
+	      'media_video_paths' : '',
+       'iconview_thumbnail_width' : '80',
+      'iconview_thumbnail_height' : '80',
+}
+config = Configuration(conf)
+from MediaScanHandler import MediaScanHandler
+from Logger import Logger
+from PluginsHandler import PluginsHandler
+from FileTree import FileTree
+from LocalMusicManager import LocalMusicManager
+from LocalPhotoManager import LocalPhotoManager
+from Icons import Icons
+from Utils import Utils
+from Preferences import Preferences
+from DevicesManager import DevicesManager
+
+log = Logger()
+icons = Icons()
+utils = Utils()
+
+class Syncropated:
+
+	__dryrun = False
+	__plugins = True
+	localMusicManager = None
+	localPhotoManager = None
+	localContestAnchor = None
+
+	def __init__(self, dryrun=False, plugins=True):
+		"""
+		Constructor
+
+		"""
+
+		self.__dryrun = dryrun
+		self.__plugins = plugins
+		self.localMusicManager = None
+		self.localPhotoManager = None
+		self.localContestAnchor = None
+
+	def start_engine(self):
+		"""
+		Start the engines "watch dogs". One for each type of media.
+
+		"""
+
+		musicMediaScanHandler = MediaScanHandler(self.localMusicManager)
+		photoMediaScanHandler = MediaScanHandler(self.localPhotoManager)
+
+		log.debug('Syncropated :: Engine Music: ' + 
+			str(musicMediaScanHandler.media_type))
+		log.debug('Syncropated :: Engine Photo: ' + 
+			str(photoMediaScanHandler.media_type))
+
+		musicMediaScanHandler.start()
+		photoMediaScanHandler.start()
+
+		# Ok its time to start the plugins and see whats going on =]
+		#pluginHandler = PluginsHandler(self.__plugins)
+		#pluginHandler.connect(   'media_content_change', localMusicManager.callback_media_content_change)
+		# Start the plugin handler will start all associated plugin.
+		#pluginHandler.start()
+
+
+	def close(self, button):
+		"""
+		Syncropated exit point...
+
+		"""
+		log.debug('Close called... Closing...')
+		gtk.main_quit()
+		return False
+
+
+	def start(self):
+		"""
+		Load the syncropated's main form and it's
+		components.
+
+		"""
+
+		self.localMusicManager = LocalMusicManager()
+		self.localPhotoManager = LocalPhotoManager()
+
+		xml = gtk.glade.XML(utils.get_glade_fullpath('syncropated_new.glade'))
+
+		## Menus
+		quit_menu = xml.get_widget('quit_menu')
+		quit_menu.connect('activate', self.close)
+
+		about_menu = xml.get_widget('about_menu')
+		about_menu.connect('activate', self.start_about_dialog)
+
+		# Placing the backgrounds in the widgets.
+		hbuttonbox = xml.get_widget('eventbox1')
+		style = hbuttonbox.get_style().copy()
+		pixmap = icons.load_icon_as_pixmap('bg_my_computer', 64)
+		style.bg_pixmap[gtk.STATE_NORMAL] = pixmap
+		style.bg_pixmap[gtk.STATE_INSENSITIVE]  = pixmap
+		hbuttonbox.set_style(style)
+		hbuttonbox.show()
+
+		hbuttonbox = xml.get_widget('eventbox4')
+		style = hbuttonbox.get_style().copy()
+		pixmap = icons.load_icon_as_pixmap('bg_toolbar', 64)
+		style.bg_pixmap[gtk.STATE_NORMAL] = pixmap
+		style.bg_pixmap[gtk.STATE_INSENSITIVE]  = pixmap
+		hbuttonbox.set_style(style)
+		hbuttonbox.show()
+
+		### Second line widgets....
+		my_computer_ico = xml.get_widget('my_computer_ico')
+		my_computer_ico.set_from_pixbuf(icons.load_icon('my_computer', 16))
+
+		my_device_ico = xml.get_widget('my_device_ico')
+		my_device_ico.set_from_pixbuf(icons.load_icon('pictures', 16))
+
+		xml.get_widget('syncropated_ico').set_icon_widget(icons.load_icon_as_image('syncropated', 65))
+
+		syncropated_window = xml.get_widget('syncropated')
+		syncropated_window.set_icon(icons.load_icon('syncropated', 16))
+
+		search_box_entry = xml.get_widget('search_box_entry')
+
+
+		## Local Contest anchor
+		self.localContestAnchor = xml.get_widget('scrolledwindow4')
+
+		## TreeViews
+		audio_treeview = xml.get_widget('audio_treeview')
+		audio_filter_treeview = xml.get_widget('audio_filter_treeview')
+
+		## IconView
+		photo_icon_view = gtk.IconView()
+
+		## Status widgets...
+		stats_size = xml.get_widget('stats_size')
+		stats_play_time = xml.get_widget('stats_play_time')
+
+
+		## Notebook 
+		#notebook = xml.get_widget('devices_notebook')
+		#if notebook == None:
+		#	sys.exit(1)
+		## Starts the device manager creating a new tab for each device.
+		## And adding the correct signals to keep its up-to-date of all
+		## device information. (Free space, etc....)
+		#self.devicesManager = DevicesManager(notebook, self.dryrun)
+
+
+		## Tolbar widget setup
+		audio_button = xml.get_widget('audio_button')
+		audio_button.set_icon_widget(icons.load_icon_as_image('audio', 64))
+		audio_button.connect('clicked', self.change_contest_to, self.localMusicManager)
+		#audio_button.set_label('Audio')
+
+		video_button = xml.get_widget('video_button')
+		video_button.set_icon_widget(icons.load_icon_as_image('video', 64))
+		#video_button.set_label('Video')
+
+		photo_button = xml.get_widget('photo_button')
+		photo_button.set_icon_widget(icons.load_icon_as_image('photo', 64))
+		photo_button.connect('clicked', self.change_contest_to, self.localPhotoManager)
+		#photo_button.set_label('Photo')
+
+		preferences_button = xml.get_widget('preferences_button')
+		preferences_button.set_icon_widget(icons.load_icon_as_image('preferences-desktop', 48))
+		preferences_button.connect('clicked', self.start_preferences)
+		#preferences_button.set_label('Preferences...')
+
+		## Attaching the tree view and relatives componets.
+		self.localMusicManager.attach_tree_view(audio_treeview)
+		self.localMusicManager.attach_filter_tree_view(audio_filter_treeview)
+		self.localMusicManager.attach_search_box_entry(search_box_entry)
+		self.localMusicManager.attach_stats_bars(stats_size, stats_play_time)
+
+		## Attaching the photo manager
+		self.localPhotoManager.attach_icon_view(photo_icon_view)
+
+		
+		# Ok its time to start the engine
+		self.start_engine()
+
+		gtk.main()
+
+
+	def start_preferences(self, button):
+		"""
+		Start the preferences dialog.
+
+		"""
+		log.debug('Syncropated :: Starting preferences...')
+		preferences = Preferences()
+		preferences.start()
+
+	
+	def start_about_dialog(self, button):
+		"""
+		Open the about dialog....
+
+		"""
+		log.debug('Syncropated :: Starting the about dialog...')
+
+		print 'Syncropated :) Sorry but the about dialog is not ready.'
+
+
+	def change_contest_to(self, button, new_contest):
+		"""
+		Change the contest between the media types....
+		 
+		"""
+
+		log.debug('Syncropated :: Changing the contest to: ' + str(new_contest))
+		log.debug('Syncropated :: Old Local Anchor: ' + str(self.localContestAnchor))
+		log.debug('Syncropated :: Contest window  : ' + str(new_contest.get_attached_tree_view()))
+		for i in self.localContestAnchor.get_children():
+			log.debug('Syncropaed  :: Children: ' + str(i))
+			self.localContestAnchor.remove(i)
+		new_contest.get_attached_tree_view().show()
+		self.localContestAnchor.add(new_contest.get_attached_tree_view())
+		#new_contest.get_attached_tree_view().set_parent(self.localContestAnchor)
+		log.debug('Syncropated :: parent  : ' + str(new_contest.get_attached_tree_view().get_parent()))
+



More information about the Syncropated-commits mailing list