1 # Pyvconv - A simple frontend for ffmpeg/mencoder
2 # Copyright (C) 2008, Kristian Rumberg (kristianrumberg@gmail.com)
4 # Permission to use, copy, modify, and/or distribute this software for any
5 # purpose with or without fee is hereby granted, provided that the above
6 # copyright notice and this permission notice appear in all copies.
8 # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
21 def on_treeview_click_row(self
, data
):
22 self
.widgets
.get_widget("removebutton").set_sensitive(True)
24 def on_removebutton_clicked(self
, data
):
25 selection
= self
.tree_view
.get_selection()
26 (model
, index
) = selection
.get_selected_rows()
28 itmtoremove
= self
.tree_store
.get(self
.tree_store
.iter_nth_child(None, i
[0]), 0)[0]
29 self
.file_list
.remove(itmtoremove
)
30 self
.tree_store
.clear()
31 for f
in self
.file_list
:
32 self
.tree_store
.append(None, [f
])
33 self
.tree_view
.expand_all()
34 self
.widgets
.get_widget("removebutton").set_sensitive(False)
36 def on_addbutton_clicked(self
, data
):
37 chooser
= gtk
.FileChooserDialog(title
=None,action
=gtk
.FILE_CHOOSER_ACTION_OPEN
,
38 buttons
=(gtk
.STOCK_CANCEL
,gtk
.RESPONSE_CANCEL
,gtk
.STOCK_OPEN
,gtk
.RESPONSE_OK
))
39 chooser
.set_select_multiple(True)
41 filter = gtk
.FileFilter()
42 filter.set_name("Videos")
43 filter.add_mime_type("video/*")
44 chooser
.add_filter(filter)
46 response
= chooser
.run()
47 if response
== gtk
.RESPONSE_OK
:
48 for f
in chooser
.get_filenames():
49 if f
not in self
.file_list
:
50 self
.file_list
.append(f
)
51 self
.tree_store
.clear()
52 for f
in self
.file_list
:
53 self
.tree_store
.append(None, [f
])
54 self
.tree_view
.expand_all()
55 self
.widgets
.get_widget("removebutton").set_sensitive(False)
57 elif response
== gtk
.RESPONSE_CANCEL
:
61 def on_outdirbrowsebutton_clicked(self
, data
):
62 chooser
= gtk
.FileChooserDialog(title
=None,action
=gtk
.FILE_CHOOSER_ACTION_SELECT_FOLDER
,
63 buttons
=(gtk
.STOCK_CANCEL
,gtk
.RESPONSE_CANCEL
,gtk
.STOCK_OPEN
,gtk
.RESPONSE_OK
))
65 response
= chooser
.run()
66 if response
== gtk
.RESPONSE_OK
:
67 self
.widgets
.get_widget("outdirentry").set_text(chooser
.get_filename())
68 elif response
== gtk
.RESPONSE_CANCEL
:
73 self
.widgets
= gtk
.glade
.XML("window.glade")
75 self
.tree_store
= gtk
.TreeStore(gobject
.TYPE_STRING
)
77 self
.tree_view
= self
.widgets
.get_widget("fileview")
78 self
.tree_view
.set_model(self
.tree_store
)
79 r
= gtk
.CellRendererText()
80 p_column
= gtk
.TreeViewColumn("", r
)
81 p_column
.add_attribute(r
,"text",0)
82 selection
= self
.tree_view
.get_selection()
83 selection
.set_mode(gtk
.SELECTION_MULTIPLE
)
84 selection
.connect("changed", self
.on_treeview_click_row
)
86 #self.iter = self.tree_store.append(None,["List of files to be converted"]) #Add package name
88 #tree_store.append(iter,["test.avi"])
91 self
.tree_view
.insert_column(p_column
,0)
92 self
.tree_view
.set_rules_hint(True)
94 self
.widgets
.get_widget("addbutton").connect("clicked", self
.on_addbutton_clicked
)
95 self
.widgets
.get_widget("removebutton").connect("clicked", self
.on_removebutton_clicked
)
96 self
.widgets
.get_widget("outdirbrowsebutton").connect("clicked", self
.on_outdirbrowsebutton_clicked
)
98 self
.widgets
.get_widget("window1").show_all()
100 if __name__
== "__main__":