beagle r4806 - in trunk/beagle/search: Beagle.Search Beagle.Search.Pages
- From: dbera svn gnome org
- To: svn-commits-list gnome org
- Subject: beagle r4806 - in trunk/beagle/search: Beagle.Search Beagle.Search.Pages
- Date: Sat, 5 Jul 2008 15:47:15 +0000 (UTC)
Author: dbera
Date: Sat Jul 5 15:47:15 2008
New Revision: 4806
URL: http://svn.gnome.org/viewvc/beagle?rev=4806&view=rev
Log:
Add a menu for beagled specific options. Add menu entries to start, stop beagled and move Index-Info to this menu option. Note that we never mention "beagled" in beagle-search but always refer to it as "service".
Modified:
trunk/beagle/search/Beagle.Search.Pages/StartDaemon.cs
trunk/beagle/search/Beagle.Search/SearchWindow.cs
trunk/beagle/search/Beagle.Search/UIManager.cs
Modified: trunk/beagle/search/Beagle.Search.Pages/StartDaemon.cs
==============================================================================
--- trunk/beagle/search/Beagle.Search.Pages/StartDaemon.cs (original)
+++ trunk/beagle/search/Beagle.Search.Pages/StartDaemon.cs Sat Jul 5 15:47:15 2008
@@ -28,6 +28,11 @@
private void OnStartDaemon (object o, EventArgs args)
{
+ DoStartDaemon (DaemonStarted);
+ }
+
+ internal static void DoStartDaemon (DaemonStarted DaemonStarted)
+ {
string beagled_filename = "beagled";
Process daemon = new Process ();
@@ -42,15 +47,11 @@
// Give the daemon some time to start
if (DaemonStarted != null)
- GLib.Timeout.Add (5000, DaemonStartedTimeout);
- }
-
- private bool DaemonStartedTimeout ()
- {
- if (DaemonStarted != null)
- DaemonStarted ();
-
- return false;
+ GLib.Timeout.Add (5000, delegate () {
+ if (DaemonStarted != null)
+ DaemonStarted ();
+ return false;
+ });
}
}
}
Modified: trunk/beagle/search/Beagle.Search/SearchWindow.cs
==============================================================================
--- trunk/beagle/search/Beagle.Search/SearchWindow.cs (original)
+++ trunk/beagle/search/Beagle.Search/SearchWindow.cs Sat Jul 5 15:47:15 2008
@@ -129,6 +129,8 @@
uim.ToggleDetails += OnToggleDetails;
uim.ShowQuickTips += OnShowQuickTips;
uim.ShowIndexInfo += OnShowIndexInfo;
+ uim.StartDaemon += OnStartDaemon;
+ uim.StopDaemon += OnStopDaemon;
vbox.PackStart (uim.MenuBar, false, false, 0);
HBox hbox = new HBox (false, 6);
@@ -418,6 +420,8 @@
private void ShowInformation (Tiles.Tile tile)
{
+ notification_area.Hide ();
+
if (tile != null) {
panes.Details = tile.Details;
if (tile.Details != null)
@@ -494,6 +498,64 @@
}
#endif
+ private void OnStartDaemon ()
+ {
+ notification_area.Hide ();
+
+ DaemonInformationRequest request = new DaemonInformationRequest (true, false, false, false);
+
+ try {
+ request.Send ();
+ } catch (Beagle.ResponseMessageException) {
+ // beagled is not running
+ // Start beagled and once it is started, display the quicktips page
+ Beagle.Search.Pages.StartDaemon.DoStartDaemon (delegate () {
+ this.statusbar.Pop (0);
+ this.statusbar.Push (0, Catalog.GetString ("Search service started"));
+ });
+ pages.CurrentPage = pages.PageNum (quicktips);
+ return;
+ } catch (Exception e) {
+ Console.WriteLine ("Stopping the Beagle daemon failed: {0}", e.Message);
+ }
+
+ // beagled is running
+ NotificationMessage m = new NotificationMessage ();
+ m.Icon = Gtk.Stock.DialogError;
+ m.Title = Catalog.GetString ("Starting service failed");
+ m.Message = Catalog.GetString ("Service is already running!");
+ notification_area.Display (m);
+ }
+
+ private void OnStopDaemon ()
+ {
+ notification_area.Hide ();
+
+ ShutdownRequest request = new ShutdownRequest ();
+ try {
+ request.Send ();
+ } catch (Beagle.ResponseMessageException) {
+ // beagled is not running
+ NotificationMessage m = new NotificationMessage ();
+ m.Icon = Gtk.Stock.DialogError;
+ m.Title = Catalog.GetString ("Stopping service failed");
+ m.Message = Catalog.GetString ("Service was not running!");
+ notification_area.Display (m);
+
+ // show the start daemon if the user wants to start the daemom
+ pages.CurrentPage = pages.PageNum (startdaemon);
+ return;
+ } catch (Exception e) {
+ Console.WriteLine ("Stopping the Beagle daemon failed: {0}", e.Message);
+ }
+
+ // beagled was running and should be now stopped.
+ // Show the start page. The start-daemon page feels as if the user-request failed.
+ pages.CurrentPage = pages.PageNum (quicktips);
+ this.statusbar.Pop (0);
+ this.statusbar.Push (0, Catalog.GetString ("Search service stopped"));
+ }
+
private void CheckNoMatch ()
{
MatchType matches = view.MatchState;
Modified: trunk/beagle/search/Beagle.Search/UIManager.cs
==============================================================================
--- trunk/beagle/search/Beagle.Search/UIManager.cs (original)
+++ trunk/beagle/search/Beagle.Search/UIManager.cs Sat Jul 5 15:47:15 2008
@@ -73,6 +73,9 @@
new ActionEntry ("View", null,
Catalog.GetString ("_View"),
null, null, null),
+ new ActionEntry ("Service", null,
+ Catalog.GetString ("Service _Options"),
+ null, null, null),
new ActionEntry ("Help", null,
Catalog.GetString ("_Help"),
null, null, null),
@@ -81,6 +84,15 @@
null, null,
Catalog.GetString ("Exit Desktop Search"),
Preferences),
+ new ActionEntry ("StartService", Gtk.Stock.Execute,
+ Catalog.GetString ("Start service"),
+ null, null, StartService),
+ new ActionEntry ("StopService", Gtk.Stock.Stop,
+ Catalog.GetString ("Stop service"),
+ null, null, StopService),
+ new ActionEntry ("IndexInfo", Gtk.Stock.Index,
+ Catalog.GetString ("Index information"),
+ null, null, IndexInfo),
new ActionEntry ("Contents", Gtk.Stock.Help,
Catalog.GetString ("_Contents"),
"F1",
@@ -93,9 +105,6 @@
new ActionEntry ("QuickTips", null,
Catalog.GetString ("Quick Tips"),
null, null, QuickTips),
- new ActionEntry ("IndexInfo", null,
- Catalog.GetString ("Index information"),
- null, null, IndexInfo),
new ActionEntry ("FocusSearchEntry", null, "",
"<control>K", null,
OnFocusSearchEntry),
@@ -209,10 +218,14 @@
" <separator/>" +
" <menuitem action='ShowDetails'/>" +
" </menu>" +
+ " <menu action='Service'>" +
+ " <menuitem action='StartService'/>" +
+ " <menuitem action='StopService'/>" +
+ " <menuitem action='IndexInfo'/>" +
+ " </menu>" +
" <menu action='Help'>" +
" <menuitem action='Contents'/>" +
" <menuitem action='QuickTips'/>" +
- " <menuitem action='IndexInfo'/>" +
" <menuitem action='About'/>" +
" </menu>" +
" </menubar>" +
@@ -340,11 +353,29 @@
public delegate void ShowIndexInfoDelegate ();
public event ShowIndexInfoDelegate ShowIndexInfo;
-
+
private void IndexInfo (object obj, EventArgs args)
{
if (ShowIndexInfo != null)
ShowIndexInfo ();
}
+
+ public delegate void StartDaemonDelegate ();
+ public event StartDaemonDelegate StartDaemon;
+
+ private void StartService (object obj, EventArgs args)
+ {
+ if (StartDaemon != null)
+ StartDaemon ();
+ }
+
+ public delegate void StopDaemonDelegate ();
+ public event StopDaemonDelegate StopDaemon;
+
+ private void StopService (object obj, EventArgs args)
+ {
+ if (StopDaemon != null)
+ StopDaemon ();
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]