| 1 |
# Copyright 2014 (C) Raster Software Vigo (Sergio Costas) |
| 2 |
# |
| 3 |
# This file is part of DeVeDe-NG |
| 4 |
# |
| 5 |
# DeVeDe-NG is free software; you can redistribute it and/or modify |
| 6 |
# it under the terms of the GNU General Public License version 3 |
| 7 |
# as published by the Free Software Foundation. |
| 8 |
# |
| 9 |
# DeVeDe-NG is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this program. If not, see <http://www.gnu.org/licenses/> |
| 16 |
|
| 17 |
from gi.repository import Gtk, GObject |
| 18 |
import os |
| 19 |
import subprocess |
| 20 |
|
| 21 |
import devedeng.configuration_data |
| 22 |
|
| 23 |
class choose_disc_type(GObject.GObject): |
| 24 |
|
| 25 |
def __init__(self): |
| 26 |
|
| 27 |
self.config = devedeng.configuration_data.configuration.get_config() |
| 28 |
|
| 29 |
builder = Gtk.Builder() |
| 30 |
builder.set_translation_domain(self.config.gettext_domain) |
| 31 |
|
| 32 |
builder.add_from_file(os.path.join( |
| 33 |
self.config.glade, "wselect_disk.ui")) |
| 34 |
builder.connect_signals(self) |
| 35 |
self.wask_window = builder.get_object("wselect_disk") |
| 36 |
|
| 37 |
self.cv = devedeng.converter.converter.get_converter() |
| 38 |
dvd = True |
| 39 |
vcd = True |
| 40 |
cvd = True |
| 41 |
svcd = True |
| 42 |
divx = True |
| 43 |
mkv = True |
| 44 |
hevc = True |
| 45 |
analizers, players, converters, menuers, burners, mkiso = self.cv.get_needed_programs() |
| 46 |
|
| 47 |
if (analizers is not None) or (converters is not None): |
| 48 |
dvd = False |
| 49 |
vcd = False |
| 50 |
cvd = False |
| 51 |
svcd = False |
| 52 |
divx = False |
| 53 |
mkv = False |
| 54 |
hevc = False |
| 55 |
|
| 56 |
if menuers is not None: |
| 57 |
dvd = False |
| 58 |
|
| 59 |
if mkiso is not None: |
| 60 |
dvd = False |
| 61 |
|
| 62 |
if self.check_program(["dvdauthor", "--help"]) == False: |
| 63 |
dvd = False |
| 64 |
if self.check_program(["vcdimager", "--help"]) == False: |
| 65 |
vcd = False |
| 66 |
svcd = False |
| 67 |
cvd = False |
| 68 |
if self.check_program(["spumux", "--help"]) == False: |
| 69 |
dvd = False |
| 70 |
vcd = False |
| 71 |
svcd = False |
| 72 |
cvd = False |
| 73 |
|
| 74 |
if self.cv.discs.count("dvd") == 0: |
| 75 |
dvd = False |
| 76 |
if self.cv.discs.count("vcd") == 0: |
| 77 |
vcd = False |
| 78 |
if self.cv.discs.count("svcd") == 0: |
| 79 |
svcd = False |
| 80 |
if self.cv.discs.count("cvd") == 0: |
| 81 |
cvd = False |
| 82 |
if self.cv.discs.count("divx") == 0: |
| 83 |
divx = False |
| 84 |
if self.cv.discs.count("mkv") == 0: |
| 85 |
mkv = False |
| 86 |
if self.cv.discs.count("hevc") == 0: |
| 87 |
hevc = False |
| 88 |
|
| 89 |
builder.get_object("button_dvd").set_sensitive(dvd) |
| 90 |
builder.get_object("button_vcd").set_sensitive(vcd) |
| 91 |
builder.get_object("button_svcd").set_sensitive(svcd) |
| 92 |
builder.get_object("button_cvd").set_sensitive(cvd) |
| 93 |
builder.get_object("button_divx").set_sensitive(divx) |
| 94 |
builder.get_object("button_mkv").set_sensitive(mkv) |
| 95 |
builder.get_object("button_hevc").set_sensitive(hevc) |
| 96 |
|
| 97 |
self.wask_window.show_all() |
| 98 |
|
| 99 |
def check_program(self, command_line): |
| 100 |
try: |
| 101 |
handle = subprocess.Popen( |
| 102 |
command_line, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 103 |
(stdout, stderr) = handle.communicate() |
| 104 |
retval = handle.wait() |
| 105 |
return True |
| 106 |
except: |
| 107 |
return False |
| 108 |
|
| 109 |
def set_type(self, disc_type): |
| 110 |
|
| 111 |
self.config.set_disc_type(disc_type) |
| 112 |
self.wask_window.hide() |
| 113 |
self.wask_window.destroy() |
| 114 |
self.wask_window = None |
| 115 |
|
| 116 |
def on_button_dvd_clicked(self, b): |
| 117 |
|
| 118 |
self.set_type("dvd") |
| 119 |
|
| 120 |
def on_button_vcd_clicked(self, b): |
| 121 |
|
| 122 |
self.set_type("vcd") |
| 123 |
|
| 124 |
def on_button_svcd_clicked(self, b): |
| 125 |
|
| 126 |
self.set_type("svcd") |
| 127 |
|
| 128 |
def on_button_cvd_clicked(self, b): |
| 129 |
|
| 130 |
self.set_type("cvd") |
| 131 |
|
| 132 |
def on_button_divx_clicked(self, b): |
| 133 |
|
| 134 |
self.set_type("divx") |
| 135 |
|
| 136 |
def on_button_mkv_clicked(self, b): |
| 137 |
|
| 138 |
self.set_type("mkv") |
| 139 |
|
| 140 |
def on_button_hevc_clicked(self, b): |
| 141 |
|
| 142 |
self.set_type("hevc") |
| 143 |
|
| 144 |
def on_help_clicked(self, b): |
| 145 |
|
| 146 |
help_file = devedeng.help.help("select.html") |
| 147 |
|
| 148 |
def on_programs_needed_clicked(self, b): |
| 149 |
|
| 150 |
builder = Gtk.Builder() |
| 151 |
builder.set_translation_domain(self.config.gettext_domain) |
| 152 |
builder.add_from_file(os.path.join(self.config.glade, "wneeded.ui")) |
| 153 |
window = builder.get_object("needed") |
| 154 |
textbuf = builder.get_object("textbuffer") |
| 155 |
|
| 156 |
window.show_all() |
| 157 |
|
| 158 |
analizers, players, menuers, converters, burners, mkiso = self.cv.get_supported_programs() |
| 159 |
analizers_i, players_i, menuers_i, converters_i, burners_i, mkiso_i = self.cv.get_available_programs() |
| 160 |
|
| 161 |
text = "" |
| 162 |
for e in analizers: |
| 163 |
if analizers_i.count(e.display_name) == 0: |
| 164 |
text += _("\t%(program_name)s (not installed)\n") % { |
| 165 |
"program_name": e.display_name} |
| 166 |
else: |
| 167 |
text += _("\t%(program_name)s (installed)\n") % { |
| 168 |
"program_name": e.display_name} |
| 169 |
text1 = _("Movie identifiers (install at least one of these):\n\n%(program_list)s\n") % { |
| 170 |
"program_list": text} |
| 171 |
|
| 172 |
text = "" |
| 173 |
for e in players: |
| 174 |
if players_i.count(e.display_name) == 0: |
| 175 |
text += _("\t%(program_name)s (not installed)\n") % { |
| 176 |
"program_name": e.display_name} |
| 177 |
else: |
| 178 |
text += _("\t%(program_name)s (installed)\n") % { |
| 179 |
"program_name": e.display_name} |
| 180 |
text2 = _("Movie players (install at least one of these):\n\n%(program_list)s\n") % { |
| 181 |
"program_list": text} |
| 182 |
|
| 183 |
text = "" |
| 184 |
for e in converters: |
| 185 |
sup = "" |
| 186 |
for s in e.disc_types: |
| 187 |
if sup != "": |
| 188 |
sup += ", " |
| 189 |
sup += s |
| 190 |
if converters_i.count(e.display_name) == 0: |
| 191 |
text += _("\t%(program_name)s (not installed)\n") % { |
| 192 |
"program_name": e.display_name + " (" + sup + ")"} |
| 193 |
else: |
| 194 |
text += _("\t%(program_name)s (installed)\n") % { |
| 195 |
"program_name": e.display_name + " (" + sup + ")"} |
| 196 |
text3 = _("Movie Converters (install at least one of these):\n\n%(program_list)s\n") % { |
| 197 |
"program_list": text} |
| 198 |
|
| 199 |
text = "" |
| 200 |
for e in burners: |
| 201 |
if burners_i.count(e.display_name) == 0: |
| 202 |
text += _("\t%(program_name)s (not installed)\n") % { |
| 203 |
"program_name": e.display_name} |
| 204 |
else: |
| 205 |
text += _("\t%(program_name)s (installed)\n") % { |
| 206 |
"program_name": e.display_name} |
| 207 |
text4 = _( |
| 208 |
"CD/DVD burners (install at least one of these):\n\n%(program_list)s\n") % {"program_list": text} |
| 209 |
|
| 210 |
text = "" |
| 211 |
for e in mkiso: |
| 212 |
if mkiso_i.count(e.display_name) == 0: |
| 213 |
text += _("\t%(program_name)s (not installed)\n") % { |
| 214 |
"program_name": e.display_name} |
| 215 |
else: |
| 216 |
text += _("\t%(program_name)s (installed)\n") % { |
| 217 |
"program_name": e.display_name} |
| 218 |
text5 = _("ISO creators (install at least one of these):\n\n%(program_list)s\n") % { |
| 219 |
"program_list": text} |
| 220 |
|
| 221 |
text = "" |
| 222 |
if self.check_program(["dvdauthor", "--help"]) == False: |
| 223 |
text += _("\t%(program_name)s (not installed)\n") % { |
| 224 |
"program_name": "DVDAUTHOR (dvd)"} |
| 225 |
else: |
| 226 |
text += _("\t%(program_name)s (installed)\n") % { |
| 227 |
"program_name": "DVDAUTHOR (dvd)"} |
| 228 |
if self.check_program(["vcdimager", "--help"]) == False: |
| 229 |
text += _("\t%(program_name)s (not installed)\n") % { |
| 230 |
"program_name": "VCDIMAGER (vcd, svcd, cvd)"} |
| 231 |
else: |
| 232 |
text += _("\t%(program_name)s (installed)\n") % { |
| 233 |
"program_name": "VCDIMAGER (vcd, svcd, cvd)"} |
| 234 |
if self.check_program(["spumux", "--help"]) == False: |
| 235 |
text += _("\t%(program_name)s (not installed)\n") % { |
| 236 |
"program_name": "SPUMUX (dvd, vcd, svcd, cvd)"} |
| 237 |
else: |
| 238 |
text += _("\t%(program_name)s (installed)\n") % { |
| 239 |
"program_name": "SPUMUX (dvd, vcd, svcd, cvd)"} |
| 240 |
|
| 241 |
text6 = _("Other programs:\n\n%(program_list)s\n") % { |
| 242 |
"program_list": text} |
| 243 |
|
| 244 |
final_text = text1 + text2 + text3 + text4 + text5 + text6 |
| 245 |
textbuf.set_text(final_text) |
| 246 |
window.run() |
| 247 |
window.destroy() |
| 248 |
|
| 249 |
def on_wselect_disk_destroy_event(self, w, b): |
| 250 |
|
| 251 |
Gtk.main_quit() |