[Thunar-workers] CVS: design/ui ThunarHistory.py, NONE, 1.1 ChangeLog, 1.12, 1.13 ThunarBookmarksPane.py, 1.3, 1.4 ThunarSidePane.py, 1.2, 1.3 ThunarWindow.py, 1.7, 1.8 thunar.ui, 1.4, 1.5

Benedikt Meurer benny at xfce.org
Fri Mar 4 20:14:19 CET 2005


Update of /var/cvs/thunar/design/ui
In directory espresso.foo-projects.org:/tmp/cvs-serv1489

Modified Files:
	ChangeLog ThunarBookmarksPane.py ThunarSidePane.py 
	ThunarWindow.py thunar.ui 
Added Files:
	ThunarHistory.py 
Log Message:
2005-03-04	Benedikt Meurer <benny at xfce.org>

	* ThunarBookmarksPane.py: Do not include Desktop here, as its highly
	  redundant and useless in the normal window view. Get the GType
	  handling right.
	* ThunarSidePane.y: Get The GType handling right.
	* ThunarHistory.py, ThunarSidePane.py, ThunarWindow.py, thunar.ui: Add
	  GtkFileChooser-like view, changable using the View-menu.




--- NEW FILE: ThunarHistory.py ---
#!/usr/bin/env python
# vi:set ts=4 sw=4 et ai nocindent:
#
# $Id: ThunarHistory.py,v 1.1 2005/03/04 19:14:17 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 ThunarHistory(gtk.HBox):
    def __init__(self):
        gtk.HBox.__init__(self)
        self.set_spacing(2)

        self.__info = None


    def get_info(self, info):
        return self.__info


    def set_info(self, info):
        # 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 == self.__info:
                button = gtk.ToggleButton()
                button.set_active(True)
            else:
                button = gtk.Button()
            button.set_data('thunar-info', info)
            button.connect('clicked', lambda button: self.emit('directory-changed', 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 == self.__info:
                text = '<b>%s</b>' % name
            else:
                text = name

            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()



gobject.type_register(ThunarHistory)
gobject.signal_new('directory-changed', ThunarHistory, \
                   gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, \
                   [ThunarFileInfo])


Index: ChangeLog
===================================================================
RCS file: /var/cvs/thunar/design/ui/ChangeLog,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- ChangeLog	3 Mar 2005 22:35:09 -0000	1.12
+++ ChangeLog	4 Mar 2005 19:14:17 -0000	1.13
@@ -1,3 +1,12 @@
+2005-03-04	Benedikt Meurer <benny at xfce.org>
+
+	* ThunarBookmarksPane.py: Do not include Desktop here, as its highly
+	  redundant and useless in the normal window view. Get the GType
+	  handling right.
+	* ThunarSidePane.y: Get The GType handling right.
+	* ThunarHistory.py, ThunarSidePane.py, ThunarWindow.py, thunar.ui: Add
+	  GtkFileChooser-like view, changable using the View-menu.
+
 2005-03-03	Benedikt Meurer <benny at xfce.org>
 
 	* ThunarBookmarksPane.py: Increase the icon size to 32.
@@ -85,3 +94,5 @@
 2005-02-14	Benedikt Meurer <benny at xfce.org>
 
 	* Initial import.
+
+# vi:set ts=8 sw=8 noet ai:

Index: ThunarBookmarksPane.py
===================================================================
RCS file: /var/cvs/thunar/design/ui/ThunarBookmarksPane.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ThunarBookmarksPane.py	3 Mar 2005 22:35:09 -0000	1.3
+++ ThunarBookmarksPane.py	4 Mar 2005 19:14:17 -0000	1.4
@@ -31,8 +31,6 @@
 
 from ThunarFileInfo import ThunarFileInfo
 
-signals_registered = False
-
 class ThunarBookmarksPane(gtk.TreeView):
     COLUMN_NAME = 0
     COLUMN_ICON = 1
@@ -44,13 +42,6 @@
     def __init__(self):
         gtk.TreeView.__init__(self, self._create_model())
 
-        # register signals
-        global signals_registered
-        if not signals_registered:
-            gobject.signal_new('directory-changed1', self, gobject.SIGNAL_RUN_LAST, \
-                               gobject.TYPE_NONE, [ThunarFileInfo])
-            signals_registered = True
-
         column = gtk.TreeViewColumn('Name')
         renderer = gtk.CellRendererPixbuf()
         column.pack_start(renderer, False)
@@ -74,7 +65,7 @@
 
         home = os.getenv('HOME')
 
-        for path in [home, os.path.join(home, 'Desktop'), '/']:
+        for path in [home, '/']:
             try:
                 info = ThunarFileInfo(path)
                 self.model.append([info.get_visible_name(), info.render_icon(self.ICON_SIZE), info])
@@ -116,3 +107,12 @@
                 self.get_selection().select_path(path)
                 return
             iter = self.model.iter_next(iter)
+
+
+
+
+gobject.type_register(ThunarBookmarksPane)
+gobject.signal_new('directory-changed1', ThunarBookmarksPane, \
+                   gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, \
+                   [ThunarFileInfo])
+

Index: ThunarSidePane.py
===================================================================
RCS file: /var/cvs/thunar/design/ui/ThunarSidePane.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ThunarSidePane.py	3 Mar 2005 00:16:18 -0000	1.2
+++ ThunarSidePane.py	4 Mar 2005 19:14:17 -0000	1.3
@@ -33,8 +33,6 @@
 from ThunarTreePane import ThunarTreePane
 from ThunarBookmarksPane import ThunarBookmarksPane
 
-signals_registered = False
-
 class ThunarSidePane(gtk.VBox):
     DISABLED = 0
     TREE = 1
@@ -42,27 +40,17 @@
 
     def __init__(self):
         gtk.VBox.__init__(self)
+        self.set_spacing(0)
 
-        #self.set_size_request(150, -1)
-
-        # register signals
-        global signals_registered
-        if not signals_registered:
-            gobject.signal_new('directory-changed', self, gobject.SIGNAL_RUN_LAST, \
-                               gobject.TYPE_NONE, [ThunarFileInfo])
-            gobject.signal_new('hide-sidepane', self, gobject.SIGNAL_RUN_LAST, \
-                               gobject.TYPE_NONE, [])
-            signals_registered = True
-
-        frame = gtk.Frame()
-        frame.set_border_width(0)
-        frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
-        self.pack_start(frame, False, False, 0)
-        frame.show()
+        self.frame = gtk.Frame()
+        self.frame.set_border_width(0)
+        self.frame.set_shadow_type(gtk.SHADOW_ETCHED_IN)
+        self.pack_start(self.frame, False, False, 0)
+        self.frame.show()
 
         hbox = gtk.HBox(False, 6)
         hbox.set_border_width(0)
-        frame.add(hbox)
+        self.frame.add(hbox)
         hbox.show()
 
         self.label = gtk.Label('')
@@ -92,6 +80,15 @@
         self.emit('directory-changed', info)
 
 
+    def set_gtkfilechooser_like(self, value):
+        if value:
+            self.frame.hide()
+            self.swin.set_shadow_type(gtk.SHADOW_ETCHED_IN)
+        else:
+            self.frame.show()
+            self.swin.set_shadow_type(gtk.SHADOW_NONE)
+
+
     def set_state(self, state):
         if self.child:
             self.child.destroy()
@@ -122,3 +119,12 @@
             self.child.select_by_info(info)
             self.child.handler_unblock(self.handler_id)
 
+
+
+gobject.type_register(ThunarSidePane)
+gobject.signal_new('directory-changed', ThunarSidePane, \
+                   gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, \
+                   [ThunarFileInfo])
+gobject.signal_new('hide-sidepane', ThunarSidePane, \
+                   gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
+

Index: ThunarWindow.py
===================================================================
RCS file: /var/cvs/thunar/design/ui/ThunarWindow.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ThunarWindow.py	3 Mar 2005 19:11:22 -0000	1.7
+++ ThunarWindow.py	4 Mar 2005 19:14:17 -0000	1.8
@@ -29,6 +29,7 @@
 import gtk
 
 from ThunarModel import ThunarModel
+from ThunarHistory import ThunarHistory
 from ThunarFileInfo import ThunarFileInfo
 from ThunarListView import ThunarListView
 from ThunarSidePane import ThunarSidePane
@@ -85,6 +86,10 @@
             ('sidebar-shortcuts', 'thunar-shortcuts', 'Shortcuts', None, 'Display the shortcuts on the left', 2),
             ('sidebar-disabled', None, 'Hidden', None, 'Hide the sidebar', 3),
         ], 2, lambda action, whatever, self: self._action_sidebar_toggled(), self)
+        self.action_group.add_toggle_actions([
+            ('view-gtkfilechooser', None, 'GtkFileChooser-like', None, None, lambda ign, self: self._action_gtkfilechooser_like()),
+            ('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-list', None, 'View as _List'),
@@ -153,9 +158,20 @@
         self.main_hbox.pack1(self.sidepane, False, False)
         self.sidepane.show()
 
+        vbox = gtk.VBox(False, 6)
+        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.hide()
+
         self.swin = gtk.ScrolledWindow(None, None)
         self.swin.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
-        self.main_hbox.pack2(self.swin, True, False)
+        self.swin.set_shadow_type(gtk.SHADOW_IN)
+        vbox.pack_start(self.swin, True, True, 0)
         self.swin.show()
 
         if icon_view_support:
@@ -202,6 +218,17 @@
         self.view.show()
 
 
+    def _action_gtkfilechooser_like(self):
+        value = self.action_group.get_action('view-gtkfilechooser').get_active()
+        self.sidepane.set_gtkfilechooser_like(value)
+        if value:
+            self.history.show()
+            self.main_hbox.set_border_width(6)
+        else:
+            self.history.hide()
+            self.main_hbox.set_border_width(0)
+
+
     def _action_sidebar_toggled(self):
         if self.action_group.get_action('sidebar-tree').get_active():
             self.sidepane.set_state(ThunarSidePane.TREE)
@@ -212,6 +239,13 @@
         self.sidepane.select_by_info(self.info)
 
 
+    def _action_show_toolbars(self):
+        if self.action_group.get_action('view-toolbars').get_active():
+            self.ui_manager.get_widget('/main-toolbar').show()
+        else:
+            self.ui_manager.get_widget('/main-toolbar').hide()
+
+
     def _action_get_info(self):
         infos = self.view.get_selected_files()
         for info in infos:
@@ -261,6 +295,8 @@
         self.sidepane.select_by_info(info)
         self.sidepane.handler_unblock(self.sidepane_selection_id)
 
+        self.history.set_info(info)
+
         # scroll to (0,0)
         self.swin.get_hadjustment().set_value(0)
         self.swin.get_vadjustment().set_value(0)

Index: thunar.ui
===================================================================
RCS file: /var/cvs/thunar/design/ui/thunar.ui,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- thunar.ui	3 Mar 2005 00:16:19 -0000	1.4
+++ thunar.ui	4 Mar 2005 19:14:17 -0000	1.5
@@ -63,6 +63,11 @@
 
       <separator />
 
+      <menuitem action="view-toolbars" />
+      <menuitem action="view-gtkfilechooser" />
+
+      <separator />
+
       <menuitem action="view-as-icons" />
       <menuitem action="view-as-list" />
     </menu>




More information about the Thunar-workers mailing list