如何使用 GTK、XLib 或任何类似程序将程序嵌入到另一个程序中?

发布于 2024-11-25 06:34:54 字数 240 浏览 1 评论 0原文

我正在尝试制作一个“简单”程序,它所做的只是列出所有打开的程序,一旦您选择一个程序,它就会在您的窗口中打开它(就像您可能会说的缩略图,但您也可以进行交互)。

一件事,它必须只是一种方式(例如,我无法更改嵌入程序并添加“插座”或“插头”)。我希望能够嵌入任何程序(例如 Opera、evince、JDownloader 等)。

有谁知道我该怎么做?

如果使用 GTK 无法完成,可以使用 X 或类似的工具来完成吗?如何?

I'm trying to make a "simple" program, all it does is to list all opened programs and, once you choose one, it opens it inside your window (like a thumbnail you may say, but you can also interact).

One thing, it has to be one way only (I can't alter the embbeded program and add a "socket" or "plug" for instance). I want to be able to embbed any program (e.g. Opera, evince, JDownloader etc).

Does anyone have any idea of how can I do it?

If it can't be done using GTK, can it be done using X or any similar? How?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

妄想挽回 2024-12-02 06:34:54

您似乎正在寻找类似 XEmbed 的东西。 python 和 gtk 的一个很好的教程位于 http://www.moeraki.com/ pygtktutorial/pygtk2tutorial/sec-PlugsAndSockets.html

It appears that you're looking for something like XEmbed. A good tutorial in python and gtk is at http://www.moeraki.com/pygtktutorial/pygtk2tutorial/sec-PlugsAndSockets.html

薆情海 2024-12-02 06:34:54

您可以使用 GtkPlugGtkSocket

You can use GtkPlug and GtkSocket for that.

时光无声 2024-12-02 06:34:54
using System;using Gtk;using System.Runtime.InteropServices;       public partial class MainWindow : Gtk.Window{



public MainWindow () : base(Gtk.WindowType.Toplevel)
{
    Gtk.Socket socket;
    int xid;
    Fixed fixed2=new Fixed();
    this.socket = new Socket();
    this.socket.WidthRequest = 500;
    this.socket.HeightRequest = 500;
    this.socket.Visible = true;
    this.socket.Realized += new EventHandler(OnVideoWidgetRealized);

    fixed2.Put(socket, 0, 0);
    fixed2.SetSizeRequest(500,500);
    this.Add(fixed2);
    this.ShowAll();

    OnButton17Clicked();

}

protected virtual void OnVideoWidgetRealized (object sender, EventArgs
                                              args)
{
    this.xid = (int)socket.Id;
    Console.WriteLine("this.xid:"+this.xid);
}

protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
    Application.Quit ();
    a.RetVal = true;
    this.socket = new Socket();
}

protected  void OnButton17Clicked ()
{
    var paramString = string.Format("-wid {0} 1.avi", xid);
    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.StartInfo.FileName = "mplayer.exe";
    proc.StartInfo.Arguments = paramString;
    proc.Start();
    proc.WaitForExit();

}
public static void Main()
{
    Application.Init();
    new MainWindow();
    Application.Run();
}}
using System;using Gtk;using System.Runtime.InteropServices;       public partial class MainWindow : Gtk.Window{



public MainWindow () : base(Gtk.WindowType.Toplevel)
{
    Gtk.Socket socket;
    int xid;
    Fixed fixed2=new Fixed();
    this.socket = new Socket();
    this.socket.WidthRequest = 500;
    this.socket.HeightRequest = 500;
    this.socket.Visible = true;
    this.socket.Realized += new EventHandler(OnVideoWidgetRealized);

    fixed2.Put(socket, 0, 0);
    fixed2.SetSizeRequest(500,500);
    this.Add(fixed2);
    this.ShowAll();

    OnButton17Clicked();

}

protected virtual void OnVideoWidgetRealized (object sender, EventArgs
                                              args)
{
    this.xid = (int)socket.Id;
    Console.WriteLine("this.xid:"+this.xid);
}

protected void OnDeleteEvent (object sender, DeleteEventArgs a)
{
    Application.Quit ();
    a.RetVal = true;
    this.socket = new Socket();
}

protected  void OnButton17Clicked ()
{
    var paramString = string.Format("-wid {0} 1.avi", xid);
    System.Diagnostics.Process proc = new System.Diagnostics.Process();
    proc.StartInfo.FileName = "mplayer.exe";
    proc.StartInfo.Arguments = paramString;
    proc.Start();
    proc.WaitForExit();

}
public static void Main()
{
    Application.Init();
    new MainWindow();
    Application.Run();
}}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文