diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/debian/bzr-builder.manifest rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/debian/bzr-builder.manifest --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/debian/bzr-builder.manifest 1970-01-01 00:00:00.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/debian/bzr-builder.manifest 2011-05-15 15:47:36.000000000 +0000 @@ -0,0 +1,4 @@ +# bzr-builder format 0.3 deb-version {debupstream}+9+3 +lp:rhythmbox-plugin-folderview revid:svn-v4:80c2eb4c-f05b-eaac-2b63-2035ae10867d:trunk/FolderView:10 +nest-part packaging lp:~zedtux/rhythmbox-plugin-folderview/debian debian debian revid:zedtux@zedroot.org-20110515112337-rwlrshg1kn7wqnjo +nest-part setup.py lp:~zedtux/rhythmbox-plugin-folderview/debian setup.py setup.py revid:zedtux@zedroot.org-20110515112337-rwlrshg1kn7wqnjo diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/debian/changelog rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/debian/changelog --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/debian/changelog 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/debian/changelog 2011-05-15 15:47:36.000000000 +0000 @@ -1,28 +1,34 @@ -rhythmbox-plugin-folderview (20101010.svn.r10ubuntu1~karmic) karmic; urgency=low +rhythmbox-plugin-folderview (20101010.svn.r10ubuntu1+9+3~karmic1) maverick; urgency=low + + * Auto build. + + -- zedtux Sun, 15 May 2011 15:47:36 +0000 + +rhythmbox-plugin-folderview (20101010.svn.r10ubuntu1) maverick; urgency=low * Fixed rules file -- Launchpad PPA for Guillaume HAIN Sun, 10 Oct 2010 19:12:22 +0200 -rhythmbox-plugin-folderview (20101010.svn.r10ubuntu0) karmic; urgency=low +rhythmbox-plugin-folderview (20101010.svn.r10ubuntu0) maverick; urgency=low * Updating to revision 10 -- Launchpad PPA for Guillaume HAIN Sun, 10 Oct 2010 19:00:14 +0200 -rhythmbox-plugin-folderview (20100928.svn.r9ubuntu0) karmic; urgency=low +rhythmbox-plugin-folderview (20100928.svn.r9ubuntu0) maverick; urgency=low * Updating to revision 9 -- Launchpad PPA for Guillaume HAIN Tue, 28 Sep 2010 18:20:20 +0200 -rhythmbox-plugin-folderview (20100927.svn.r7ubuntu0) karmic; urgency=low +rhythmbox-plugin-folderview (20100927.svn.r7ubuntu0) maverick; urgency=low * Updating to revision 7 -- Launchpad PPA for Guillaume HAIN Mon, 27 Sep 2010 23:54:56 +0200 -rhythmbox-plugin-folderview (20100927ubuntu0) karmic; urgency=low +rhythmbox-plugin-folderview (20100927ubuntu0) maverick; urgency=low * Ready for packaging ! diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/debian/patches/debian-changes-20100928.svn.r9ubuntu0 rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/debian/patches/debian-changes-20100928.svn.r9ubuntu0 --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/debian/patches/debian-changes-20100928.svn.r9ubuntu0 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/debian/patches/debian-changes-20100928.svn.r9ubuntu0 1970-01-01 00:00:00.000000000 +0000 @@ -1,48 +0,0 @@ -Description: Upstream changes introduced in version 20100928.svn.r9ubuntu0 - This patch has been created by dpkg-source during the package build. - Here's the last changelog entry, hopefully it gives details on why - those changes were made: - . - rhythmbox-plugin-folderview (20100928.svn.r9ubuntu0) maverick; urgency=low - . - * Updating to revision 9 - . - The person named in the Author field signed this changelog entry. -Author: Launchpad PPA for Guillaume HAIN - ---- -The information above should follow the Patch Tagging Guidelines, please -checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here -are templates for supplementary fields that you might want to add: - -Origin: , -Bug: -Bug-Debian: http://bugs.debian.org/ -Bug-Ubuntu: https://launchpad.net/bugs/ -Forwarded: -Reviewed-By: -Last-Update: - ---- /dev/null -+++ rhythmbox-plugin-folderview-20100928.svn.r9ubuntu0/setup.py -@@ -0,0 +1,20 @@ -+from distutils.core import setup -+ -+destination = "/usr/lib/rhythmbox/plugins/FolderView/" -+ -+setup(name='rhythmbox-plugin-folderview', -+ version='20100927', -+ data_files=[ -+ (destination, ["src/folder_view.rb-plugin", -+ "src/FolderView.py", -+ "src/FolderViewSource.py", -+ "src/treefilebrowser.py"]) -+ ], -+ author='Imdiot', -+ author_email='sunshine1985115@gmail.com', -+ maintainer='zedtux', -+ maintainer_email='zedtux@zedroot.org', -+ url='http://code.google.com/p/folderview/', -+ keywords=['rhythmbox','plugins'], -+ license='GNU GPLv3', -+ description='Rhythmbox folder view plugin.') diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/debian/patches/debian-changes-20101010.svn.r10ubuntu1~karmic rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/debian/patches/debian-changes-20101010.svn.r10ubuntu1~karmic --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/debian/patches/debian-changes-20101010.svn.r10ubuntu1~karmic 2010-10-10 17:27:32.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/debian/patches/debian-changes-20101010.svn.r10ubuntu1~karmic 1970-01-01 00:00:00.000000000 +0000 @@ -1,223 +0,0 @@ -Description: Upstream changes introduced in version 20101010.svn.r10ubuntu1~karmic - This patch has been created by dpkg-source during the package build. - Here's the last changelog entry, hopefully it gives details on why - those changes were made: - . - rhythmbox-plugin-folderview (20101010.svn.r10ubuntu1~karmic) karmic; urgency=low - . - * Fixed rules file - . - The person named in the Author field signed this changelog entry. -Author: Launchpad PPA for Guillaume HAIN - ---- -The information above should follow the Patch Tagging Guidelines, please -checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here -are templates for supplementary fields that you might want to add: - -Origin: , -Bug: -Bug-Debian: http://bugs.debian.org/ -Bug-Ubuntu: https://launchpad.net/bugs/ -Forwarded: -Reviewed-By: -Last-Update: - ---- /dev/null -+++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/setup.py -@@ -0,0 +1,20 @@ -+from distutils.core import setup -+ -+destination = "/usr/lib/rhythmbox/plugins/FolderView/" -+ -+setup(name='rhythmbox-plugin-folderview', -+ version='20100927', -+ data_files=[ -+ (destination, ["src/folder_view.rb-plugin", -+ "src/FolderView.py", -+ "src/FolderViewSource.py", -+ "src/treefilebrowser.py"]) -+ ], -+ author='Imdiot', -+ author_email='sunshine1985115@gmail.com', -+ maintainer='zedtux', -+ maintainer_email='zedtux@zedroot.org', -+ url='http://code.google.com/p/folderview/', -+ keywords=['rhythmbox','plugins'], -+ license='GNU GPLv3', -+ description='Rhythmbox folder view plugin.') ---- /dev/null -+++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/debian/changelog -@@ -0,0 +1,35 @@ -+rhythmbox-plugin-folderview (20101010.svn.r10ubuntu1~lucid) lucid; urgency=low -+ -+ * Fixed rules file -+ -+ -- Launchpad PPA for Guillaume HAIN Sun, 10 Oct 2010 19:12:22 +0200 -+ -+rhythmbox-plugin-folderview (20101010.svn.r10ubuntu0) lucid; urgency=low -+ -+ * Updating to revision 10 -+ -+ -- Launchpad PPA for Guillaume HAIN Sun, 10 Oct 2010 19:00:14 +0200 -+ -+rhythmbox-plugin-folderview (20100928.svn.r9ubuntu0) lucid; urgency=low -+ -+ * Updating to revision 9 -+ -+ -- Launchpad PPA for Guillaume HAIN Tue, 28 Sep 2010 18:20:20 +0200 -+ -+rhythmbox-plugin-folderview (20100927.svn.r7ubuntu0) lucid; urgency=low -+ -+ * Updating to revision 7 -+ -+ -- Launchpad PPA for Guillaume HAIN Mon, 27 Sep 2010 23:54:56 +0200 -+ -+rhythmbox-plugin-folderview (20100927ubuntu0) lucid; urgency=low -+ -+ * Ready for packaging ! -+ -+ -- Launchpad PPA for Guillaume HAIN Mon, 27 Sep 2010 18:33:53 +0200 -+ -+rhythmbox-plugin-folderview (20100927) unstable; urgency=low -+ -+ * Initial release -+ -+ -- Launchpad PPA for Guillaume HAIN Mon, 27 Sep 2010 18:16:23 +0200 ---- /dev/null -+++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/debian/copyright -@@ -0,0 +1,39 @@ -+This work was packaged for Debian by: -+ -+ Launchpad PPA for Guillaume HAIN on Mon, 27 Sep 2010 18:15:01 +0200 -+ -+It was downloaded from: -+ -+ http://code.google.com/p/folderview/ -+ -+Upstream Author(s): -+ -+ Imdiot -+ -+Copyright: -+ -+ -+ -+License: -+ -+ 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 3 of the License, or -+ (at your option) any later version. -+ -+ This package 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, see . -+ -+On Debian systems, the complete text of the GNU General -+Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". -+ -+The Debian packaging is: -+ -+ Copyright (C) 2010 Launchpad PPA for Guillaume HAIN -+ -+and is licensed under the GPL version 3, see above. ---- /dev/null -+++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/debian/compat -@@ -0,0 +1 @@ -+7 ---- /dev/null -+++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/debian/control -@@ -0,0 +1,13 @@ -+Source: rhythmbox-plugin-folderview -+Section: gnome -+Priority: extra -+Maintainer: Launchpad PPA for Guillaume HAIN -+Build-Depends: debhelper (>= 7.0.50~), rhythmbox, python (>= 2.6), python-gobject, python-gtk2, python-gconf -+Standards-Version: 3.9.1 -+Homepage: http://code.google.com/p/folderview/ -+ -+Package: rhythmbox-plugin-folderview -+Architecture: any -+Depends: ${shlibs:Depends}, ${misc:Depends} -+Description: Rhythmbox folder view plugin -+ This plugin implement a new view as Folder view in Rhythmbox. ---- /dev/null -+++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/debian/rules -@@ -0,0 +1,13 @@ -+#!/usr/bin/make -f -+# -*- makefile -*- -+# Sample debian/rules that uses debhelper. -+# This file was originally written by Joey Hess and Craig Small. -+# As a special exception, when this file is copied by dh-make into a -+# dh-make output file, you may use that output file without restriction. -+# This special exception was added by Craig Small in version 0.37 of dh-make. -+ -+# Uncomment this to turn on verbose mode. -+#export DH_VERBOSE=1 -+ -+%: -+ dh $@ ---- /dev/null -+++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/debian/patches/debian-changes-20100928.svn.r9ubuntu0 -@@ -0,0 +1,48 @@ -+Description: Upstream changes introduced in version 20100928.svn.r9ubuntu0 -+ This patch has been created by dpkg-source during the package build. -+ Here's the last changelog entry, hopefully it gives details on why -+ those changes were made: -+ . -+ rhythmbox-plugin-folderview (20100928.svn.r9ubuntu0) maverick; urgency=low -+ . -+ * Updating to revision 9 -+ . -+ The person named in the Author field signed this changelog entry. -+Author: Launchpad PPA for Guillaume HAIN -+ -+--- -+The information above should follow the Patch Tagging Guidelines, please -+checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here -+are templates for supplementary fields that you might want to add: -+ -+Origin: , -+Bug: -+Bug-Debian: http://bugs.debian.org/ -+Bug-Ubuntu: https://launchpad.net/bugs/ -+Forwarded: -+Reviewed-By: -+Last-Update: -+ -+--- /dev/null -++++ rhythmbox-plugin-folderview-20100928.svn.r9ubuntu0/setup.py -+@@ -0,0 +1,20 @@ -++from distutils.core import setup -++ -++destination = "/usr/lib/rhythmbox/plugins/FolderView/" -++ -++setup(name='rhythmbox-plugin-folderview', -++ version='20100927', -++ data_files=[ -++ (destination, ["src/folder_view.rb-plugin", -++ "src/FolderView.py", -++ "src/FolderViewSource.py", -++ "src/treefilebrowser.py"]) -++ ], -++ author='Imdiot', -++ author_email='sunshine1985115@gmail.com', -++ maintainer='zedtux', -++ maintainer_email='zedtux@zedroot.org', -++ url='http://code.google.com/p/folderview/', -++ keywords=['rhythmbox','plugins'], -++ license='GNU GPLv3', -++ description='Rhythmbox folder view plugin.') ---- /dev/null -+++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/debian/patches/series -@@ -0,0 +1 @@ -+debian-changes-20100928.svn.r9ubuntu0 ---- /dev/null -+++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/debian/source/format -@@ -0,0 +1 @@ -+3.0 (quilt) diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/debian/patches/series rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/debian/patches/series --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/debian/patches/series 2010-10-10 17:27:32.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -debian-changes-20100928.svn.r9ubuntu0 -debian-changes-20101010.svn.r10ubuntu1~karmic diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/debian/source/format rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/debian/source/format --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/debian/source/format 2011-05-15 16:00:51.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/debian/source/format 1970-01-01 00:00:00.000000000 +0000 @@ -1 +0,0 @@ -3.0 (quilt) diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/FolderView.py rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/FolderView.py --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/FolderView.py 1970-01-01 00:00:00.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/FolderView.py 2011-05-15 15:47:36.000000000 +0000 @@ -0,0 +1,74 @@ +#!/usr/bin/env python +#-*- coding: UTF-8 -*- + +import gobject +import gtk +import rb +import rhythmdb +import logging,logging.handlers +from FolderViewSource import FolderViewSource + +log=logging.getLogger('FolderView') + +class FolderViewEntryType(rhythmdb.EntryType): + def __init__(self): + rhythmdb.EntryType.__init__(self, name = 'FolderViewEntryType') + +class FolderView (rb.Plugin): + def __init__(self): + rb.Plugin.__init__(self) + + log.setLevel(logging.DEBUG) + console_handler = logging.StreamHandler() + console_handler.setLevel(logging.DEBUG) + console_handler.setFormatter(logging.Formatter('%(name)s %(levelname)-8s %(module)s::%(funcName)s - %(message)s')) + log.addHandler(console_handler) + + def activate(self, shell): + self.shell = shell + + group = rb.rb_source_group_get_by_name ("library") + self.db = shell.get_property("db") + try: + self.entry_type = FolderViewEntryType() + self.db.register_entry_type(self.entry_type) + except NotImplementedError: + self.entry_type = self.db.entry_register_type("FolderViewEntryType") + self.entry_type.can_sync_metadata = True + self.entry_type.save_to_disk = True + self.entry_type.category = rhythmdb.ENTRY_STREAM + self.source = gobject.new (FolderViewSource, + shell=self.shell, + name="Folder View", + entry_type=self.entry_type, + plugin=self, + source_group=group + ) + self.source.set_property( "icon", self.get_folder_closed_icon()) + shell.append_source(self.source, None) + shell.register_entry_type_for_source(self.source, self.entry_type) + + def deactivate(self, shell): + log.info("deactivate") + self.db.entry_delete_by_type(self.entry_type) + #self.db.commit() + self.db = None + self.entry_type = None + self.source.delete_thyself() + self.source = None + + def get_folder_closed_icon(self): + """ Returns a pixbuf with the current theme closed folder icon """ + + icon_theme = gtk.icon_theme_get_default() + try: + icon = icon_theme.load_icon("gnome-fs-directory", 24, 0) + return icon + except gobject.GError, exc: + #print "Can't load icon", exc + try: + icon = icon_theme.load_icon("gtk-directory", 24, 0) + return icon + except: + #print "Can't load default icon" + return None diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/folder_view.rb-plugin rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/folder_view.rb-plugin --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/folder_view.rb-plugin 1970-01-01 00:00:00.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/folder_view.rb-plugin 2011-05-15 15:47:36.000000000 +0000 @@ -0,0 +1,11 @@ +[RB Plugin] +Loader=python +Module=FolderView +IAge=1 +Name=FolderView +Name[zh_CN]=文件夹视图 +Description=Browse music file with folder +Description[zh_CN]=文件夹式浏览音乐文件 +Authors=Imdiot +Copyright=Copyright © 2010 Imdiot +Website=http://code.google.com/p/folderview/ \ No newline at end of file diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/FolderViewSource.py rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/FolderViewSource.py --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/FolderViewSource.py 1970-01-01 00:00:00.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/FolderViewSource.py 2011-05-15 15:47:36.000000000 +0000 @@ -0,0 +1,96 @@ +#!/usr/bin/env python +#-*- coding: UTF-8 -*- + +import gobject +import gtk +import os +import gio +import urllib +import gconf +import rb,rhythmdb +import treefilebrowser +import logging,logging.handlers + +log=logging.getLogger('FolderView') +LAST_PATH_KEY = '/rhythmbox.plugin.FolderView.lastpath' + +class FolderViewSource(rb.BrowserSource): + #__gproperties__ = {'plugin': (rb.Plugin, 'plugin', 'plugin', gobject.PARAM_WRITABLE|gobject.PARAM_CONSTRUCT_ONLY),} + + def __init__(self): + rb.BrowserSource.__init__(self) + + self.shell = None + + self.g_client = gconf.client_get_default() + self.library_location = urllib.unquote(self.g_client.get_list('/apps/rhythmbox/library_locations', gconf.VALUE_STRING)[0]) + + def do_impl_activate(self): + log.info('Activate') + if self.shell == None: + self.shell = self.get_property('shell') + self.db = self.shell.get_property('db') + self.entry_type = self.get_property('entry-type') + self.entry_view = self.get_entry_view() + self.filebrowser.set_active_dir(gconf.client_get_default().get_without_default(LAST_PATH_KEY).get_string()) + + ui_browse=self.shell.get_ui_manager().get_widget('/ToolBar/Browse') + #ui_browse.set_sensitive(False) + ui_browse.hide() + #gconf.client_get_default().set_string(LAST_PATH_KEY,userName) + rb.BrowserSource.do_impl_activate(self) + + def do_impl_deactivate(self): + log.info('Deactivate') + ui_browse=self.shell.get_ui_manager().get_widget('/ToolBar/Browse') + ui_browse.show() + rb.BrowserSource.do_impl_deactivate(self) + #uim.get_widget('/ToolBar/Browse').set_sensitive(False) + + #def set_entry(self, uri): + # entry = self.db.entry_lookup_by_location(uri) + # if entry != None: + # if self.db.entry_get(entry, rhythmdb.PROP_DURATION) != 0: + # #self.props.query_model.add_entry(entry, 0) + # self.db.query_append(self.query, (rhythmdb.QUERY_PROP_SUFFIX, rhythmdb.PROP_LOCATION, self.db.entry_get(entry, rhythmdb.PROP_LOCATION))) + + def on_treeview_cursor_changed(self, widget): + for row in self.props.query_model: + entry = row[0] + self.props.query_model.remove_entry(entry) + + self.query = self.db.query_new() + song_type = self.db.entry_type_get_by_name('song') + path = self.filebrowser.get_selected() + gconf.client_get_default().set_string(LAST_PATH_KEY,path) + #for item in os.listdir(path): + # filename = os.path.join(path, item) + # if os.path.isfile(filename): + # tmp = str(path_to_uri(filename)) + #self.set_entry(path_to_uri(filename)) + self.db.query_append(self.query, (rhythmdb.QUERY_PROP_EQUALS, rhythmdb.PROP_TYPE, song_type)) + self.db.query_append(self.query, (rhythmdb.QUERY_PROP_PREFIX, rhythmdb.PROP_LOCATION, path_to_uri(path))) + self.db.do_full_query_parsed(self.props.query_model, self.query) + + if self.shell.props.shell_player.props.playing: + pass + else: + self.shell.props.shell_player.stop() + + def do_impl_pack_paned (self, paned): + self.__paned_box = gtk.HPaned() + self.filebrowser = treefilebrowser.TreeFileBrowser(self.library_location[7:]) + self.scrolled = self.filebrowser.get_scrolled() + self.scrolled.set_size_request(200,-1) + self.treeview = self.filebrowser.get_view() + self.treeview.connect('cursor-changed', self.on_treeview_cursor_changed) + self.pack_start(self.__paned_box) + self.__paned_box.add1(self.scrolled) + self.__paned_box.add2(paned) + + +def path_to_uri(path): + gfile = gio.File(path) + return gfile.get_uri() + +gobject.type_register(FolderViewSource) diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/FolderView.py rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/FolderView.py --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/FolderView.py 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/FolderView.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -#!/usr/bin/env python -#-*- coding: UTF-8 -*- - -import gobject -import gtk -import rb -import rhythmdb -import logging,logging.handlers -from FolderViewSource import FolderViewSource - -log=logging.getLogger('FolderView') - -class FolderViewEntryType(rhythmdb.EntryType): - def __init__(self): - rhythmdb.EntryType.__init__(self, name = 'FolderViewEntryType') - -class FolderView (rb.Plugin): - def __init__(self): - rb.Plugin.__init__(self) - - log.setLevel(logging.DEBUG) - console_handler = logging.StreamHandler() - console_handler.setLevel(logging.DEBUG) - console_handler.setFormatter(logging.Formatter('%(name)s %(levelname)-8s %(module)s::%(funcName)s - %(message)s')) - log.addHandler(console_handler) - - def activate(self, shell): - self.shell = shell - - group = rb.rb_source_group_get_by_name ("library") - self.db = shell.get_property("db") - try: - self.entry_type = FolderViewEntryType() - self.db.register_entry_type(self.entry_type) - except NotImplementedError: - self.entry_type = self.db.entry_register_type("FolderViewEntryType") - self.entry_type.can_sync_metadata = True - self.entry_type.save_to_disk = True - self.entry_type.category = rhythmdb.ENTRY_STREAM - self.source = gobject.new (FolderViewSource, - shell=self.shell, - name="Folder View", - entry_type=self.entry_type, - plugin=self, - source_group=group - ) - self.source.set_property( "icon", self.get_folder_closed_icon()) - shell.append_source(self.source, None) - shell.register_entry_type_for_source(self.source, self.entry_type) - - def deactivate(self, shell): - log.info("deactivate") - self.db.entry_delete_by_type(self.entry_type) - #self.db.commit() - self.db = None - self.entry_type = None - self.source.delete_thyself() - self.source = None - - def get_folder_closed_icon(self): - """ Returns a pixbuf with the current theme closed folder icon """ - - icon_theme = gtk.icon_theme_get_default() - try: - icon = icon_theme.load_icon("gnome-fs-directory", 24, 0) - return icon - except gobject.GError, exc: - #print "Can't load icon", exc - try: - icon = icon_theme.load_icon("gtk-directory", 24, 0) - return icon - except: - #print "Can't load default icon" - return None diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/folder_view.rb-plugin rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/folder_view.rb-plugin --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/folder_view.rb-plugin 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/folder_view.rb-plugin 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -[RB Plugin] -Loader=python -Module=FolderView -IAge=1 -Name=FolderView -Name[zh_CN]=文件夹视图 -Description=Browse music file with folder -Description[zh_CN]=文件夹式浏览音乐文件 -Authors=Imdiot -Copyright=Copyright © 2010 Imdiot -Website=http://code.google.com/p/folderview/ \ No newline at end of file diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/FolderViewSource.py rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/FolderViewSource.py --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/FolderViewSource.py 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/FolderViewSource.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -#!/usr/bin/env python -#-*- coding: UTF-8 -*- - -import gobject -import gtk -import os -import gio -import urllib -import gconf -import rb,rhythmdb -import treefilebrowser -import logging,logging.handlers - -log=logging.getLogger('FolderView') -LAST_PATH_KEY = '/rhythmbox.plugin.FolderView.lastpath' - -class FolderViewSource(rb.BrowserSource): - #__gproperties__ = {'plugin': (rb.Plugin, 'plugin', 'plugin', gobject.PARAM_WRITABLE|gobject.PARAM_CONSTRUCT_ONLY),} - - def __init__(self): - rb.BrowserSource.__init__(self) - - self.shell = None - - self.g_client = gconf.client_get_default() - self.library_location = urllib.unquote(self.g_client.get_list('/apps/rhythmbox/library_locations', gconf.VALUE_STRING)[0]) - - def do_impl_activate(self): - log.info('Activate') - if self.shell == None: - self.shell = self.get_property('shell') - self.db = self.shell.get_property('db') - self.entry_type = self.get_property('entry-type') - self.entry_view = self.get_entry_view() - self.filebrowser.set_active_dir(gconf.client_get_default().get_without_default(LAST_PATH_KEY).get_string()) - - ui_browse=self.shell.get_ui_manager().get_widget('/ToolBar/Browse') - #ui_browse.set_sensitive(False) - ui_browse.hide() - #gconf.client_get_default().set_string(LAST_PATH_KEY,userName) - rb.BrowserSource.do_impl_activate(self) - - def do_impl_deactivate(self): - log.info('Deactivate') - ui_browse=self.shell.get_ui_manager().get_widget('/ToolBar/Browse') - ui_browse.show() - rb.BrowserSource.do_impl_deactivate(self) - #uim.get_widget('/ToolBar/Browse').set_sensitive(False) - - #def set_entry(self, uri): - # entry = self.db.entry_lookup_by_location(uri) - # if entry != None: - # if self.db.entry_get(entry, rhythmdb.PROP_DURATION) != 0: - # #self.props.query_model.add_entry(entry, 0) - # self.db.query_append(self.query, (rhythmdb.QUERY_PROP_SUFFIX, rhythmdb.PROP_LOCATION, self.db.entry_get(entry, rhythmdb.PROP_LOCATION))) - - def on_treeview_cursor_changed(self, widget): - for row in self.props.query_model: - entry = row[0] - self.props.query_model.remove_entry(entry) - - self.query = self.db.query_new() - song_type = self.db.entry_type_get_by_name('song') - path = self.filebrowser.get_selected() - gconf.client_get_default().set_string(LAST_PATH_KEY,path) - #for item in os.listdir(path): - # filename = os.path.join(path, item) - # if os.path.isfile(filename): - # tmp = str(path_to_uri(filename)) - #self.set_entry(path_to_uri(filename)) - self.db.query_append(self.query, (rhythmdb.QUERY_PROP_EQUALS, rhythmdb.PROP_TYPE, song_type)) - self.db.query_append(self.query, (rhythmdb.QUERY_PROP_PREFIX, rhythmdb.PROP_LOCATION, path_to_uri(path))) - self.db.do_full_query_parsed(self.props.query_model, self.query) - - if self.shell.props.shell_player.props.playing: - pass - else: - self.shell.props.shell_player.stop() - - def do_impl_pack_paned (self, paned): - self.__paned_box = gtk.HPaned() - self.filebrowser = treefilebrowser.TreeFileBrowser(self.library_location[7:]) - self.scrolled = self.filebrowser.get_scrolled() - self.scrolled.set_size_request(200,-1) - self.treeview = self.filebrowser.get_view() - self.treeview.connect('cursor-changed', self.on_treeview_cursor_changed) - self.pack_start(self.__paned_box) - self.__paned_box.add1(self.scrolled) - self.__paned_box.add2(paned) - - -def path_to_uri(path): - gfile = gio.File(path) - return gfile.get_uri() - -gobject.type_register(FolderViewSource) diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/treefilebrowser.py rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/treefilebrowser.py --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/treefilebrowser.py 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid/src/treefilebrowser.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,487 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -TreeFileBrowser a tree-like gtk file browser -Copyright (C) 2006-2008 Adolfo González Blázquez - -This library 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 library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -If you find any bugs or have any suggestions email: code@infinicode.org -""" - -try: - import pygtk - pygtk.require('2.0') -except: - print "PyGtk 2.0 or later required for this app to run" - raise SystemExit - -try: - import gtk - import gobject -except: - raise SystemExit - -from gettext import gettext as _ - -try: - from os import path as ospath - import dircache -except: - raise SystemExit - -class TreeFileBrowser(gobject.GObject): - """ A widget that implements a tree-like file browser, like the - one used on Nautilus spatial view in list mode """ - - __gproperties__ = { - 'show-hidden': (gobject.TYPE_BOOLEAN, 'show hidden files', - 'show hidden files and folders', False, gobject.PARAM_READWRITE), - 'show-only-dirs': (gobject.TYPE_BOOLEAN, 'show only directories', - 'show only directories, not files', True, gobject.PARAM_READWRITE), - 'rules-hint': (gobject.TYPE_BOOLEAN, 'rules hint', - 'show rows background in alternate colors', True, gobject.PARAM_READWRITE), - 'root': (gobject.TYPE_STRING, 'initial path', - 'initial path selected on tree browser', '/', gobject.PARAM_READWRITE) - } - - __gsignals__ = { 'row-expanded' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)), - 'cursor-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)) - } - - def __init__(self, root=None): - """ Path is where we wan the tree initialized """ - - gobject.GObject.__init__(self) - - self.show_hidden = False - self.show_only_dirs = True - self.show_rules_hint = True - - self.root = '/' - if root != None and ospath.isdir(root): self.root = root - #elif root != None: print "ERROR: %s doesn't exist." % root - - self.view, self.scrolled = self.make_view() - self.create_new() - self.create_popup() - - ##################################################### - # Accessors and Mutators - - def do_get_property(self, property): - """ GObject get_property method """ - if property.name == 'show-hidden': - return self.show_hidden - elif property.name == 'show-only-dirs': - return self.show_only_dirs - elif property.name == 'rules-hint': - return self.show_rules_hint - elif property.name == 'path': - return self.root - else: - raise AttributeError, 'unknown property %s' % property.name - - def do_set_property(self, property, value): - """ GObject set_property method """ - if property.name == 'show-hidden': - self.show_hidden = value - elif property.name == 'show-only-dirs': - self.show_only_dirs = value - elif property.name == 'rules-hint': - self.show_rules_hint = value - elif property.name == 'path': - self.root = value - else: - raise AttributeError, 'unknown property %s' % property.name - - def get_view(self): - return self.view - - def get_scrolled(self): - return self.scrolled - - def set_show_hidden(self, hidden): - self.show_hidden = hidden - activedir = self.get_selected() - self.create_new() - if activedir != None: - if "/." in activedir: self.set_active_dir(self.root) - else: self.set_active_dir(activedir) - self.hidden_check_menu.set_active(hidden) - - def get_show_hidden(self): - return self.show_hidden - - def set_rules_hint(self, rules): - self.show_rules_hint = rules - self.view.set_rules_hint(rules) - - def get_rules_hint(self): - return self.show_rules_hint - - def set_show_only_dirs(self, only_dirs): - self.show_only_dirs = only_dirs - self.create_new() - - def get_show_only_dirs(self): - return self.show_only_dirs - - def get_selected(self): - """ Returns selected item in browser """ - model, iter = self.view.get_selection().get_selected() - if iter != None: - return model.get_value(iter, 2) - else: - return None - - - ##################################################### - # Callbacks - - def row_expanded(self, treeview, iter, path): - """ CALLBACK: a row is expanded """ - - model = treeview.get_model() - model.set_value(iter, 0, self.get_folder_opened_icon()) - self.get_file_list(model, iter, model.get_value(iter,2)) - self.remove_empty_child(model, iter) - - # Send signal with path of expanded row - self.emit('row-expanded', model.get_value(iter,2)) - - - def row_collapsed(self, treeview, iter, path): - """ CALLBACK: a row is collapsed """ - - model = treeview.get_model() - model.set_value(iter, 0, self.get_folder_closed_icon()) - while model.iter_has_child(iter): - child = model.iter_children(iter) - model.remove(child) - self.add_empty_child(model, iter) - - - def row_activated(self, treeview, path, view_column): - """ CALLBACK: row activated using return, double-click, shift-right, etc. """ - - if treeview.row_expanded(path): - treeview.collapse_row(path) - else: - treeview.expand_row(path, False) - - - def cursor_changed(self, treeview): - """ CALLBACK: a new row has been selected """ - model, iter = treeview.get_selection().get_selected() - - # Send signal with path of expanded row - if iter == None: - path = treeview.get_cursor()[0] - iter = self.model.get_iter(path) - - self.emit('cursor-changed', model.get_value(iter,2)) - - - def button_pressed(self, widget, event): - """ CALLBACK: clicked on widget """ - if event.button == 3: - x = int(event.x) - y = int(event.y) - time = event.time - pthinfo = self.view.get_path_at_pos(x, y) - if pthinfo is not None: - path, col, cellx, celly = pthinfo - #self.view.grab_focus() - #self.view.set_cursor( path, col, 0) - self.popup.popup( None, None, None, event.button, time) - return 1 - - def show_hidden_toggled(self, widget): - """ CALLBACK: Show hidden files on context menu toggled """ - state = widget.get_active() - self.set_show_hidden(state) - - - ##################################################### - # Directories and files, nodes and icons - - def set_cursor_on_first_row(self): - model = self.view.get_model() - iter = model.get_iter_root() - path = model.get_path(iter) - self.view.set_cursor(path) - - def check_active_dir(self, directory): - rootdir = self.root - if not ospath.isdir(directory): - return False - if not (rootdir in directory): - return False - if directory == rootdir: - return True - return True - - - def set_active_dir(self, directory): - - rootdir = self.root - - # Expand root - model = self.view.get_model() - iter = model.get_iter_root() - path = model.get_path(iter) - self.view.expand_row(path, False) - iter = model.iter_children(iter) - - # Add trailing / to paths - if len(directory) > 1 and directory[-1] != '/': directory += '/' - if len(rootdir) > 1 and rootdir[-1] != '/': rootdir += '/' - - if not ospath.isdir(directory): - #print "ERROR: %s doesn't exist." % directory - self.set_cursor_on_first_row() - return False - if not (rootdir in directory): - #print "ERROR: %s is not on root path." % directory - self.set_cursor_on_first_row() - return False - if directory == rootdir: - self.set_cursor_on_first_row() - return True - else: - - # Now we check if the desired dir is valid - # Convert the given '/home/user/dir/' to ['/', 'home/', 'user/', 'dir/'] - if len(directory) > 1: - dirtree = directory.split('/') - dirtree.pop(-1) - else: dirtree = ['/'] - if len(dirtree) > 1: - dirtree[0] = '/' - for i in range(len(dirtree)-1): dirtree[i+1] = dirtree[i+1] + '/' - - # Convert root to '/home/user/dir/' to ['/', 'home/', 'user/', 'dir/'] - if len(rootdir) > 1: - roottree = rootdir.split('/') - roottree.pop(-1) - else: roottree = ['/'] - if len(roottree) > 1: - roottree[0] = '/' - for i in range(len(roottree)-1): roottree[i+1] = roottree[i+1] + '/' - - # Check if the dir is in the same path as the desired root - long = len(roottree) - for i in range(long): - if roottree[i] != dirtree[i]: return False - - # End checking - - # Star expanding - # Count how many iterations we need - depth = len(dirtree) - len(roottree) - - # Expand baby expand! - exp = len(roottree) - for i in range(depth): - newpath = dirtree[i+exp] - if iter == None: continue - val = model.get_value(iter, 1).replace('/','') + '/' - while val != newpath: - iter = model.iter_next(iter) - val = model.get_value(iter, 1).replace('/','') + '/' - - path = model.get_path(iter) - self.view.expand_row(path, False) - iter = model.iter_children(iter) - - # Don't expand last row - self.view.collapse_row(path) - - # Set the cursor - self.view.set_cursor(path) - - return True - - - def add_empty_child(self, model, iter): - """ Adds a empty child to a node. - Used when we need a folder that have children to show the expander arrow """ - - model.insert_before(iter, None) - - - def remove_empty_child(self, model, iter): - """ Delete empty child from a node. - Used to remove the extra child used to show the expander arrow - on folders with children """ - - newiter = model.iter_children(iter) - model.remove(newiter) - - - def get_file_list(self, model, iter, dir): - """ Get the file list from a given directory """ - - ls = dircache.listdir(dir) - ls.sort(key=str.lower) - for i in ls: - path = ospath.join(dir,i) - if ospath.isdir(path) or not self.show_only_dirs : - if i[0] != '.' or (self.show_hidden and i[0] == '.'): - newiter = model.append(iter) - if ospath.isdir(path): icon = self.get_folder_closed_icon() - else: icon = self.get_file_icon() - model.set_value(newiter, 0, icon) - model.set_value(newiter, 1, i) - model.set_value(newiter, 2, path) - if ospath.isdir(path): - try: subdir = dircache.listdir(path) - except: subdir = [] - if subdir != []: - for i in subdir: - if ospath.isdir(ospath.join(path,i)) or not self.show_only_dirs: - if i[0] != '.' or (self.show_hidden and i[0] == '.'): - self.add_empty_child(model, newiter) - break - - def create_root(self): - - model = self.view.get_model() - - if self.root != '/': - if self.root[-1] == '/': self.root = self.root.rsplit('/',1)[0] # Remove last / if neccesary - directory = self.root.split('/')[-1] - else: directory = self.root - - iter = model.insert_before(None, None) - model.set_value(iter, 0, self.get_folder_opened_icon()) - model.set_value(iter, 1, directory) - model.set_value(iter, 2, self.root) - iter = model.insert_before(iter, None) - return iter - - def create_new(self): - """ Create tree from scratch """ - - model = self.view.get_model() - model.clear() - iter = self.create_root() - self.get_file_list(self.view.get_model(), iter, self.root) - - - def create_popup(self): - """ Create popup menu for right click """ - self.popup = gtk.Menu() - - self.hidden_check_menu = gtk.CheckMenuItem(_("Show hidden files")) - self.hidden_check_menu.connect('toggled', self.show_hidden_toggled) - - self.popup.add(self.hidden_check_menu) - self.popup.show_all() - - - def get_folder_closed_icon(self): - """ Returns a pixbuf with the current theme closed folder icon """ - - icon_theme = gtk.icon_theme_get_default() - try: - icon = icon_theme.load_icon("gnome-fs-directory", 16, 0) - return icon - except gobject.GError, exc: - #print "Can't load icon", exc - try: - icon = icon_theme.load_icon("gtk-directory", 16, 0) - return icon - except: - #print "Can't load default icon" - return None - - - def get_folder_opened_icon(self): - """ Returns a pixbuf with the current theme opened folder icon """ - - icon_theme = gtk.icon_theme_get_default() - try: - icon = icon_theme.load_icon("gnome-fs-directory-accept", 16, 0) - return icon - except gobject.GError, exc: - #print "Can't load icon", exc - try: - icon = icon_theme.load_icon("gtk-directory", 16, 0) - return icon - except: - #print "Can't load default icon" - return None - - - def get_file_icon(self): - """ Returns a pixbuf with the current theme file icon """ - - icon_theme = gtk.icon_theme_get_default() - try: - icon = icon_theme.load_icon("text-x-generic", gtk.ICON_SIZE_MENU, 0) - return icon - except gobject.GError, exc: - #print "Can't load icon", exc - return None - - - ##################################################### - # Model, treeview and scrolledwindow - - def make_view(self): - """ Create the view itself. - (Icon, dir name, path) """ - self.model = gtk.TreeStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING) - - view = gtk.TreeView(self.model) - view.set_headers_visible(False) - view.set_enable_search(True) - view.set_reorderable(False) - view.set_rules_hint(self.show_rules_hint) - view.connect('row-expanded', self.row_expanded) - view.connect('row-collapsed', self.row_collapsed) - view.connect('row-activated', self.row_activated) - view.connect('cursor-changed', self.cursor_changed) - view.connect('button_press_event', self.button_pressed) - - col = gtk.TreeViewColumn() - - # The icon - render_pixbuf = gtk.CellRendererPixbuf() - col.pack_start(render_pixbuf, expand=False) - col.add_attribute(render_pixbuf, 'pixbuf', 0) - - # The dir name - render_text = gtk.CellRendererText() - col.pack_start(render_text, expand=True) - col.add_attribute(render_text, 'text', 1) - - view.append_column(col) - view.show() - - # Create scrollbars around the view - scrolled = gtk.ScrolledWindow() - scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - scrolled.set_shadow_type(gtk.SHADOW_ETCHED_IN) - scrolled.add(view) - scrolled.show() - - return view, scrolled - -gobject.type_register(TreeFileBrowser) - -# End TreeFileBrowser Binary files /tmp/AnbEpJwVgm/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.debian.tar.gz and /tmp/_6vodRA91b/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.debian.tar.gz differ diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.dsc rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.dsc --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.dsc 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.dsc 1970-01-01 00:00:00.000000000 +0000 @@ -1,33 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -Format: 3.0 (quilt) -Source: rhythmbox-plugin-folderview -Binary: rhythmbox-plugin-folderview -Architecture: any -Version: 20101010.svn.r10ubuntu1~lucid -Maintainer: Launchpad PPA for Guillaume HAIN -Homepage: http://code.google.com/p/folderview/ -Standards-Version: 3.9.1 -Build-Depends: debhelper (>= 7.0.50~), rhythmbox, python (>= 2.6), python-gobject, python-gtk2, python-gconf -Checksums-Sha1: - e42700c310495acb21eb5e19b756f880c91c61f6 6358 rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.orig.tar.gz - a6fbc10ac03189065432a4a66c5920638f40a4cc 2612 rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.debian.tar.gz -Checksums-Sha256: - fff6d2a4d3ab71228d2b8343283f94b502362385151bdce95eabb9107704181d 6358 rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.orig.tar.gz - b18b3707d857cdd090177c26d5bb136acdfa700131decd30ad000d131617ec9e 2612 rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.debian.tar.gz -Files: - 9714f0a23db131fc6b8bd3f9dbb8f142 6358 rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.orig.tar.gz - 2785f748e139fbd91c32eec9c52e790e 2612 rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.debian.tar.gz - ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.10 (GNU/Linux) - -iQEcBAEBAgAGBQJMsfd2AAoJEKwlrlHW1qGXlMsIAJTl3fysLHORWbxyaGGSGqyE -tuCXH5ixf6hImGOSj+TgyH3oSfASBa4hj0HdlEoDvK8zohQNv3mveDBFhprZhlT/ -o43VAJ2H1amc8mboTn4G5aOivYUj1K/uzxYLKfTF/NJDF18SYbFaHabxPgDwEAdd -5yZVhvtPM4+brunCmYlZu8dSeM0I4L7LW5rSME263INbeP//wkmCepvIOTqpPNob -wvl+cqFtq+UTIaPGNM6+eJVrd44CcH8uqbnoxplSDBQNMquJMweEKU6NFbDGrPn2 -UHC699hGmywYiqY3Kyx/RTD6CjqKMAEPl6D7+iH0y4q5g6rzKkAHxDNi3YJJJNY= -=4gaH ------END PGP SIGNATURE----- Binary files /tmp/AnbEpJwVgm/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.orig.tar.gz and /tmp/_6vodRA91b/rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.orig.tar.gz differ diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid_source.build rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid_source.build --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid_source.build 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid_source.build 1970-01-01 00:00:00.000000000 +0000 @@ -1,39 +0,0 @@ - dpkg-buildpackage -rfakeroot -d -us -uc -S -sa -dpkg-buildpackage: export de CFLAGS depuis dpkg-buildflags (origine : vendor): -g -O2 -dpkg-buildpackage: export de CPPFLAGS depuis dpkg-buildflags (origine : vendor): -dpkg-buildpackage: export de CXXFLAGS depuis dpkg-buildflags (origine : vendor): -g -O2 -dpkg-buildpackage: export de FFLAGS depuis dpkg-buildflags (origine : vendor): -g -O2 -dpkg-buildpackage: export de LDFLAGS depuis dpkg-buildflags (origine : vendor): -Wl,-Bsymbolic-functions -dpkg-buildpackage: paquet source rhythmbox-plugin-folderview -dpkg-buildpackage: version source 20101010.svn.r10ubuntu1~lucid -dpkg-buildpackage: source changé par Launchpad PPA for Guillaume HAIN - dpkg-source --before-build rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid - fakeroot debian/rules clean -dh clean - dh_testdir - dh_auto_clean -running clean -'build/lib.linux-x86_64-2.6' does not exist -- can't clean it -'build/bdist.linux-x86_64' does not exist -- can't clean it -'build/scripts-2.6' does not exist -- can't clean it - dh_clean - dpkg-source -b rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid -dpkg-source: avertissement: Le numéro de version indique des modifications Ubuntu mais le champ « Maintainer: » ne comporte pas d'adresse Ubuntu -dpkg-source: avertissement: Le numéro de version indique des modifications Ubuntu mais il n'existe pas de champ « XSBC-Original-Maintainer: » -dpkg-source: info: utilisation du format source « 3.0 (quilt) » -dpkg-source: info: construction de rhythmbox-plugin-folderview à partir de ./rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.orig.tar.gz -dpkg-source: info: construction de rhythmbox-plugin-folderview dans rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.debian.tar.gz -dpkg-source: info: construction de rhythmbox-plugin-folderview dans rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.dsc - dpkg-genchanges -S -sa >../rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid_source.changes -dpkg-genchanges: inclusion du code source original dans l'envoi (« upload ») - dpkg-source --after-build rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~lucid -dpkg-buildpackage: envoi complet (inclusion du code source d'origine) -Now running lintian... -W: rhythmbox-plugin-folderview source: non-native-package-with-native-version -Finished running lintian. -Now signing changes and any dsc files... - signfile rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.dsc Launchpad PPA for Guillaume HAIN - - signfile rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid_source.changes Launchpad PPA for Guillaume HAIN - -Successfully signed dsc and changes files diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid_source.changes rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid_source.changes --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid_source.changes 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/publishfor_lucid/rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid_source.changes 1970-01-01 00:00:00.000000000 +0000 @@ -1,43 +0,0 @@ ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA1 - -Format: 1.8 -Date: Sun, 10 Oct 2010 19:12:22 +0200 -Source: rhythmbox-plugin-folderview -Binary: rhythmbox-plugin-folderview -Architecture: source -Version: 20101010.svn.r10ubuntu1~lucid -Distribution: lucid -Urgency: low -Maintainer: Launchpad PPA for Guillaume HAIN -Changed-By: Launchpad PPA for Guillaume HAIN -Description: - rhythmbox-plugin-folderview - Rhythmbox folder view plugin -Changes: - rhythmbox-plugin-folderview (20101010.svn.r10ubuntu1~lucid) lucid; urgency=low - . - * Fixed rules file -Checksums-Sha1: - 12a43b1e7b33781e56012981042cdb498a181ffd 1718 rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.dsc - e42700c310495acb21eb5e19b756f880c91c61f6 6358 rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.orig.tar.gz - a6fbc10ac03189065432a4a66c5920638f40a4cc 2612 rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.debian.tar.gz -Checksums-Sha256: - 6b1ca627ec5c11fb77bf379dbbe923eaf95df688b45d67f1bdb189a6c34ffc85 1718 rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.dsc - fff6d2a4d3ab71228d2b8343283f94b502362385151bdce95eabb9107704181d 6358 rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.orig.tar.gz - b18b3707d857cdd090177c26d5bb136acdfa700131decd30ad000d131617ec9e 2612 rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.debian.tar.gz -Files: - 531afa04f82fe02ec5725efac1099a4e 1718 gnome extra rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.dsc - 9714f0a23db131fc6b8bd3f9dbb8f142 6358 gnome extra rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.orig.tar.gz - 2785f748e139fbd91c32eec9c52e790e 2612 gnome extra rhythmbox-plugin-folderview_20101010.svn.r10ubuntu1~lucid.debian.tar.gz - ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1.4.10 (GNU/Linux) - -iQEcBAEBAgAGBQJMsfd6AAoJEKwlrlHW1qGXZPQH/3ZZshxz5F2W0tc3/pi93OR0 -HGCBaMMmH9N7XacCg2BvxKy5IPVsNWi/g7HSUFUULLXJX7CVp8BxJRYDYYJ7f4Jj -aJueFz77lnSX66JbPeNhpiNO4lvGq7E/EiwcS6LjreJzCaZN7N7YbEo8topk8/dh -PIL8m93aH0kC5kgKBXtUoFzqZNRuf15qiQhbC7thzu7NJU4wVUixg+t3mi3JFdkD -6y9g6vtCr6LwmpkLUPsz0gc+zo33F7QY+UVL6RLbiKV0lJE3wYvFMJVoMWKwaXWM -fG9BH36KJTaxXoeUl02h2m2ApFE2iiZzIGlBSw+FcI8W2pYDumlalp/c5wZjBfw= -=e/1I ------END PGP SIGNATURE----- diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/setup.py rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/setup.py --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/setup.py 1970-01-01 00:00:00.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/setup.py 2011-05-15 15:47:36.000000000 +0000 @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +from distutils.core import setup + +if __name__ == '__main__': + + setup(name='rhythmbox-plugin-folderview', + version='20110512~svn.r10', + description='Rhythmbox folder view plugin', + long_description="""Rhythmbox folder view plugin.""", + author='sunshine1985115', + author_email='sunshine1985115@gmail.org', + maintainer='Guillaume Hain (zedtux)', + maintainer_email='zedtux@zedroot.org', + keywords=['rhythmbox','plugins','folder','folderview'], + url='http://code.google.com/p/folderview/', + license='GNU GPL v3', + platforms='UNIX', + data_files = [ + ('/usr/lib/rhythmbox/plugins/', [ + 'folder_view.rb-plugin', + 'FolderView.py', + 'FolderViewSource.py', + 'treefilebrowser.py' + ] + ) + ] + ) + diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/src/FolderView.py rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/src/FolderView.py --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/src/FolderView.py 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/src/FolderView.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,74 +0,0 @@ -#!/usr/bin/env python -#-*- coding: UTF-8 -*- - -import gobject -import gtk -import rb -import rhythmdb -import logging,logging.handlers -from FolderViewSource import FolderViewSource - -log=logging.getLogger('FolderView') - -class FolderViewEntryType(rhythmdb.EntryType): - def __init__(self): - rhythmdb.EntryType.__init__(self, name = 'FolderViewEntryType') - -class FolderView (rb.Plugin): - def __init__(self): - rb.Plugin.__init__(self) - - log.setLevel(logging.DEBUG) - console_handler = logging.StreamHandler() - console_handler.setLevel(logging.DEBUG) - console_handler.setFormatter(logging.Formatter('%(name)s %(levelname)-8s %(module)s::%(funcName)s - %(message)s')) - log.addHandler(console_handler) - - def activate(self, shell): - self.shell = shell - - group = rb.rb_source_group_get_by_name ("library") - self.db = shell.get_property("db") - try: - self.entry_type = FolderViewEntryType() - self.db.register_entry_type(self.entry_type) - except NotImplementedError: - self.entry_type = self.db.entry_register_type("FolderViewEntryType") - self.entry_type.can_sync_metadata = True - self.entry_type.save_to_disk = True - self.entry_type.category = rhythmdb.ENTRY_STREAM - self.source = gobject.new (FolderViewSource, - shell=self.shell, - name="Folder View", - entry_type=self.entry_type, - plugin=self, - source_group=group - ) - self.source.set_property( "icon", self.get_folder_closed_icon()) - shell.append_source(self.source, None) - shell.register_entry_type_for_source(self.source, self.entry_type) - - def deactivate(self, shell): - log.info("deactivate") - self.db.entry_delete_by_type(self.entry_type) - #self.db.commit() - self.db = None - self.entry_type = None - self.source.delete_thyself() - self.source = None - - def get_folder_closed_icon(self): - """ Returns a pixbuf with the current theme closed folder icon """ - - icon_theme = gtk.icon_theme_get_default() - try: - icon = icon_theme.load_icon("gnome-fs-directory", 24, 0) - return icon - except gobject.GError, exc: - #print "Can't load icon", exc - try: - icon = icon_theme.load_icon("gtk-directory", 24, 0) - return icon - except: - #print "Can't load default icon" - return None diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/src/folder_view.rb-plugin rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/src/folder_view.rb-plugin --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/src/folder_view.rb-plugin 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/src/folder_view.rb-plugin 1970-01-01 00:00:00.000000000 +0000 @@ -1,11 +0,0 @@ -[RB Plugin] -Loader=python -Module=FolderView -IAge=1 -Name=FolderView -Name[zh_CN]=文件夹视图 -Description=Browse music file with folder -Description[zh_CN]=文件夹式浏览音乐文件 -Authors=Imdiot -Copyright=Copyright © 2010 Imdiot -Website=http://code.google.com/p/folderview/ \ No newline at end of file diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/src/FolderViewSource.py rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/src/FolderViewSource.py --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/src/FolderViewSource.py 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/src/FolderViewSource.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,96 +0,0 @@ -#!/usr/bin/env python -#-*- coding: UTF-8 -*- - -import gobject -import gtk -import os -import gio -import urllib -import gconf -import rb,rhythmdb -import treefilebrowser -import logging,logging.handlers - -log=logging.getLogger('FolderView') -LAST_PATH_KEY = '/rhythmbox.plugin.FolderView.lastpath' - -class FolderViewSource(rb.BrowserSource): - #__gproperties__ = {'plugin': (rb.Plugin, 'plugin', 'plugin', gobject.PARAM_WRITABLE|gobject.PARAM_CONSTRUCT_ONLY),} - - def __init__(self): - rb.BrowserSource.__init__(self) - - self.shell = None - - self.g_client = gconf.client_get_default() - self.library_location = urllib.unquote(self.g_client.get_list('/apps/rhythmbox/library_locations', gconf.VALUE_STRING)[0]) - - def do_impl_activate(self): - log.info('Activate') - if self.shell == None: - self.shell = self.get_property('shell') - self.db = self.shell.get_property('db') - self.entry_type = self.get_property('entry-type') - self.entry_view = self.get_entry_view() - self.filebrowser.set_active_dir(gconf.client_get_default().get_without_default(LAST_PATH_KEY).get_string()) - - ui_browse=self.shell.get_ui_manager().get_widget('/ToolBar/Browse') - #ui_browse.set_sensitive(False) - ui_browse.hide() - #gconf.client_get_default().set_string(LAST_PATH_KEY,userName) - rb.BrowserSource.do_impl_activate(self) - - def do_impl_deactivate(self): - log.info('Deactivate') - ui_browse=self.shell.get_ui_manager().get_widget('/ToolBar/Browse') - ui_browse.show() - rb.BrowserSource.do_impl_deactivate(self) - #uim.get_widget('/ToolBar/Browse').set_sensitive(False) - - #def set_entry(self, uri): - # entry = self.db.entry_lookup_by_location(uri) - # if entry != None: - # if self.db.entry_get(entry, rhythmdb.PROP_DURATION) != 0: - # #self.props.query_model.add_entry(entry, 0) - # self.db.query_append(self.query, (rhythmdb.QUERY_PROP_SUFFIX, rhythmdb.PROP_LOCATION, self.db.entry_get(entry, rhythmdb.PROP_LOCATION))) - - def on_treeview_cursor_changed(self, widget): - for row in self.props.query_model: - entry = row[0] - self.props.query_model.remove_entry(entry) - - self.query = self.db.query_new() - song_type = self.db.entry_type_get_by_name('song') - path = self.filebrowser.get_selected() - gconf.client_get_default().set_string(LAST_PATH_KEY,path) - #for item in os.listdir(path): - # filename = os.path.join(path, item) - # if os.path.isfile(filename): - # tmp = str(path_to_uri(filename)) - #self.set_entry(path_to_uri(filename)) - self.db.query_append(self.query, (rhythmdb.QUERY_PROP_EQUALS, rhythmdb.PROP_TYPE, song_type)) - self.db.query_append(self.query, (rhythmdb.QUERY_PROP_PREFIX, rhythmdb.PROP_LOCATION, path_to_uri(path))) - self.db.do_full_query_parsed(self.props.query_model, self.query) - - if self.shell.props.shell_player.props.playing: - pass - else: - self.shell.props.shell_player.stop() - - def do_impl_pack_paned (self, paned): - self.__paned_box = gtk.HPaned() - self.filebrowser = treefilebrowser.TreeFileBrowser(self.library_location[7:]) - self.scrolled = self.filebrowser.get_scrolled() - self.scrolled.set_size_request(200,-1) - self.treeview = self.filebrowser.get_view() - self.treeview.connect('cursor-changed', self.on_treeview_cursor_changed) - self.pack_start(self.__paned_box) - self.__paned_box.add1(self.scrolled) - self.__paned_box.add2(paned) - - -def path_to_uri(path): - gfile = gio.File(path) - return gfile.get_uri() - -gobject.type_register(FolderViewSource) diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/src/treefilebrowser.py rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/src/treefilebrowser.py --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/src/treefilebrowser.py 2010-10-10 17:27:31.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/src/treefilebrowser.py 1970-01-01 00:00:00.000000000 +0000 @@ -1,487 +0,0 @@ -# -*- coding: utf-8 -*- - -""" -TreeFileBrowser a tree-like gtk file browser -Copyright (C) 2006-2008 Adolfo González Blázquez - -This library 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 library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - -If you find any bugs or have any suggestions email: code@infinicode.org -""" - -try: - import pygtk - pygtk.require('2.0') -except: - print "PyGtk 2.0 or later required for this app to run" - raise SystemExit - -try: - import gtk - import gobject -except: - raise SystemExit - -from gettext import gettext as _ - -try: - from os import path as ospath - import dircache -except: - raise SystemExit - -class TreeFileBrowser(gobject.GObject): - """ A widget that implements a tree-like file browser, like the - one used on Nautilus spatial view in list mode """ - - __gproperties__ = { - 'show-hidden': (gobject.TYPE_BOOLEAN, 'show hidden files', - 'show hidden files and folders', False, gobject.PARAM_READWRITE), - 'show-only-dirs': (gobject.TYPE_BOOLEAN, 'show only directories', - 'show only directories, not files', True, gobject.PARAM_READWRITE), - 'rules-hint': (gobject.TYPE_BOOLEAN, 'rules hint', - 'show rows background in alternate colors', True, gobject.PARAM_READWRITE), - 'root': (gobject.TYPE_STRING, 'initial path', - 'initial path selected on tree browser', '/', gobject.PARAM_READWRITE) - } - - __gsignals__ = { 'row-expanded' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)), - 'cursor-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)) - } - - def __init__(self, root=None): - """ Path is where we wan the tree initialized """ - - gobject.GObject.__init__(self) - - self.show_hidden = False - self.show_only_dirs = True - self.show_rules_hint = True - - self.root = '/' - if root != None and ospath.isdir(root): self.root = root - #elif root != None: print "ERROR: %s doesn't exist." % root - - self.view, self.scrolled = self.make_view() - self.create_new() - self.create_popup() - - ##################################################### - # Accessors and Mutators - - def do_get_property(self, property): - """ GObject get_property method """ - if property.name == 'show-hidden': - return self.show_hidden - elif property.name == 'show-only-dirs': - return self.show_only_dirs - elif property.name == 'rules-hint': - return self.show_rules_hint - elif property.name == 'path': - return self.root - else: - raise AttributeError, 'unknown property %s' % property.name - - def do_set_property(self, property, value): - """ GObject set_property method """ - if property.name == 'show-hidden': - self.show_hidden = value - elif property.name == 'show-only-dirs': - self.show_only_dirs = value - elif property.name == 'rules-hint': - self.show_rules_hint = value - elif property.name == 'path': - self.root = value - else: - raise AttributeError, 'unknown property %s' % property.name - - def get_view(self): - return self.view - - def get_scrolled(self): - return self.scrolled - - def set_show_hidden(self, hidden): - self.show_hidden = hidden - activedir = self.get_selected() - self.create_new() - if activedir != None: - if "/." in activedir: self.set_active_dir(self.root) - else: self.set_active_dir(activedir) - self.hidden_check_menu.set_active(hidden) - - def get_show_hidden(self): - return self.show_hidden - - def set_rules_hint(self, rules): - self.show_rules_hint = rules - self.view.set_rules_hint(rules) - - def get_rules_hint(self): - return self.show_rules_hint - - def set_show_only_dirs(self, only_dirs): - self.show_only_dirs = only_dirs - self.create_new() - - def get_show_only_dirs(self): - return self.show_only_dirs - - def get_selected(self): - """ Returns selected item in browser """ - model, iter = self.view.get_selection().get_selected() - if iter != None: - return model.get_value(iter, 2) - else: - return None - - - ##################################################### - # Callbacks - - def row_expanded(self, treeview, iter, path): - """ CALLBACK: a row is expanded """ - - model = treeview.get_model() - model.set_value(iter, 0, self.get_folder_opened_icon()) - self.get_file_list(model, iter, model.get_value(iter,2)) - self.remove_empty_child(model, iter) - - # Send signal with path of expanded row - self.emit('row-expanded', model.get_value(iter,2)) - - - def row_collapsed(self, treeview, iter, path): - """ CALLBACK: a row is collapsed """ - - model = treeview.get_model() - model.set_value(iter, 0, self.get_folder_closed_icon()) - while model.iter_has_child(iter): - child = model.iter_children(iter) - model.remove(child) - self.add_empty_child(model, iter) - - - def row_activated(self, treeview, path, view_column): - """ CALLBACK: row activated using return, double-click, shift-right, etc. """ - - if treeview.row_expanded(path): - treeview.collapse_row(path) - else: - treeview.expand_row(path, False) - - - def cursor_changed(self, treeview): - """ CALLBACK: a new row has been selected """ - model, iter = treeview.get_selection().get_selected() - - # Send signal with path of expanded row - if iter == None: - path = treeview.get_cursor()[0] - iter = self.model.get_iter(path) - - self.emit('cursor-changed', model.get_value(iter,2)) - - - def button_pressed(self, widget, event): - """ CALLBACK: clicked on widget """ - if event.button == 3: - x = int(event.x) - y = int(event.y) - time = event.time - pthinfo = self.view.get_path_at_pos(x, y) - if pthinfo is not None: - path, col, cellx, celly = pthinfo - #self.view.grab_focus() - #self.view.set_cursor( path, col, 0) - self.popup.popup( None, None, None, event.button, time) - return 1 - - def show_hidden_toggled(self, widget): - """ CALLBACK: Show hidden files on context menu toggled """ - state = widget.get_active() - self.set_show_hidden(state) - - - ##################################################### - # Directories and files, nodes and icons - - def set_cursor_on_first_row(self): - model = self.view.get_model() - iter = model.get_iter_root() - path = model.get_path(iter) - self.view.set_cursor(path) - - def check_active_dir(self, directory): - rootdir = self.root - if not ospath.isdir(directory): - return False - if not (rootdir in directory): - return False - if directory == rootdir: - return True - return True - - - def set_active_dir(self, directory): - - rootdir = self.root - - # Expand root - model = self.view.get_model() - iter = model.get_iter_root() - path = model.get_path(iter) - self.view.expand_row(path, False) - iter = model.iter_children(iter) - - # Add trailing / to paths - if len(directory) > 1 and directory[-1] != '/': directory += '/' - if len(rootdir) > 1 and rootdir[-1] != '/': rootdir += '/' - - if not ospath.isdir(directory): - #print "ERROR: %s doesn't exist." % directory - self.set_cursor_on_first_row() - return False - if not (rootdir in directory): - #print "ERROR: %s is not on root path." % directory - self.set_cursor_on_first_row() - return False - if directory == rootdir: - self.set_cursor_on_first_row() - return True - else: - - # Now we check if the desired dir is valid - # Convert the given '/home/user/dir/' to ['/', 'home/', 'user/', 'dir/'] - if len(directory) > 1: - dirtree = directory.split('/') - dirtree.pop(-1) - else: dirtree = ['/'] - if len(dirtree) > 1: - dirtree[0] = '/' - for i in range(len(dirtree)-1): dirtree[i+1] = dirtree[i+1] + '/' - - # Convert root to '/home/user/dir/' to ['/', 'home/', 'user/', 'dir/'] - if len(rootdir) > 1: - roottree = rootdir.split('/') - roottree.pop(-1) - else: roottree = ['/'] - if len(roottree) > 1: - roottree[0] = '/' - for i in range(len(roottree)-1): roottree[i+1] = roottree[i+1] + '/' - - # Check if the dir is in the same path as the desired root - long = len(roottree) - for i in range(long): - if roottree[i] != dirtree[i]: return False - - # End checking - - # Star expanding - # Count how many iterations we need - depth = len(dirtree) - len(roottree) - - # Expand baby expand! - exp = len(roottree) - for i in range(depth): - newpath = dirtree[i+exp] - if iter == None: continue - val = model.get_value(iter, 1).replace('/','') + '/' - while val != newpath: - iter = model.iter_next(iter) - val = model.get_value(iter, 1).replace('/','') + '/' - - path = model.get_path(iter) - self.view.expand_row(path, False) - iter = model.iter_children(iter) - - # Don't expand last row - self.view.collapse_row(path) - - # Set the cursor - self.view.set_cursor(path) - - return True - - - def add_empty_child(self, model, iter): - """ Adds a empty child to a node. - Used when we need a folder that have children to show the expander arrow """ - - model.insert_before(iter, None) - - - def remove_empty_child(self, model, iter): - """ Delete empty child from a node. - Used to remove the extra child used to show the expander arrow - on folders with children """ - - newiter = model.iter_children(iter) - model.remove(newiter) - - - def get_file_list(self, model, iter, dir): - """ Get the file list from a given directory """ - - ls = dircache.listdir(dir) - ls.sort(key=str.lower) - for i in ls: - path = ospath.join(dir,i) - if ospath.isdir(path) or not self.show_only_dirs : - if i[0] != '.' or (self.show_hidden and i[0] == '.'): - newiter = model.append(iter) - if ospath.isdir(path): icon = self.get_folder_closed_icon() - else: icon = self.get_file_icon() - model.set_value(newiter, 0, icon) - model.set_value(newiter, 1, i) - model.set_value(newiter, 2, path) - if ospath.isdir(path): - try: subdir = dircache.listdir(path) - except: subdir = [] - if subdir != []: - for i in subdir: - if ospath.isdir(ospath.join(path,i)) or not self.show_only_dirs: - if i[0] != '.' or (self.show_hidden and i[0] == '.'): - self.add_empty_child(model, newiter) - break - - def create_root(self): - - model = self.view.get_model() - - if self.root != '/': - if self.root[-1] == '/': self.root = self.root.rsplit('/',1)[0] # Remove last / if neccesary - directory = self.root.split('/')[-1] - else: directory = self.root - - iter = model.insert_before(None, None) - model.set_value(iter, 0, self.get_folder_opened_icon()) - model.set_value(iter, 1, directory) - model.set_value(iter, 2, self.root) - iter = model.insert_before(iter, None) - return iter - - def create_new(self): - """ Create tree from scratch """ - - model = self.view.get_model() - model.clear() - iter = self.create_root() - self.get_file_list(self.view.get_model(), iter, self.root) - - - def create_popup(self): - """ Create popup menu for right click """ - self.popup = gtk.Menu() - - self.hidden_check_menu = gtk.CheckMenuItem(_("Show hidden files")) - self.hidden_check_menu.connect('toggled', self.show_hidden_toggled) - - self.popup.add(self.hidden_check_menu) - self.popup.show_all() - - - def get_folder_closed_icon(self): - """ Returns a pixbuf with the current theme closed folder icon """ - - icon_theme = gtk.icon_theme_get_default() - try: - icon = icon_theme.load_icon("gnome-fs-directory", 16, 0) - return icon - except gobject.GError, exc: - #print "Can't load icon", exc - try: - icon = icon_theme.load_icon("gtk-directory", 16, 0) - return icon - except: - #print "Can't load default icon" - return None - - - def get_folder_opened_icon(self): - """ Returns a pixbuf with the current theme opened folder icon """ - - icon_theme = gtk.icon_theme_get_default() - try: - icon = icon_theme.load_icon("gnome-fs-directory-accept", 16, 0) - return icon - except gobject.GError, exc: - #print "Can't load icon", exc - try: - icon = icon_theme.load_icon("gtk-directory", 16, 0) - return icon - except: - #print "Can't load default icon" - return None - - - def get_file_icon(self): - """ Returns a pixbuf with the current theme file icon """ - - icon_theme = gtk.icon_theme_get_default() - try: - icon = icon_theme.load_icon("text-x-generic", gtk.ICON_SIZE_MENU, 0) - return icon - except gobject.GError, exc: - #print "Can't load icon", exc - return None - - - ##################################################### - # Model, treeview and scrolledwindow - - def make_view(self): - """ Create the view itself. - (Icon, dir name, path) """ - self.model = gtk.TreeStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING) - - view = gtk.TreeView(self.model) - view.set_headers_visible(False) - view.set_enable_search(True) - view.set_reorderable(False) - view.set_rules_hint(self.show_rules_hint) - view.connect('row-expanded', self.row_expanded) - view.connect('row-collapsed', self.row_collapsed) - view.connect('row-activated', self.row_activated) - view.connect('cursor-changed', self.cursor_changed) - view.connect('button_press_event', self.button_pressed) - - col = gtk.TreeViewColumn() - - # The icon - render_pixbuf = gtk.CellRendererPixbuf() - col.pack_start(render_pixbuf, expand=False) - col.add_attribute(render_pixbuf, 'pixbuf', 0) - - # The dir name - render_text = gtk.CellRendererText() - col.pack_start(render_text, expand=True) - col.add_attribute(render_text, 'text', 1) - - view.append_column(col) - view.show() - - # Create scrollbars around the view - scrolled = gtk.ScrolledWindow() - scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - scrolled.set_shadow_type(gtk.SHADOW_ETCHED_IN) - scrolled.add(view) - scrolled.show() - - return view, scrolled - -gobject.type_register(TreeFileBrowser) - -# End TreeFileBrowser diff -Nru rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/treefilebrowser.py rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/treefilebrowser.py --- rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1~karmic/treefilebrowser.py 1970-01-01 00:00:00.000000000 +0000 +++ rhythmbox-plugin-folderview-20101010.svn.r10ubuntu1+9+3~karmic1/treefilebrowser.py 2011-05-15 15:47:36.000000000 +0000 @@ -0,0 +1,487 @@ +# -*- coding: utf-8 -*- + +""" +TreeFileBrowser a tree-like gtk file browser +Copyright (C) 2006-2008 Adolfo González Blázquez + +This library 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 library 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +If you find any bugs or have any suggestions email: code@infinicode.org +""" + +try: + import pygtk + pygtk.require('2.0') +except: + print "PyGtk 2.0 or later required for this app to run" + raise SystemExit + +try: + import gtk + import gobject +except: + raise SystemExit + +from gettext import gettext as _ + +try: + from os import path as ospath + import dircache +except: + raise SystemExit + +class TreeFileBrowser(gobject.GObject): + """ A widget that implements a tree-like file browser, like the + one used on Nautilus spatial view in list mode """ + + __gproperties__ = { + 'show-hidden': (gobject.TYPE_BOOLEAN, 'show hidden files', + 'show hidden files and folders', False, gobject.PARAM_READWRITE), + 'show-only-dirs': (gobject.TYPE_BOOLEAN, 'show only directories', + 'show only directories, not files', True, gobject.PARAM_READWRITE), + 'rules-hint': (gobject.TYPE_BOOLEAN, 'rules hint', + 'show rows background in alternate colors', True, gobject.PARAM_READWRITE), + 'root': (gobject.TYPE_STRING, 'initial path', + 'initial path selected on tree browser', '/', gobject.PARAM_READWRITE) + } + + __gsignals__ = { 'row-expanded' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)), + 'cursor-changed' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, (gobject.TYPE_STRING,)) + } + + def __init__(self, root=None): + """ Path is where we wan the tree initialized """ + + gobject.GObject.__init__(self) + + self.show_hidden = False + self.show_only_dirs = True + self.show_rules_hint = True + + self.root = '/' + if root != None and ospath.isdir(root): self.root = root + #elif root != None: print "ERROR: %s doesn't exist." % root + + self.view, self.scrolled = self.make_view() + self.create_new() + self.create_popup() + + ##################################################### + # Accessors and Mutators + + def do_get_property(self, property): + """ GObject get_property method """ + if property.name == 'show-hidden': + return self.show_hidden + elif property.name == 'show-only-dirs': + return self.show_only_dirs + elif property.name == 'rules-hint': + return self.show_rules_hint + elif property.name == 'path': + return self.root + else: + raise AttributeError, 'unknown property %s' % property.name + + def do_set_property(self, property, value): + """ GObject set_property method """ + if property.name == 'show-hidden': + self.show_hidden = value + elif property.name == 'show-only-dirs': + self.show_only_dirs = value + elif property.name == 'rules-hint': + self.show_rules_hint = value + elif property.name == 'path': + self.root = value + else: + raise AttributeError, 'unknown property %s' % property.name + + def get_view(self): + return self.view + + def get_scrolled(self): + return self.scrolled + + def set_show_hidden(self, hidden): + self.show_hidden = hidden + activedir = self.get_selected() + self.create_new() + if activedir != None: + if "/." in activedir: self.set_active_dir(self.root) + else: self.set_active_dir(activedir) + self.hidden_check_menu.set_active(hidden) + + def get_show_hidden(self): + return self.show_hidden + + def set_rules_hint(self, rules): + self.show_rules_hint = rules + self.view.set_rules_hint(rules) + + def get_rules_hint(self): + return self.show_rules_hint + + def set_show_only_dirs(self, only_dirs): + self.show_only_dirs = only_dirs + self.create_new() + + def get_show_only_dirs(self): + return self.show_only_dirs + + def get_selected(self): + """ Returns selected item in browser """ + model, iter = self.view.get_selection().get_selected() + if iter != None: + return model.get_value(iter, 2) + else: + return None + + + ##################################################### + # Callbacks + + def row_expanded(self, treeview, iter, path): + """ CALLBACK: a row is expanded """ + + model = treeview.get_model() + model.set_value(iter, 0, self.get_folder_opened_icon()) + self.get_file_list(model, iter, model.get_value(iter,2)) + self.remove_empty_child(model, iter) + + # Send signal with path of expanded row + self.emit('row-expanded', model.get_value(iter,2)) + + + def row_collapsed(self, treeview, iter, path): + """ CALLBACK: a row is collapsed """ + + model = treeview.get_model() + model.set_value(iter, 0, self.get_folder_closed_icon()) + while model.iter_has_child(iter): + child = model.iter_children(iter) + model.remove(child) + self.add_empty_child(model, iter) + + + def row_activated(self, treeview, path, view_column): + """ CALLBACK: row activated using return, double-click, shift-right, etc. """ + + if treeview.row_expanded(path): + treeview.collapse_row(path) + else: + treeview.expand_row(path, False) + + + def cursor_changed(self, treeview): + """ CALLBACK: a new row has been selected """ + model, iter = treeview.get_selection().get_selected() + + # Send signal with path of expanded row + if iter == None: + path = treeview.get_cursor()[0] + iter = self.model.get_iter(path) + + self.emit('cursor-changed', model.get_value(iter,2)) + + + def button_pressed(self, widget, event): + """ CALLBACK: clicked on widget """ + if event.button == 3: + x = int(event.x) + y = int(event.y) + time = event.time + pthinfo = self.view.get_path_at_pos(x, y) + if pthinfo is not None: + path, col, cellx, celly = pthinfo + #self.view.grab_focus() + #self.view.set_cursor( path, col, 0) + self.popup.popup( None, None, None, event.button, time) + return 1 + + def show_hidden_toggled(self, widget): + """ CALLBACK: Show hidden files on context menu toggled """ + state = widget.get_active() + self.set_show_hidden(state) + + + ##################################################### + # Directories and files, nodes and icons + + def set_cursor_on_first_row(self): + model = self.view.get_model() + iter = model.get_iter_root() + path = model.get_path(iter) + self.view.set_cursor(path) + + def check_active_dir(self, directory): + rootdir = self.root + if not ospath.isdir(directory): + return False + if not (rootdir in directory): + return False + if directory == rootdir: + return True + return True + + + def set_active_dir(self, directory): + + rootdir = self.root + + # Expand root + model = self.view.get_model() + iter = model.get_iter_root() + path = model.get_path(iter) + self.view.expand_row(path, False) + iter = model.iter_children(iter) + + # Add trailing / to paths + if len(directory) > 1 and directory[-1] != '/': directory += '/' + if len(rootdir) > 1 and rootdir[-1] != '/': rootdir += '/' + + if not ospath.isdir(directory): + #print "ERROR: %s doesn't exist." % directory + self.set_cursor_on_first_row() + return False + if not (rootdir in directory): + #print "ERROR: %s is not on root path." % directory + self.set_cursor_on_first_row() + return False + if directory == rootdir: + self.set_cursor_on_first_row() + return True + else: + + # Now we check if the desired dir is valid + # Convert the given '/home/user/dir/' to ['/', 'home/', 'user/', 'dir/'] + if len(directory) > 1: + dirtree = directory.split('/') + dirtree.pop(-1) + else: dirtree = ['/'] + if len(dirtree) > 1: + dirtree[0] = '/' + for i in range(len(dirtree)-1): dirtree[i+1] = dirtree[i+1] + '/' + + # Convert root to '/home/user/dir/' to ['/', 'home/', 'user/', 'dir/'] + if len(rootdir) > 1: + roottree = rootdir.split('/') + roottree.pop(-1) + else: roottree = ['/'] + if len(roottree) > 1: + roottree[0] = '/' + for i in range(len(roottree)-1): roottree[i+1] = roottree[i+1] + '/' + + # Check if the dir is in the same path as the desired root + long = len(roottree) + for i in range(long): + if roottree[i] != dirtree[i]: return False + + # End checking + + # Star expanding + # Count how many iterations we need + depth = len(dirtree) - len(roottree) + + # Expand baby expand! + exp = len(roottree) + for i in range(depth): + newpath = dirtree[i+exp] + if iter == None: continue + val = model.get_value(iter, 1).replace('/','') + '/' + while val != newpath: + iter = model.iter_next(iter) + val = model.get_value(iter, 1).replace('/','') + '/' + + path = model.get_path(iter) + self.view.expand_row(path, False) + iter = model.iter_children(iter) + + # Don't expand last row + self.view.collapse_row(path) + + # Set the cursor + self.view.set_cursor(path) + + return True + + + def add_empty_child(self, model, iter): + """ Adds a empty child to a node. + Used when we need a folder that have children to show the expander arrow """ + + model.insert_before(iter, None) + + + def remove_empty_child(self, model, iter): + """ Delete empty child from a node. + Used to remove the extra child used to show the expander arrow + on folders with children """ + + newiter = model.iter_children(iter) + model.remove(newiter) + + + def get_file_list(self, model, iter, dir): + """ Get the file list from a given directory """ + + ls = dircache.listdir(dir) + ls.sort(key=str.lower) + for i in ls: + path = ospath.join(dir,i) + if ospath.isdir(path) or not self.show_only_dirs : + if i[0] != '.' or (self.show_hidden and i[0] == '.'): + newiter = model.append(iter) + if ospath.isdir(path): icon = self.get_folder_closed_icon() + else: icon = self.get_file_icon() + model.set_value(newiter, 0, icon) + model.set_value(newiter, 1, i) + model.set_value(newiter, 2, path) + if ospath.isdir(path): + try: subdir = dircache.listdir(path) + except: subdir = [] + if subdir != []: + for i in subdir: + if ospath.isdir(ospath.join(path,i)) or not self.show_only_dirs: + if i[0] != '.' or (self.show_hidden and i[0] == '.'): + self.add_empty_child(model, newiter) + break + + def create_root(self): + + model = self.view.get_model() + + if self.root != '/': + if self.root[-1] == '/': self.root = self.root.rsplit('/',1)[0] # Remove last / if neccesary + directory = self.root.split('/')[-1] + else: directory = self.root + + iter = model.insert_before(None, None) + model.set_value(iter, 0, self.get_folder_opened_icon()) + model.set_value(iter, 1, directory) + model.set_value(iter, 2, self.root) + iter = model.insert_before(iter, None) + return iter + + def create_new(self): + """ Create tree from scratch """ + + model = self.view.get_model() + model.clear() + iter = self.create_root() + self.get_file_list(self.view.get_model(), iter, self.root) + + + def create_popup(self): + """ Create popup menu for right click """ + self.popup = gtk.Menu() + + self.hidden_check_menu = gtk.CheckMenuItem(_("Show hidden files")) + self.hidden_check_menu.connect('toggled', self.show_hidden_toggled) + + self.popup.add(self.hidden_check_menu) + self.popup.show_all() + + + def get_folder_closed_icon(self): + """ Returns a pixbuf with the current theme closed folder icon """ + + icon_theme = gtk.icon_theme_get_default() + try: + icon = icon_theme.load_icon("gnome-fs-directory", 16, 0) + return icon + except gobject.GError, exc: + #print "Can't load icon", exc + try: + icon = icon_theme.load_icon("gtk-directory", 16, 0) + return icon + except: + #print "Can't load default icon" + return None + + + def get_folder_opened_icon(self): + """ Returns a pixbuf with the current theme opened folder icon """ + + icon_theme = gtk.icon_theme_get_default() + try: + icon = icon_theme.load_icon("gnome-fs-directory-accept", 16, 0) + return icon + except gobject.GError, exc: + #print "Can't load icon", exc + try: + icon = icon_theme.load_icon("gtk-directory", 16, 0) + return icon + except: + #print "Can't load default icon" + return None + + + def get_file_icon(self): + """ Returns a pixbuf with the current theme file icon """ + + icon_theme = gtk.icon_theme_get_default() + try: + icon = icon_theme.load_icon("text-x-generic", gtk.ICON_SIZE_MENU, 0) + return icon + except gobject.GError, exc: + #print "Can't load icon", exc + return None + + + ##################################################### + # Model, treeview and scrolledwindow + + def make_view(self): + """ Create the view itself. + (Icon, dir name, path) """ + self.model = gtk.TreeStore(gtk.gdk.Pixbuf, gobject.TYPE_STRING, gobject.TYPE_STRING) + + view = gtk.TreeView(self.model) + view.set_headers_visible(False) + view.set_enable_search(True) + view.set_reorderable(False) + view.set_rules_hint(self.show_rules_hint) + view.connect('row-expanded', self.row_expanded) + view.connect('row-collapsed', self.row_collapsed) + view.connect('row-activated', self.row_activated) + view.connect('cursor-changed', self.cursor_changed) + view.connect('button_press_event', self.button_pressed) + + col = gtk.TreeViewColumn() + + # The icon + render_pixbuf = gtk.CellRendererPixbuf() + col.pack_start(render_pixbuf, expand=False) + col.add_attribute(render_pixbuf, 'pixbuf', 0) + + # The dir name + render_text = gtk.CellRendererText() + col.pack_start(render_text, expand=True) + col.add_attribute(render_text, 'text', 1) + + view.append_column(col) + view.show() + + # Create scrollbars around the view + scrolled = gtk.ScrolledWindow() + scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + scrolled.set_shadow_type(gtk.SHADOW_ETCHED_IN) + scrolled.add(view) + scrolled.show() + + return view, scrolled + +gobject.type_register(TreeFileBrowser) + +# End TreeFileBrowser