107
109
self.combobox_drive = gtk.combo_box_new_text()
108
110
self.combobox_drive.connect("changed", self._refresh_drives)
112
# Get the navigation widgets
113
self.button_location_up = self.toplevel.get_widget('button_location_up')
114
self.button_location_jump = self.toplevel.get_widget('button_location_jump')
115
self.entry_location = self.toplevel.get_widget('entry_location')
116
self.image_location_error = self.toplevel.get_widget('image_location_error')
110
118
self.vbox_main_right = self.toplevel.get_widget('vbox_main_right')
113
120
# Dictionary for signal_autoconnect
114
121
dic = { "on_window_main_destroy": gtk.main_quit,
148
155
"on_treeview_right_button_press_event": self.on_treeview_right_button_press_event,
149
156
"on_treeview_right_row_activated": self.on_treeview_right_row_activated,
150
157
"on_treeview_left_button_press_event": self.on_treeview_left_button_press_event,
151
"on_treeview_left_row_activated": self.on_treeview_left_row_activated }
158
"on_treeview_left_row_activated": self.on_treeview_left_row_activated,
159
"on_button_location_up_clicked": self.on_button_location_up_clicked,
160
"on_button_location_jump_clicked": self.on_button_location_jump_clicked,
161
"on_entry_location_key_press_event": self.on_entry_location_key_press_event
153
164
# Connect the signals to the handlers
154
165
self.toplevel.signal_autoconnect(dic)
200
211
self.notbranch = True
202
213
self.statusbar.push(self.context_id, path)
214
self.entry_location.set_text(path)
216
# If we're in the root, we cannot go up anymore
217
if sys.platform == 'win32':
218
drive, tail = os.path.splitdrive(self.path)
219
if tail in ('', '/', '\\'):
220
self.button_location_up.set_sensitive(False)
222
self.button_location_up.set_sensitive(True)
225
self.button_location_up.set_sensitive(False)
227
self.button_location_up.set_sensitive(True)
204
229
def get_path(self):
208
233
from bzrlib.plugins.gtk.dialog import about
236
def on_button_location_up_clicked(self, widget):
237
""" Location Up button handler. """
238
self.set_path(os.path.split(self.get_path())[0])
241
def on_button_location_jump_clicked(self, widget):
242
""" Location Jump button handler. """
243
location = self.entry_location.get_text()
244
if os.path.isdir(location):
245
self.set_path(location)
247
self.image_location_error.hide()
249
self.image_location_error.show()
251
def on_entry_location_key_press_event(self, widget, event):
252
""" Key pressed handler for the location entry. """
253
if event.keyval == 65293:
254
# Return was hit, so we have to jump
255
self.on_button_location_jump_clicked(widget)
211
257
def on_menuitem_add_files_activate(self, widget):
212
258
""" Add file(s)... menu handler. """
213
259
from add import OliveAdd
576
622
# Expand the tree
577
623
self.treeview_left.expand_all()
579
def _add_updir_to_dirlist(self, dirlist, curdir):
580
"""Add .. to the top of directories list if we not in root directory
582
:param dirlist: list of directories (modified in place)
583
:param curdir: current directory
589
if sys.platform == 'win32':
590
drive, tail = os.path.splitdrive(curdir)
591
if tail in ('', '/', '\\'):
597
# insert always as first element
598
dirlist.insert(0, '..')
600
625
def _load_right(self):
601
626
""" Load data into the right panel. (Filelist) """
602
627
# Create ListStore
603
liststore = gtk.ListStore(str, str, str)
628
# Model: [icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local)]
629
liststore = gtk.ListStore(str, gobject.TYPE_BOOLEAN, str, str, str, gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_INT, gobject.TYPE_STRING)
629
648
delta = self.wt.changes_from(tree2, want_unchanged=True)
631
650
# Add'em to the ListStore
633
liststore.append([gtk.STOCK_DIRECTORY, item, ''])
652
statinfo = os.stat(self.path + os.sep + item)
653
liststore.append([gtk.STOCK_DIRECTORY, True, item, '', '', statinfo.st_size, self._format_size(statinfo.st_size), statinfo.st_mtime, self._format_date(statinfo.st_mtime)])
634
654
for item in files:
635
655
status = 'unknown'
636
656
if not self.notbranch:
679
699
st = _('ignored')
681
701
st = _('unknown')
682
liststore.append([gtk.STOCK_FILE, item, st])
703
statinfo = os.stat(self.path + os.sep + item)
704
liststore.append([gtk.STOCK_FILE, False, item, st, status, statinfo.st_size, self._format_size(statinfo.st_size), statinfo.st_mtime, self._format_date(statinfo.st_mtime)])
684
706
# Create the columns and add them to the TreeView
685
707
self.treeview_right.set_model(liststore)
686
708
tvcolumn_filename = gtk.TreeViewColumn(_('Filename'))
687
709
tvcolumn_status = gtk.TreeViewColumn(_('Status'))
710
tvcolumn_size = gtk.TreeViewColumn(_('Size'))
711
tvcolumn_mtime = gtk.TreeViewColumn(_('Last modified'))
688
712
self.treeview_right.append_column(tvcolumn_filename)
689
713
self.treeview_right.append_column(tvcolumn_status)
714
self.treeview_right.append_column(tvcolumn_size)
715
self.treeview_right.append_column(tvcolumn_mtime)
691
717
# Set up the cells
692
718
cellpb = gtk.CellRendererPixbuf()
694
720
tvcolumn_filename.pack_start(cellpb, False)
695
721
tvcolumn_filename.pack_start(cell, True)
696
722
tvcolumn_filename.set_attributes(cellpb, stock_id=0)
697
tvcolumn_filename.add_attribute(cell, 'text', 1)
723
tvcolumn_filename.add_attribute(cell, 'text', 2)
698
724
tvcolumn_status.pack_start(cell, True)
699
tvcolumn_status.add_attribute(cell, 'text', 2)
725
tvcolumn_status.add_attribute(cell, 'text', 3)
726
tvcolumn_size.pack_start(cell, True)
727
tvcolumn_size.add_attribute(cell, 'text', 6)
728
tvcolumn_mtime.pack_start(cell, True)
729
tvcolumn_mtime.add_attribute(cell, 'text', 8)
731
# Set up the properties of the TreeView
732
self.treeview_right.set_headers_visible(True)
733
self.treeview_right.set_headers_clickable(True)
734
self.treeview_right.set_search_column(1)
735
tvcolumn_filename.set_resizable(True)
737
liststore.set_sort_func(13, self._sort_filelist_callback, None)
738
liststore.set_sort_column_id(13, gtk.SORT_ASCENDING)
739
tvcolumn_filename.set_sort_column_id(13)
740
tvcolumn_status.set_sort_column_id(3)
741
tvcolumn_size.set_sort_column_id(5)
742
tvcolumn_mtime.set_sort_column_id(7)
701
744
# Set sensitivity
702
745
self.set_sensitivity()
712
return model.get_value(iter, 1)
755
return model.get_value(iter, 2)
714
757
def get_selected_left(self):
715
758
""" Get the selected bookmark. """
833
869
# Add'em to the ListStore
834
870
for item in dirs:
835
liststore.append([gtk.STOCK_DIRECTORY, item, ''])
871
statinfo = os.stat(self.path + os.sep + item)
872
liststore.append([gtk.STOCK_DIRECTORY, True, item, '', '', statinfo.st_size, self._format_size(statinfo.st_size), statinfo.st_mtime, self._format_date(statinfo.st_mtime)])
836
873
for item in files:
837
874
status = 'unknown'
838
875
if not notbranch:
881
918
st = _('ignored')
883
920
st = _('unknown')
884
liststore.append([gtk.STOCK_FILE, item, st])
922
statinfo = os.stat(self.path + os.sep + item)
923
liststore.append([gtk.STOCK_FILE, False, item, st, status, statinfo.st_size, self._format_size(statinfo.st_size), statinfo.st_mtime, self._format_date(statinfo.st_mtime)])
886
925
# Add the ListStore to the TreeView
887
926
self.treeview_right.set_model(liststore)
927
self.treeview_right.columns_autosize()
889
929
# Set sensitivity
890
930
self.set_sensitivity()
979
def _sort_filelist_callback(self, model, iter1, iter2, data):
980
""" The sort callback for the file list, return values:
985
name1 = model.get_value(iter1, 2)
986
name2 = model.get_value(iter2, 2)
988
if model.get_value(iter1, 1):
989
# item1 is a directory
990
if not model.get_value(iter2, 1):
994
# both of them are directories, we compare their names
1002
# item1 is not a directory
1003
if model.get_value(iter2, 1):
1007
# both of them are files, compare them
1010
elif name1 == name2:
1015
def _format_size(self, size):
1016
""" Format size to a human readable format. """
1019
def _format_date(self, timestamp):
1020
""" Format the time (given in secs) to a human readable format. """
1021
return time.ctime(timestamp)
939
1023
import ConfigParser