9 class FilmView(gtk.HBox):
10 def __init__(self, parent):
11 gtk.HBox.__init__(self)
13 self.parent_window = parent
15 self.inhibit_save = True
17 self.table = gtk.Table()
18 self.pack_start(self.table, True, True)
20 self.table.set_row_spacings(4)
21 self.table.set_col_spacings(12)
22 self.film_name = gtk.Entry()
23 self.ratio = gtk.combo_box_new_text()
24 for r in ratio.ratios:
25 self.ratio.append_text(r.name())
26 self.content_file_radio = gtk.RadioButton()
27 self.content_file_radio.set_label("File")
28 self.content_file_chooser = gtk.FileChooserDialog("Content", self.parent_window, gtk.FILE_CHOOSER_ACTION_OPEN, (("Select", gtk.RESPONSE_OK)))
29 self.content_file_button = gtk.FileChooserButton(self.content_file_chooser)
30 self.content_folder_radio = gtk.RadioButton()
31 self.content_folder_radio.set_label("Folder")
32 self.content_folder_radio.set_group(self.content_file_radio)
33 self.content_folder_chooser = gtk.FileChooserDialog("Content", self.parent_window, gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER, (("Select", gtk.RESPONSE_OK)))
34 self.content_folder_button = gtk.FileChooserButton(self.content_folder_chooser)
35 self.dvd = gtk.CheckButton("DVD")
36 self.dvd_title = gtk.SpinButton()
37 self.dvd_title.set_range(0, 32)
38 self.dvd_title.set_increments(1, 4)
39 self.deinterlace = gtk.CheckButton("Deinterlace")
40 self.left_crop = self.crop_spinbutton()
41 self.right_crop = self.crop_spinbutton()
42 self.top_crop = self.crop_spinbutton()
43 self.bottom_crop = self.crop_spinbutton()
45 # Information about the content (immutable)
46 self.source_size = self.label()
47 self.fps = self.label()
48 self.length = self.label()
51 self.thumbs_button = gtk.Button("Show Thumbnails")
53 self.film_name.connect("changed", self.changed, self)
54 self.ratio.connect("changed", self.changed, self)
55 self.deinterlace.connect("toggled", self.changed, self)
56 self.thumbs_button.connect("clicked", self.thumbs_clicked, self)
57 self.content_file_radio.connect("toggled", self.content_radio_toggled, self)
58 self.content_folder_radio.connect("toggled", self.content_radio_toggled, self)
59 self.content_file_button.connect("file-set", self.content_file_chooser_file_set, self)
60 self.content_folder_button.connect("file-set", self.content_folder_chooser_file_set, self)
61 self.dvd.connect("toggled", self.changed, self)
62 self.dvd_title.connect("value-changed", self.changed, self)
65 self.table.attach(self.label("Film"), 0, 1, n, n + 1)
66 self.table.attach(self.film_name, 1, 2, n, n + 1)
68 self.table.attach(self.label("Ratio"), 0, 1, n, n + 1)
69 self.table.attach(self.ratio, 1, 2, n, n + 1)
71 self.table.attach(self.label("Content"), 0, 1, n, n + 1)
74 b.pack_start(self.content_file_radio, False, False)
75 b.pack_start(self.content_file_button, True, True)
76 b.pack_start(self.content_folder_radio, False, False)
77 b.pack_start(self.content_folder_button, True, True)
78 self.table.attach(b, 1, 2, n, n + 1)
80 self.table.attach(self.dvd, 0, 2, n, n + 1)
82 self.table.attach(self.label("DVD title"), 0, 1, n, n + 1)
83 self.table.attach(self.dvd_title, 1, 2, n, n + 1)
85 self.table.attach(self.deinterlace, 0, 2, n, n + 1)
87 self.table.attach(self.label("Left Crop"), 0, 1, n, n + 1)
88 self.table.attach(self.left_crop, 1, 2, n, n + 1)
90 self.table.attach(self.label("Right Crop"), 0, 1, n, n + 1)
91 self.table.attach(self.right_crop, 1, 2, n, n + 1)
93 self.table.attach(self.label("Top Crop"), 0, 1, n, n + 1)
94 self.table.attach(self.top_crop, 1, 2, n, n + 1)
96 self.table.attach(self.label("Bottom Crop"), 0, 1, n, n + 1)
97 self.table.attach(self.bottom_crop, 1, 2, n, n + 1)
99 self.table.attach(self.label("Source size"), 0, 1, n, n + 1)
100 self.table.attach(self.source_size, 1, 2, n, n + 1)
102 self.table.attach(self.label("Frames per second"), 0, 1, n, n + 1)
103 self.table.attach(self.fps, 1, 2, n, n + 1)
105 self.table.attach(self.label("Length"), 0, 1, n, n + 1)
106 self.table.attach(self.length, 1, 2, n, n + 1)
108 self.right_vbox = gtk.VBox()
109 self.pack_start(self.right_vbox, False, False)
111 self.right_vbox.pack_start(self.thumbs_button, False, False)
113 self.inhibit_save = False
116 self.inhibit_save = True
119 self.film_name.set_text(film.name)
120 self.ratio.set_active(ratio.ratio_to_index(film.ratio))
121 if film.content is not None:
122 if os.path.isfile(film.content):
123 self.set_content_is_file(True)
124 self.content_file_button.set_filename(film.content)
126 self.set_content_is_file(False)
127 self.content_folder_button.set_filename(film.content)
128 self.dvd.set_active(film.dvd)
129 self.dvd_title.set_value(film.dvd_title)
130 self.dvd_title.set_sensitive(film.dvd)
131 self.deinterlace.set_active(film.deinterlace)
132 self.left_crop.set_value(film.left_crop)
133 self.right_crop.set_value(film.right_crop)
134 self.top_crop.set_value(film.top_crop)
135 self.bottom_crop.set_value(film.bottom_crop)
137 # Content information
138 if film.width is not None and film.height is not None:
139 self.source_size.set_text("%dx%d" % (film.width, film.height))
141 self.source_size.set_text("Unknown")
142 if film.fps is not None:
143 self.fps.set_text(str(film.fps))
144 if film.length is not None:
145 self.length.set_text("%d:%02d:%02d" % util.s_to_hms(film.length))
147 self.inhibit_save = False
149 def set_content_is_file(self, f):
150 self.content_file_button.set_sensitive(f)
151 self.content_folder_button.set_sensitive(not f)
152 self.content_file_radio.set_active(f)
153 self.content_folder_radio.set_active(not f)
155 def label(self, text = ""):
157 l.set_alignment(0, 0.5)
160 def changed(self, a, b):
161 self.dvd_title.set_sensitive(self.dvd.get_active())
164 def crop_spinbutton(self):
167 s.set_increments(1, 16)
168 s.connect("value-changed", self.changed, self)
172 if self.inhibit_save:
175 self.film.name = self.film_name.get_text()
176 self.film.ratio = ratio.index_to_ratio(self.ratio.get_active()).ratio
178 if self.content_file_radio.get_active():
179 self.film.set_content(self.content_file_button.get_filename())
181 self.film.set_content(self.content_folder_button.get_filename())
182 self.film.set_dvd(self.dvd.get_active())
183 self.film.set_dvd_title(self.dvd_title.get_value_as_int())
184 self.film.deinterlace = self.deinterlace.get_active()
185 self.film.left_crop = self.left_crop.get_value_as_int()
186 self.film.right_crop = self.right_crop.get_value_as_int()
187 self.film.top_crop = self.top_crop.get_value_as_int()
188 self.film.bottom_crop = self.bottom_crop.get_value_as_int()
191 def thumbs_clicked(self, a, b):
192 if self.film.thumbs() == 0:
193 self.film.make_thumbs()
195 t = thumbs.Thumbs(self.film)
198 self.left_crop.set_value(t.left_crop())
199 self.right_crop.set_value(t.right_crop())
200 self.top_crop.set_value(t.top_crop())
201 self.bottom_crop.set_value(t.bottom_crop())
203 def content_file_chooser_file_set(self, a, b):
206 def content_folder_chooser_file_set(self, a, b):
209 def content_radio_toggled(self, a, b):
210 self.set_content_is_file(self.content_file_radio.get_active())