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 _enable_or_disable_convertbutton(self
):
22 if len(self
.file_list
) > 0 and len(self
.widgets
.get_widget("outdirentry").get_text()) > 0:
23 self
.widgets
.get_widget("convertbutton").set_sensitive(True)
25 self
.widgets
.get_widget("convertbutton").set_sensitive(False)
27 def on_treeview_click_row(self
, data
):
28 self
.widgets
.get_widget("removebutton").set_sensitive(True)
30 def on_removebutton_clicked(self
, data
):
31 selection
= self
.tree_view
.get_selection()
32 (model
, index
) = selection
.get_selected_rows()
34 itmtoremove
= self
.tree_store
.get(self
.tree_store
.iter_nth_child(None, i
[0]), 0)[0]
35 self
.file_list
.remove(itmtoremove
)
36 self
.tree_store
.clear()
37 for f
in self
.file_list
:
38 self
.tree_store
.append(None, [f
])
39 self
.tree_view
.expand_all()
40 self
.widgets
.get_widget("removebutton").set_sensitive(False)
42 self
._enable
_or
_disable
_convertbutton
()
44 def on_addbutton_clicked(self
, data
):
45 chooser
= gtk
.FileChooserDialog(title
=None,action
=gtk
.FILE_CHOOSER_ACTION_OPEN
,
46 buttons
=(gtk
.STOCK_CANCEL
,gtk
.RESPONSE_CANCEL
,gtk
.STOCK_OPEN
,gtk
.RESPONSE_OK
))
47 chooser
.set_select_multiple(True)
49 filter = gtk
.FileFilter()
50 filter.set_name("Videos")
51 filter.add_mime_type("video/*")
52 chooser
.add_filter(filter)
54 response
= chooser
.run()
55 if response
== gtk
.RESPONSE_OK
:
56 for f
in chooser
.get_filenames():
57 if f
not in self
.file_list
:
58 self
.file_list
.append(f
)
59 self
.tree_store
.clear()
60 for f
in self
.file_list
:
61 self
.tree_store
.append(None, [f
])
62 self
.tree_view
.expand_all()
63 self
.widgets
.get_widget("removebutton").set_sensitive(False)
65 self
._enable
_or
_disable
_convertbutton
()
67 elif response
== gtk
.RESPONSE_CANCEL
:
71 def on_outdirbrowsebutton_clicked(self
, data
):
72 chooser
= gtk
.FileChooserDialog(title
=None,action
=gtk
.FILE_CHOOSER_ACTION_SELECT_FOLDER
,
73 buttons
=(gtk
.STOCK_CANCEL
,gtk
.RESPONSE_CANCEL
,gtk
.STOCK_OPEN
,gtk
.RESPONSE_OK
))
75 response
= chooser
.run()
76 if response
== gtk
.RESPONSE_OK
:
77 self
.widgets
.get_widget("outdirentry").set_text(chooser
.get_filename())
78 self
._enable
_or
_disable
_convertbutton
()
81 def on_convertbutton_clicked(self
, data
):
82 command
= self
.commands
[self
.combobox
.get_active_text()]
84 def __init__(self
, commands
):
85 self
.widgets
= gtk
.glade
.XML("window.glade")
87 self
.tree_store
= gtk
.TreeStore(gobject
.TYPE_STRING
)
89 self
.tree_view
= self
.widgets
.get_widget("fileview")
90 self
.tree_view
.set_model(self
.tree_store
)
91 r
= gtk
.CellRendererText()
92 p_column
= gtk
.TreeViewColumn("", r
)
93 p_column
.add_attribute(r
,"text",0)
94 selection
= self
.tree_view
.get_selection()
95 selection
.set_mode(gtk
.SELECTION_MULTIPLE
)
96 selection
.connect("changed", self
.on_treeview_click_row
)
98 #self.iter = self.tree_store.append(None,["List of files to be converted"]) #Add package name
100 #tree_store.append(iter,["test.avi"])
103 self
.tree_view
.insert_column(p_column
,0)
104 self
.tree_view
.set_rules_hint(True)
106 self
.widgets
.get_widget("addbutton").connect("clicked", self
.on_addbutton_clicked
)
107 self
.widgets
.get_widget("removebutton").connect("clicked", self
.on_removebutton_clicked
)
108 self
.widgets
.get_widget("outdirbrowsebutton").connect("clicked", self
.on_outdirbrowsebutton_clicked
)
110 self
.commands
= commands
111 self
.widgets
.get_widget("convertbutton").connect("clicked", self
.on_convertbutton_clicked
)
113 self
.combobox
= self
.widgets
.get_widget("commandcombo")
114 self
.combobox
.set_model(gtk
.ListStore(str))
115 cell
= gtk
.CellRendererText()
116 self
.combobox
.pack_start(cell
, True)
117 self
.combobox
.add_attribute(cell
, 'text', 0)
120 self
.combobox
.append_text(c
.get_name())
121 self
.combobox
.set_active(0)
123 self
.widgets
.get_widget("window1").connect("delete-event", gtk
.main_quit
)
125 self
.widgets
.get_widget("window1").show_all()