1

I'm converting an .NET Windows application for Mono to run on Linux (Ubuntu). One of the features depends on a native library (user32.dll). The Mono guide that talks about conversion of applications (Linux Platform Differences) suggests that one approach would be to modify this code.

I'm trying to use GDK to access the Title of a Gdk.Window that I had access through the property Gdk.Global.ActiveWindow. But I found this error at compile time:

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

If i remove the code that reads de Title property of activeW, everything works fine. There is another way to read this property?

Here my unit of work:

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);
            }
        }
    }
}

1 Answers1

0

I think that with Gdk is imposible. Try it with Wnck library giving to a C compiler this '-DWNCK_I_KNOW_THIS_IS_UNSTABLE' and works but with a warning: Unhandled action type _OB_WM_ACTION_UNDECORATE

Sorry I have used genie instead 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()
txasatonga
  • 419
  • 2
  • 11