File simple-ccsm-cm-dry.patch of Package simple-ccsm
Index: simple-ccsm.in
===================================================================
--- simple-ccsm.in.orig
+++ simple-ccsm.in
@@ -214,6 +214,17 @@ def SetupBoxModel(box):
else:
box.get_model().clear()
+def ReallyEnableEffectsConfirmationResponse(dialog, response, mainwin):
+ if response != gtk.RESPONSE_YES:
+ mainwin.EnableEffectsButton.set_active(False)
+ os.system("killall -9 compiz")
+
+ dialog.destroy()
+
+def DialogCloseOnTimeout(dialog):
+ dialog.response(gtk.RESPONSE_NO)
+ return False
+
class DesktopPreview(gtk.Widget):
def __init__(self, size=(0,0)):
gtk.Widget.__init__(self)
@@ -1220,26 +1231,17 @@ class MainWin:
enabled = self.EnableEffectsButton.get_active()
if enabled:
# First try to check if compiz can be run
- cmd = CompizDryRunCommand.split(" ")
- proc = subprocess.Popen(cmd, shell=True)
- proc.wait()
- if proc.returncode != 0:
+ if os.system(CompizDryRunCommand) != 0:
# Dry run detected problems, warn the user
- dialog = gtk.Dialog ()
- dialog.set_title("Error")
- dialog.set_border_width(6)
- label = gtk.Label(_("Desktop effects are not supported on your current hardware / configuration. Would you like to cancel enabling of desktop effects or run them anyway?"))
- label.set_line_wrap(True)
- dialog.vbox.pack_start(label,
- gtk.TRUE,
- gtk.FALSE,
- 3)
- dialog.add_button(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL)
- dialog.add_button("Run anyway", gtk.RESPONSE_OK)
+ dialog = gtk.MessageDialog(self.Window,
+ 0,
+ gtk.MESSAGE_WARNING,
+ gtk.BUTTONS_YES_NO,
+ _("Desktop effects are not supported on your current hardware / configuration. Would you like to activate them anyway?"))
dialog.show_all()
response = dialog.run()
dialog.destroy()
- if response != gtk.RESPONSE_OK:
+ if response != gtk.RESPONSE_YES:
self.EnableEffectsButton.set_active(False)
return
@@ -1267,7 +1269,7 @@ class MainWin:
# Start compiz
cmd = CompizStartCommand.split(" ")
- subprocess.Popen(cmd)
+ proc = subprocess.Popen(cmd)
# Enable compiz in kde
try:
@@ -1284,6 +1286,16 @@ class MainWin:
os.remove(path)
except (IOError, OSError):
pass
+
+ # Show a timeout dialog to rollback if there's any problem
+ dialog = gtk.MessageDialog(self.Window,
+ 0,
+ gtk.MESSAGE_QUESTION,
+ gtk.BUTTONS_YES_NO,
+ _("Do you want to keep these settings? In 10 seconds, previous settings will be restored if you don't aknowledge the changes to your configuration"))
+ dialog.show_all()
+ dialog.connect("response", ReallyEnableEffectsConfirmationResponse, self)
+ gobject.timeout_add(10000, DialogCloseOnTimeout, dialog)
else:
fallbackWM = ""
if GnomeSession in os.environ and os.environ[GnomeSession]:
@@ -1297,8 +1309,10 @@ class MainWin:
subprocess.Popen(cmd)
# Reset window manager config for KDE
- cmd = "kwriteconfig --file ksmserverrc --group General --key windowManager kwin".split(" ")
- subprocess.Popen(cmd)
+ try:
+ subprocess.call('kwriteconfig --file ksmserverrc --group General --key windowManager kwin'.split())
+ except (IOError, OSError):
+ pass
# Create a file that indicates compiz is explicitly disabled, so should not
# be started