2013-04-28 16 views
1

我正在將Mono的.NET Windows應用程序轉換爲在Linux(Ubuntu)上運行。其中一個功能取決於本地庫(user32.dll)。討論應用程序轉換的單聲道指南(Linux Platform Differences)表明,一種方法是修改此代碼。我如何閱讀GDK的Title屬性。窗口

我想使用GDK來訪問我通過屬性Gdk.Global.ActiveWindow訪問的Gdk.Window的標題。但我發現這個錯誤在編譯時:

Error CS0154: The property or indexer `Gdk.Window.Title` cannot be used in this context because it lacks the `get` accessor (CS0154) (GetActiveWindow) 

如果我刪除,上面寫着德activeW的Title屬性的代碼,一切工作正常。還有另一種方式來閱讀此屬性?

這裏我的工作單位:

using System; 
using Gtk; 
using Gdk; 
using System.Threading; 

namespace GetActiveWindow 
{ 
    class GdkApp : Gtk.Window 
    { 

     public static void Main() 
     { 
      Application.Init(); 
      new GdkApp(); 
      Application.Run(); 
     } 

     public GdkApp() : base("Simple App") 
     { 
      SetDefaultSize (150, 150); 
      ShowAll(); 
      while (true) { 
       var activeW = Gdk.Global.ActiveWindow; 
       Console.WriteLine("Active Window: {0}",activeW.Title); // Where my compile error happens. 
       Console.WriteLine("Simple App Window: {0}",this.Title); // This code works perfectily. 
       Thread.Sleep(1000); 
      } 
     } 
    } 
} 
+0

的,什麼是您所使用的樣子是你這樣的位於''GDK' gtk_window_get_title' – MethodMan 2013-04-28 00:55:34

+0

@ DJ-KRAZE對不起,忘了附上我的代碼。 – 2013-04-28 01:09:02

+0

'base'類是否有'Title'屬性..?我假設你想顯示或顯示在控制檯'簡單應用程序' – MethodMan 2013-04-28 01:15:57

回答

0

我認爲,隨着GDK是IMPOSIBLE。與Wnck庫給予C編譯器試試這個「-DWNCK_I_KNOW_THIS_IS_UNSTABLE」和作品,但有警告:未處理的動作類型_OB_WM_ACTION_UNDECORATE

對不起,我已經用精靈代替VALA。

//valac *.gs --pkg gtk+-3.0 --pkg libwnck-3.0 -X '-DWNCK_I_KNOW_THIS_IS_UNSTABLE' 

init 
    Gtk.init(ref args) 
    var ventana= new win() 
    ventana.inicio() 
    ventana.printinfo() 
    Gtk.main() 


class win:Gtk.Window 

    won:weak GLib.List of Wnck.Window 

    def inicio() 

     var button= new Gtk.Button() 
     button.clicked.connect(printinfo) 
     this.add(button) 
     this.show_all() 

    def printinfo() 
     won= Wnck.Screen.get_default().get_windows() 
     won.foreach(allwin) 

    def allwin(w:Wnck.Window) 
     if w.is_skip_tasklist() or w.is_skip_pager() 
      pass 
     else 
      print w.get_name() 
+0

注意:點擊按鈕時程序將獲取所有窗口的名稱。 – txasatonga 2016-05-23 00:02:25