Re: [jokosher-devel] [PATCH] Added button to revert to previously saved version (bug #85941)

2007-08-19 Thread Laszlo Pandy
David Corrales wrote:
> Heya Erik,
> 
> First of all, why is the button inside File and not Project? I think the 
> entry should be under Project, called "Revert Changes" maybe?
> Also, I'm getting following error after simply adding an instrument and 
> then reverting changes:
> 
> Traceback (most recent call last):
>   File "/home/david/Projects/Jokosher/trunk/Jokosher/RecordingView.py", 
> line 264, in OnInstrumentRemoved
> instrViewer.Destroy()
>   File 
> "/home/david/Projects/Jokosher/trunk/Jokosher/InstrumentViewer.py", line 
> 252, in Destroy
> self.eventLane.Destroy()
>   File 
> "/home/david/Projects/Jokosher/trunk/Jokosher/EventLaneViewer.py", line 
> 194, in Destroy
> self.instrument.disconnect_by_func(self.OnInstrumentSignal)
> TypeError: nothing connected to  EventLaneViewer.OnInstrumentSignal of  (GtkEventBox) at 0xb5ce02fc>>
> 
> -David :)
> 


My bad. Fixed now.

Laszlo
___
jokosher-devel-list mailing list
jokosher-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/jokosher-devel-list


Re: [jokosher-devel] [PATCH] Added button to revert to previously saved version (bug #85941)

2007-08-19 Thread Laszlo Pandy
Knut Erik Teigen wrote:
> Hello,
> 
> I added a button in the menu that reverts the project back to the 
> previously saved version.
> This is done by executing all the actions in the undo stack.
> 
> Regards,
> Knut Erik Teigen
> 

This is probably not as easy to find, but you can just click on the 
first item in the recent projects menu and it will do the same thing.

Laszlo
___
jokosher-devel-list mailing list
jokosher-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/jokosher-devel-list


Re: [jokosher-devel] [PATCH] Added button to revert to previously saved version (bug #85941)

2007-08-19 Thread David Corrales
Heya Erik,

First of all, why is the button inside File and not Project? I think the
entry should be under Project, called "Revert Changes" maybe?
Also, I'm getting following error after simply adding an instrument and then
reverting changes:

Traceback (most recent call last):
  File "/home/david/Projects/Jokosher/trunk/Jokosher/RecordingView.py", line
264, in OnInstrumentRemoved
instrViewer.Destroy()
  File "/home/david/Projects/Jokosher/trunk/Jokosher/InstrumentViewer.py",
line 252, in Destroy
self.eventLane.Destroy()
  File "/home/david/Projects/Jokosher/trunk/Jokosher/EventLaneViewer.py",
line 194, in Destroy
self.instrument.disconnect_by_func(self.OnInstrumentSignal)
TypeError: nothing connected to >

-David :)

On 8/19/07, Knut Erik Teigen <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I added a button in the menu that reverts the project back to the
> previously saved version.
> This is done by executing all the actions in the undo stack.
>
> Regards,
> Knut Erik Teigen
>
> ___
> jokosher-devel-list mailing list
> jokosher-devel-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/jokosher-devel-list
>
>
>
___
jokosher-devel-list mailing list
jokosher-devel-list@gnome.org
http://mail.gnome.org/mailman/listinfo/jokosher-devel-list


[jokosher-devel] [PATCH] Added button to revert to previously saved version (bug #85941)

2007-08-19 Thread Knut Erik Teigen
Hello,

I added a button in the menu that reverts the project back to the previously
saved version.
This is done by executing all the actions in the undo stack.

Regards,
Knut Erik Teigen
Index: Jokosher.glade
===
--- Jokosher.glade	(revision 1462)
+++ Jokosher.glade	(working copy)
@@ -129,6 +129,16 @@
 		  
 
 		  
+		
+  		  True
+  		  Revert to a saved version of the project
+  gtk-revert-to-saved
+		  True
+		  
+		
+		  
+
+		  
 		
 		  True
 		  Close the current project
Index: Project.py
===
--- Project.py	(revision 1462)
+++ Project.py	(working copy)
@@ -814,7 +814,23 @@
 			len(self.__savedRedoStack) > 0
 	
 	#_
-	
+
+def Revert(self):
+"""
+Empties the undo stack.
+"""
+
+	self.__performingUndo = True
+		
+while len(self.__undoStack):
+cmd = self.__undoStack.pop()
+self.ExecuteAction(cmd)
+
+self.__performingUndo = False
+
+
+	#_
+
 	def CanPerformUndo(self):
 		"""
 		Whether it's possible to perform an undo operation.
Index: JokosherApp.py
===
--- JokosherApp.py	(revision 1462)
+++ JokosherApp.py	(working copy)
@@ -88,6 +88,7 @@
 			"on_open_activate" : self.OnOpenProject,
 			"on_save_activate" : self.OnSaveProject,
 			"on_save_as_activate" : self.OnSaveAsProject,
+			"on_revert_activate" : self.OnRevertProject,
 			"on_new_activate" : self.OnNewProject,
 			"on_close_activate" : self.OnCloseProject,
 			"on_show_as_bars_beats_ticks_toggled" : self.OnShowBarsBeats,
@@ -122,6 +123,7 @@
 		self.record = self.wTree.get_widget("Record")
 		self.save = self.wTree.get_widget("save")
 		self.save_as = self.wTree.get_widget("save_as")
+		self.revert = self.wTree.get_widget("revert")
 		self.close = self.wTree.get_widget("close")
 		self.reverse = self.wTree.get_widget("Rewind")
 		self.forward = self.wTree.get_widget("Forward")
@@ -800,6 +802,52 @@
 		
 	#_
 
+	def OnRevertProject(self, widget=None):
+		"""
+		Creates and shows a dialog which allows the user to revert
+		the current project to the previously saved version.
+		
+		Parameters:
+			widget -- reserved for GTK callbacks, don't use it explicitly.
+		"""
+
+message = _("Revert unsaved changes to project \"%s\"?\n\nChanges made to the project will be permanently lost.") % self.project.name
+
+dlg = gtk.MessageDialog(self.window,
+gtk.DIALOG_MODAL |
+gtk.DIALOG_DESTROY_WITH_PARENT,
+gtk.MESSAGE_QUESTION,
+gtk.BUTTONS_NONE)
+dlg.set_markup(message)
+
+dlg.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
+defaultAction = dlg.add_button(gtk.STOCK_REVERT_TO_SAVED, gtk.RESPONSE_YES)
+dlg.set_default(defaultAction)
+
+dlg.set_transient_for(self.window)
+
+response = dlg.run()
+dlg.destroy()
+if response == gtk.RESPONSE_YES:
+# Reverts by emptying the undoStack
+self.project.Revert()
+
+
+# Reverts by closing the project and reopening it
+# 
+# path = self.project.projectfile
+# 
+# self.Stop()
+# self.project.CloseProject()
+# self.project = None
+# self.mode = None
+# 
+# self.OpenProjectFromPath(path)
+elif response == gtk.RESPONSE_CANCEL or response == gtk.RESPONSE_DELETE_EVENT:
+pass 
+
+	#_
+
 	def OnNewProject(self, widget, destroyCallback=None):
 		"""
 		Creates and shows the "New Project" dialog.
@@ -1278,7 +1326,7 @@
 		if self.tvtoolitem in self.toolbar.get_children():
 			self.toolbar.remove(self.tvtoolitem)
 		
-		ctrls = (self.save, self.save_as, self.close, self.addInstrumentButton, self.addAudioFileButton,
+		ctrls = (self.save, self.save_as, self.revert, self.close, self.addInstrumentButton, self.addAudioFileButton,
 			self.reverse, self.forward, self.play, self.stop, self.record,
 			self.projectMenu, self.instrumentMenu, self.export, self.cut, self.copy, self.paste,
 			self.undo, self.redo, self.delete, self.compactMixButton)
@@ -1383,11 +1431,19 @@
 	def OnFileMenu(self, widget):
 		"