tags:

views:

52

answers:

1
#include <gtk/gtk.h> 

int main( int argc, char *argv[]) 
{ 
  GtkWidget *window; 

  gtk_init(&argc, &argv); 

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 
  gtk_widget_show(window); 

  gtk_main(); 

  return 0; 
} 

The above can pop up a window and a corresponding icon on taskbar.

I googled a lot but can't find any article that handles this problem.

So any information is greatly appreciated!

A: 

I don't think there's anything built into GTK for this. The menu that you get when you right-click on a taskbar button (at least in Windows <= Vista) is called the system menu. It's the same menu you get when you click on the window's icon (on the left-hand side of the titlebar).

You can use the GetSystemMenu function to get a handle to it and add items as you see fit. As I said, it's pretty platform-specific, so I doubt GTK has a wrapper for it (but maybe it does?)

I should also note that in Windows 7, all that stuff has been replaced and the taskbar works quite differently. Here's a good overview of the changes, and here's some more specific info about "jump lists" (which is what replaces the right-click menu).

Dean Harding
`g_main_context_check()` and `g_main_context_prepare()` will be called recursively when I right click the icon on taskbar,but won't when click on the window's icon.But it seems impossible to step into it,at least for me :(
Gtker
I believe when you click the icon in the titlebar, Windows displays the menu in a modal loop, so your main event loop isn't going to see the messages. That's why `g_main_context_check` et al don't get called.
Dean Harding
Is there any way to make windows display the menu the same way when I right click the icon on taskbar? I'm in fact dealing with this annoying problem: http://stackoverflow.com/questions/2753382/infinite-gtk-warnings-when-i-right-click-on-the-icon
Gtker
Sounds like a GTK bug to me: https://bugzilla.gnome.org/show_bug.cgi?id=552041
Dean Harding
Oh,it seems a very old bug,which isn't gonna be fixed..
Gtker