import pygtk
pygtk.require('2.0')
import gtk
import gtk.glade
import gtk.gdk as gdk
import gobject
import compizconfig
from execute import run
from subprocess import Popen
import ccm
class Base:
def SystemInfoCheck(self):
self.glxinfo = run('glxinfo', 'output')
self.xvinfo = run('xvinfo', 'output')
self.xdpyinfo = run('xdpyinfo', 'output')
# We need to check if TFP is direct or Indirect
self.tfp = False
if self.glxinfo.count('GLX_EXT_texture_from_pixmap') == 0:
self.tfp = 'none'
elif self.glxinfo.count('GLX_EXT_texture_from_pixmap') < 3:
self.tfp = 'indirect'
else:
self.tfp = 'direct'
# Because Xgl is an entirely new server, we need to check for it first
if 'Xgl' in self.xvinfo:
self.XglIsActive = True
self.possible = True
self.StartupCommand = "compiz --replace ccp"
else:
self.XglIsActive = False
if self.XglIsActive == True:
self.RenderingPathString = 'Xgl. Desktop effects are provided by an OpenGL overlay. You may notice slowness with 3D applications and Video'
else:
if self.tfp == 'direct':
self.RenderingPathString = 'Direct Rendering. Desktop effects are provided by your graphics card. You may experience driver glitches.'
self.possible = True
elif self.tfp == 'indirect':
self.RenderingPathString = 'X.org AIGLX. Some 3D applications and video may not display correctly when desktop effects are enabled'
self.possible = True
elif self.tfp == 'none':
self.RenderingPathString = 'Desktop effects cannot be enabled. You will need to configure your X server'
self.possible = False
line = [l for l in self.glxinfo.splitlines() if 'OpenGL renderer string:' in l]
if line:
self.GlxRenderer = ' '.join(line[0].split()[4:])
if 'Intel' in self.GlxRenderer:
self.StartupCommand = "INTEL_BATCH=1 LIBGL_ALWAYS_INDIRECT=1 compiz --replace ccp"
elif 'ATI' in self.GlxRenderer:
self.StartupCommand = "LIBGL_ALWAYS_INDIRECT=1 compiz --replace ccp"
elif 'NVIDIA' in self.GlxRenderer:
if self.tfp == "direct":
self.StartupCommand = "__GL_YEILD='NOTHING' compiz --replace --loose-binding ccp"
elif self.tfp == "indirect":
self.StartupCommand = "LIBGL_ALWAYS_INDIRECT=1 compiz --replace ccp"
print "For reference, your startup command is:" + " " + self.StartupCommand
def delete(self, widget, event=None):
gtk.main_quit()
return False
def openccsm(self, widget, event=None):
run("ccsm")
gtk.main_quit()
return False
def openemerald(self, widget, event=None):
run("emerald-theme-manager")
def EnableDisableCompiz(self, widget, event=None):
# First, we need to check if we are enabling or disabling
EnabledOrDisabled = self.EnableEffects.get_active()
# If it is disabled, we kill compiz, wait - then (FIXME) execute metacity
if EnabledOrDisabled == False:
run(['killall', 'compiz'])
run(['metacity', '--replace'])
elif EnabledOrDisabled == True:
run(['killall', 'metacity'])
run("compiz-manager")
def __init__(self):
self.SystemInfoCheck()
self.gladefile = gtk.glade.XML('compiz-fusion-settings.glade')
self.context = compizconfig.Context (basic_metadata = True)
self.core = self.context.Plugins["core"]
# When the window is closed, the app is closed.
self.Window = self.gladefile.get_widget('CompizFusionConfigWindow')
self.Window.connect("delete_event", self.delete)
# When we click the button, the app is closed
self.QuitButton = self.gladefile.get_widget('QuitButton')
self.QuitButton.connect("clicked", self.delete)
# When we click 'Open CCSM, this window closes
self.OpenCCSMButton = self.gladefile.get_widget('OpenCCSMButton')
self.OpenCCSMButton.connect("clicked", self.openccsm)
## Other Stuff
# We need to import the notebook, and grab the tab to set some text and stuff
self.NoteBook = self.gladefile.get_widget('FlipPages')
self.NoteBook.connect('switch-page', self.CreateTitle)
self.TitleLabel = self.gladefile.get_widget('CurrentTabLabel')
self.TitleImage = self.gladefile.get_widget('CurrentTabImage')
# Nice Function
self.CreateTitle("signal", 0, 0)
## The "General" Tab
# Enable Desktop Effects
self.EnableEffects = self.gladefile.get_widget('EnableFXCheckButton')
if run(['pgrep', 'compiz'], 'call', quiet=True) == 0:
self.EffectsAreEnabled = True
else:
self.EffectsAreEnabled = False
self.EnableEffects.set_active(self.EffectsAreEnabled)
self.EnableEffects.connect("clicked", self.EnableDisableCompiz)
# The Rendering Path Identifier
self.RenderingPathIdentifier = self.gladefile.get_widget('RenderingMethod')
self.RenderingPathIdentifier.set_text(self.RenderingPathString)
self.RenderingPathIdentifier.set_use_markup(True)
# The "Configure" Button
self.ConfigureButton = self.gladefile.get_widget('ConfigureDesktopButton')
# The "Theme" Button
self.ThemeButton = self.gladefile.get_widget('ThemeButton')
self.ThemeButton.connect("clicked", self.openemerald)
# Gfx card identifier
self.GraphicsAdaptorIdentifier = self.gladefile.get_widget('GraphicsCard')
self.GraphicsAdaptorIdentifier.set_use_markup(True)
# Xgl screws up some stuff in glxinfo, putting "Generic Graphics Card" there.
# We need to notify the user that the graphics card cannot be displayed at the
# moment
if self.XglIsActive == True:
self.GraphicsAdaptorIdentifier.set_text("Xgl is currently enabled. Therefore, your graphics card cannot be determined at this time. If you want to know your graphics card's model, disable Xgl")
else:
self.GraphicsAdaptorIdentifier.set_text(self.GlxRenderer)
# Gfx Card Image
self.DisplayImage = self.gladefile.get_widget('MonitorImage')
self.DisplayImage.set_from_file('images/display.png')
# Rendering Path Image
self.RenderImage = self.gladefile.get_widget('RenderingMethodImage')
self.RenderImage.set_from_file('images/Rendering.svg')
# Lighting Check Box
self.LightingCheckBox = self.gladefile.get_widget('EnableLighting')
self.OldLightingBool = self.core.Screens[0]["lighting"].Value
self.LightingCheckBox.set_active(self.OldLightingBool)
self.LightingCheckBox.connect("clicked", self.LightingToggled)
# VSync Check Box
self.VSyncCheckBox = self.gladefile.get_widget('VSyncEnable')
self.OldVSyncBool = self.core.Screens[0]["sync_to_vblank"].Value
self.VSyncCheckBox.set_active(self.OldVSyncBool)
self.VSyncCheckBox.connect("clicked", self.VSyncToggled)
# Now for the hard part - The Texture Filter
self.TextureFilterCombo = self.gladefile.get_widget('TextureFilteringCombo')
self.OldTextureFilteringComboValue = self.core.Display["texture_filter"].Value
self.TextureFilterCombo.set_active(self.OldTextureFilteringComboValue)
self.TextureFilterCombo.connect("changed", self.TextureFilterModified)
## The 'Windows' Tab
self.text = self.context.Plugins["text"]
self.switcher = self.context.Plugins["switcher"]
self.ring = self.context.Plugins["ring"]
self.shift = self.context.Plugins["shift"]
self.scale = self.context.Plugins["scale"]
self.scalefilter = self.context.Plugins["scalefilter"]
self.scaleaddon = self.context.Plugins["scaleaddon"]
self.thumbnail = self.context.Plugins["thumbnail"]
self.group = self.context.Plugins["group"]
self.extrawm = self.context.Plugins["extrawm"]
self.widget = self.context.Plugins["widget"]
self.expo = self.context.Plugins["expo"]
# Which Switcher to use
self.UseFlatSwitcher = self.gladefile.get_widget('AppSwitcherTypeFlat')
self.UseRingSwitcher = self.gladefile.get_widget('AppSwitcherTypeRing')
self.UseFlipSwitcher = self.gladefile.get_widget('AppSwitcherTypeFlip')
self.UseCoverSwitcher = self.gladefile.get_widget('AppSwitcherTypeCover')
# Here, we determine which of the switchers is the 'Active'
# one, and hence we set the key. The only problem is that
# flat switcher must be active by default if all switchers are enabled
# already.
if (self.switcher.Enabled == True):
self.UseFlatSwitcher.set_active(True)
self.CurSwitcherKey = self.switcher.Display["next_key"].Value
self.ring.Enabled = False
self.shift.Enabled = False
self.context.Write()
elif (self.ring.Enabled == True):
self.UseRingSwitcher.set_active(True)
self.CurSwitcherKey = self.ring.Display["next_key"].Value
self.switcher.Enabled = False
self.shift.Enabled = False
self.context.Write()
elif (self.shift.Enabled == True):
self.CurSwitcherKey = self.shift.Display["next_key"].Value
self.ring.Enabled = False
self.switcher.Enabled = False
self.context.Write
if (self.shift.Screens[0]["mode"].Value == 0):
self.UseCoverSwitcher.set_active(True)
else:
self.UseFlipSwitcher.set_active(True)
# Now we need to connect these with some functions that will do stuff. Whoppe!
self.UseFlatSwitcher.connect("clicked", self.SwitcherModeChanged)
self.UseRingSwitcher.connect("clicked", self.SwitcherModeChanged)
self.UseFlipSwitcher.connect("clicked", self.SwitcherModeChanged)
self.UseCoverSwitcher.connect("clicked", self.SwitcherModeChanged)
# Here we are going to do the screencorners. What we need to do here is
# check every possible option to see if a screencorner is set for that widget
# First, we need to set options up
self.ScaleCurrent = self.scale.Display["initiate_edge"]
self.ScaleAll = self.scale.Display["initiate_all_edge"]
self.ScaleApp = self.scale.Display["initiate_group_edge"]
self.ShowDesktop = self.core.Display["show_desktop_edge"]
self.ExpoEdge = self.expo.Display["expo_edge"]
self.Widgets = self.widget.Display["toggle_edge"]
self.Nothing = "Nothing"
# Now we need to create a dictionary that relates the option names back to the numbers
self.ScreenCornerPlugins = [self.Nothing, self.ScaleCurrent, self.ScaleAll, self.ScaleApp, self.ExpoEdge, self.ShowDesktop, self.Widgets]
# Now, we create a loop to find out which number has which option
for OptionName in self.ScreenCornerPlugins:
if OptionName != "Nothing":
if OptionName.Value == "TopRight":
self.CurTopRight = self.ScreenCornerPlugins.index(OptionName)
self.TopRightOldOption = OptionName
break
else:
self.CurTopRight = 0
self.TopRightOldOption = "Nothing"
for OptionName in self.ScreenCornerPlugins:
if OptionName != "Nothing":
if OptionName.Value == "TopLeft":
self.CurTopLeft = self.ScreenCornerPlugins.index(OptionName)
self.TopLeftOldOption = OptionName
break
else:
self.CurTopLeft = 0
self.TopLeftOldOption = "Nothing"
for OptionName in self.ScreenCornerPlugins:
if OptionName != "Nothing":
if OptionName.Value == "BottomRight":
self.CurBottomRight = self.ScreenCornerPlugins.index(OptionName)
self.BottomRightOldOption = OptionName
break
else:
self.CurBottomRight = 0
self.BottomRightOldOption = "Nothing"
for OptionName in self.ScreenCornerPlugins:
if OptionName != "Nothing":
if OptionName.Value == "BottomLeft":
print OptionName.Value
self.CurBottomLeft = self.ScreenCornerPlugins.index(OptionName)
self.BottomLeftOldOption = OptionName
break
else:
self.CurBottomLeft = 0
self.BottomLeftOldOption = "Nothing"
# Now that we know which screencorner contains what option,
# we can set up each widget to contain each option by default
self.TopLeftSelect = self.gladefile.get_widget('TopLeftEdgeSelect')
if (self.CurTopLeft != None):
self.TopLeftSelect.set_active(self.CurTopLeft)
else:
self.TopLeftSelect.set_active(0)
self.TopLeftSelect.connect("changed", self.TopLeftSelectChanged)
self.TopRightSelect = self.gladefile.get_widget('TopRightEdgeSelect')
if (self.CurTopRight != None):
self.TopRightSelect.set_active(self.CurTopRight)
else:
self.TopRightSelect.set_active(0)
self.TopRightSelect.connect("changed", self.TopRightSelectChanged)
self.BottomLeftSelect = self.gladefile.get_widget('BottomLeftEdgeSelect')
if (self.CurBottomLeft != None):
self.BottomLeftSelect.set_active(self.CurBottomLeft)
else:
self.BottomLeftSelect.set_active(0)
self.BottomLeftSelect.connect("changed", self.BottomLeftSelectChanged)
self.BottomRightSelect = self.gladefile.get_widget('BottomRightEdgeSelect')
if (self.CurBottomRight != None):
self.BottomRightSelect.set_active(self.CurBottomRight)
else:
self.BottomRightSelect.set_active(0)
self.BottomRightSelect.connect("changed", self.BottomRightSelectChanged)
# The 'App switch with' entry
self.SwitcherKey = self.gladefile.get_widget('AppSwitcherKey')
self.SwitcherKey.set_text(self.CurSwitcherKey)
self.SwitcherKey.connect("activate", self.SwitcherKeyChanged)
# Allow grouping / allow tabbing
self.AllowTabbing = self.gladefile.get_widget('AllowTabbingCheckBox')
self.AllowTabbingOld = self.group.Screens[0]["autotab_create"].Value
self.AllowTabbing.set_active(self.AllowTabbingOld)
self.AllowTabbing.connect("clicked", self.AllowTabbingToggled)
self.AllowGrouping = self.gladefile.get_widget('AllowGroupingCheckBox')
self.AllowGroupingOld = self.group.Enabled
self.AllowGrouping.set_active(self.AllowGroupingOld)
self.AllowGrouping.connect("clicked", self.AllowGroupingToggled)
# A little statement to make inactive the "Tabbing" combox
# as it is required by group
if (self.AllowGrouping.get_active() == False):
self.AllowTabbing.set_sensitive(False)
else:
self.AllowTabbing.set_sensitive(True)
# Scale information
self.ScaleInfo = self.gladefile.get_widget('TextScale')
# FIXME : We are currently only checking scalefilter
if (self.scalefilter.Enabled == True):
self.OldScaleInfoBool = True
self.text.Enabled = True
self.scaleaddon.Enabled = True
self.scalefilter.Enabled = True
self.context.Write()
else:
self.OldScaleInfoBool = False
self.scaleaddon.Enabled = False
self.scalefilter.Enabled = False
self.context.Write()
self.ScaleInfo.set_active(self.OldScaleInfoBool)
self.ScaleInfo.connect("clicked", self.ScaleInfoToggled)
# Window Thumbnails
self.WinThumbnails = self.gladefile.get_widget('Thumbnails')
if (self.thumbnail.Enabled == True):
self.OldThumbnailBool = True
self.text.Enabled
self.context.Write()
else:
self.OldThumbnailBool = False
self.WinThumbnails.set_active(self.OldThumbnailBool)
self.WinThumbnails.connect("clicked", self.WinThumbnailsToggled)
# FullScreen Key
self.FullscreenKey = self.gladefile.get_widget('FullscreenEntry')
self.FullscreenOld = self.extrawm.Display["toggle_fullscreen_key"].Value
self.FullscreenKey.set_text(self.FullscreenOld)
self.FullscreenKey.connect("activate", self.FullscreenKeyChanged)
# Sticky Key
self.StickyKey = self.gladefile.get_widget('StickEntry')
self.StickyOld = self.extrawm.Display["toggle_sticky_key"].Value
self.StickyKey.set_text(self.StickyOld)
self.StickyKey.connect("activate", self.StickyKeyChanged)
# Desktop Tab
self.cube = self.context.Plugins["cube"]
self.rotate = self.context.Plugins["rotate"]
self.wall = self.context.Plugins["wall"]
self.plane = self.context.Plugins["plane"]
self.cubereflex = self.context.Plugins["cubereflex"]
self.TD = self.context.Plugins["3d"]
self.gears = self.context.Plugins["gears"]
self.atlantis = self.context.Plugins["atlantis"]
# HSize Config
self.Hsize = self.gladefile.get_widget('DesktopSizeX')
self.OldHsize = self.core.Screens[0]["hsize"].Value
self.Hsize.set_value(self.OldHsize)
self.Hsize.connect('format-value', self.HsizeChanged)
# VSize Config
self.Vsize = self.gladefile.get_widget('DesktopSizeY')
self.OldVsize = self.core.Screens[0]["vsize"].Value
self.Vsize.set_value(self.OldVsize)
self.Vsize.connect('format-value', self.VsizeChanged)
# Desktop Appearance
self.DesktopAppearance = self.gladefile.get_widget('DesktopAppearanceCombo')
if (self.cube.Enabled == True):
self.desktopactive = 0
self.CurrentlyActive = "cube"
self.rotate.Enabled = True
self.wall.Enabled = False
self.plane.Enabled = False
self.expo.Enabled = True
self.context.Write()
elif (self.wall.Enabled == True):
self.desktopactive = 1
self.CurrentlyActive = "wall"
self.cube.Enabled = False
self.rotate.Enabled = False
self.plane.Enabled = False
self.expo.Enabled = True
self.TD.Enabled = False
self.atlantis.Enabled = False
self.gears.Enabled = False
self.cubereflex.Enabled = False
elif (self.plane.Enabled == True):
self.desktopactive = 2
self.CurrentlyActive = "plane"
self.cube.Enabled = False
self.rotate.Enabled = False
self.plane.Enabled = False
self.expo.Enabled = False
self.TD.Enabled = False
self.atlantis.Enabled = False
self.gears.Enabled = False
self.cubereflex.Enabled = False
self.DesktopAppearance.set_active(self.desktopactive)
self.DesktopAppearance.connect('changed', self.DesktopAppearanceChanged)
# Expo Reflex
self.ExpoReflexCheck = self.gladefile.get_widget('ReflectionCheck')
self.OldExpoReflexValue = self.expo.Display["reflection"].Value
self.ExpoReflexCheck.set_active(self.OldExpoReflexValue)
self.ExpoReflexCheck.connect('clicked', self.ExpoReflexToggled)
# Cube Reflex
self.CubeReflexCheck = self.gladefile.get_widget('CubeReflectionCheck')
self.OldCubeReflexValue = self.cubereflex.Enabled
self.CubeReflexCheck.set_active(self.OldCubeReflexValue)
self.CubeReflexCheck.connect('clicked', self.
CubeReflexToggled)
# Cube Transparency
self.TransCube = self.gladefile.get_widget('CubeTransparency')
self.OldTransCubeValue = self.cube.Screens[0]["active_opacity"].Value
self.TransCube.set_value(self.OldTransCubeValue)
self.TransCube.connect('format-value', self.TransCubeValueChanged)
# I love you glade ;-)
self.gladefile.get_widget('CompizFusionConfigWindow').show_all()
if self.RenderingPathString != 'none':
self.ConfigureButton.hide()
else:
self.ConfigureButton.show()
if self.possible == False:
self.EnableEffects.set_sensitive(False)
# Effects Settings
self.wobbly = self.context.Plugins["wobbly"]
self.animation = self.context.Plugins["animation"]
self.resize = self.context.Plugins["resize"]
# Move Effect Combo
self.MoveEffect = self.gladefile.get_widget('MoveCombo')
if self.wobbly.Enabled == True:
self.MoveEffect.set_active(1)
else:
self.MoveEffect.set_active(0)
self.MoveEffect.connect("changed", self.MoveEffectChanged)
# Resize Effect Combo
self.ResizeEffect = self.gladefile.get_widget('ResizeCombo')
self.OldResizeEffectValue = self.resize.Display["mode"].Value
self.ResizeEffect.set_active(self.OldResizeEffectValue)
self.ResizeEffect.connect("changed", self.ResizeEffectChanged)
# Animation Boxes. Thanks to marex for the functions
self.FillAnimationBoxes()
self.CreateCombo = self.gladefile.get_widget('CreateCombo')
self.CreateCombo.connect('changed', self.AnimationBoxChanged, "open_effects")
self.CloseCombo = self.gladefile.get_widget('CloseCombo')
self.CloseCombo.connect('changed', self.AnimationBoxChanged, "close_effects")
self.MinimizeCombo = self.gladefile.get_widget('MinimizeCombo')
self.MinimizeCombo.connect('changed', self.AnimationBoxChanged, "minimize_effects")
self.ShadeCombo = self.gladefile.get_widget('ShadeCombo')
self.ShadeCombo.connect('changed', self.AnimationBoxChanged, "shade_effects")
self.FocusCombo = self.gladefile.get_widget('FocusCombo')
self.ShadeCombo.connect('changed', self.AnimationBoxChanged, "shade_effects")
def CreateTitle(self, signal, page, page_num):
print page_num
if page_num == 0:
self.TitleLabel.set_text('General Graphics Options')
self.TitleLabel.set_use_markup(True)
self.TitleImage.set_from_file('images/general.svg')
if page_num == 1:
self.TitleLabel.set_text('Configure how your windows are managed')
self.TitleLabel.set_use_markup(True)
self.TitleImage.set_from_file('images/windowman.svg')
if page_num == 2:
self.TitleLabel.set_text('Configure how your desktops are managed')
self.TitleLabel.set_use_markup(True)
self.TitleImage.set_from_file('images/desktopman.svg')
if page_num == 3:
self.TitleLabel.set_text('Configure various effects')
self.TitleLabel.set_use_markup(True)
self.TitleImage.set_from_file('images/effects.svg')
if page_num == 4:
self.TitleLabel.set_text('Make your desktop more usable and accessible')
self.TitleLabel.set_use_markup(True)
self.TitleImage.set_from_file('images/access.svg')
# Here begins the area where widgets are and options are checked if
# they are unequal and if so, the option is changed to match the widget.
# Some areas may require conversion of intergers to strings, so that both
# the widget and the settings value can make sense
# Core Options
def LightingToggled(self, signal):
LightingToggledCurrentValue = self.LightingCheckBox.get_active()
LightingToggledCompizValue = self.core.Screens[0]["lighting"].Value
if (LightingToggledCurrentValue != LightingToggledCompizValue):
self.core.Screens[0]["lighting"].Value = LightingToggledCurrentValue
self.context.Write()
def VSyncToggled(self, signal):
VSyncToggledCurrentValue = self.VSyncCheckBox.get_active()
VSyncToggledCompizValue = self.core.Screens[0]["sync_to_vblank"].Value
if (VSyncToggledCurrentValue != VSyncToggledCompizValue):
self.core.Screens[0]["sync_to_vblank"].Value = VSyncToggledCurrentValue
self.context.Write()
def TextureFilterModified(self, signal):
TextureFilterModifiedCurrentValue = self.TextureFilterCombo.get_active()
TextureFilterModifiedCompizValue = self.core.Display["texture_filter"].Value
if (TextureFilterModifiedCurrentValue != TextureFilterModifiedCompizValue):
self.core.Display["texture_filter"].Value = TextureFilterModifiedCurrentValue
self.context.Write()
# Windows Options
def SwitcherModeChanged(self, signal):
# Check to see which radio button is active and
# enable / disable plugins accordingly
if (self.UseFlatSwitcher.get_active() == True):
self.CurSwitcherKey = self.switcher.Display["next_key"].Value
self.SwitcherKey.set_text(self.CurSwitcherKey)
self.switcher.Enabled = True
self.ring.Enabled = False
self.shift.Enabled = False
self.context.Write()
elif (self.UseRingSwitcher.get_active() == True):
self.CurSwitcherKey = self.ring.Display["next_key"].Value
self.SwitcherKey.set_text(self.CurSwitcherKey)
self.ring.Enabled = True
self.switcher.Enabled = False
self.shift.Enabled = False
self.context.Write()
elif (self.UseFlipSwitcher.get_active() == True):
self.CurSwitcherKey = self.shift.Display["next_key"].Value
self.SwitcherKey.set_text(self.CurSwitcherKey)
self.shift.Enabled = True
# Because Flip and Cover are not separate plugins,
# we need to set an option here
self.shift.Screens[0]["mode"].Value = 1
self.switcher.Enabled = False
self.ring.Enabled = False
self.context.Write()
elif (self.UseCoverSwitcher.get_active() == True):
self.CurSwitcherKey = self.shift.Display["next_key"].Value
self.SwitcherKey.set_text(self.CurSwitcherKey)
self.shift.Enabled = True
self.shift.Screens[0]["mode"].Value = 0
self.switcher.Enabled = False
self.ring.Enabled = False
self.context.Write()
def SwitcherKeyChanged(self, signal):
ValueInBox = self.SwitcherKey.get_text()
if (self.UseFlatSwitcher.get_active() == True):
FlatSwitcherValue = self.switcher.Display["next_key"].Value
if (FlatSwitcherValue !=ValueInBox):
self.switcher.Display["next_key"].Value = ValueInBox
self.context.Write()
if (self.UseRingSwitcher.get_active() == True):
RingSwitcherValue = self.ring.Display["next_key"].Value
if (RingSwitcherValue !=ValueInBox):
self.ring.Display["next_key"].Value = ValueInBox
self.context.Write()
if (self.UseFlipSwitcher.get_active() == True):
FlipSwitcherValue = self.shift.Display["next_key"].Value
if (FlipSwitcherValue !=ValueInBox):
self.shift.Display["next_key"].Value = ValueInBox
self.context.Write()
if (self.UseCoverSwitcher.get_active() == True):
CoverSwitcherValue = self.shift.Display["next_key"].Value
if (CoverSwitcherValue !=ValueInBox):
self.shift.Display["next_key"].Value = ValueInBox
self.context.Write()
def TopLeftSelectChanged(self, signal):
self.GlobalUpdater = Updater()
CurrentValue = self.TopLeftSelect.get_active()
for OptionName in self.ScreenCornerPlugins:
if OptionName != "Nothing":
if OptionName.Value == "TopLeft":
CompizValue = self.ScreenCornerPlugins.index(OptionName)
# Otherwise, compizvalue is none
else:
CompizValue = 0
for OptionName in self.ScreenCornerPlugins:
# First, we need to disable the old option.
if self.TopLeftOldOption != "Nothing":
self.TopLeftOldOption.Value = "Disabled"
self.context.Write()
if self.ScreenCornerPlugins.index(OptionName) == CurrentValue:
if CurrentValue != 0:
Setting = OptionName
Edge = "TopLeft"
Conflict = ccm.ActionConflict(Setting, edges = Edge)
if Conflict.Resolve(self.GlobalUpdater):
OptionName.Value = Edge
self.TopLeftOldOption = OptionName
self.context.Write()
break
else:
break
def TopRightSelectChanged(self, signal):
self.GlobalUpdater = Updater()
CurrentValue = self.TopRightSelect.get_active()
for OptionName in self.ScreenCornerPlugins:
if OptionName != "Nothing":
if OptionName.Value == "TopRight":
CompizValue = self.ScreenCornerPlugins.index(OptionName)
# Otherwise, compizvalue is none
else:
CompizValue = 0
for OptionName in self.ScreenCornerPlugins:
# First, we need to disable the old option.
if self.TopRightOldOption != "Nothing":
self.TopRightOldOption.Value = "Disabled"
self.context.Write()
if self.ScreenCornerPlugins.index(OptionName) == CurrentValue:
if CurrentValue != 0:
Setting = OptionName
Edge = "TopRight"
Conflict = ActionConflict(Setting, edges = Edge)
if Conflict.Resolve(self.GlobalUpdater):
OptionName.Value = Edge
self.TopRightOldOption = OptionName
self.context.Write()
break
else:
break
def BottomLeftSelectChanged(self, signal):
self.GlobalUpdater = Updater()
CurrentValue = self.BottomLeftSelect.get_active()
for OptionName in self.ScreenCornerPlugins:
if OptionName != "Nothing":
if OptionName.Value == "BottomLeft":
CompizValue = self.ScreenCornerPlugins.index(OptionName)
# Otherwise, compizvalue is none
else:
CompizValue = 0
for OptionName in self.ScreenCornerPlugins:
# First, we need to disable the old option.
if self.TopLeftOldOption != "Nothing":
self.TopLeftOldOption.Value = "Disabled"
self.context.Write()
if self.ScreenCornerPlugins.index(OptionName) == CurrentValue:
if CurrentValue != 0:
Setting = OptionName
Edge = "BottomLeft"
Conflict = ActionConflict(Setting, edges = Edge)
if Conflict.Resolve(self.GlobalUpdater):
OptionName.Value = Edge
self.TopLeftOldOption = OptionName
self.context.Write()
break
else:
break
def BottomRightSelectChanged(self, signal):
self.GlobalUpdater = Updater()
CurrentValue = self.BottomRightSelect.get_active()
for OptionName in self.ScreenCornerPlugins:
if OptionName != "Nothing":
if OptionName.Value == "BottomRight":
CompizValue = self.ScreenCornerPlugins.index(OptionName)
# Otherwise, compizvalue is none
else:
CompizValue = 0
for OptionName in self.ScreenCornerPlugins:
# First, we need to disable the old option.
if self.BottomRightOldOption != "Nothing":
self.BottomRightOldOption.Value = "Disabled"
self.context.Write()
if self.ScreenCornerPlugins.index(OptionName) == CurrentValue:
if CurrentValue != 0:
Setting = OptionName
Edge = "BottomRight"
Conflict = ActionConflict(Setting, edges = Edge)
if Conflict.Resolve(self.GlobalUpdater):
OptionName.Value = Edge
self.BottomRightOldOption = OptionName
self.context.Write()
break
else:
break
# Allow Grouping / Tabbing Options
def AllowGroupingToggled(self, signal):
CurrentValue = self.AllowGrouping.get_active()
CompizValue = self.group.Enabled
if (CurrentValue != CompizValue):
self.group.Enabled = CurrentValue
self.context.Write()
def AllowTabbingToggled(self, signal):
CurrentValue = self.AllowTabbing.get_active()
CompizValue = self.group.Screens[0]["autotab_create"].Value
if (CurrentValue != CompizValue):
self.group.Screens[0]["autotab_create"].Value = CurrentValue
self.context.Write()
# Fullscreen Key
def FullscreenKeyChanged(self, signal):
CurrentValue = self.FullscreenKey.get_text()
CompizValue = self.extrawm.Display["toggle_fullscreen_key"].Value
if (CurrentValue != CompizValue):
self.extrawm.Display["toggle_fullscreen_key"].Value = CurrentValue
self.context.Write()
def StickyKeyChanged(self, signal):
CurrentValue = self.StickyKey.get_text()
CompizValue = self.extrawm.Display["toggle_sticky_key"].Value
if (CurrentValue != CompizValue):
self.extrawm.Display["toggle_sticky_key"].Value = CurrentValue
self.context.Write()
# Desktop Options
def DesktopAppearanceChanged(self, signal):
# To do this properly, we need to determine whether Wall, Cube
# or Plane are active. Earlier, I set a string to determine which
# compiz option was the active one
CurrentValue = self.DesktopAppearance.get_active()
if (CurrentValue == 0):
CurrentlySelected = "cube"
elif (CurrentValue == 1):
CurrentlySelected = "wall"
elif (CurrentValue == 2):
CurrentlySelected = "plane"
# Enable / Disable Plugins accordingly
if (CurrentlySelected == "cube"):
self.wall.Enabled = False
self.cube.Enabled = True
self.rotate.Enabled = True
self.plane.Enabled = False
self.expo.Enabled = True
self.context.Write()
elif (CurrentlySelected == "wall"):
self.rotate.Enabled = False
self.plane.Enabled = False
self.expo.Enabled = True
self.TD.Enabled = False
self.atlantis.Enabled = False
self.gears.Enabled = False
self.cubereflex.Enabled = False
self.cube.Enabled = False
self.wall.Enabled = True
self.context.Write()
elif (CurrentlySelected == "plane"):
self.plane.Enabled = True
self.rotate.Enabled = False
self.expo.Enabled = False
self.TD.Enabled = False
self.atlantis.Enabled = False
self.gears.Enabled = False
self.cubereflex.Enabled = False
self.cube.Enabled = False
self.wall.Enabled = False
self.context.Write()
def HsizeChanged(self, signal, arg=None):
CurrentSize = self.Hsize.get_value()
CompizSize = self.core.Screens[0]["hsize"].Value
if (CurrentSize != CompizSize):
self.core.Screens[0]["hsize"].Value = CurrentSize
self.context.Write()
def VsizeChanged(self, signal, arg=None):
CurrentSize = self.Vsize.get_value()
CompizSize = self.core.Screens[0]["vsize"].Value
if (CurrentSize != CompizSize):
self.core.Screens[0]["vsize"].Value = CurrentSize
self.context.Write()
def TransCubeValueChanged(self, signal, arg=None):
CurrentValue = self.TransCube.get_value()
CompizValue = self.cube.Screens[0]["active_opacity"].Value
if (CurrentValue != CompizValue):
self.cube.Screens[0]["active_opacity"].Value = CurrentValue
self.context.Write()
def ExpoReflexToggled(self, signal):
CurrentValue = self.ExpoReflexCheck.get_active()
CompizValue = self.expo.Display["reflection"].Value
if (CurrentValue != CompizValue):
self.expo.Display["reflection"].Value = CurrentValue
self.context.Write()
def CubeReflexToggled(self, signal):
CurrentValue = self.CubeReflexCheck.get_active()
CompizValue = self.cubereflex.Enabled
if (CurrentValue != CompizValue):
self.cubereflex.Enabled = CurrentValue
self.context.Write()
def ScaleInfoToggled(self, signal):
CurrentValue = self.ScaleInfo.get_active()
if (self.scalefilter.Enabled == True) or (self.scaleaddon.Enabled == True):
CompizValue = True
else:
CompizValue = False
if (CurrentValue != CompizValue):
if CurrentValue == True:
self.text.Enabled = True
self.scalefilter.Enabled = True
self.scaleaddon.Enabled = True
self.context.Write()
else:
self.scalefilter.Enabled = False
self.scaleaddon.Enabled = False
self.context.Write()
def WinThumbnailsToggled(self, signal):
CurrentValue = self.WinThumbnails.get_active()
CompizValue = self.thumbnail.Enabled
if (CurrentValue != CompizValue):
if CurrentValue == True:
self.text.Enabled = True
self.thumbnail.Enabled = True
self.context.Write()
else:
self.text.Enabled = False
self.thumbnail.Enabled = False
self.context.Write()
# Effects Options
def MoveEffectChanged(self, signal):
if self.MoveEffect.get_active() == 0:
self.wobbly.Enabled = False
self.context.Write()
elif self.MoveEffect.get_active() == 1:
self.wobbly.Enabled = True
self.context.Write()
def ResizeEffectChanged(self, signal):
self.resize.Display["mode"].Value = self.ResizeEffect.get_active()
self.context.Write()
# Animation Boxes. Thanks to marex's 'simple-ccsm' for these
def SetupBoxModel(self, box):
store = gtk.ListStore(gobject.TYPE_STRING)
box.set_model(store)
cell = gtk.CellRendererText()
box.pack_start(cell, True)
box.add_attribute(cell, 'text', 0)
def FillAnimationBoxes(self):
plugin = self.context.Plugins['animation']
boxes = {}
boxes['CloseCombo'] = "close_effects"
boxes['CreateCombo'] = "open_effects"
boxes['MinimizeCombo'] = "minimize_effects"
boxes['ShadeCombo'] = "shade_effects"
boxes['FocusCombo'] = "focus_effects"
set = plugin.Screens[0]["close_effects"]
print set.Info[1][2]
for boxName, settingName in boxes.items():
print boxName + " has " + settingName
for boxName, settingName in boxes.items():
box = self.gladefile.get_widget(boxName)
setting = plugin.Screens[0][settingName]
items = sorted(setting.Info[1][2].items(), ccm.EnumSettingSortCompare)
#if settingName == "close_effects":
# items = ["None", "Random", "Airplane", "Beam Up", "Burn", "Curved Fold", "Domino", "Dream", "Explode", "Fade", "Fold", "Glide 1", "Glide 2", "Horizontal Folds", "Leaf Spread", "Magic Lamp", "RAZR", "Sidekick", "Skewer", "Vacuum", "Wave", "Zoom"]
#if settingName == "open_effects":
# items = ["None", "Random", "Airplane", "Beam Up", "Burn", "Curved Fold", "Domino", "Dream", "Explode", "Fade", "Fold", "Glide 1", "Glide 2", "Horizontal Folds", "Leaf Spread", "Magic Lamp", "RAZR", "Sidekick", "Skewer", "Vacuum", "Wave", "Zoom"]
#if settingName == "minimize_effects":
# items = ["None", "Random", "Airplane", "Beam Up", "Burn", "Curved Fold", "Domino", "Dream", "Explode", "Fade", "Fold", "Glide 1", "Glide 2", "Horizontal Folds", "Leaf Spread", "Magic Lamp", "RAZR", "Sidekick", "Skewer", "Zoom"]
#if settingName == "shade_effects":
# items = ["None", "Random", "Curved Fold", "Horizontal Folds", "Roll Up"]
#if settingName == "focus_effects":
# items = ["None", "Dodge", "Fade", "Wave"]
self.SetupBoxModel(box)
for key in items:
box.append_text(key)
if len(setting.Value):
box.set_active(setting.Value[0])
else:
box.set_active(0)
def AnimationBoxChanged(self, widget, settingName):
newval = widget.get_active_text()
plugin = self.context.Plugins['animation']
setting = plugin.Screens[0][settingName]
value = setting.Value
if len(value) >= 1:
value[0] = setting.Info[1][2][newval]
setting.Value = value
setting.Value = widget.get_active()
self.context.Write()
else:
for setting in plugin.Groups[setting.Group][setting.SubGroup].Screens[0].values():
setting.Reset()
self.context.Write()
self.AnimationBoxChanged(widget, settingName)
if __name__=='__main__':
Base()
gtk.main()