openshot.code team mailing list archive
-
openshot.code team
-
Mailing list archive
-
Message #00008
[Branch ~openshot.code/openshot/main] Rev 503: Applied a patch from Emil to fix bug# 712947, Adding new titles with existing name overwrites the...
------------------------------------------------------------
revno: 503
committer: Andy Finch <we.rocked.in79@xxxxxxxxx>
branch nick: openshot
timestamp: Tue 2011-08-16 21:46:41 +0100
message:
Applied a patch from Emil to fix bug# 712947, Adding new titles with existing name overwrites the older file.
modified:
openshot/windows/Titles.py
--
lp:openshot
https://code.launchpad.net/~openshot.code/openshot/main
Your team OpenShot Code is subscribed to branch lp:openshot.
To unsubscribe from this branch go to https://code.launchpad.net/~openshot.code/openshot/main/+edit-subscription
=== modified file 'openshot/windows/Titles.py'
--- openshot/windows/Titles.py 2011-03-07 04:29:13 +0000
+++ openshot/windows/Titles.py 2011-08-16 20:46:41 +0000
@@ -187,31 +187,65 @@
self.btnCreate.set_sensitive(True)
def setTitleName(self):
+
+ base_name = project_path = os.path.join(self.project.folder, "thumbnail")
+
#base this on a message dialog
- dialog = gtk.MessageDialog(
+ name_dialog = gtk.MessageDialog(
None,
gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
gtk.MESSAGE_QUESTION,
gtk.BUTTONS_OK,
- None)
- dialog.set_markup(_('Please enter a name for the new Title file:'))
+ _('Please enter a name for the new Title file.'))
+ name_dialog.set_title("Enter Name")
#create the text input field
entry = gtk.Entry()
entry.set_text(_("New Title"))
#allow the user to press enter as well as the OK button
- entry.connect("activate", self.ShowInputDialog, dialog, gtk.RESPONSE_OK)
+ entry.connect("activate", self.ShowInputDialog, name_dialog, gtk.RESPONSE_OK)
hbox = gtk.HBox()
hbox.pack_start(gtk.Label(_("Name:")), False, 5, 5)
hbox.pack_end(entry)
#add it and show it
- dialog.vbox.pack_end(hbox, True, True, 0)
- dialog.show_all()
- #show the dialog
- if dialog.run() == gtk.RESPONSE_OK:
- text = entry.get_text()
- else:
- text = ''
- dialog.destroy()
+ name_dialog.vbox.pack_end(hbox, True, True, 0)
+ name_dialog.show_all()
+
+ # Show the dialog until the name doesn't exist in the project or the user gives permission to overwrite
+ while True:
+
+ # OK clicked
+ if name_dialog.run() == gtk.RESPONSE_OK:
+ text = entry.get_text()
+ # The path to the image, if created
+ path = os.path.join(base_name, text + ".svg")
+
+ # If a file with the path already is imported to the project
+ if self.project.project_folder.file_exists_in_project(path):
+
+ # Create an "Are you sure you want to overwrite?" dialog
+ overwrite_dialog = gtk.MessageDialog(
+ name_dialog,
+ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+ gtk.MESSAGE_QUESTION,
+ gtk.BUTTONS_YES_NO,
+ _("An image with the name '%s' already exists in the project.\nDo you want to overwrite it?" % (text + ".svg")))
+ overwrite_dialog.set_title("Overwrite Image?")
+ response = overwrite_dialog.run()
+ overwrite_dialog.destroy()
+
+ # If the user clicked yes, stop showing the dialog
+ if response == gtk.RESPONSE_YES:
+ break
+ else:
+ # Stop looping
+ break
+ # The user clicked 'x'
+ else:
+ text = ''
+ # Stop looping
+ break
+
+ name_dialog.destroy()
return text
def ShowInputDialog(self,entry, dialog, response):