/*
* Copyright (C) 2006 Eskil Bylund
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
using NDesk.DBus;
using org.freedesktop.DBus;
namespace DCSharp.GUI{
[Interface ("org.gnome.DCSharp.Core")]
public interface ICore
{
void Present();
void Shutdown();
}
public class Core : ICore
{
const string ServicePath = "org.gnome.DCSharp";
static ObjectPath CorePath = new ObjectPath ("/org/gnome/DCSharp/Controller");
public static ICore FindInstance()
{
if (Bus.Session.NameHasOwner(ServicePath))
{
return Bus.Session.GetObject<ICore>(ServicePath, CorePath);
}
return null;
}
public void RegisterServer()
{
Bus.Session.RequestName(ServicePath);
Bus.Session.Register(ServicePath, CorePath, this);
}
public void UnregisterServer()
{
Bus.Session.ReleaseName(ServicePath);
}
public void Present()
{
MainWindow window = GUI.MainWindow;
if (window != null)
{
window.Show();
}
}
public void Shutdown()
{
Gtk.Application.Quit();
}
}
}
|