| 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 |
| 18 |
import os |
| 19 |
import devedeng.configuration_data |
| 20 |
|
| 21 |
|
| 22 |
class create_disk_window: |
| 23 |
|
| 24 |
def __init__(self): |
| 25 |
|
| 26 |
self.config = devedeng.configuration_data.configuration.get_config() |
| 27 |
|
| 28 |
def run(self): |
| 29 |
|
| 30 |
builder = Gtk.Builder() |
| 31 |
builder.set_translation_domain(self.config.gettext_domain) |
| 32 |
|
| 33 |
builder.add_from_file(os.path.join(self.config.glade, "wcreate.ui")) |
| 34 |
builder.connect_signals(self) |
| 35 |
wcreate_window = builder.get_object("dialog_create") |
| 36 |
self.wpath = builder.get_object("path") |
| 37 |
self.wname = builder.get_object("name") |
| 38 |
wshutdown = builder.get_object("shutdown") |
| 39 |
self.waccept = builder.get_object("accept") |
| 40 |
|
| 41 |
self.wname.set_text("movie") |
| 42 |
self.wpath.set_current_folder(self.config.final_folder) |
| 43 |
|
| 44 |
wcreate_window.show_all() |
| 45 |
self.on_iface_changed(None) |
| 46 |
retval = wcreate_window.run() |
| 47 |
self.name = self.wname.get_text() |
| 48 |
self.path = os.path.join(self.wpath.get_filename(), self.name) |
| 49 |
self.shutdown = wshutdown.get_active() |
| 50 |
|
| 51 |
if (retval == 1): |
| 52 |
self.config.final_folder = self.wpath.get_filename() |
| 53 |
self.config.save_config() |
| 54 |
|
| 55 |
wcreate_window.destroy() |
| 56 |
if (retval == 1): |
| 57 |
return True |
| 58 |
else: |
| 59 |
return False |
| 60 |
|
| 61 |
def on_iface_changed(self, b): |
| 62 |
|
| 63 |
path = self.wpath.get_filename() |
| 64 |
name = self.wname.get_text() |
| 65 |
|
| 66 |
if ((path is None) or (path == "") or (name is None) or (name == "")): |
| 67 |
self.waccept.set_sensitive(False) |
| 68 |
else: |
| 69 |
self.waccept.set_sensitive(True) |