Add methods and messages to retrieve specific information from beagle-info. Clients...
[beagle.git] / search / Pages / StartDaemon.cs
blobaae0272a2c5d5352e0441a0749681ce977ea33a4
1 using System;
2 using System.Diagnostics;
3 using Mono.Unix;
4 using Gtk;
6 namespace Search.Pages {
8 public delegate void DaemonStarted ();
10 public class StartDaemon : Base {
12 public DaemonStarted DaemonStarted;
14 private Gtk.Button button;
16 public StartDaemon ()
18 HeaderIconStock = Stock.DialogError;
19 HeaderMarkup = "<big><b>" + Catalog.GetString ("Search service not running") + "</b></big>";
21 button = new Gtk.Button (Catalog.GetString ("Start search service"));
22 button.Clicked += OnStartDaemon;
23 button.Show ();
24 Append (button);
27 private void OnStartDaemon (object o, EventArgs args)
29 string beagled_filename = "beagled";
31 Process daemon = new Process ();
32 daemon.StartInfo.FileName = beagled_filename;
33 daemon.StartInfo.UseShellExecute = false;
35 try {
36 daemon.Start ();
37 } catch (System.ComponentModel.Win32Exception e) {
38 Console.WriteLine ("Unable to start daemon: {0}", e.Message);
41 // Give the daemon some time to start
42 if (DaemonStarted != null)
43 GLib.Timeout.Add (5000, DaemonStartedTimeout);
46 private bool DaemonStartedTimeout ()
48 DaemonStarted ();
49 return false;