2012-05-06 21 views
9

Sto provando a far funzionare correttamente il terminale Guake in Unity. La sua finestra ha una larghezza che è uguale alla larghezza dello schermo. Ma a causa del bordo destro della barra di sinistra Unity la barra diventa invisibile. Quindi, voglio impostare la larghezza adeguata per la finestra. Deve essere più piccolo della dimensione effettiva della finestra. E il codice deve funzionare correttamente con o senza Unity.Come ottengo le dimensioni dello schermo escludendo il pannello laterale Unity in GDK

Questo è il modo in Guake determina la posizione e le dimensioni della sua finestra:

def get_final_window_rect(self): 

    """Gets the final size of the main window of guake. The height 
    is the window_height property, width is window_width and the 
    horizontal alignment is given by window_alignment. 
    """ 
    screen = self.window.get_screen() 
    height = self.client.get_int(KEY('/general/window_height')) 
    width = 100 
    halignment = self.client.get_int(KEY('/general/window_halignment')) 

    # get the rectangle just from the first/default monitor in the 
    # future we might create a field to select which monitor you 
    # wanna use 
    window_rect = screen.get_monitor_geometry(0) 
    total_width = window_rect.width 
    window_rect.height = window_rect.height * height/100 
    window_rect.width = window_rect.width * width/100 

    if width < total_width: 
     if halignment == ALIGN_CENTER: 
      window_rect.x = (total_width - window_rect.width)/2 
     elif halignment == ALIGN_LEFT: 
      window_rect.x = 0 
     elif halignment == ALIGN_RIGHT: 
      window_rect.x = total_width - window_rect.width 
    window_rect.y = 0 
    window_rect.width = 250 
    return window_rect 

risposta

1

Così si vuole sottrarre larghezza unità lanciatore dal total_width. Questa dimensione può essere determinata utilizzando gconf per ottenere il valore di icone di avvio:

self.client.get_int('/apps/compiz-1/plugins/unityshell/screen0/options/icon_size') 

naturalmente anche voi volete sapere se la sessione in esecuzione corrente è infatti l'unità:

os.environ.get('DESKTOP_SESSION') == 'ubuntu' 

sembra essere un buon soluzione. (http://stackoverflow.com/questions/2035657/what-is-my-current-desktop-environment)

+0

La larghezza del launcher è maggiore del valore di 'icon_size'. Ora ho launcher width = 50 e icon_size = 32. –

Problemi correlati