GTK# switch between Process window handles - linux

GTK# switch between Process window handles
Hi,
In a GTK# program. Does anyone know how to switch between Process Window Handles? For example if I press a button in a GTK# program it switches the window to process gedit (text editor), or switches window process to another GTK# program running.
Basically I'm trying to port some of my previous windows C# code which switches between windows (processes). For example in C# to switch windows I used:
[DllImport("user32", EntryPoint = "SetForegroundWindow")]
public static extern int SetForegroundWindow(IntPtr hWnd);
I simply passed the Process Main Window Handle to this function above. Is there something similar I can use in GTK# on MonoDevelop for Centos Linux?
Thank you,
Andy

There is a library called libwnck: http://developer.gnome.org/libwnck/stable/ (Window Navigator Construction Kit) which handles all this functionality. There seems to be bindings for Mono called wnck-sharp which as far as I can tell, are included with gtk-sharp.

Related

wxwidgets detect mouse click on another window

Is it possible to detect a double click on another window in wxwidgets?
In my quest to switch to linux I wanna build a program that reacts to double click on the desktop and the file manager and displays a menu.
Same as listary does on Windows.
Is this something that can be done with wxwidgets (preferably wxpython) under linux? What about on Windows?
You can't receive mouse clicks, or any other events, for windows of another process unless you capture the mouse (and never release it, which would be a bad idea).
You can try to use FindWindow() and then Bind() the event handler.

Mac's Menu bar's sub class not working as in Lunx and Windows

I'd like to run a qt code from linux to Mac pc, I subclass a QMenu, to implment a functionality like, when selecting a sub menu's option, it doesn't close the top level's menu.
And the code working in Linux, but it doesn't work in Mac OS, is it linked to the Mac's menu bar moved to the system's menu, that its behavior not the same?
the related part of code:
void MySubMenu::mouseReleaseEvent(QMouseEvent * e)
{
QAction *action = activeAction();
if (action && action->isEnabled()) {
action->setEnabled(false);
QMenu::mouseReleaseEvent(e);
action->setEnabled(true);
action->trigger();
}
else
QMenu::mouseReleaseEvent(e);
}
When I debug above code,adding trace in the blocks, I find that, in env Mac when mouse clicking on menus bar's option, this mouseReleaseEvent() has never been entered.
Mac menus are not handled by Qt, they are handled by native code and Qt doesn't get notified of anything happening there. The menu bar is a shared system resource, IIRC. You can't override it's behavior - even if you could, it'd make your application feel out-of-place. Don't do it, that's all.

Show/Hide window from process handle on Mono

I am writing an application in VB.Net to be run on Mono.
I can close a window from a process like so:
Dim procs = System.Diagnostics.Process.GetProcessesByName("Firefox")
procs(0).CloseMainWindow()
However I want to be able to show/hide this window as well, but I have to do so in a way that is compatible with Mono running on linux, so the common way I have seen of doing so through P/Invoke will not work
Is there a way to do this? Thanks.

Is it possible to display multiple choice dialog in gVIM?

I have a gVIM script that parses current buffer and offers user to select one of multiple choices. It is implemented as console input, but since i'm using graphical version of gVIM, maybe it's possible to use graphical version of multiple choice dialog? I have tried to use python + Tkinter but it's very unstable and is not working on some NIX boxes :(. Any ideas?
GVim has, in its functions and settings, nothing that would enable showing GUI elements (with a few noble exceptions, like closing dialog and such.).
That being said, GVim is open source, and nothing stops you from downloading the source and messing with it.
After some research i have found a solution. VIM supports so-called "clientserver" mode and external application can send a command to it. So this task (and many others) can be solved with following technique (tested on Windows, OSX and Ubuntu):
VIMscript that handles a command launches standalone GUI script in
separate process and returns.
Standalone GUI script (python/ruby/.exe/whatever) displays GUI and
waits for user interaction.
After user interaction, standalone GUI script closes it's window,
communicates back to VIM via "clientserver" interface (call another
script, open file, move cursor etc) and exits.

Debian Start Qt GUI application with no desktop

I have Debian 2.6 running on a SBC that I plan on using in an embedded setup. What I need to do is configure it so that linux will start up and run just my Qt GUI application. Do I need a window manager to do this or can I just do it with X11. Also because it is going to be for an embedded system I do not want to load any desktop manager. Any info on how this can be done would be great!
Yes you can do this without a window manager.
first: You need to boot into a non X session, init level 1 or 3.
second: You need to start the X server, in a basic mode by just calling X or xinit.
third: Start your app. You may need to take a little more control over where your app is positioned on the screen and its dimensions in your code, as you will not have a window manager to help with this.
alternatively: you can launch one of the more basic window managers to see how they play with your system. Motif Window Manager (mwm) and Tab Window Manager (twm)
Note: While working without a window manager, you may get into a state where you cannot do some very basic operations (ex: close a window, move a window, resize a window). You may find that you cannot survive without at least some of the more basic window management functions. Until you close the loop on this, remember, Ctrl + Alt + Backspace will kill the XServer.
If you want to start your app just with X11, you need do:
copy file /etc/X11/xinit/xinitrc to ~/.xinitrc
write all you want to run to it
run command startx
It worked for me and I hope it will help you

Resources