diff --git a/src/devede/interface_manager.py b/src/devede/interface_manager.py index b1bbfae..b639426 100644 --- a/src/devede/interface_manager.py +++ b/src/devede/interface_manager.py @@ -255,7 +255,6 @@ class interface_manager(GObject.GObject): counter = 0 dv = 0 for item in element[1]: - print (item) the_list.append([item]) if (item == obj): dv = counter diff --git a/src/devede/project.py b/src/devede/project.py index bdc6293..5a765a8 100644 --- a/src/devede/project.py +++ b/src/devede/project.py @@ -18,6 +18,7 @@ from gi.repository import Gtk import os import time +import shutil import devede.file_movie import devede.ask @@ -31,6 +32,7 @@ import devede.dvdauthor_converter import devede.mkisofs import devede.end_job import devede.vcdimager_converter +import devede.shutdown class devede_project: @@ -373,6 +375,16 @@ class devede_project: if (not data.run()): return + if os.path.exists(data.path): + ask_w = devede.ask.ask_window() + retval = ask_w.run(_("The selected folder already exists. If you continue, it will be deleted. Continue?"),_("Delete folder")) + if retval: + shutil.rmtree(data.path,True) + else: + return + + self.shutdown = data.shutdown + run_window = devede.runner.runner() file_movies = self.get_all_files() @@ -432,6 +444,10 @@ class devede_project: def disc_done(self,object,value): + if self.shutdown: + Gtk.main_quit() + devede.shutdown.shutdown() + if value == 0: ended = devede.end_job.end_window() if self.disc_image_name == None: diff --git a/src/devede/shutdown.py b/src/devede/shutdown.py new file mode 100644 index 0000000..0bfb805 --- /dev/null +++ b/src/devede/shutdown.py @@ -0,0 +1,52 @@ +# 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 + +import dbus + +class shutdown: + + def __init__(self): + + # First, try with logind + try: + bus = dbus.SystemBus() + bus_object = bus.get_object("org.freedesktop.login1", "/org/freedesktop/login1") + bus_object.PowerOff(False, dbus_interface="org.freedesktop.login1.Manager") + except: + failure=True + + if (failure): + failure=False + + # If it fails, try with ConsoleKit + try: + bus = dbus.SystemBus() + bus_object = bus.get_object("org.freedesktop.ConsoleKit", "/org/freedesktop/ConsoleKit/Manager") + bus_object.Stop(dbus_interface="org.freedesktop.ConsoleKit.Manager") + except: + failure=True + + if (failure): + failure=False + + # If it fails, try with HAL + try: + bus = dbus.SystemBus() + bus_object = bus.get_object("org.freedesktop.Hal", "/org/freedesktop/Hal/devices/computer") + bus_object.Shutdown(dbus_interface="org.freedesktop.Hal.Device.SystemPowerManagement") + except: + failure=True