Jelmer Vernooij пишет: > On Wed, 2006-10-25 at 09:06 +0000, bialix wrote: >> Fix available in my branch: >> https://launchpad.net/people/bialix/+branch/bzr-gtk/win32 > Is there any chance you can make this fix available separately? I'd like to merge your fixes for gcommit, but without merging your unicode fixes. Here is cherrypicked patch. === added file 'olive/guifiles.py' --- olive/guifiles.py 1970-01-01 00:00:00 +0000 +++ olive/guifiles.py 2006-11-02 13:06:16 +0000 @@ -0,0 +1,54 @@ +# 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 of the License, 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 + +"""Glade file name""" + +import os +import sys + + +# Get the glade file name +if sys.platform == 'win32': + GLADEFILENAME = os.path.join(os.path.dirname(sys.executable), + "share/olive/olive.glade") +else: + GLADEFILENAME = "/usr/share/olive/olive.glade" + +if not os.path.isfile(GLADEFILENAME): + # Load from sources directory if not installed + dir_ = os.path.split(os.path.dirname(__file__))[0] + GLADEFILENAME = os.path.join(dir_, "olive.glade") + # Check again + if not os.path.isfile(GLADEFILENAME): + # Fail + print _('Glade file cannot be found.') + sys.exit(1) + +# Get the cmenu.ui file name +if sys.platform == 'win32': + UIFILENAME = os.path.dirname(sys.executable) + "/share/olive/cmenu.ui" +else: + UIFILENAME = "/usr/share/olive/cmenu.ui" + +if not os.path.isfile(UIFILENAME): + # Load from current directory if not installed + dir_ = os.path.split(os.path.dirname(__file__))[0] + UIFILENAME = os.path.join(dir_, "cmenu.ui") + # Check again + if not os.path.isfile(UIFILENAME): + # Fail + print _('UI description file cannot be found.') + sys.exit(1) + + === modified file '__init__.py' --- __init__.py 2006-10-08 20:51:52 +0000 +++ __init__.py 2006-11-02 13:07:43 +0000 @@ -71,7 +71,7 @@ tree1 = wt tree2 = tree1.basis_tree() - from bzrlib.plugins.gtk.viz.diffwin import DiffWindow + from viz.diffwin import DiffWindow import gtk window = DiffWindow() window.connect("destroy", lambda w: gtk.main_quit()) @@ -210,14 +210,31 @@ from olive.commit import CommitDialog from bzrlib.commit import Commit - from bzrlib.errors import (BzrCommandError, PointlessCommit, ConflictsInTree, - StrictCommitFailed) - - (wt, path) = WorkingTree.open_containing(filename) - - dialog = CommitDialog(wt, path) - dialog.display() - gtk.main() + from bzrlib.errors import (BzrCommandError, + NotBranchError, + NoWorkingTree, + PointlessCommit, + ConflictsInTree, + StrictCommitFailed) + + wt = None + branch = None + try: + (wt, path) = WorkingTree.open_containing(filename) + branch = wt.branch + except NotBranchError, e: + path = e.path + except NoWorkingTree, e: + path = e.base + try: + (branch, path) = Branch.open_containing(path) + except NotBranchError, e: + path = e.path + + dialog = CommitDialog(wt, path, not branch) + if dialog.display(): + dialog.window.connect("destroy", lambda w: gtk.main_quit()) + gtk.main() register_command(cmd_gcommit) === modified file 'olive/__init__.py' --- olive/__init__.py 2006-10-24 06:38:50 +0000 +++ olive/__init__.py 2006-11-02 13:06:58 +0000 @@ -38,23 +38,8 @@ # Olive GTK UI version __version__ = '0.11.0' -# Load the glade file -if sys.platform == 'win32': - gladefile = os.path.dirname(sys.executable) + "/share/olive/olive.glade" -else: - gladefile = "/usr/share/olive/olive.glade" - -if not os.path.exists(gladefile): - # Load from sources directory if not installed - dir_ = os.path.split(os.path.dirname(__file__))[0] - gladefile = os.path.join(dir_, "olive.glade") - # Check again - if not os.path.exists(gladefile): - # Fail - print _('Glade file cannot be found.') - sys.exit(1) - from dialog import error_dialog, info_dialog +from guifiles import GLADEFILENAME # import this classes only once try: @@ -74,7 +59,7 @@ program. """ def __init__(self): - self.toplevel = gtk.glade.XML(gladefile, 'window_main', 'olive-gtk') + self.toplevel = gtk.glade.XML(GLADEFILENAME, 'window_main', 'olive-gtk') self.window = self.toplevel.get_widget('window_main') @@ -238,7 +223,7 @@ def on_menuitem_branch_commit_activate(self, widget): """ Branch/Commit... menu handler. """ from commit import CommitDialog - commit = CommitDialog(self.wt, self.wtpath) + commit = CommitDialog(self.wt, self.wtpath, self.notbranch) commit.display() def on_menuitem_branch_merge_activate(self, widget): === modified file 'olive/add.py' --- olive/add.py 2006-10-03 06:44:48 +0000 +++ olive/add.py 2006-11-02 13:06:16 +0000 @@ -28,14 +28,15 @@ import bzrlib.add import bzrlib.errors as errors -from olive import gladefile from dialog import error_dialog +from guifiles import GLADEFILENAME + class OliveAdd: """ Display the Add file(s) dialog and perform the needed actions. """ def __init__(self, wt, wtpath, selected=[]): """ Initialize the Add file(s) dialog. """ - self.glade = gtk.glade.XML(gladefile, 'window_add', 'olive-gtk') + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_add', 'olive-gtk') self.window = self.glade.get_widget('window_add') === modified file 'olive/bookmark.py' --- olive/bookmark.py 2006-09-29 22:22:20 +0000 +++ olive/bookmark.py 2006-11-02 13:06:17 +0000 @@ -23,14 +23,16 @@ import gtk import gtk.glade -from olive import gladefile, OlivePreferences +from olive import OlivePreferences from dialog import error_dialog +from guifiles import GLADEFILENAME + class OliveBookmark: """ Display the Edit bookmark dialog and perform the needed actions. """ def __init__(self, selected): """ Initialize the Edit bookmark dialog. """ - self.glade = gtk.glade.XML(gladefile, 'window_bookmark', 'olive-gtk') + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_bookmark', 'olive-gtk') self.window = self.glade.get_widget('window_bookmark') === modified file 'olive/branch.py' --- olive/branch.py 2006-10-04 19:11:46 +0000 +++ olive/branch.py 2006-11-02 13:06:16 +0000 @@ -28,14 +28,15 @@ from bzrlib.branch import Branch import bzrlib.errors as errors -from __init__ import gladefile from dialog import error_dialog, info_dialog +from guifiles import GLADEFILENAME + class BranchDialog: """ Display branch dialog and perform the needed operations. """ def __init__(self, path=None): """ Initialize the Branch dialog. """ - self.glade = gtk.glade.XML(gladefile, 'window_branch', 'olive-gtk') + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_branch', 'olive-gtk') self.window = self.glade.get_widget('window_branch') === modified file 'olive/checkout.py' --- olive/checkout.py 2006-09-30 09:18:20 +0000 +++ olive/checkout.py 2006-11-02 13:06:16 +0000 @@ -30,14 +30,15 @@ import bzrlib.errors as errors import bzrlib.osutils -from olive import gladefile from dialog import error_dialog +from guifiles import GLADEFILENAME + class OliveCheckout: """ Display checkout dialog and perform the needed operations. """ def __init__(self, path=None): """ Initialize the Checkout dialog. """ - self.glade = gtk.glade.XML(gladefile, 'window_checkout', 'olive-gtk') + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_checkout', 'olive-gtk') self.window = self.glade.get_widget('window_checkout') === modified file 'olive/commit.py' --- olive/commit.py 2006-10-15 17:47:36 +0000 +++ olive/commit.py 2006-11-02 13:06:58 +0000 @@ -26,18 +26,26 @@ import pango import bzrlib.errors as errors +from bzrlib import osutils from dialog import error_dialog -from olive import gladefile +from guifiles import GLADEFILENAME + class CommitDialog: """ Display Commit dialog and perform the needed actions. """ - def __init__(self, wt, wtpath): - """ Initialize the Commit dialog. """ - self.glade = gtk.glade.XML(gladefile, 'window_commit', 'olive-gtk') + def __init__(self, wt, wtpath, notbranch): + """ Initialize the Commit dialog. + @param wt: bzr WorkingTree object + @param wtpath: path to working tree root + @param notbranch: flag that path is not a brach + @type notbranch: bool + """ + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_commit', 'olive-gtk') self.wt = wt self.wtpath = wtpath + self.notbranch = notbranch # Get some important widgets self.window = self.glade.get_widget('window_commit') @@ -47,11 +55,7 @@ self.pending_label = self.glade.get_widget('label_commit_pending') self.pending_view = self.glade.get_widget('treeview_commit_pending') - file_id = self.wt.path2id(wtpath) - - self.notbranch = False - if file_id is None: - self.notbranch = True + if wt is None or notbranch: return # Set the delta @@ -64,7 +68,7 @@ # Dictionary for signal_autoconnect dic = { "on_button_commit_commit_clicked": self.commit, "on_button_commit_cancel_clicked": self.close } - + # Connect the signals to the handlers self.glade.signal_autoconnect(dic) @@ -74,11 +78,19 @@ self._create_pending_merges() def display(self): - """ Display the Push dialog. """ + """ Display the Push dialog. + @return: True if dialog is shown. + """ + if self.wt is None and not self.notbranch: + error_dialog(_('Directory does not have a working tree'), + _('Operation aborted.')) + self.close() + return False if self.notbranch: error_dialog(_('Directory is not a branch'), _('You can perform this action only in a branch.')) self.close() + return False else: if self.wt.branch.get_bound_location() is not None: # we have a checkout, so the local commit checkbox must appear @@ -93,12 +105,13 @@ self.textview.modify_font(pango.FontDescription("Monospace")) self.window.show() - + return True def _create_file_view(self): - self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN, - gobject.TYPE_STRING, - gobject.TYPE_STRING) + self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN, # [0] checkbox + gobject.TYPE_STRING, # [1] path to display + gobject.TYPE_STRING, # [2] changes type + gobject.TYPE_STRING) # [3] real path self.file_view.set_model(self.file_store) crt = gtk.CellRendererToggle() crt.set_property("activatable", True) @@ -111,16 +124,28 @@ gtk.CellRendererText(), text=2)) for path, id, kind in self.delta.added: - self.file_store.append([ True, path, _('added') ]) + marker = osutils.kind_marker(kind) + self.file_store.append([ True, path+marker, _('added'), path ]) for path, id, kind in self.delta.removed: - self.file_store.append([ True, path, _('removed') ]) + marker = osutils.kind_marker(kind) + self.file_store.append([ True, path+marker, _('removed'), path ]) for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed: - self.file_store.append([ True, oldpath, _('renamed') ]) + marker = osutils.kind_marker(kind) + if text_modified or meta_modified: + changes = _('renamed and modified') + else: + changes = _('renamed') + self.file_store.append([ True, + oldpath+marker + ' => ' + newpath+marker, + changes, + newpath + ]) for path, id, kind, text_modified, meta_modified in self.delta.modified: - self.file_store.append([ True, path, _('modified') ]) + marker = osutils.kind_marker(kind) + self.file_store.append([ True, path+marker, _('modified'), path ]) def _create_pending_merges(self): liststore = gtk.ListStore(gobject.TYPE_STRING, @@ -148,7 +173,8 @@ it = self.file_store.get_iter_first() while it: if self.file_store.get_value(it, 0): - ret.append(self.file_store.get_value(it, 1)) + # get real path from hidden column 3 + ret.append(self.file_store.get_value(it, 3)) it = self.file_store.iter_next(it) return ret @@ -270,8 +296,8 @@ except Exception, msg: error_dialog(_('Unknown error'), str(msg)) return - + self.close() - + def close(self, widget=None): self.window.destroy() === modified file 'olive/dialog.py' --- olive/dialog.py 2006-10-04 19:11:46 +0000 +++ olive/dialog.py 2006-11-02 13:06:16 +0000 @@ -27,9 +27,10 @@ def about(): """ Display the AboutDialog. """ import olive + from guifiles import GLADEFILENAME # Load AboutDialog description - dglade = gtk.glade.XML(olive.gladefile, 'aboutdialog') + dglade = gtk.glade.XML(GLADEFILENAME, 'aboutdialog') dialog = dglade.get_widget('aboutdialog') # Set version === modified file 'olive/info.py' --- olive/info.py 2006-09-30 13:04:15 +0000 +++ olive/info.py 2006-11-02 13:06:17 +0000 @@ -25,8 +25,9 @@ import bzrlib.errors as errors -from olive import gladefile from dialog import error_dialog +from guifiles import GLADEFILENAME + def info(location): """ Get info about branch, working tree, and repository @@ -143,7 +144,7 @@ """ Display Informations window and perform the needed actions. """ def __init__(self, wt): """ Initialize the Informations window. """ - self.glade = gtk.glade.XML(gladefile, 'window_info', 'olive-gtk') + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_info', 'olive-gtk') # Get the Informations window widget self.window = self.glade.get_widget('window_info') === modified file 'olive/menu.py' --- olive/menu.py 2006-10-14 11:44:16 +0000 +++ olive/menu.py 2006-11-02 13:06:17 +0000 @@ -36,20 +36,10 @@ """ This class is responsible for building the context menus. """ def __init__(self, path, selected): # Load the UI file - if sys.platform == 'win32': - self.uifile = os.path.dirname(sys.executable) + "/share/olive/cmenu.ui" - else: - self.uifile = "/usr/share/olive/cmenu.ui" - - if not os.path.exists(self.uifile): - # Load from current directory if not installed - self.uifile = "cmenu.ui" - # Check again - if not os.path.exists(self.uifile): - # Fail - print _('UI description file cannot be found.') - sys.exit(1) - + from guifiles import UIFILENAME + + self.uifile = UIFILENAME + # Preferences handler self.pref = OlivePreferences() === modified file 'olive/merge.py' --- olive/merge.py 2006-10-17 23:47:33 +0000 +++ olive/merge.py 2006-11-02 13:06:16 +0000 @@ -28,14 +28,15 @@ from bzrlib.branch import Branch import bzrlib.errors as errors -from __init__ import gladefile from dialog import error_dialog, info_dialog, warning_dialog +from guifiles import GLADEFILENAME + class MergeDialog: """ Display the Merge dialog and perform the needed actions. """ def __init__(self, wt, wtpath): """ Initialize the Merge dialog. """ - self.glade = gtk.glade.XML(gladefile, 'window_merge', 'olive-gtk') + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_merge', 'olive-gtk') self.window = self.glade.get_widget('window_merge') === modified file 'olive/mkdir.py' --- olive/mkdir.py 2006-09-30 13:04:15 +0000 +++ olive/mkdir.py 2006-11-02 13:06:17 +0000 @@ -27,14 +27,15 @@ import bzrlib.errors as errors -from olive import gladefile from dialog import error_dialog, warning_dialog +from guifiles import GLADEFILENAME + class OliveMkdir: """ Display the Make directory dialog and perform the needed actions. """ def __init__(self, wt, wtpath): """ Initialize the Make directory dialog. """ - self.glade = gtk.glade.XML(gladefile, 'window_mkdir', 'olive-gtk') + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_mkdir', 'olive-gtk') self.window = self.glade.get_widget('window_mkdir') === modified file 'olive/move.py' --- olive/move.py 2006-09-30 13:04:15 +0000 +++ olive/move.py 2006-11-02 13:06:16 +0000 @@ -29,14 +29,15 @@ import bzrlib.errors as errors from bzrlib.workingtree import WorkingTree -from olive import gladefile from dialog import error_dialog +from guifiles import GLADEFILENAME + class OliveMove: """ Display the Move dialog and perform the needed actions. """ def __init__(self, wt, wtpath, selected=[]): """ Initialize the Move dialog. """ - self.glade = gtk.glade.XML(gladefile, 'window_move', 'olive-gtk') + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_move', 'olive-gtk') self.window = self.glade.get_widget('window_move') === modified file 'olive/push.py' --- olive/push.py 2006-10-24 06:38:50 +0000 +++ olive/push.py 2006-11-02 13:06:17 +0000 @@ -26,14 +26,15 @@ import bzrlib.errors as errors -from olive import gladefile from dialog import error_dialog, info_dialog +from guifiles import GLADEFILENAME + class OlivePush: """ Display Push dialog and perform the needed actions. """ def __init__(self, branch): """ Initialize the Push dialog. """ - self.glade = gtk.glade.XML(gladefile, 'window_push') + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_push') self.window = self.glade.get_widget('window_push') === modified file 'olive/remove.py' --- olive/remove.py 2006-10-03 06:44:48 +0000 +++ olive/remove.py 2006-11-02 13:06:16 +0000 @@ -27,14 +27,15 @@ import bzrlib.errors as errors -from olive import gladefile from dialog import error_dialog, warning_dialog +from guifiles import GLADEFILENAME + class OliveRemove: """ Display the Remove file(s) dialog and perform the needed actions. """ def __init__(self, wt, wtpath, selected=[]): """ Initialize the Remove file(s) dialog. """ - self.glade = gtk.glade.XML(gladefile, 'window_remove') + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_remove') self.window = self.glade.get_widget('window_remove') === modified file 'olive/rename.py' --- olive/rename.py 2006-09-30 13:04:15 +0000 +++ olive/rename.py 2006-11-02 13:06:17 +0000 @@ -28,14 +28,15 @@ import bzrlib.errors as errors from bzrlib.workingtree import WorkingTree -from olive import gladefile from dialog import error_dialog +from guifiles import GLADEFILENAME + class OliveRename: """ Display the Rename dialog and perform the needed actions. """ def __init__(self, wt, wtpath, selected=[]): """ Initialize the Rename dialog. """ - self.glade = gtk.glade.XML(gladefile, 'window_rename') + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_rename') self.window = self.glade.get_widget('window_rename') === modified file 'olive/status.py' --- olive/status.py 2006-09-30 13:04:15 +0000 +++ olive/status.py 2006-11-02 13:06:17 +0000 @@ -23,13 +23,14 @@ import gtk import gtk.glade -from olive import gladefile +from guifiles import GLADEFILENAME + class OliveStatus: """ Display Status window and perform the needed actions. """ def __init__(self, wt, wtpath): """ Initialize the Status window. """ - self.glade = gtk.glade.XML(gladefile, 'window_status') + self.glade = gtk.glade.XML(GLADEFILENAME, 'window_status') # Get the Status window widget self.window = self.glade.get_widget('window_status')