106
95
# Get some important menu items
107
96
self.menuitem_add_files = self.toplevel.get_widget('menuitem_add_files')
108
97
self.menuitem_remove_files = self.toplevel.get_widget('menuitem_remove_file')
109
self.menuitem_file_bookmark = self.toplevel.get_widget('menuitem_file_bookmark')
110
98
self.menuitem_file_make_directory = self.toplevel.get_widget('menuitem_file_make_directory')
111
99
self.menuitem_file_rename = self.toplevel.get_widget('menuitem_file_rename')
112
100
self.menuitem_file_move = self.toplevel.get_widget('menuitem_file_move')
113
101
self.menuitem_file_annotate = self.toplevel.get_widget('menuitem_file_annotate')
114
102
self.menuitem_view_show_hidden_files = self.toplevel.get_widget('menuitem_view_show_hidden_files')
115
self.menuitem_view_show_ignored_files = self.toplevel.get_widget('menuitem_view_show_ignored_files')
116
103
self.menuitem_branch = self.toplevel.get_widget('menuitem_branch')
117
104
self.menuitem_branch_init = self.toplevel.get_widget('menuitem_branch_initialize')
118
105
self.menuitem_branch_get = self.toplevel.get_widget('menuitem_branch_get')
119
106
self.menuitem_branch_checkout = self.toplevel.get_widget('menuitem_branch_checkout')
120
107
self.menuitem_branch_pull = self.toplevel.get_widget('menuitem_branch_pull')
121
108
self.menuitem_branch_push = self.toplevel.get_widget('menuitem_branch_push')
122
self.menuitem_branch_update = self.toplevel.get_widget('menuitem_branch_update')
123
109
self.menuitem_branch_revert = self.toplevel.get_widget('menuitem_branch_revert')
124
110
self.menuitem_branch_merge = self.toplevel.get_widget('menuitem_branch_merge')
125
111
self.menuitem_branch_commit = self.toplevel.get_widget('menuitem_branch_commit')
163
148
"on_about_activate": self.on_about_activate,
164
149
"on_menuitem_add_files_activate": self.on_menuitem_add_files_activate,
165
150
"on_menuitem_remove_file_activate": self.on_menuitem_remove_file_activate,
166
"on_menuitem_file_bookmark_activate": self.on_menuitem_file_bookmark_activate,
167
151
"on_menuitem_file_make_directory_activate": self.on_menuitem_file_make_directory_activate,
168
152
"on_menuitem_file_move_activate": self.on_menuitem_file_move_activate,
169
153
"on_menuitem_file_rename_activate": self.on_menuitem_file_rename_activate,
170
154
"on_menuitem_file_annotate_activate": self.on_menuitem_file_annotate_activate,
171
155
"on_menuitem_view_show_hidden_files_activate": self.on_menuitem_view_show_hidden_files_activate,
172
"on_menuitem_view_show_ignored_files_activate": self.on_menuitem_view_show_ignored_files_activate,
173
156
"on_menuitem_view_refresh_activate": self.on_menuitem_view_refresh_activate,
174
157
"on_menuitem_branch_initialize_activate": self.on_menuitem_branch_initialize_activate,
175
158
"on_menuitem_branch_get_activate": self.on_menuitem_branch_get_activate,
179
162
"on_menuitem_branch_commit_activate": self.on_menuitem_branch_commit_activate,
180
163
"on_menuitem_branch_push_activate": self.on_menuitem_branch_push_activate,
181
164
"on_menuitem_branch_pull_activate": self.on_menuitem_branch_pull_activate,
182
"on_menuitem_branch_update_activate": self.on_menuitem_branch_update_activate,
183
165
"on_menuitem_branch_tags_activate": self.on_menuitem_branch_tags_activate,
184
166
"on_menuitem_branch_status_activate": self.on_menuitem_branch_status_activate,
185
167
"on_menuitem_branch_missing_revisions_activate": self.on_menuitem_branch_missing_revisions_activate,
194
176
"on_toolbutton_commit_clicked": self.on_menuitem_branch_commit_activate,
195
177
"on_toolbutton_pull_clicked": self.on_menuitem_branch_pull_activate,
196
178
"on_toolbutton_push_clicked": self.on_menuitem_branch_push_activate,
197
"on_toolbutton_update_clicked": self.on_menuitem_branch_update_activate,
198
179
"on_treeview_right_button_press_event": self.on_treeview_right_button_press_event,
199
180
"on_treeview_right_row_activated": self.on_treeview_right_row_activated,
200
181
"on_treeview_left_button_press_event": self.on_treeview_left_button_press_event,
201
"on_treeview_left_button_release_event": self.on_treeview_left_button_release_event,
202
182
"on_treeview_left_row_activated": self.on_treeview_left_row_activated,
203
183
"on_button_location_up_clicked": self.on_button_location_up_clicked,
204
184
"on_button_location_jump_clicked": self.on_button_location_jump_clicked,
509
488
def on_menuitem_branch_commit_activate(self, widget):
510
489
""" Branch/Commit... menu handler. """
511
# def __init__(self, wt, wtpath, notbranch, selected=None, parent=None):
512
selected = self.get_selected_right()
514
selected = os.path.join(self.wtpath, selected)
515
commit = CommitDialog(wt=self.wt,
490
commit = CommitDialog(self.wt, self.wtpath, self.notbranch, self.get_selected_right(), self.window)
519
491
response = commit.run()
520
492
if response != gtk.RESPONSE_NONE:
537
509
from bzrlib.plugins.gtk.merge import MergeDialog
539
511
if self.check_for_changes():
540
error_dialog(_i18n('There are local changes in the branch'),
541
_i18n('Please commit or revert the changes before merging.'))
512
error_dialog(_('There are local changes in the branch'),
513
_('Please commit or revert the changes before merging.'))
543
parent_branch_path = self.wt.branch.get_parent()
544
merge = MergeDialog(self.wt, self.wtpath,default_branch_path=parent_branch_path )
515
merge = MergeDialog(self.wt, self.wtpath)
548
519
def on_menuitem_branch_missing_revisions_activate(self, widget):
549
520
""" Branch/Missing revisions menu handler. """
551
from bzrlib.missing import find_unmerged, iter_log_revisions
553
521
local_branch = self.wt.branch
554
parent_branch_path = local_branch.get_parent()
555
if parent_branch_path is None:
556
error_dialog(_i18n('Parent location is unknown'),
557
_i18n('Cannot determine missing revisions if no parent location is known.'))
523
other_branch = local_branch.get_parent()
524
if other_branch is None:
525
error_dialog(_('Parent location is unknown'),
526
_('Cannot determine missing revisions if no parent location is known.'))
560
parent_branch = Branch.open(parent_branch_path)
562
if parent_branch.base == local_branch.base:
563
parent_branch = local_branch
565
local_extra, remote_extra = find_unmerged(local_branch,parent_branch)
567
if local_extra or remote_extra:
569
## def log_revision_one_line_text(log_revision):
570
## """ Generates one line description of log_revison ended with end of line."""
571
## revision = log_revision.rev
572
## txt = "- %s (%s)\n" % (revision.get_summary(), revision.committer, )
573
## txt = txt.replace("<"," ") # Seems < > chars are expected to be xml tags ...
574
## txt = txt.replace(">"," ")
579
dlg_txt += _i18n('%d local extra revision(s). \n') % (len(local_extra),)
580
## NOTE: We do not want such ugly info about missing revisions
581
## Revision Browser should be used there
582
## max_revisions = 10
583
## for log_revision in iter_log_revisions(local_extra, local_branch.repository, verbose=1):
584
## dlg_txt += log_revision_one_line_text(log_revision)
585
## if max_revisions <= 0:
586
## dlg_txt += _i18n("more ... \n")
588
## max_revisions -= 1
591
dlg_txt += _i18n('%d local missing revision(s).\n') % (len(remote_extra),)
592
## max_revisions = 10
593
## for log_revision in iter_log_revisions(remote_extra, parent_branch.repository, verbose=1):
594
## dlg_txt += log_revision_one_line_text(log_revision)
595
## if max_revisions <= 0:
596
## dlg_txt += _i18n("more ... \n")
598
## max_revisions -= 1
600
info_dialog(_i18n('There are missing revisions'),
529
remote_branch = Branch.open(other_branch)
531
if remote_branch.base == local_branch.base:
532
remote_branch = local_branch
534
ret = len(local_branch.missing_revisions(remote_branch))
537
info_dialog(_('There are missing revisions'),
538
_('%d revision(s) missing.') % ret)
603
info_dialog(_i18n('Local branch up to date'),
604
_i18n('There are no missing revisions.'))
540
info_dialog(_('Local branch up to date'),
541
_('There are no missing revisions.'))
607
544
def on_menuitem_branch_pull_activate(self, widget):
622
559
ret = branch_to.pull(branch_from)
624
info_dialog(_i18n('Pull successful'), _i18n('%d revision(s) pulled.') % ret)
627
def on_menuitem_branch_update_activate(self, widget):
628
""" Brranch/checkout update menu handler. """
630
ret = self.wt.update()
631
conflicts = self.wt.conflicts()
633
info_dialog(_i18n('Update successful but conflicts generated'), _i18n('Number of conflicts generated: %d.') % (len(conflicts),) )
635
info_dialog(_i18n('Update successful'), _i18n('No conflicts generated.') )
561
info_dialog(_('Pull successful'), _('%d revision(s) pulled.') % ret)
637
563
def on_menuitem_branch_push_activate(self, widget):
638
564
""" Branch/Push... menu handler. """
639
push = PushDialog(repository=None,revid=None,branch=self.wt.branch, parent=self.window)
565
push = PushDialog(self.wt.branch, self.window)
640
566
response = push.run()
641
567
if response != gtk.RESPONSE_NONE:
646
572
""" Branch/Revert all changes menu handler. """
647
573
ret = self.wt.revert([])
649
warning_dialog(_i18n('Conflicts detected'),
650
_i18n('Please have a look at the working tree before continuing.'))
575
warning_dialog(_('Conflicts detected'),
576
_('Please have a look at the working tree before continuing.'))
652
info_dialog(_i18n('Revert successful'),
653
_i18n('All files reverted to last revision.'))
578
info_dialog(_('Revert successful'),
579
_('All files reverted to last revision.'))
654
580
self.refresh_right()
656
582
def on_menuitem_branch_status_activate(self, widget):
685
611
def on_menuitem_file_annotate_activate(self, widget):
686
612
""" File/Annotate... menu handler. """
687
613
if self.get_selected_right() is None:
688
error_dialog(_i18n('No file was selected'),
689
_i18n('Please select a file from the list.'))
614
error_dialog(_('No file was selected'),
615
_('Please select a file from the list.'))
692
618
branch = self.wt.branch
693
619
file_id = self.wt.path2id(self.wt.relpath(os.path.join(self.path, self.get_selected_right())))
695
window = GAnnotateWindow(all=False, plain=False, parent=self.window)
621
window = GAnnotateWindow(all=False, plain=False)
696
622
window.set_title(os.path.join(self.path, self.get_selected_right()) + " - Annotate")
697
623
config = GAnnotateConfig(window)
705
def on_menuitem_file_bookmark_activate(self, widget):
706
""" File/Bookmark current directory menu handler. """
707
if self.pref.add_bookmark(self.path):
708
info_dialog(_i18n('Bookmark successfully added'),
709
_i18n('The current directory was bookmarked. You can reach\nit by selecting it from the left panel.'))
712
warning_dialog(_i18n('Location already bookmarked'),
713
_i18n('The current directory is already bookmarked.\nSee the left panel for reference.'))
717
631
def on_menuitem_file_make_directory_activate(self, widget):
718
632
""" File/Make directory... menu handler. """
719
633
from mkdir import OliveMkdir
768
682
def on_menuitem_stats_log_activate(self, widget):
769
683
""" Statistics/Log... menu handler. """
684
window = branchwin.BranchWindow()
771
685
if not self.remote:
772
branch = self.wt.branch
686
window.set_branch(self.wt.branch, self.wt.branch.last_revision(), None)
774
branch = self.remote_branch
776
window = branchwin.BranchWindow(branch, branch.last_revision(), None, parent=self.window)
688
window.set_branch(self.remote_branch, self.remote_branch.last_revision(), None)
779
691
def on_menuitem_view_refresh_activate(self, widget):
811
717
menu.left_context_menu().popup(None, None, None, 0,
814
def on_treeview_left_button_release_event(self, widget, event):
815
""" Occurs when somebody just clicks a bookmark. """
816
if event.button != 3:
817
# Allow one-click bookmark opening
818
if self.get_selected_left() == None:
821
newdir = self.get_selected_left()
825
if self.set_path(newdir):
828
720
def on_treeview_left_row_activated(self, treeview, path, view_column):
829
721
""" Occurs when somebody double-clicks or enters an item in the
830
722
bookmark list. """
940
832
bookmarks = self.pref.get_bookmarks()
942
834
# Add them to the TreeStore
943
titer = treestore.append(None, [_i18n('Bookmarks'), None])
835
titer = treestore.append(None, [_('Bookmarks'), None])
944
836
for item in bookmarks:
945
837
title = self.pref.get_bookmark_title(item)
946
838
treestore.append(titer, [title, item])
948
840
# Create the column and add it to the TreeView
949
841
self.treeview_left.set_model(treestore)
950
tvcolumn_bookmark = gtk.TreeViewColumn(_i18n('Bookmark'))
842
tvcolumn_bookmark = gtk.TreeViewColumn(_('Bookmark'))
951
843
self.treeview_left.append_column(tvcolumn_bookmark)
953
845
# Set up the cells
961
853
def _load_right(self):
962
854
""" Load data into the right panel. (Filelist) """
963
855
# Create ListStore
964
# Model: [ icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local), fileid ]
856
# Model: [ icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local), fileid]
965
857
liststore = gtk.ListStore(gobject.TYPE_STRING,
966
858
gobject.TYPE_BOOLEAN,
967
859
gobject.TYPE_STRING,
968
860
gobject.TYPE_STRING,
969
861
gobject.TYPE_STRING,
971
863
gobject.TYPE_STRING,
972
864
gobject.TYPE_INT,
973
865
gobject.TYPE_STRING,
1047
933
self.wt.unlock()
1049
935
if status == 'renamed':
1050
st = _i18n('renamed')
1051
937
elif status == 'removed':
1052
st = _i18n('removed')
1053
939
elif status == 'added':
1055
941
elif status == 'modified':
1056
st = _i18n('modified')
1057
943
elif status == 'unchanged':
1058
st = _i18n('unchanged')
1059
945
elif status == 'ignored':
1060
st = _i18n('ignored')
1062
st = _i18n('unknown')
1065
statinfo = os.stat(self.path + os.sep + item)
950
statinfo = os.stat(self.path + os.sep + item)
1071
951
liststore.append([gtk.STOCK_FILE,
1076
str(statinfo.st_size), # NOTE: if int used there it will fail for large files (size expressed as long int)
1077
957
self._format_size(statinfo.st_size),
1078
958
statinfo.st_mtime,
1079
959
self._format_date(statinfo.st_mtime),
1082
962
# Create the columns and add them to the TreeView
1083
963
self.treeview_right.set_model(liststore)
1084
self._tvcolumn_filename = gtk.TreeViewColumn(_i18n('Filename'))
1085
self._tvcolumn_status = gtk.TreeViewColumn(_i18n('Status'))
1086
self._tvcolumn_size = gtk.TreeViewColumn(_i18n('Size'))
1087
self._tvcolumn_mtime = gtk.TreeViewColumn(_i18n('Last modified'))
964
self._tvcolumn_filename = gtk.TreeViewColumn(_('Filename'))
965
self._tvcolumn_status = gtk.TreeViewColumn(_('Status'))
966
self._tvcolumn_size = gtk.TreeViewColumn(_('Size'))
967
self._tvcolumn_mtime = gtk.TreeViewColumn(_('Last modified'))
1088
968
self.treeview_right.append_column(self._tvcolumn_filename)
1089
969
self.treeview_right.append_column(self._tvcolumn_status)
1090
970
self.treeview_right.append_column(self._tvcolumn_size)