58
55
from bzrlib.plugins.gtk.push import PushDialog
59
56
from bzrlib.plugins.gtk.revbrowser import RevisionBrowser
62
""" Display the AboutDialog. """
63
from bzrlib.plugins.gtk import __version__
64
from bzrlib.plugins.gtk.olive.guifiles import GLADEFILENAME
66
# Load AboutDialog description
67
dglade = gtk.glade.XML(GLADEFILENAME, 'aboutdialog')
68
dialog = dglade.get_widget('aboutdialog')
71
dialog.set_version(__version__)
72
dialog.set_authors([ _i18n("Lead Developer:"),
73
"Szilveszter Farkas <szilveszter.farkas@gmail.com>",
74
_i18n("Contributors:"),
75
"Jelmer Vernooij <jelmer@samba.org>",
76
"Mateusz Korniak <mateusz.korniak@ant.gliwice.pl>",
77
"Gary van der Merwe <garyvdm@gmail.com>" ])
78
dialog.set_artists([ "Simon Pascal Klein <klepas@klepas.org>",
79
"Jakub Steiner <jimmac@novell.com>" ])
86
59
""" The main Olive GTK frontend class. This is called when launching the
106
79
# Get some important menu items
107
80
self.menuitem_add_files = self.toplevel.get_widget('menuitem_add_files')
108
81
self.menuitem_remove_files = self.toplevel.get_widget('menuitem_remove_file')
109
self.menuitem_file_bookmark = self.toplevel.get_widget('menuitem_file_bookmark')
110
82
self.menuitem_file_make_directory = self.toplevel.get_widget('menuitem_file_make_directory')
111
83
self.menuitem_file_rename = self.toplevel.get_widget('menuitem_file_rename')
112
84
self.menuitem_file_move = self.toplevel.get_widget('menuitem_file_move')
113
85
self.menuitem_file_annotate = self.toplevel.get_widget('menuitem_file_annotate')
114
86
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
87
self.menuitem_branch = self.toplevel.get_widget('menuitem_branch')
117
88
self.menuitem_branch_init = self.toplevel.get_widget('menuitem_branch_initialize')
118
89
self.menuitem_branch_get = self.toplevel.get_widget('menuitem_branch_get')
119
90
self.menuitem_branch_checkout = self.toplevel.get_widget('menuitem_branch_checkout')
120
91
self.menuitem_branch_pull = self.toplevel.get_widget('menuitem_branch_pull')
121
92
self.menuitem_branch_push = self.toplevel.get_widget('menuitem_branch_push')
122
self.menuitem_branch_update = self.toplevel.get_widget('menuitem_branch_update')
123
93
self.menuitem_branch_revert = self.toplevel.get_widget('menuitem_branch_revert')
124
94
self.menuitem_branch_merge = self.toplevel.get_widget('menuitem_branch_merge')
125
95
self.menuitem_branch_commit = self.toplevel.get_widget('menuitem_branch_commit')
163
132
"on_about_activate": self.on_about_activate,
164
133
"on_menuitem_add_files_activate": self.on_menuitem_add_files_activate,
165
134
"on_menuitem_remove_file_activate": self.on_menuitem_remove_file_activate,
166
"on_menuitem_file_bookmark_activate": self.on_menuitem_file_bookmark_activate,
167
135
"on_menuitem_file_make_directory_activate": self.on_menuitem_file_make_directory_activate,
168
136
"on_menuitem_file_move_activate": self.on_menuitem_file_move_activate,
169
137
"on_menuitem_file_rename_activate": self.on_menuitem_file_rename_activate,
170
138
"on_menuitem_file_annotate_activate": self.on_menuitem_file_annotate_activate,
171
139
"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
140
"on_menuitem_view_refresh_activate": self.on_menuitem_view_refresh_activate,
174
141
"on_menuitem_branch_initialize_activate": self.on_menuitem_branch_initialize_activate,
175
142
"on_menuitem_branch_get_activate": self.on_menuitem_branch_get_activate,
179
146
"on_menuitem_branch_commit_activate": self.on_menuitem_branch_commit_activate,
180
147
"on_menuitem_branch_push_activate": self.on_menuitem_branch_push_activate,
181
148
"on_menuitem_branch_pull_activate": self.on_menuitem_branch_pull_activate,
182
"on_menuitem_branch_update_activate": self.on_menuitem_branch_update_activate,
183
149
"on_menuitem_branch_tags_activate": self.on_menuitem_branch_tags_activate,
184
150
"on_menuitem_branch_status_activate": self.on_menuitem_branch_status_activate,
185
151
"on_menuitem_branch_missing_revisions_activate": self.on_menuitem_branch_missing_revisions_activate,
194
160
"on_toolbutton_commit_clicked": self.on_menuitem_branch_commit_activate,
195
161
"on_toolbutton_pull_clicked": self.on_menuitem_branch_pull_activate,
196
162
"on_toolbutton_push_clicked": self.on_menuitem_branch_push_activate,
197
"on_toolbutton_update_clicked": self.on_menuitem_branch_update_activate,
198
163
"on_treeview_right_button_press_event": self.on_treeview_right_button_press_event,
199
164
"on_treeview_right_row_activated": self.on_treeview_right_row_activated,
200
165
"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
166
"on_treeview_left_row_activated": self.on_treeview_left_row_activated,
203
167
"on_button_location_up_clicked": self.on_button_location_up_clicked,
204
168
"on_button_location_jump_clicked": self.on_button_location_jump_clicked,
509
474
def on_menuitem_branch_commit_activate(self, widget):
510
475
""" 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,
476
commit = CommitDialog(self.wt, self.wtpath, self.notbranch, self.get_selected_right(), self.window)
519
477
response = commit.run()
520
478
if response != gtk.RESPONSE_NONE:
537
495
from bzrlib.plugins.gtk.merge import MergeDialog
539
497
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.'))
498
error_dialog(_('There are local changes in the branch'),
499
_('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 )
501
merge = MergeDialog(self.wt, self.wtpath)
548
505
def on_menuitem_branch_missing_revisions_activate(self, widget):
549
506
""" Branch/Missing revisions menu handler. """
551
from bzrlib.missing import find_unmerged, iter_log_revisions
553
507
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.'))
509
other_branch = local_branch.get_parent()
510
if other_branch is None:
511
error_dialog(_('Parent location is unknown'),
512
_('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'),
515
remote_branch = Branch.open(other_branch)
517
if remote_branch.base == local_branch.base:
518
remote_branch = local_branch
520
ret = len(local_branch.missing_revisions(remote_branch))
523
info_dialog(_('There are missing revisions'),
524
_('%d revision(s) missing.') % ret)
603
info_dialog(_i18n('Local branch up to date'),
604
_i18n('There are no missing revisions.'))
526
info_dialog(_('Local branch up to date'),
527
_('There are no missing revisions.'))
607
530
def on_menuitem_branch_pull_activate(self, widget):
622
545
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.') )
547
info_dialog(_('Pull successful'), _('%d revision(s) pulled.') % ret)
637
549
def on_menuitem_branch_push_activate(self, widget):
638
550
""" Branch/Push... menu handler. """
639
push = PushDialog(repository=None,revid=None,branch=self.wt.branch, parent=self.window)
551
push = PushDialog(self.wt.branch, self.window)
640
552
response = push.run()
641
553
if response != gtk.RESPONSE_NONE:
646
558
""" Branch/Revert all changes menu handler. """
647
559
ret = self.wt.revert([])
649
warning_dialog(_i18n('Conflicts detected'),
650
_i18n('Please have a look at the working tree before continuing.'))
561
warning_dialog(_('Conflicts detected'),
562
_('Please have a look at the working tree before continuing.'))
652
info_dialog(_i18n('Revert successful'),
653
_i18n('All files reverted to last revision.'))
564
info_dialog(_('Revert successful'),
565
_('All files reverted to last revision.'))
654
566
self.refresh_right()
656
568
def on_menuitem_branch_status_activate(self, widget):
685
597
def on_menuitem_file_annotate_activate(self, widget):
686
598
""" File/Annotate... menu handler. """
687
599
if self.get_selected_right() is None:
688
error_dialog(_i18n('No file was selected'),
689
_i18n('Please select a file from the list.'))
600
error_dialog(_('No file was selected'),
601
_('Please select a file from the list.'))
692
604
branch = self.wt.branch
693
605
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)
607
window = GAnnotateWindow(all=False, plain=False)
696
608
window.set_title(os.path.join(self.path, self.get_selected_right()) + " - Annotate")
697
609
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
617
def on_menuitem_file_make_directory_activate(self, widget):
718
618
""" File/Make directory... menu handler. """
719
619
from mkdir import OliveMkdir
768
668
def on_menuitem_stats_log_activate(self, widget):
769
669
""" Statistics/Log... menu handler. """
670
window = branchwin.BranchWindow()
771
671
if not self.remote:
772
branch = self.wt.branch
672
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)
674
window.set_branch(self.remote_branch, self.remote_branch.last_revision(), None)
779
677
def on_menuitem_view_refresh_activate(self, widget):
811
703
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
706
def on_treeview_left_row_activated(self, treeview, path, view_column):
829
707
""" Occurs when somebody double-clicks or enters an item in the
830
708
bookmark list. """
940
818
bookmarks = self.pref.get_bookmarks()
942
820
# Add them to the TreeStore
943
titer = treestore.append(None, [_i18n('Bookmarks'), None])
821
titer = treestore.append(None, [_('Bookmarks'), None])
944
822
for item in bookmarks:
945
823
title = self.pref.get_bookmark_title(item)
946
824
treestore.append(titer, [title, item])
948
826
# Create the column and add it to the TreeView
949
827
self.treeview_left.set_model(treestore)
950
tvcolumn_bookmark = gtk.TreeViewColumn(_i18n('Bookmark'))
828
tvcolumn_bookmark = gtk.TreeViewColumn(_('Bookmark'))
951
829
self.treeview_left.append_column(tvcolumn_bookmark)
953
831
# Set up the cells
961
839
def _load_right(self):
962
840
""" Load data into the right panel. (Filelist) """
963
841
# Create ListStore
964
# Model: [ icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local), fileid ]
842
# Model: [ icon, dir, name, status text, status, size (int), size (human), mtime (int), mtime (local), fileid]
965
843
liststore = gtk.ListStore(gobject.TYPE_STRING,
966
844
gobject.TYPE_BOOLEAN,
967
845
gobject.TYPE_STRING,
968
846
gobject.TYPE_STRING,
969
847
gobject.TYPE_STRING,
971
849
gobject.TYPE_STRING,
972
850
gobject.TYPE_INT,
973
851
gobject.TYPE_STRING,
1047
919
self.wt.unlock()
1049
921
if status == 'renamed':
1050
st = _i18n('renamed')
1051
923
elif status == 'removed':
1052
st = _i18n('removed')
1053
925
elif status == 'added':
1055
927
elif status == 'modified':
1056
st = _i18n('modified')
1057
929
elif status == 'unchanged':
1058
st = _i18n('unchanged')
1059
931
elif status == 'ignored':
1060
st = _i18n('ignored')
1062
st = _i18n('unknown')
1065
statinfo = os.stat(self.path + os.sep + item)
936
statinfo = os.stat(self.path + os.sep + item)
1071
937
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
943
self._format_size(statinfo.st_size),
1078
944
statinfo.st_mtime,
1079
945
self._format_date(statinfo.st_mtime),
1082
948
# Create the columns and add them to the TreeView
1083
949
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'))
950
self._tvcolumn_filename = gtk.TreeViewColumn(_('Filename'))
951
self._tvcolumn_status = gtk.TreeViewColumn(_('Status'))
952
self._tvcolumn_size = gtk.TreeViewColumn(_('Size'))
953
self._tvcolumn_mtime = gtk.TreeViewColumn(_('Last modified'))
1088
954
self.treeview_right.append_column(self._tvcolumn_filename)
1089
955
self.treeview_right.append_column(self._tvcolumn_status)
1090
956
self.treeview_right.append_column(self._tvcolumn_size)