[transmageddon] First stab at drag and drop support, also check for
- From: Christian Fredrik Kalager Schaller <uraeus src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [transmageddon] First stab at drag and drop support, also check for
- Date: Sun, 13 Sep 2009 22:46:37 +0000 (UTC)
commit 5e8ca35ce05d082123f8550e42cbc7dbdd3e1f72
Author: Christian Schaller <christian schaller collabora co uk>
Date: Sun Sep 13 23:47:23 2009 +0100
First stab at drag and drop support, also check for
valid value in filechooser before taking any action
src/transmageddon.glade | 1 +
src/transmageddon.py | 38 ++++++++++++++++++++++++++++++++------
2 files changed, 33 insertions(+), 6 deletions(-)
---
diff --git a/src/transmageddon.glade b/src/transmageddon.glade
index 96991eb..f24e5f8 100644
--- a/src/transmageddon.glade
+++ b/src/transmageddon.glade
@@ -267,6 +267,7 @@
<widget class="GtkFileChooserButton" id="FileChooser">
<property name="visible">True</property>
<signal name="file_set" handler="on_FileChooser_file_set"/>
+ <signal name="selection_changed" handler="on_FileChooser_file_set"/>
</widget>
<packing>
<property name="left_attach">2</property>
diff --git a/src/transmageddon.py b/src/transmageddon.py
index 7f5386a..e926c71 100644
--- a/src/transmageddon.py
+++ b/src/transmageddon.py
@@ -52,6 +52,9 @@ if (major == 2) and (minor < 18):
print "You need version 2.18.0 or higher of pygobject for Transmageddon"
sys.exit(1)
+TARGET_TYPE_URI_LIST = 80
+dnd_list = [ ( 'text/uri-list', 0, TARGET_TYPE_URI_LIST ) ]
+
os.environ["GST_DEBUG_DUMP_DOT_DIR"] = "/tmp"
os.putenv('GST_DEBUG_DUMP_DIR_DIR', '/tmp')
@@ -151,6 +154,27 @@ class TransmageddonUI (gtk.glade.XML):
self.StatusBar = self.get_widget("StatusBar")
self.TopWindow.connect("destroy", gtk.main_quit)
+
+ def get_file_path_from_dnd_dropped_uri(self, uri):
+ # get the path to file
+ path = ""
+ if uri.startswith('file:\\\\\\'): # windows
+ path = uri[8:] # 8 is len('file:///')
+ elif uri.startswith('file://'): # nautilus, rox
+ path = uri[7:] # 7 is len('file://')
+ elif uri.startswith('file:'): # xffm
+ path = uri[5:] # 5 is len('file:')
+
+ return path
+
+ def on_drag_data_received(widget, context, x, y, selection, target_type, timestamp):
+ if target_type == TARGET_TYPE_URI_LIST:
+ uri = selection.data.strip('\r\n\x00')
+ self.get_widget ("FileChooser").set_uri(uri)
+
+ self.TopWindow.connect('drag_data_received', on_drag_data_received)
+ self.TopWindow.drag_dest_set( gtk.DEST_DEFAULT_MOTION |
+ gtk.DEST_DEFAULT_HIGHLIGHT | gtk.DEST_DEFAULT_DROP, dnd_list, gtk.gdk.ACTION_COPY)
self.signal_autoconnect(self) # Initialize User Interface
@@ -455,12 +479,13 @@ class TransmageddonUI (gtk.glade.XML):
def on_FileChooser_file_set(self, widget):
self.filename = self.get_widget ("FileChooser").get_filename()
self.audiodata = {}
- codecinfo = self.mediacheck(self.filename)
- self.containerchoice.set_sensitive(True)
- self.presetchoice.set_sensitive(True)
- self.presetchoice.set_active(0)
- self.ProgressBar.set_fraction(0.0)
- self.ProgressBar.set_text(_("Transcoding Progress"))
+ if self.filename is not None:
+ codecinfo = self.mediacheck(self.filename)
+ self.containerchoice.set_sensitive(True)
+ self.presetchoice.set_sensitive(True)
+ self.presetchoice.set_active(0)
+ self.ProgressBar.set_fraction(0.0)
+ self.ProgressBar.set_text(_("Transcoding Progress"))
def _start_transcoding(self):
filechoice = self.get_widget ("FileChooser").get_uri()
@@ -676,6 +701,7 @@ class TransmageddonUI (gtk.glade.XML):
print "The debug feature requiers Eye of GNOME (eog) and graphviz (dot) to be installed"
os.system("dot -Tpng -o /tmp/transmageddon-pipeline.png /tmp/transmageddon-debug-graph.dot")
os.system("eog /tmp/transmageddon-pipeline.png &")
+
if __name__ == "__main__":
hwg = TransmageddonUI()
gtk.main()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]