Re: Compiz Fusion?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hikaru Amano wrote:
back to topic ,

I just rewrote desktop-effects in .py to make use compizconfig-python ..

attached them together with this email ..

attached a version with the error dialog (left the nvidia stuff for now).
whats still mising is support for gettext (translations)

#!/usr/bin/env python
# Re implementation of desktop-effects in pyglade
# and compizconfig-python
# Author(s): KageSenshi
#
# TODO
# get Timeout working with the timeout_dialog
# create an error dialog when compiz failed to start

import gtk
import gtk.glade
import sys
import gconf
from os import system,path
import compizconfig
from subprocess import Popen
from commands import getoutput
from time import sleep

context=compizconfig.Context()
context.Read()
WINDOW_MANAGER_KEY='/apps/gnome-session/rh/window_manager'
decorator='gtk-window-decorator --replace'

# xml = gtk.glade.XML("/usr/share/compiz/desktop-effects.glade")
xml = gtk.glade.XML("desktop-effects.glade")

################### Compiz Launcher #######################
### codes borrowed*cough*stolen*cough* from fusion-icon ###
# Author(s): crdlb

def env_intel():
    if not getoutput('xvinfo 2>/dev/null|grep Intel') == '':
        print '* intel found, exporting: INTEL_BATCH=1'
        return 'INTEL_BATCH=1 '
    else: return ''

def is_always_indirect():
    if int(getoutput('glxinfo 2>/dev/null | grep GLX_EXT_texture_from_pixmap -c')) < 3:
        if int(getoutput('LIBGL_ALWAYS_INDIRECT=1 glxinfo 2>/dev/null | grep GLX_EXT_texture_from_pixmap -c')) == 3:
           return True

def env_indirect():
    if is_always_indirect():
        print '* No GLX_EXT_texture_from_pixmap present with direct rendering context'
        print '... present with indirect rendering, exporting: LIBGL_ALWAYS_INDIRECT=1'
        return 'LIBGL_ALWAYS_INDIRECT=1 '
    else: return ''

def env_fglrx():    
    if path.exists('/usr/lib/fglrx/libGL.so.1.2.xlibmesa'):
        print '* fglrx found, exporting: LD_PRELOAD=/usr/lib/fglrx/libGL.so.1.2.xlibmesa'
        return 'LD_PRELOAD=/usr/lib/fglrx/libGL.so.1.2.xlibmesa '
    else: return ''
    
def env_nvidia():
    if not getoutput('xdpyinfo 2>/dev/null|grep NV-GLX') == '':
        print '* nvidia found, exporting: __GL_YIELD=nothing '
        return '__GL_YIELD=nothing '
    else: return ''

def get_env():
    return env_intel() + env_indirect() + env_fglrx() + env_nvidia()

def start_compiz():
    # Get Env Variables                                                                
    env_variables = get_env()
    # Start Compiz WM
    system('killall gtk-window-decorator kde-window-decorator emerald')
    decoplugin=context.Plugins['decoration']
    if not decoplugin.Enabled:
        context.ProcessEvents()
        decoplugin.Enabled = True
        context.Write()
    #sleep(2)
    
    direct_rendering = ""
    if system('pgrep Xgl') == 0: direct_rendering="--direct-rendering"
    run_compiz = env_variables + 'compiz --replace --sm-disable --ignore-desktop-hints ccp ' + direct_rendering
    print run_compiz
    Popen(decorator,shell=True)
    return Popen(run_compiz, shell=True)
    
############################# EOF Borrowed Code #############################

def start_metacity():
    run_wm = 'metacity --replace'
    Popen(run_wm, shell=True)

def cancel_compiz(widget):
    start_metacity()
    gconfclient.set_string(WINDOW_MANAGER_KEY,'metacity')
    timeout_dialog.hide()

def save_settings(widget):
    gconfclient.set_string(WINDOW_MANAGER_KEY,'compiz')
    timeout_dialog.hide()

def on_timeout_dialog_close(widget,arg2):
    widget.hide()
    print arg2
    return True

def gtk_main_quit(widget):
    sys.exit(0)

def on_cube_checkbox_toggled(widget):
    context.Read()
    context.ProcessEvents()
    if cube_checkbox.get_active():
       context.Plugins['cube'].Enabled = True
       context.Plugins['rotate'].Enabled = True
    else:
       context.Plugins['rotate'].Enabled = False
       context.Plugins['cube'].Enabled = False 
       # Bug?. For some reasons, cube is still loaded
    context.Write()

def on_enable_togglebutton_toggled(widget):
    
    print widget.get_active()
    if widget.get_active() == False:
       if system('pgrep compiz') == 0:
          start_metacity()
       if gconfclient.get_string(WINDOW_MANAGER_KEY) == 'compiz': 
          gconfclient.set_string(WINDOW_MANAGER_KEY,'metacity')
       wobble_checkbox.set_sensitive(False)
       cube_checkbox.set_sensitive(False)
    else:
       wobble_checkbox.set_sensitive(True)
       cube_checkbox.set_sensitive(True)
       process = start_compiz()
       procpoll = None
       for i in range(0,5):
           sleep(1)
           procpoll = process.poll()
       if not procpoll:
           timeout_dialog.show()
       else:
           dialog = gtk.MessageDialog(xml.get_widget('dialog', gtk.DIALOG_DESTROY_WITH_PARENT,
           gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, "Desktop effects could not be enabled")
    	   dialog.run()
   	   dialog.destroy()

def on_wobble_checkbox_toggled(widget):
    context.Read()
    context.ProcessEvents()
    if wobble_checkbox.get_active(): context.Plugins['wobbly'].Enabled = True
    else: context.Plugins['wobbly'].Enabled = False
    context.Write()

# main 

enable_togglebutton = xml.get_widget('enable_togglebutton')
cube_checkbox = xml.get_widget('cube_checkbox')
wobble_checkbox = xml.get_widget('wobble_checkbox')
timeout_dialog = xml.get_widget('timeout_dialog')


gconfclient = gconf.client_get_default ()
startup_enabled=False

if gconfclient.get_string(WINDOW_MANAGER_KEY) == 'compiz':
   startup_enabled = True


if not startup_enabled:
   enable_togglebutton.set_active(False)
   cube_checkbox.set_sensitive(False)
   wobble_checkbox.set_sensitive(False)
else:
   enable_togglebutton.set_active(True)

if context.Plugins['rotate'].Enabled && context.Plugins['cube'].Enabled: cube_checkbox.set_active(True)
if context.Plugins['wobbly'].Enabled: wobble_checkbox.set_active(True)

signaldict={
  'on_cube_checkbox_toggled' : on_cube_checkbox_toggled,
  'on_enable_togglebutton_toggled' : on_enable_togglebutton_toggled,
  'on_wobble_checkbox_toggled' : on_wobble_checkbox_toggled,
  'gtk_main_quit' : gtk_main_quit,
  'on_timeout_dialog_close' : on_timeout_dialog_close,
  'cancel_compiz' : cancel_compiz,
  'save_settings' : save_settings,
}
xml.signal_autoconnect(signaldict)

gtk.main()

-- 
fedora-devel-list mailing list
fedora-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/fedora-devel-list

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Formulas]     [Fedora PHP Devel]     [Kernel Development]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Gimp]     [Yosemite News]
  Powered by Linux