diff --git a/ui/ChangeLog b/ui/ChangeLog index fe6fecce39ed496f641246eba2b3ec60e6f01316..c273db175cde300ce1bc66a1fdd7ff342b092fe8 100644 --- a/ui/ChangeLog +++ b/ui/ChangeLog @@ -1,3 +1,9 @@ +2005-03-05 Benedikt Meurer <benny@xfce.org> + + * ThunarColumnsView.py, ThunarView.py, ThunarWindow.py, thunar.ui: Add + a Columns View ala Aqua Finder. Note, that this Columns View is a + really bad hack, so don't complain about the bad usability. + 2005-03-04 Benedikt Meurer <benny@xfce.org> * ThunarHistory.py: Implement a more GtkFileChooser-like behaviour diff --git a/ui/ThunarColumnsView.py b/ui/ThunarColumnsView.py new file mode 100644 index 0000000000000000000000000000000000000000..c625e8884bf37cc188dee4501eae6e647bbf3cf6 --- /dev/null +++ b/ui/ThunarColumnsView.py @@ -0,0 +1,220 @@ +#!/usr/bin/env python +# vi:set ts=4 sw=4 et ai nocindent: +# +# $Id$ +# +# Copyright (c) 2005 Benedikt Meurer <benny@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 + +from ThunarFileInfo import ThunarFileInfo +from ThunarModel import ThunarModel +from ThunarView import ThunarView + + +class ThunarColumnsView(gtk.Viewport, ThunarView): + def __init__(self, info): + gtk.Viewport.__init__(self) + ThunarView.__init__(self) + + self.set_model(ThunarModel(info)) + + + def set_model(self, model): + # remove the old view (if any) + child = self.get_child() + if child: + child.destroy() + + self.__model = model + + box = gtk.HPaned() + self.add(box) + box.show() + + column = self.__create_column(model) + box.pack1(column, False, False) + column.show() + + expander = self.__create_column(None) + box.pack2(expander, True, True) + expander.show() + + column.set_data('thunar-box', box) + column.set_data('thunar-next', expander) + + + def get_model(self): + return self.__model + + + def get_selected_files(self): + return [] + + + def __selection_changed(self, view): + selection = view.get_selection() + model, iter = selection.get_selected() + if not iter: + return + + column = view.get_parent() + box = column.get_data('thunar-box') + next = column.get_data('thunar-next') + if next: + next.destroy() + + info = model.get(iter, ThunarModel.COLUMN_FILEINFO)[0] + if info.is_directory(): + box2 = gtk.HPaned() + box.pack2(box2, True, True) + box2.show() + + column.set_data('thunar-next', box2) + + column = self.__create_column(ThunarModel(info)) + box2.pack1(column, False, False) + column.show() + + expander = self.__create_column(None) + box2.pack2(expander, True, True) + expander.show() + + column.set_data('thunar-box', box2) + column.set_data('thunar-next', expander) + else: + ebox = gtk.EventBox() + ebox.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse('White')) + column.set_data('thunar-next', ebox) + box.pack2(ebox, True, False) + ebox.show() + + alignment = gtk.Alignment(0.5, 0.5, 0, 0) + ebox.add(alignment) + alignment.show() + + vbox = gtk.VBox(False, 12) + alignment.add(vbox) + vbox.show() + + image = gtk.Image() + image.set_from_pixbuf(info.render_icon(128)) + image.set_property('width-request', 168) + vbox.pack_start(image, False, False, 0) + image.show() + + label = gtk.Label(info.get_visible_name()) + vbox.pack_start(label, False, False, 0) + label.show() + + align = gtk.Alignment(0.5, 0.5) + vbox.pack_start(align, False, False, 0) + align.show() + + table = gtk.Table(3, 2, False) + table.set_col_spacings(6) + table.set_row_spacings(3) + align.add(table) + table.show() + + label = gtk.Label('<small>Kind:</small>') + label.set_use_markup(True) + label.set_alignment(1.0, 0.5) + table.attach(label, 0, 1, 0, 1, gtk.FILL, gtk.FILL) + label.show() + + label = gtk.Label('<small>%s</small>' % info.get_mime_info().get_comment()) + label.set_use_markup(True) + label.set_alignment(0.0, 0.5) + table.attach(label, 1, 2, 0, 1, gtk.FILL, gtk.FILL) + label.show() + + label = gtk.Label('<small>Size:</small>') + label.set_use_markup(True) + label.set_alignment(1.0, 0.5) + table.attach(label, 0, 1, 1, 2, gtk.FILL, gtk.FILL) + label.show() + + label = gtk.Label('<small>%s</small>' % info.get_size()) + label.set_use_markup(True) + label.set_alignment(0.0, 0.5) + table.attach(label, 1, 2, 1, 2, gtk.FILL, gtk.FILL) + label.show() + + self.get_hadjustment().set_value(self.get_hadjustment().upper) + + + def __create_column(self, model): + view = gtk.TreeView() + view.set_model(model) + + column = gtk.TreeViewColumn('Name') + renderer = gtk.CellRendererPixbuf() + column.pack_start(renderer, False) + column.add_attribute(renderer, 'pixbuf', ThunarModel.COLUMN_ICON) + renderer = gtk.CellRendererText() + column.pack_start(renderer, True) + column.add_attribute(renderer, 'text', ThunarModel.COLUMN_NAME) + column.set_resizable(True) + column.set_expand(True) + column.set_sizing(gtk.TREE_VIEW_COLUMN_AUTOSIZE) + view.append_column(column) + view.set_expander_column(column) + + view.set_rules_hint(False) + view.set_headers_visible(False) + + swin = gtk.ScrolledWindow() + swin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC) + swin.add(view) + view.show() + + view.connect('button-press-event', lambda view, event: self.__button_pressed(view, event)) + + selection = view.get_selection() + selection.connect('changed', lambda selection: self.__selection_changed(selection.get_tree_view())) + + return swin + + + def __button_pressed(self, view, event): + if event.button == 3 and event.type == gtk.gdk.BUTTON_PRESS: + path, column, x, y = view.get_path_at_pos(int(event.x), int(event.y)) + if path: + selection = view.get_selection() + if not selection.path_is_selected(path): + selection.unselect_all() + selection.select_path(path) + view.grab_focus() + self.context_menu() + return True + return False + + +gobject.type_register(ThunarColumnsView) +gobject.signal_new('activated', ThunarColumnsView, gobject.SIGNAL_RUN_LAST, \ + gobject.TYPE_NONE, [ThunarFileInfo]) +gobject.signal_new('context-menu', ThunarColumnsView, \ + gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []) +gobject.signal_new('selection-changed', ThunarColumnsView, \ + gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []) diff --git a/ui/ThunarView.py b/ui/ThunarView.py index e2fdc32652301652ad2fabb7f1fd22080d4c41c3..a5bf3cb8562be191325eb54ea38b8bbf79a23896 100644 --- a/ui/ThunarView.py +++ b/ui/ThunarView.py @@ -52,3 +52,4 @@ class ThunarView(gobject.GInterface): def selection_changed(self): self.emit('selection-changed') + diff --git a/ui/ThunarWindow.py b/ui/ThunarWindow.py index f307780d92f6a8bbe6238b5944bf3b0f63d3bd07..77d2837f7c3755ed847e79f4cbdd0ef077be887d 100644 --- a/ui/ThunarWindow.py +++ b/ui/ThunarWindow.py @@ -32,6 +32,7 @@ from ThunarModel import ThunarModel from ThunarHistory import ThunarHistory from ThunarFileInfo import ThunarFileInfo from ThunarListView import ThunarListView +from ThunarColumnsView import ThunarColumnsView from ThunarSidePane import ThunarSidePane from ThunarPropertiesDialog import ThunarPropertiesDialog @@ -91,9 +92,10 @@ class ThunarWindow(gtk.Window): ('view-toolbars', None, 'Show Toolbars', None, None, lambda ign, self: self._action_show_toolbars(), True), ], self) self.action_group.add_radio_actions([ - ('view-as-icons', None, 'View as _Icons'), + ('view-as-icons', None, 'View as _Icons', None, None, 1), ('view-as-list', None, 'View as _List'), - ], 0, lambda action, whatever, self: self._action_view_toggled(), self) + ('view-as-columns', None, 'View as _Columns'), + ], 1, lambda action, whatever, self: self._action_view_toggled(), self) self.action_group.add_actions([ ('go-menu', None, '_Go'), ('go-up', gtk.STOCK_GO_UP, '_Up', '<Alt>Up', None, lambda ign, self: self._action_open_dir(self.info.get_parent())), @@ -209,8 +211,10 @@ class ThunarWindow(gtk.Window): other.destroy() if self.action_group.get_action('view-as-icons').get_active(): self.view = ThunarIconView(self.info) - else: + elif self.action_group.get_action('view-as-list').get_active(): self.view = ThunarListView(self.info) + else: + self.view = ThunarColumnsView(self.info) self.view.connect('context-menu', lambda view: self._context_menu()) self.view.connect('activated', lambda widget, info: self._action_open_dir(info)) self.view.connect('selection-changed', lambda widget: self._selection_changed()) diff --git a/ui/thunar.ui b/ui/thunar.ui index 620992b3753ffeda2202b120971849c34608c90d..ed9e8c28991d254e468d0b85c1f58efad91f0213 100644 --- a/ui/thunar.ui +++ b/ui/thunar.ui @@ -70,6 +70,7 @@ <menuitem action="view-as-icons" /> <menuitem action="view-as-list" /> + <menuitem action="view-as-columns" /> </menu> <menu action="go-menu">