blam r602 - trunk/src
- From: cmartin svn gnome org
- To: svn-commits-list gnome org
- Subject: blam r602 - trunk/src
- Date: Mon, 16 Jun 2008 15:46:06 +0000 (UTC)
Author: cmartin
Date: Mon Jun 16 15:46:05 2008
New Revision: 602
URL: http://svn.gnome.org/viewvc/blam?rev=602&view=rev
Log:
Change from libbacon to D-Bus.
Instead of using libbacon to make the app single-instance, use managed
D-Bus for that.
Modified:
trunk/src/Application.cs
trunk/src/DBus.cs
Modified: trunk/src/Application.cs
==============================================================================
--- trunk/src/Application.cs (original)
+++ trunk/src/Application.cs Mon Jun 16 15:46:05 2008
@@ -121,19 +121,8 @@
public Application (string[] args, params object[] props) : base ("Blam", Defines.VERSION, Modules.UI, args, props)
{
-#if USE_BACON
- messageConn = new MessageConnection ("Blam");
- if (!messageConn.IsServer) {
- messageConn.Send ("ShowWindow");
- messageConn.Close ();
- Gdk.Global.NotifyStartupComplete ();
- Environment.Exit (0);
- }
+ SetupDBus();
- mIpcHandler = new MessageConnection.MessageReceivedHandler (MessageReceivedCb) ;
- messageConn.SetCallback (mIpcHandler);
-#endif
-
client = new Gnome.Client();
client.Connect();
client.SaveYourself += SaveMyself;
@@ -164,8 +153,6 @@
GLib.Idle.Add (new GLib.IdleHandler (IdleRefreshAll));
- SetupDBus ();
-
if(Conf.Get(Preference.REFRESH_AT_START, false) == true){
mCollection.RefreshAll();
}
@@ -246,13 +233,28 @@
Conf.Set("ui/show_item_list", 1);
}
}
-
+
+ public void ShowWindow()
+ {
+ this.mainWindow.Present();
+ }
+
#if ENABLE_DBUS
private void SetupDBus()
{
try{
dbusmgr = new DBusMgr(this);
dbusmgr.Register();
+
+ /* Yes, this is the state that's returned to us. */
+ if(dbusmgr.ReqNameReply == org.freedesktop.DBus.RequestNameReply.InQueue){
+ DBusClient dbc = new DBusClient();
+ dbc.SetUp();
+ dbc.ShowWindow();
+ Gdk.Global.NotifyStartupComplete ();
+ Environment.Exit(0);
+ }
+
} catch (Exception e){
Console.WriteLine("Unable to start DBus interface: {0}", e.Message);
}
@@ -818,16 +820,6 @@
}
}
- private void MessageReceivedCb (string message, IntPtr userData)
- {
- if (!message.Equals ("ShowWindow")) {
- return;
- }
-
- mainWindow.Present ();
- //mCollection.RefreshAll ();
- }
-
public static void SetProcessName(string name)
{
if(prctl(15 /* PR_SET_NAME */, Encoding.ASCII.GetBytes(name + "\0"),
Modified: trunk/src/DBus.cs
==============================================================================
--- trunk/src/DBus.cs (original)
+++ trunk/src/DBus.cs Mon Jun 16 15:46:05 2008
@@ -4,21 +4,18 @@
* This file is under GPLv2 or later.
*/
+using System;
using NDesk.DBus;
using org.freedesktop.DBus;
namespace Imendio.Blam {
[Interface("org.gnome.feed.Reader")]
- public interface IDBlam {
- void Test();
- bool Subscribe(string url);
- }
-
- public class DBusMgr : IDBlam {
-
+ public class DBusMgr : MarshalByRefObject {
+
public static string bus_name = "org.gnome.feed.Reader";
public static ObjectPath obj_path = new ObjectPath("/org/gnome/feed/Reader");
public static Bus bus = Bus.Session;
+ public RequestNameReply ReqNameReply;
private Application app = null;
@@ -40,7 +37,8 @@
public void Register()
{
- if(bus.RequestName(bus_name) == RequestNameReply.PrimaryOwner){
+ ReqNameReply = bus.RequestName(bus_name);
+ if(ReqNameReply == RequestNameReply.PrimaryOwner){
bus.Register(obj_path, this);
}
}
@@ -75,5 +73,25 @@
return true;
}
+
+ public void ShowWindow()
+ {
+ app.ShowWindow();
+ }
+ }
+
+ public class DBusClient
+ {
+ DBusMgr dbus = null;
+
+ public void SetUp()
+ {
+ dbus = DBusMgr.GetInstance();
+ }
+
+ public void ShowWindow()
+ {
+ dbus.ShowWindow();
+ }
}
-}
\ No newline at end of file
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]