[Thunar-workers] CVS: design/ui ThunarImageLoader.py, NONE, 1.1 ThunarPathBar.py, NONE, 1.1 ChangeLog, 1.18, 1.19 ThunarBookmarksPane.py, 1.4, 1.5 ThunarFileInfo.py, 1.2, 1.3 ThunarMimeDatabase.py, 1.2, 1.3 ThunarPropertiesDialog.py, 1.7, 1.8 ThunarWindow.py, 1.10, 1.11 ThunarHistory.py, 1.2, NONE
Benedikt Meurer
benny at xfce.org
Sun Mar 6 16:25:59 CET 2005
Update of /var/cvs/thunar/design/ui
In directory espresso.foo-projects.org:/tmp/cvs-serv1610
Modified Files:
ChangeLog ThunarBookmarksPane.py ThunarFileInfo.py
ThunarMimeDatabase.py ThunarPropertiesDialog.py
ThunarWindow.py
Added Files:
ThunarImageLoader.py ThunarPathBar.py
Removed Files:
ThunarHistory.py
Log Message:
2005-03-06 Benedikt Meurer <benny at xfce.org>
* ThunarFileInfo.py, ThunarImageLoader.py, ThunarMimeDatabase.py: Add
a separate image loader class with caching.
* ThunarWindow.py, ThunarPathBar.py: Rename the ThunarHistory class
to ThunarPathBar.
* ThunarBookmarksPane.py: Re-Add the 'Desktop' bookmark.
* ThunarMimeDatabase.py, ThunarFileInfo.py: Add caching for the MIME
database.
* ThunarFileInfo.py: Support loading of existing thumbnails.
* ThunarPropertiesDialog.py: Connect the 'Text view' in the
'Permissions' tab.
--- NEW FILE: ThunarImageLoader.py ---
#!/usr/bin/env python
# vi:set ts=4 sw=4 et ai nocindent:
#
# $Id: ThunarImageLoader.py,v 1.1 2005/03/06 15:25:56 benny Exp $
#
# Copyright (c) 2005 Benedikt Meurer <benny at xfce.org>
# All rights reserved.
#
# 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, 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 pygtk
pygtk.require('2.0')
import gobject
import gtk
__ALL__ = [ 'get_default' ]
default_loader = None
def get_default():
global default_loader
if not default_loader:
default_loader = ThunarImageLoader()
return default_loader
class ThunarImageLoader:
def __init__(self):
self.__theme = gtk.icon_theme_get_default()
self.__cache = {}
def load_icon(self, name, size):
key = '%s@%sx%s' % (name, size, size)
if self.__cache.has_key(key):
icon = self.__cache[key]
else:
icon = self.__theme.load_icon(name, size, 0)
self.__cache[key] = icon
return icon
--- NEW FILE: ThunarPathBar.py ---
#!/usr/bin/env python
# vi:set ts=4 sw=4 et ai nocindent:
#
# $Id: ThunarPathBar.py,v 1.1 2005/03/06 15:25:56 benny Exp $
#
# Copyright (c) 2005 Benedikt Meurer <benny at xfce.org>
# All rights reserved.
#
# 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, 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 os
import pygtk
pygtk.require('2.0')
import gobject
import gtk
from ThunarFileInfo import ThunarFileInfo
class ThunarPathBar(gtk.HBox):
def __init__(self):
gtk.HBox.__init__(self)
self.set_spacing(2)
self.__info = None
self.__rebuild_disabled = False
def __clicked(self, info):
self.__rebuild(self.__info, info)
self.__rebuild_disabled = True
self.emit('directory-changed', info)
self.__rebuild_disabled = False
def __rebuild(self, info, selected_info):
if self.__rebuild_disabled:
return
# remove all existing buttons
self.foreach(lambda child: child.destroy())
icon_size = gtk.icon_size_lookup(gtk.ICON_SIZE_BUTTON)[0]
align = gtk.Alignment(1.0, 1.0, 1.0, 1.0)
align.set_property('width-request', 16)
self.pack_start(align, False, False, 0)
align.show()
self.__info = info
while info:
if info.get_path() == selected_info.get_path():
button = gtk.ToggleButton()
button.set_active(True)
else:
button = gtk.Button()
button.set_data('thunar-info', info)
button.connect('clicked', lambda button: self.__clicked(button.get_data('thunar-info')))
self.pack_start(button, False, False, 0)
self.reorder_child(button, 0)
button.show()
if info.get_path() == '/':
image = gtk.Image()
image.set_from_pixbuf(info.render_icon(icon_size))
button.add(image)
image.show()
break
hbox = gtk.HBox(False, 2)
button.add(hbox)
hbox.show()
image = gtk.Image()
image.set_from_pixbuf(info.render_icon(icon_size))
hbox.pack_start(image, False, False, 0)
image.show()
if info.is_home():
name = 'Home'
elif info.is_desktop():
name = 'Desktop'
else:
name = info.get_visible_name()
if info.get_path() == selected_info.get_path():
text = '<b>%s</b>' % name.replace('&', '&')
else:
text = name.replace('&', '&')
label = gtk.Label(text)
label.set_use_markup(True)
hbox.pack_start(label, True, True, 0)
label.show()
if info.is_home() or info.is_desktop():
break
info = info.get_parent()
def get_info(self, info):
return self.__info
def set_info(self, info):
self.__rebuild(info, info)
gobject.type_register(ThunarPathBar)
gobject.signal_new('directory-changed', ThunarPathBar, \
gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, \
[ThunarFileInfo])
Index: ChangeLog
===================================================================
RCS file: /var/cvs/thunar/design/ui/ChangeLog,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- ChangeLog 6 Mar 2005 11:55:38 -0000 1.18
+++ ChangeLog 6 Mar 2005 15:25:56 -0000 1.19
@@ -1,5 +1,18 @@
2005-03-06 Benedikt Meurer <benny at xfce.org>
+ * ThunarFileInfo.py, ThunarImageLoader.py, ThunarMimeDatabase.py: Add
+ a separate image loader class with caching.
+ * ThunarWindow.py, ThunarPathBar.py: Rename the ThunarHistory class
+ to ThunarPathBar.
+ * ThunarBookmarksPane.py: Re-Add the 'Desktop' bookmark.
+ * ThunarMimeDatabase.py, ThunarFileInfo.py: Add caching for the MIME
+ database.
+ * ThunarFileInfo.py: Support loading of existing thumbnails.
+ * ThunarPropertiesDialog.py: Connect the 'Text view' in the
+ 'Permissions' tab.
+
+2005-03-06 Benedikt Meurer <benny at xfce.org>
+
* ThunarWindow.py: Make the GtkFileChooser-like layout the default.
2005-03-05 Benedikt Meurer <benny at xfce.org>
Index: ThunarBookmarksPane.py
===================================================================
RCS file: /var/cvs/thunar/design/ui/ThunarBookmarksPane.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ThunarBookmarksPane.py 4 Mar 2005 19:14:17 -0000 1.4
+++ ThunarBookmarksPane.py 6 Mar 2005 15:25:56 -0000 1.5
@@ -65,7 +65,7 @@
home = os.getenv('HOME')
- for path in [home, '/']:
+ for path in [home, os.path.join(home, 'Desktop'), '/']:
try:
info = ThunarFileInfo(path)
self.model.append([info.get_visible_name(), info.render_icon(self.ICON_SIZE), info])
Index: ThunarFileInfo.py
===================================================================
RCS file: /var/cvs/thunar/design/ui/ThunarFileInfo.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ThunarFileInfo.py 3 Mar 2005 22:35:09 -0000 1.2
+++ ThunarFileInfo.py 6 Mar 2005 15:25:56 -0000 1.3
@@ -29,12 +29,14 @@
import gobject
import gtk
-from ThunarMimeDatabase import ThunarMimeDatabase
+import ThunarImageLoader
+
+import ThunarMimeDatabase
class ThunarFileInfo(gobject.GObject):
def __init__(self, path):
gobject.GObject.__init__(self)
- self.mimedb = ThunarMimeDatabase()
+ self.mimedb = ThunarMimeDatabase.get_default()
# build up a normalized path
self.path = ''
@@ -50,22 +52,35 @@
self.stat = os.lstat(self.path)
+ def __try_thumbnail(self, size):
+ import md5
+ uri = 'file://' + self.path
+ name = md5.new(uri).hexdigest() + '.png'
+ path = os.path.join(os.getenv('HOME'), '.thumbnails', 'normal', name)
+ return gtk.gdk.pixbuf_new_from_file_at_size(path, size, size)
+
+
def render_icon(self, size):
- theme = gtk.icon_theme_get_default()
+ loader = ThunarImageLoader.get_default()
icon = None
try:
- if self.is_home(): icon = theme.load_icon('gnome-fs-home', size, 0)
+ if self.is_home(): icon = loader.load_icon('gnome-fs-home', size)
except:
pass
try:
- if not icon and self.is_desktop(): icon = theme.load_icon('gnome-fs-desktop', size, 0)
+ if not icon and self.is_desktop(): icon = loader.load_icon('gnome-fs-desktop', size)
except:
pass
try:
- if not icon and self.path == '/': icon = theme.load_icon('gnome-dev-harddisk', size, 0)
+ if not icon and self.path == '/': icon = loader.load_icon('gnome-dev-harddisk', size)
except:
pass
if not icon:
+ try:
+ icon = self.__try_thumbnail(size)
+ except:
+ pass
+ if not icon:
icon = self.get_mime_info().render_icon(size)
return icon
Index: ThunarMimeDatabase.py
===================================================================
RCS file: /var/cvs/thunar/design/ui/ThunarMimeDatabase.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ThunarMimeDatabase.py 4 Mar 2005 21:16:50 -0000 1.2
+++ ThunarMimeDatabase.py 6 Mar 2005 15:25:56 -0000 1.3
@@ -29,46 +29,73 @@
import rox, rox.mime
+import ThunarImageLoader
+
+
+__ALL__ = [ 'get_default' ]
+
+
+default_database = None
+def get_default():
+ global default_database
+ if not default_database:
+ default_database = ThunarMimeDatabase()
+ return default_database
+
+
class ThunarMimeDatabase:
+ def __init__(self):
+ self.__cache = {}
+
+
def match(self, path):
type = rox.mime.get_type(path)
- return ThunarMimeInfo(type)
+ name = '%s' % type
+ if self.__cache.has_key(name):
+ type = self.__cache[name]
+ else:
+ type = ThunarMimeInfo(type)
+ self.__cache[name] = type
+ return type
+
class ThunarMimeInfo:
def __init__(self, type):
- self.theme = gtk.icon_theme_get_default()
- self.type = type
+ self.__loader = ThunarImageLoader.get_default()
+ self.__type = type
+
def get_comment(self):
- return self.type.get_comment()
+ return self.__type.get_comment()
+
def render_icon(self, size):
- type = '%s' % self.type
+ type = '%s' % self.__type
try:
name = 'mime-' + type.replace('/', ':')
- icon = self.theme.load_icon(name, size, 0)
+ icon = self.__loader.load_icon(name, size)
except gobject.GError:
try:
name = 'gnome-mime-' + type.replace('/', '-')
- icon = self.theme.load_icon(name, size, 0)
+ icon = self.__loader.load_icon(name, size)
except gobject.GError:
try:
name = 'mime-' + type.split('/')[0]
- icon = self.theme.load_icon(name, size, 0)
+ icon = self.__loader.load_icon(name, size)
except gobject.GError:
try:
name = 'gnome-mime-' + type.split('/')[0]
- icon = self.theme.load_icon(name, size, 0)
+ icon = self.__loader.load_icon(name, size)
except gobject.GError:
try:
name = 'mime-application:octet-stream'
- icon = self.theme.load_icon(name, size, 0)
+ icon = self.__loader.load_icon(name, size)
except gobject.GError:
try:
name = 'gnome-mime-application-octet-stream'
- icon = self.theme.load_icon(name, size, 0)
+ icon = self.__loader.load_icon(name, size)
except gobject.GError:
icon = gtk.gdk.pixbuf_new_from_file_at_size('fallback.svg', size, size)
return icon
Index: ThunarPropertiesDialog.py
===================================================================
RCS file: /var/cvs/thunar/design/ui/ThunarPropertiesDialog.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ThunarPropertiesDialog.py 3 Mar 2005 22:35:09 -0000 1.7
+++ ThunarPropertiesDialog.py 6 Mar 2005 15:25:56 -0000 1.8
@@ -408,7 +408,7 @@
table.attach(label, 0, 1, row, row + 1, gtk.FILL, gtk.FILL)
label.show()
- label = gtk.Label('-rw-r--r--')
+ label = gtk.Label(info.get_permissions())
label.set_alignment(0.0, 0.5)
table.attach(label, 1, 4, row, row + 1, gtk.EXPAND | gtk.FILL, gtk.FILL)
label.show()
Index: ThunarWindow.py
===================================================================
RCS file: /var/cvs/thunar/design/ui/ThunarWindow.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ThunarWindow.py 6 Mar 2005 11:55:38 -0000 1.10
+++ ThunarWindow.py 6 Mar 2005 15:25:56 -0000 1.11
@@ -29,7 +29,7 @@
import gtk
from ThunarModel import ThunarModel
-from ThunarHistory import ThunarHistory
+from ThunarPathBar import ThunarPathBar
from ThunarFileInfo import ThunarFileInfo
from ThunarListView import ThunarListView
from ThunarColumnsView import ThunarColumnsView
@@ -165,11 +165,11 @@
self.main_hbox.pack2(vbox, True, False)
vbox.show()
- self.history = ThunarHistory()
- self.history.set_info(self.info)
- self.history.connect('directory-changed', lambda history, info: self._action_open_dir(info))
- vbox.pack_start(self.history, False, False, 0)
- self.history.show()
+ self.pathbar = ThunarPathBar()
+ self.pathbar.set_info(self.info)
+ self.pathbar.connect('directory-changed', lambda history, info: self._action_open_dir(info))
+ vbox.pack_start(self.pathbar, False, False, 0)
+ self.pathbar.show()
self.swin = gtk.ScrolledWindow(None, None)
self.swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
@@ -227,10 +227,10 @@
value = self.action_group.get_action('view-gtkfilechooser').get_active()
self.sidepane.set_gtkfilechooser_like(value)
if value:
- self.history.show()
+ self.pathbar.show()
self.main_hbox.set_border_width(6)
else:
- self.history.hide()
+ self.pathbar.hide()
self.main_hbox.set_border_width(0)
@@ -300,7 +300,7 @@
self.sidepane.select_by_info(info)
self.sidepane.handler_unblock(self.sidepane_selection_id)
- self.history.set_info(info)
+ self.pathbar.set_info(info)
# scroll to (0,0)
self.swin.get_hadjustment().set_value(0)
--- ThunarHistory.py DELETED ---
More information about the Thunar-workers
mailing list