2012-05-06 21 views
9

我試圖讓Guake終端在Unity中正常工作。它的窗口寬度等於屏幕寬度。但由於Unity左欄窗口的右邊框變得不可見。所以,我想爲窗口設置適當的寬度。它必須小於實際窗口大小。代碼必須正確使用或不使用Unity。我如何獲得排除GDK中的Unity側面板的屏幕大小

這是Guake如何確定其窗口的位置和大小:

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 

回答

1

所以,你想從你的total_width統一。減去發射寬度。

self.client.get_int('/apps/compiz-1/plugins/unityshell/screen0/options/icon_size') 
當然,你也想知道

如果當前運行的會話的確是團結:

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

似乎是一個很好的可以使用GConf獲得的啓動圖標的值來確定該尺寸解。 (http://stackoverflow.com/questions/2035657/what-is-my-current-desktop-environment)

+0

啓動寬度大於'icon_size'值。現在我有啓動寬度= 50和icon_size = 32。 –

相關問題