4 using System
.Diagnostics
;
5 using System
.Runtime
.InteropServices
;
12 private static extern int prctl(int option
, byte [] arg2
, ulong arg3
, ulong arg4
, ulong arg5
);
14 public static void SetProcessName (string name
)
16 if (prctl (15 /* PR_SET_NAME */, Encoding
.ASCII
.GetBytes (name
+ '\0'), 0, 0,
18 Global
.Logger
.Warning ("Error setting process name: " + Mono
.Unix
.Native
.Stdlib
.GetLastError());
21 static Widget
.ChatterIcon icon
;
22 static Widget
.ContactWindow contact_window
;
24 public static void Main ()
26 Gtk
.Application
.Init ();
27 Gtk
.Widget
.DefaultColormap
= Gdk
.Screen
.Default
.RgbaColormap
;
28 SetProcessName ("Chatter");
30 contact_window
= new Widget
.ContactWindow (Global
.PersistientState
.AccountStore
, Global
.ConnectionStore
);
31 contact_window
.Show ();
33 contact_window
.TreeView
.Activated
+= OnContactActivate
;
35 icon
= new Widget
.ChatterIcon ();
36 icon
.ButtonPress
+= delegate { contact_window.Visible = !contact_window.Visible; }
;
39 AccountModel
[] accounts
= Global
.PersistientState
.AccountStore
.Accounts
;
40 foreach (AccountModel account
in accounts
)
42 if (account
.AutoConnect
)
43 Global
.ConnectionStore
.Activate (account
);
46 if (accounts
.Length
== 0)
48 Widget
.LabelNotify label
= new Widget
.LabelNotify ("Welcome to Chatter\nTo add an account click on Edit -> Accounts");
49 contact_window
.AddNotify (label
);
58 Global
.Logger
.Error ("Fatal: " + e
);
62 // Clean up our connection mess if bad things happen
63 // Note ctrl-c or seg fault will miss this
68 public static void OnContactActivate (ContactModel contact
)
70 Global
.Logger
.Debug ("Activate Contact {0}", contact
.Name
);
72 // The made up policy is to activate a text channel
73 contact
.ConnectionModel
.InitiateTextChannel (contact
);
74 contact
.ConversationWindow
.Show ();
78 public static Widget.ChatterIcon NotificationIcon
83 public static void Quit ()