File: choose_disc_type.py

package info (click to toggle)
devede 4.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 3,864 kB
  • sloc: python: 5,416; makefile: 17
file content (220 lines) | stat: -rw-r--r-- 8,184 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# Copyright 2014 (C) Raster Software Vigo (Sergio Costas)
#
# This file is part of DeVeDe-NG
#
# DeVeDe-NG is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# DeVeDe-NG is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>

from gi.repository import Gtk,GObject
import os
import subprocess

import devedeng.configuration_data

class choose_disc_type(GObject.GObject):

    def __init__(self):

        self.config  = devedeng.configuration_data.configuration.get_config()

        builder = Gtk.Builder()
        builder.set_translation_domain(self.config.gettext_domain)

        builder.add_from_file(os.path.join(self.config.glade,"wselect_disk.ui"))
        builder.connect_signals(self)
        self.wask_window = builder.get_object("wselect_disk")

        self.cv = devedeng.converter.converter.get_converter()
        dvd = True
        vcd = True
        cvd = True
        svcd = True
        divx = True
        mkv = True
        analizers, players, converters, menuers, burners, mkiso = self.cv.get_needed_programs()

        if (analizers is not None) or (converters is not None):
            dvd = False
            vcd = False
            cvd = False
            svcd = False
            divx = False
            mkv = False

        if menuers is not None:
            dvd = False

        if mkiso is not None:
            dvd = False

        if self.check_program(["dvdauthor","--help"]) == False:
            dvd = False
        if self.check_program(["vcdimager","--help"]) == False:
            vcd = False
            svcd = False
            cvd = False
        if self.check_program(["spumux" , "--help"]) == False:
            dvd = False
            vcd = False
            svcd = False
            cvd = False

        if self.cv.discs.count("dvd") == 0:
            dvd = False
        if self.cv.discs.count("vcd") == 0:
            vcd = False
        if self.cv.discs.count("svcd") == 0:
            svcd = False
        if self.cv.discs.count("cvd") == 0:
            cvd = False
        if self.cv.discs.count("divx") == 0:
            divx = False
        if self.cv.discs.count("mkv") == 0:
            mkv = False

        builder.get_object("button_dvd").set_sensitive(dvd)
        builder.get_object("button_vcd").set_sensitive(vcd)
        builder.get_object("button_svcd").set_sensitive(svcd)
        builder.get_object("button_cvd").set_sensitive(cvd)
        builder.get_object("button_divx").set_sensitive(divx)
        builder.get_object("button_mkv").set_sensitive(mkv)

        self.wask_window.show_all()

    def check_program(self,command_line):
        try:
            handle = subprocess.Popen(command_line, stdout = subprocess.PIPE, stderr = subprocess.PIPE)
            (stdout, stderr) = handle.communicate()
            retval = handle.wait()
            return True
        except:
            return False

    def set_type(self,disc_type):
        
        self.config.set_disc_type(disc_type)
        self.wask_window.hide()
        self.wask_window.destroy()
        self.wask_window = None

    def on_button_dvd_clicked(self,b):

        self.set_type("dvd")

    def on_button_vcd_clicked(self,b):

        self.set_type("vcd")

    def on_button_svcd_clicked(self,b):

        self.set_type("svcd")

    def on_button_cvd_clicked(self,b):

        self.set_type("cvd")

    def on_button_divx_clicked(self,b):

        self.set_type("divx")

    def on_button_mkv_clicked(self,b):

        self.set_type("mkv")

    def on_help_clicked(self,b):
        
        help_file = devedeng.help.help("select.html")

    def on_programs_needed_clicked(self,b):

        builder = Gtk.Builder()
        builder.set_translation_domain(self.config.gettext_domain)
        builder.add_from_file(os.path.join(self.config.glade,"wneeded.ui"))
        window = builder.get_object("needed")
        textbuf = builder.get_object("textbuffer")

        window.show_all()

        analizers, players, menuers, converters, burners, mkiso = self.cv.get_supported_programs()
        analizers_i, players_i, menuers_i, converters_i, burners_i, mkiso_i = self.cv.get_available_programs()

        text = ""
        for e in analizers:
            if analizers_i.count(e.display_name) == 0:
                text += _("\t%(program_name)s (not installed)\n") % {"program_name": e.display_name}
            else:
                text += _("\t%(program_name)s (installed)\n") % {"program_name": e.display_name}
        text1 = _("Movie identifiers (install at least one of these):\n\n%(program_list)s\n") % {"program_list" : text}

        text = ""
        for e in players:
            if players_i.count(e.display_name) == 0:
                text += _("\t%(program_name)s (not installed)\n") % {"program_name": e.display_name}
            else:
                text += _("\t%(program_name)s (installed)\n") % {"program_name": e.display_name}
        text2 = _("Movie players (install at least one of these):\n\n%(program_list)s\n") % {"program_list" : text}

        text = ""
        for e in converters:
            sup = ""
            for s in e.disc_types:
                if sup != "":
                    sup += ", "
                sup += s
            if converters_i.count(e.display_name) == 0:
                text += _("\t%(program_name)s (not installed)\n") % {"program_name": e.display_name + " ("+sup+")"}
            else:
                text += _("\t%(program_name)s (installed)\n") % {"program_name": e.display_name + " ("+sup+")"}
        text3 = _("Movie Converters (install at least one of these):\n\n%(program_list)s\n") % {"program_list" : text}

        text = ""
        for e in burners:
            if burners_i.count(e.display_name) == 0:
                text += _("\t%(program_name)s (not installed)\n") % {"program_name": e.display_name}
            else:
                text += _("\t%(program_name)s (installed)\n") % {"program_name": e.display_name}
        text4 = _("CD/DVD burners (install at least one of these):\n\n%(program_list)s\n") % {"program_list" : text}

        text = ""
        for e in mkiso:
            if mkiso_i.count(e.display_name) == 0:
                text += _("\t%(program_name)s (not installed)\n") % {"program_name": e.display_name}
            else:
                text += _("\t%(program_name)s (installed)\n") % {"program_name": e.display_name}
        text5 = _("ISO creators (install at least one of these):\n\n%(program_list)s\n") % {"program_list" : text}

        text = ""
        if self.check_program(["dvdauthor","--help"]) == False:
            text += _("\t%(program_name)s (not installed)\n") % {"program_name": "DVDAUTHOR (dvd)"}
        else:
            text += _("\t%(program_name)s (installed)\n") % {"program_name":  "DVDAUTHOR (dvd)"}
        if self.check_program(["vcdimager","--help"]) == False:
            text += _("\t%(program_name)s (not installed)\n") % {"program_name": "VCDIMAGER (vcd, svcd, cvd)"}
        else:
            text += _("\t%(program_name)s (installed)\n") % {"program_name":  "VCDIMAGER (vcd, svcd, cvd)"}
        if self.check_program(["spumux" , "--help"]) == False:
            text += _("\t%(program_name)s (not installed)\n") % {"program_name": "SPUMUX (dvd, vcd, svcd, cvd)"}
        else:
            text += _("\t%(program_name)s (installed)\n") % {"program_name":  "SPUMUX (dvd, vcd, svcd, cvd)"}

        text6 = _("Other programs:\n\n%(program_list)s\n") % {"program_list" : text}

        final_text = text1+text2+text3+text4+text5+text6
        textbuf.insert_at_cursor(final_text,len(final_text))
        window.run()
        window.destroy()


    def on_wselect_disk_destroy_event(self,w,b):

        Gtk.main_quit()