开发者

How do you check whether a Window is Maximised in Gtk?

I want to give a window a specific property only when it is maximised and change it back when the maximised state ends. I am using Gtk# , but all GTK binding answers are welcome. What I am looking for is something like this (pseudocode):

 OnMaximise += new Mhandler();
 Mhandler(){ property = true;}

or:

Resize += delegate() {
     if (isMaximised()) property=true; else property = false;};

or the C way:

gtk_window_on_maximise(GTK_WINDOW(mwin),onmax);
void onmax() 
{ 
     if (gtk_window_is_max(GTK_WINDOW(mwin))        
          gtk_window_set_property(GTK_WINDOW(mwin),true); 
     else gtk_window_set_property(GTK_WINDOW(开发者_Python百科mwin),false);
}

Any suggestions? Thanks


Set up the "window-state-event" signal when you create the window and watch for it. See http://developer.gnome.org/gtk/2.24/GtkWindow.html#gtk-window-maximize and also http://developer.gnome.org/gtk/2.24/GtkWidget.html#GtkWidget-window-state-event

Your onmax() would be the handler that would be called when GDK_WINDOW_STATE_MAXIMIZED becomes TRUE. See http://developer.gnome.org/gdk/stable/gdk-Events.html#GDK-STRUCTURE-MASK:CAPS and http://developer.gnome.org/gdk/stable/gdk-Event-Structures.html#GdkEventWindowState and http://developer.gnome.org/gdk/stable/gdk-Event-Structures.html#GdkWindowState

Sorry, can't help much more than that without actually writing code. Google might have some good examples and then again might not. What documentation there is actually is for people who can already do GTK+ signals.

EDIT: I do GTK+ in C and the pages I cited are for C.

EDIT #2: The handler (callback) is executed whenever the signal is sent and the signal data is what matters. I would probably do a switch:case on each signal data value that interested me and possibly set a flag for other functions to read later on.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜