gimp-remoteに画像を渡すと、まだGimpが起動していなければGimpを起動させて画像を開き、既にGimpが起動していればそのGimpに画像を渡します。
そのgimp-remoteの機能がD-Busを利用してGimp本体に取り込まれることとなりました。
gimp-remoteはGimp本体とは別に存在する実行プログラムです。
Linuxの場合ではX WindowのAPIを使ってGimpウィンドウを探しています。Windowsの場合ではWin32 APIを使ってGimpインスタンスを探しています。そのためLinuxとWindowsのgimp-remoteプログラムのソースコードはそれぞれ別の人が作った別のものとなっています。
今まで別のプログラムとしてあったgimp-remoteの機能がD-BusのGLibバインディング(dbus-glib)を使ってGimp本体に取り込まれました。
→Bug#52866 gimp-remote is not perfect (Bugzilla)
→D-BUS homepage (www.freedesktop.org)
→D-BUSを使用してデスクトップ・アプリケーションを接続 (IBM)
Gimp developer MLより引用。
What the patch does is to let GIMP register at the session bus under the name 'org.gimp.GIMP'. It then registers an object under the path '/org/gimp/GIMP'. This object provides the interface 'org.gimp.GIMP'. This interface currently provides a single method 'Open' that takes an array of URIs.
Now when the gimp executable is launched with filename or URI arguments, it checks if the service 'org.gimp.GIMP' exists on the session bus. If it exists, it just calls the 'Open' method and exits.
今回の場合、D-Busは既に起動しているGimpとの通信のために使われます。
セッションバスの中にGimpが登録されていなければ登録し、登録されていたらD-Bus経由で画像を送ってOpenさせて終了します。
別のインスタンスで、二つめのGimpを起動させたい場合は --new-instance コマンドラインオプションを使うみたいです。
D-BusはGLibだけでなくPythonやJavaやPerl、Qtなどといったさまざまな言語のバインディングが存在します。
その中でGimpはGLibバインディングを使っています。残念ながら今のところWindowsではdbus-glibは利用できないみたいです。D-busのWindows移植版であるwinDBusというのがあるそうなので、これの完成に期待したいですね。
