All pastes #637731 Raw Edit

Mine

public text v1 · immutable
#637731 ·published 2007-07-29 04:39 UTC
rendered paste body
#!/usr/bin/env python
# This file is part of Fusion-icon.

# Fusion-icon 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 2 of the License, or
# (at your option) any later version.
#
# Fusion-icon 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/>.

# Author(s): xsacha

import sys
from PyQt4 import QtGui, QtCore
from util import *

class Build(QtGui.QApplication):
    def __init__(self, parent=None):
        QtCore.QObject.__init__(self, parent)
        init_config()
        active_wm = get_setting('active wm')
        active_decorator = get_decorator()
        def open_ccsm():
            subprocess.Popen(['ccsm'])
        def open_emeraldthemes():
            subprocess.Popen(['emerald-theme-manager'])
        def reload_wm():
            print '* Reloading Window Manager ...'
            start_wm()
        self.Tray = QtGui.QSystemTrayIcon(QtGui.QIcon(sys.path[0] + '/../icons/hicolor/22x22/apps/fusion-icon.png'))
        self.Tray.setToolTip("Compiz Fusion Icon")
        self.Tray.managerMenu = QtGui.QMenu()
        self.Tray.optionsMenu = QtGui.QMenu()
        self.Tray.decoratorMenu = QtGui.QMenu()
        def toggleWM(wm):
            if get_setting('active wm') != wm:
                set_old_wm()
                set_setting('active wm', wm)
                print '* Switching to', wms[wm][2],'...'
                start_wm()
        groupManager = QtGui.QActionGroup(self.Tray.managerMenu)
        signalMapperWM = QtCore.QSignalMapper()
        QtCore.QObject.connect(signalMapperWM, QtCore.SIGNAL("mapped(const QString &)"), self, QtCore.SIGNAL("toggleWM(const QString &)"));
        for wm in wms:
            actionWM = groupManager.addAction(self.Tray.managerMenu.addAction(wms[wm][2]))
            actionWM.setCheckable(True)
            if active_wm == wm:
                actionWM.setChecked(True)
            QtCore.QObject.connect(actionWM, QtCore.SIGNAL("triggered()"), signalMapperWM, QtCore.SLOT("map()"))
            signalMapperWM.setMapping(actionWM, wm)

        def toggleOP(option):
            value = int(not get_setting(options[option][0]))
            print '* Setting Option', options[options][2], 'to', bool(value)
            set_setting(options[option][0], value)
            if get_setting('active wm') == compiz:
                reload_wm()
        signalMapperOP = QtCore.QSignalMapper()
        QtCore.QObject.connect(signalMapperOP, QtCore.SIGNAL("mapped(const QString &)"), self, QtCore.SIGNAL("toggleOP(const QString &)"));
        for option in options:
            actionOP = self.Tray.optionsMenu.addAction(options[option][2])
            actionOP.setCheckable(True)
            if option == 'indirect_rendering' and always_indirect:
                actionOP.setEnabled(False)
            actionOP.setChecked(get_setting(options[option][0], 'bool'))
            QtCore.QObject.connect(actionOP, QtCore.SIGNAL("triggered()"), signalMapperOP, QtCore.SLOT("map()"))
            signalMapperOP.setMapping(actionOP, options[option][0])

        def toggleWD(str):
            active_wm = get_setting('active wm')
            if active_wm == compiz:
                killall = ['killall']
                for killdec in [x for x in decorators if x != str]:
                    killall.append(decorators[killdec][0])
                run(killall, 'call')
            set_decorator(str)
        groupDecorator = QtGui.QActionGroup(self.Tray.decoratorMenu)
        signalMapperWD = QtCore.QSignalMapper()
        QtCore.QObject.connect(signalMapperWD, QtCore.SIGNAL("mapped(const QString &)"), self, QtCore.SIGNAL("toggleWD(const QString &)"));
        for decorator in decorators:
            actionWD = groupDecorator.addAction(self.Tray.decoratorMenu.addAction(decorators[decorator][2]))
            actionWD.setCheckable(True)
            if active_decorator == decorators[decorator][1]:
                actionWD.setChecked(True)
            QtCore.QObject.connect(actionWD, QtCore.SIGNAL("triggered()"), signalMapperWD, QtCore.SLOT("map()"))
            signalMapperWD.setMapping(actionWD, decorators[decorator][1])
        self.Tray.menu = QtGui.QMenu()
        self.Tray.menu.addAction("Settings Manager",open_ccsm)
        self.Tray.menu.addAction("Emerald Theme Manager",open_emeraldthemes)
        self.Tray.menu.addSeparator()
        self.Tray.menu.addAction("Reload Window Manager",reload_wm)
        self.Tray.menu.addAction("Select Window Manager").setMenu(self.Tray.managerMenu)
        self.Tray.menu.addAction("Compiz Options").setMenu(self.Tray.optionsMenu)
        self.Tray.menu.addAction("Select Window Decorator").setMenu(self.Tray.decoratorMenu)
        self.Tray.menu.addSeparator()
        self.Tray.menu.addAction("Quit",self.quit)
        self.Tray.setContextMenu(self.Tray.menu)
        self.Tray.show()

Build(sys.argv).exec_()