[Pkg-bazaar-commits] ./bzr-gtk/unstable r84: Merge cleanups from Szilveszter.

Jelmer Vernooij jelmer at samba.org
Fri Apr 10 07:49:25 UTC 2009


------------------------------------------------------------
revno: 84
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: bzr-gtk
timestamp: Sat 2006-09-30 12:17:07 +0200
message:
  Merge cleanups from Szilveszter.
modified:
  olive/__init__.py
  olive/bookmark.py
  olive/menu.py
  olive/remove.py
    ------------------------------------------------------------
    revno: 0.8.93
    committer: Szilveszter Farkas (Phanatic) <Szilveszter.Farkas at gmail.com>
    branch nick: merge
    timestamp: Sat 2006-09-30 00:22:20 +0200
    message:
      Some further cleanups. More to come.
    modified:
      olive/__init__.py
      olive/bookmark.py
      olive/menu.py
      olive/remove.py
-------------- next part --------------
=== modified file 'olive/__init__.py'
--- a/olive/__init__.py	2006-09-29 12:17:19 +0000
+++ b/olive/__init__.py	2006-09-29 22:22:20 +0000
@@ -366,7 +366,6 @@
         self.refresh_left()
         # Refresh the right pane
         self.refresh_right()
-
    
     def on_menuitem_view_show_hidden_files_activate(self, widget):
         """ View/Show hidden files menu handler. """
@@ -379,8 +378,15 @@
             if self.get_selected_left() == None:
                 return
 
-            self.menu.left_context_menu().popup(None, None, None, 0,
-                                                event.time)
+            # Create a menu
+            from menu import OliveMenu
+            menu = OliveMenu(self.get_path(), self.get_selected_left())
+            
+            menu.left_context_menu().popup(None, None, None, 0,
+                                           event.time)
+            
+            # Bookmarks might have changed
+            self.pref.read()
         
     def on_treeview_left_row_activated(self, treeview, path, view_column):
         """ Occurs when somebody double-clicks or enters an item in the
@@ -785,13 +791,7 @@
         self.config = ConfigParser.RawConfigParser()
         
         # Load the configuration
-        if sys.platform == 'win32':
-            # Windows - no dotted files
-            self.config.read([os.path.expanduser('~/olive.conf')])
-        else:
-            self.config.read([os.path.expanduser('~/.olive.conf')])
- 
-
+        self.read()
         
     def _get_default(self, option):
         """ Get the default option for a preference. """
@@ -807,12 +807,16 @@
         # First write out the changes
         self.write()
         # Then load the configuration again
+        self.read()
+
+    def read(self):
+        """ Just read the configuration. """
         if sys.platform == 'win32':
             # Windows - no dotted files
             self.config.read([os.path.expanduser('~/olive.conf')])
         else:
             self.config.read([os.path.expanduser('~/.olive.conf')])
-
+    
     def write(self):
         """ Write the configuration to the appropriate files. """
         if sys.platform == 'win32':

=== modified file 'olive/bookmark.py'
--- a/olive/bookmark.py	2006-09-27 21:05:19 +0000
+++ b/olive/bookmark.py	2006-09-29 22:22:20 +0000
@@ -14,8 +14,6 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-import sys
-
 try:
     import pygtk
     pygtk.require("2.0")
@@ -24,16 +22,20 @@
 
 import gtk
 import gtk.glade
-from olive import gladefile
+
+from olive import gladefile, OlivePreferences
+from dialog import error_dialog
 
 class OliveBookmark:
     """ Display the Edit bookmark dialog and perform the needed actions. """
-    def __init__(self, comm):
+    def __init__(self, selected):
         """ Initialize the Edit bookmark dialog. """
         self.glade = gtk.glade.XML(gladefile, 'window_bookmark', 'olive-gtk')
         
         self.window = self.glade.get_widget('window_bookmark')
         
+        self.pref = self.pref = OlivePreferences()
+        
         # Dictionary for signal_autoconnect
         dic = { "on_button_bookmark_save_clicked": self.bookmark,
                 "on_button_bookmark_cancel_clicked": self.close }
@@ -44,22 +46,25 @@
         # Get some important widgets
         self.entry_location = self.glade.get_widget('entry_bookmark_location')
         self.entry_title = self.glade.get_widget('entry_bookmark_title')
+        
+        self.selected = selected
 
     def display(self):
         """ Display the Edit bookmark dialog. """
-        path = self.comm.get_selected_left()
+        path = self.selected
         self.entry_location.set_text(path)
-        self.entry_title.set_text(self.comm.pref.get_bookmark_title(path))
+        self.entry_title.set_text(self.pref.get_bookmark_title(path))
         self.window.show_all()
         
     def bookmark(self, widget):
         if self.entry_title.get_text() == '':
             error_dialog(_('No title given'),
-                                     _('Please specify a title to continue.'))
+                         _('Please specify a title to continue.'))
             return
         
-        self.comm.pref.set_bookmark_title(self.entry_location.get_text(),
-                                          self.entry_title.get_text())
+        self.pref.set_bookmark_title(self.entry_location.get_text(),
+                                     self.entry_title.get_text())
+        self.pref.write()
         
         self.close()
     

=== modified file 'olive/menu.py'
--- a/olive/menu.py	2006-09-29 12:17:19 +0000
+++ b/olive/menu.py	2006-09-29 22:22:20 +0000
@@ -230,7 +230,7 @@
         from bookmark import OliveBookmark
 
         if self.selected != None:
-            bookmark = OliveBookmark()
+            bookmark = OliveBookmark(self.selected)
             bookmark.display()
 
     def remove_bookmark(self, action):

=== modified file 'olive/remove.py'
--- a/olive/remove.py	2006-09-27 21:05:19 +0000
+++ b/olive/remove.py	2006-09-29 22:22:20 +0000
@@ -14,7 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-import sys
+import os
 
 try:
     import pygtk
@@ -26,13 +26,13 @@
 import gtk.glade
 
 import bzrlib.errors as errors
-from bzrlib.workingtree import WorkingTree
 
 from olive import gladefile
+from dialog import error_dialog, warning_dialog
 
 class OliveRemove:
     """ Display the Remove file(s) dialog and perform the needed actions. """
-    def __init__(self):
+    def __init__(self, wt, wtpath, selected=[]):
         """ Initialize the Remove file(s) dialog. """
         self.glade = gtk.glade.XML(gladefile, 'window_remove')
         
@@ -44,6 +44,10 @@
         
         # Connect the signals to the handlers
         self.glade.signal_autoconnect(dic)
+        
+        self.wt = wt
+        self.wtpath = wtpath
+        self.selected = selected
 
     def display(self):
         """ Display the Remove file(s) dialog. """
@@ -53,44 +57,39 @@
         radio_selected = self.glade.get_widget('radiobutton_remove_selected')
         radio_new = self.glade.get_widget('radiobutton_remove_new')
         
-        directory = self.comm.get_path()
-        
         if radio_selected.get_active():
             # Remove only the selected file
-            filename = self.comm.get_selected_right()
+            filename = self.selected
             
             if filename is None:
                 error_dialog(_('No file was selected'),
-                                         _('Please select a file from the list,\nor choose the other option.'))
+                             _('Please select a file from the list,\nor choose the other option.'))
                 return
             
+            if self.wtpath == "":
+                fullpath = self.wt.abspath(filename)
+            else:
+                fullpath = self.wt.abspath(self.wtpath + os.sep + filename)
+            
             try:
-                wt, path = WorkingTree.open_containing(directory + '/' + filename)
-                wt.remove(path)
+                self.wt.remove(fullpath)
             except errors.NotBranchError:
                 error_dialog(_('Directory is not a branch'),
-                                         _('You can perform this action only in a branch.'))
+                             _('You can perform this action only in a branch.'))
                 return
             except errors.NotVersionedError:
                 error_dialog(_('File not versioned'),
-                                         _('The selected file is not versioned.'))
+                             _('The selected file is not versioned.'))
                 return
         elif radio_new.get_active():
             # Remove added files recursively
-            try:
-                wt, path = WorkingTree.open_containing(directory)
-            except errors.NotBranchError:
-                error_dialog(_('Directory is not a branch'),
-                                         _('You can perform this action only in a branch.'))
-                return
-            
-            added = wt.changes_from(wt.basis_tree()).added
+            added = self.wt.changes_from(self.wt.basis_tree()).added
             file_list = sorted([f[0] for f in added], reverse=True)
             if len(file_list) == 0:
-                dialog.warning_dialog(_('No matching files'),
-                                      _('No added files were found in the working tree.'))
+                warning_dialog(_('No matching files'),
+                               _('No added files were found in the working tree.'))
                 return
-            wt.remove(file_list)
+            self.wt.remove(file_list)
         
         self.close()
     



More information about the Pkg-bazaar-commits mailing list