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.hbox_location = self.toplevel.get_widget('hbox_location')
114
self.button_location_up = self.toplevel.get_widget('button_location_up')
115
self.button_location_jump = self.toplevel.get_widget('button_location_jump')
116
self.entry_location = self.toplevel.get_widget('entry_location')
117
self.image_location_error = self.toplevel.get_widget('image_location_error')
110
119
self.vbox_main_right = self.toplevel.get_widget('vbox_main_right')
113
121
# Dictionary for signal_autoconnect
114
122
dic = { "on_window_main_destroy": gtk.main_quit,
148
156
"on_treeview_right_button_press_event": self.on_treeview_right_button_press_event,
149
157
"on_treeview_right_row_activated": self.on_treeview_right_row_activated,
150
158
"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 }
159
"on_treeview_left_row_activated": self.on_treeview_left_row_activated,
160
"on_button_location_up_clicked": self.on_button_location_up_clicked,
161
"on_button_location_jump_clicked": self.on_button_location_jump_clicked,
162
"on_entry_location_key_press_event": self.on_entry_location_key_press_event
153
165
# Connect the signals to the handlers
154
166
self.toplevel.signal_autoconnect(dic)
176
188
# Show drive selector if under Win32
177
189
if sys.platform == 'win32':
178
self.vbox_main_right.pack_start(self.combobox_drive, False, True, 0)
179
self.vbox_main_right.reorder_child(self.combobox_drive, 0)
190
self.hbox_location.pack_start(self.combobox_drive, False, False, 0)
191
self.hbox_location.reorder_child(self.combobox_drive, 1)
180
192
self.combobox_drive.show()
181
193
self.gen_hard_selector()
200
212
self.notbranch = True
202
214
self.statusbar.push(self.context_id, path)
215
self.entry_location.set_text(path)
217
# If we're in the root, we cannot go up anymore
218
if sys.platform == 'win32':
219
drive, tail = os.path.splitdrive(self.path)
220
if tail in ('', '/', '\\'):
221
self.button_location_up.set_sensitive(False)
223
self.button_location_up.set_sensitive(True)
226
self.button_location_up.set_sensitive(False)
228
self.button_location_up.set_sensitive(True)
204
230
def get_path(self):
208
234
from bzrlib.plugins.gtk.dialog import about
237
def on_button_location_up_clicked(self, widget):
238
""" Location Up button handler. """
239
self.set_path(os.path.split(self.get_path())[0])
242
def on_button_location_jump_clicked(self, widget):
243
""" Location Jump button handler. """
244
location = self.entry_location.get_text()
245
if os.path.isdir(location):
246
self.set_path(location)
248
self.image_location_error.hide()
250
self.image_location_error.show()
252
def on_entry_location_key_press_event(self, widget, event):
253
""" Key pressed handler for the location entry. """
254
if event.keyval == 65293:
255
# Return was hit, so we have to jump
256
self.on_button_location_jump_clicked(widget)
211
258
def on_menuitem_add_files_activate(self, widget):
212
259
""" Add file(s)... menu handler. """
213
260
from add import OliveAdd
344
391
""" Branch/Status... menu handler. """
345
392
from bzrlib.plugins.gtk.status import StatusDialog
346
393
status = StatusDialog(self.wt, self.wtpath)
394
response = status.run()
395
if response != gtk.RESPONSE_NONE:
349
398
def on_menuitem_branch_initialize_activate(self, widget):
350
399
""" Initialize current directory. """
574
623
# Expand the tree
575
624
self.treeview_left.expand_all()
577
def _add_updir_to_dirlist(self, dirlist, curdir):
578
"""Add .. to the top of directories list if we not in root directory
580
:param dirlist: list of directories (modified in place)
581
:param curdir: current directory
587
if sys.platform == 'win32':
588
drive, tail = os.path.splitdrive(curdir)
589
if tail in ('', '/', '\\'):
595
# insert always as first element
596
dirlist.insert(0, '..')
598
626
def _load_right(self):
599
627
""" Load data into the right panel. (Filelist) """
600
628
# Create ListStore
601
liststore = gtk.ListStore(str, str, str)
629
# Model: [icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local)]
630
liststore = gtk.ListStore(str, gobject.TYPE_BOOLEAN, str, str, str, gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_INT, gobject.TYPE_STRING)
627
649
delta = self.wt.changes_from(tree2, want_unchanged=True)
629
651
# Add'em to the ListStore
631
liststore.append([gtk.STOCK_DIRECTORY, item, ''])
653
statinfo = os.stat(self.path + os.sep + item)
654
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)])
632
655
for item in files:
633
656
status = 'unknown'
634
657
if not self.notbranch:
677
700
st = _('ignored')
679
702
st = _('unknown')
680
liststore.append([gtk.STOCK_FILE, item, st])
704
statinfo = os.stat(self.path + os.sep + item)
705
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)])
682
707
# Create the columns and add them to the TreeView
683
708
self.treeview_right.set_model(liststore)
684
709
tvcolumn_filename = gtk.TreeViewColumn(_('Filename'))
685
710
tvcolumn_status = gtk.TreeViewColumn(_('Status'))
711
tvcolumn_size = gtk.TreeViewColumn(_('Size'))
712
tvcolumn_mtime = gtk.TreeViewColumn(_('Last modified'))
686
713
self.treeview_right.append_column(tvcolumn_filename)
687
714
self.treeview_right.append_column(tvcolumn_status)
715
self.treeview_right.append_column(tvcolumn_size)
716
self.treeview_right.append_column(tvcolumn_mtime)
689
718
# Set up the cells
690
719
cellpb = gtk.CellRendererPixbuf()
692
721
tvcolumn_filename.pack_start(cellpb, False)
693
722
tvcolumn_filename.pack_start(cell, True)
694
723
tvcolumn_filename.set_attributes(cellpb, stock_id=0)
695
tvcolumn_filename.add_attribute(cell, 'text', 1)
724
tvcolumn_filename.add_attribute(cell, 'text', 2)
696
725
tvcolumn_status.pack_start(cell, True)
697
tvcolumn_status.add_attribute(cell, 'text', 2)
726
tvcolumn_status.add_attribute(cell, 'text', 3)
727
tvcolumn_size.pack_start(cell, True)
728
tvcolumn_size.add_attribute(cell, 'text', 6)
729
tvcolumn_mtime.pack_start(cell, True)
730
tvcolumn_mtime.add_attribute(cell, 'text', 8)
732
# Set up the properties of the TreeView
733
self.treeview_right.set_headers_visible(True)
734
self.treeview_right.set_headers_clickable(True)
735
self.treeview_right.set_search_column(1)
736
tvcolumn_filename.set_resizable(True)
738
liststore.set_sort_func(13, self._sort_filelist_callback, None)
739
liststore.set_sort_column_id(13, gtk.SORT_ASCENDING)
740
tvcolumn_filename.set_sort_column_id(13)
741
tvcolumn_status.set_sort_column_id(3)
742
tvcolumn_size.set_sort_column_id(5)
743
tvcolumn_mtime.set_sort_column_id(7)
699
745
# Set sensitivity
700
746
self.set_sensitivity()
710
return model.get_value(iter, 1)
756
return model.get_value(iter, 2)
712
758
def get_selected_left(self):
713
759
""" Get the selected bookmark. """
831
870
# Add'em to the ListStore
832
871
for item in dirs:
833
liststore.append([gtk.STOCK_DIRECTORY, item, ''])
872
statinfo = os.stat(self.path + os.sep + item)
873
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)])
834
874
for item in files:
835
875
status = 'unknown'
836
876
if not notbranch:
879
919
st = _('ignored')
881
921
st = _('unknown')
882
liststore.append([gtk.STOCK_FILE, item, st])
923
statinfo = os.stat(self.path + os.sep + item)
924
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)])
884
926
# Add the ListStore to the TreeView
885
927
self.treeview_right.set_model(liststore)
928
self.treeview_right.columns_autosize()
887
930
# Set sensitivity
888
931
self.set_sensitivity()
980
def _sort_filelist_callback(self, model, iter1, iter2, data):
981
""" The sort callback for the file list, return values:
986
name1 = model.get_value(iter1, 2)
987
name2 = model.get_value(iter2, 2)
989
if model.get_value(iter1, 1):
990
# item1 is a directory
991
if not model.get_value(iter2, 1):
995
# both of them are directories, we compare their names
1003
# item1 is not a directory
1004
if model.get_value(iter2, 1):
1008
# both of them are files, compare them
1011
elif name1 == name2:
1016
def _format_size(self, size):
1017
""" Format size to a human readable format. """
1020
def _format_date(self, timestamp):
1021
""" Format the time (given in secs) to a human readable format. """
1022
return time.ctime(timestamp)
937
1024
import ConfigParser