[beagle] Propose to add beagled to autostart in beagle-search
- From: Vincent Untz <vuntz src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [beagle] Propose to add beagled to autostart in beagle-search
- Date: Fri, 14 Aug 2009 11:35:59 +0000 (UTC)
commit d24194afd766fe386bbe778a4e0c0bfd3bafdd28
Author: Vincent Untz <vuntz gnome org>
Date: Fri Aug 14 13:34:08 2009 +0200
Propose to add beagled to autostart in beagle-search
When beagled is not running, beagle-search displays a page to start it.
The main use case for this page is when beagled is not autostarted
during login, I believe; however, this page doesn't let the user change
this.
http://bugzilla.gnome.org/show_bug.cgi?id=588965
beagle/search/Beagle.Search.Pages/StartDaemon.cs | 38 ++++++++++++++++++++++
beagle/search/Makefile.am | 8 +++-
2 files changed, 44 insertions(+), 2 deletions(-)
---
diff --git a/beagle/search/Beagle.Search.Pages/StartDaemon.cs b/beagle/search/Beagle.Search.Pages/StartDaemon.cs
index 2e154e1..f0308e4 100644
--- a/beagle/search/Beagle.Search.Pages/StartDaemon.cs
+++ b/beagle/search/Beagle.Search.Pages/StartDaemon.cs
@@ -1,6 +1,11 @@
using System;
using System.Diagnostics;
+using System.IO;
+using System.Reflection;
+
using Mono.Unix;
+using Mono.Unix.Native;
+
using Gtk;
namespace Beagle.Search.Pages {
@@ -10,6 +15,7 @@ namespace Beagle.Search.Pages {
public class StartDaemon : Base {
public event DaemonStarted DaemonStarted;
+ private Gtk.ToggleButton autostart_toggle;
public StartDaemon ()
{
@@ -24,13 +30,45 @@ namespace Beagle.Search.Pages {
button.Show ();
Append (button);
+
+ autostart_toggle = new Gtk.CheckButton (Catalog.GetString ("Automatically start service on login"));
+ autostart_toggle.Active = true;
+ autostart_toggle.Show ();
+
+ Append (autostart_toggle);
}
private void OnStartDaemon (object o, EventArgs args)
{
+ if (autostart_toggle.Active)
+ EnableAutostart ();
+
DoStartDaemon (DaemonStarted);
}
+ private void EnableAutostart ()
+ {
+ string local_autostart_dir = System.IO.Path.Combine (System.IO.Path.Combine (Environment.GetEnvironmentVariable ("HOME"), ".config"), "autostart");
+
+ if (! Directory.Exists (local_autostart_dir)) {
+ Directory.CreateDirectory (local_autostart_dir);
+ Syscall.chmod (local_autostart_dir, (FilePermissions) 448); // 448 == 0700
+ }
+
+ string beagled_file = System.IO.Path.Combine (local_autostart_dir, "beagled-autostart.desktop");
+
+ Assembly assembly = Assembly.GetExecutingAssembly ();
+
+ StreamReader reader = new StreamReader (assembly.GetManifestResourceStream ("beagled-autostart.desktop"));
+ StreamWriter writer = new StreamWriter (beagled_file);
+
+ string l;
+ while ((l = reader.ReadLine ()) != null)
+ writer.WriteLine (l);
+ reader.Close ();
+ writer.Close ();
+ }
+
internal static void DoStartDaemon (DaemonStarted DaemonStarted)
{
string beagled_filename = "beagled";
diff --git a/beagle/search/Makefile.am b/beagle/search/Makefile.am
index 9ab8922..15c813a 100644
--- a/beagle/search/Makefile.am
+++ b/beagle/search/Makefile.am
@@ -89,6 +89,9 @@ SOURCES = \
$(srcdir)/Beagle.Search/TileCategory.cs \
$(srcdir)/Beagle.Search/UIManager.cs
+SEARCH_RESOURCES = $(top_srcdir)/beagled/beagled-autostart.desktop
+SEARCH_RESOURCES_BUILD = $(foreach res,$(SEARCH_RESOURCES), $(addprefix -resource:,$(srcdir)/$(res)),$(notdir $(res)))
+
LOCAL_ASSEMBLIES = \
../Util/Util.dll \
../Util/UiUtil.dll \
@@ -106,8 +109,8 @@ pkglib_DATA = $(ASSEMBLY) $(ASSEMBLY).mdb $(ASSEMBLY).config
BIN_WRAPPERS = beagle-search
-$(ASSEMBLY): $(SOURCES) $(LOCAL_ASSEMBLIES)
- $(CSC) -out:$@ $(CSFLAGS) $(SOURCES) $(ASSEMBLIES)
+$(ASSEMBLY): $(SOURCES) $(SEARCH_RESOURCES) $(LOCAL_ASSEMBLIES)
+ $(CSC) -out:$@ $(SEARCH_RESOURCES_BUILD) $(CSFLAGS) $(SOURCES) $(ASSEMBLIES)
$(ASSEMBLY).mdb: $(ASSEMBLY)
@@ -146,6 +149,7 @@ uninstall-local:
EXTRA_DIST = \
$(SOURCES) \
+ $(SEARCH_RESOURCES) \
$(man_MANS) \
$(desktop_DATA).in \
$(autostart_DATA) \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]