tomboy r1965 - in trunk: . Tomboy/Addins Tomboy/Addins/Tasque
- From: btimothy svn gnome org
- To: svn-commits-list gnome org
- Subject: tomboy r1965 - in trunk: . Tomboy/Addins Tomboy/Addins/Tasque
- Date: Thu, 13 Mar 2008 04:34:16 +0000 (GMT)
Author: btimothy
Date: Thu Mar 13 04:34:16 2008
New Revision: 1965
URL: http://svn.gnome.org/viewvc/tomboy?rev=1965&view=rev
Log:
* configure.in, Tomboy.mdp, Tomboy/Addins/Tasque,
Tomboy/Addins/Tasque/Tasque.addin.xml,
Tomboy/Addins/Tasque/RemoteControl.cs,
Tomboy/Addins/Tasque/tasque-22.png,
Tomboy/Addins/Tasque/Makefile.am,
Tomboy/Addins/Tasque/TasqueNoteAddin.cs, Tomboy/Addins/Makefile.am:
Added an addin for Tasque (disabled by default).
Added:
trunk/Tomboy/Addins/Tasque/
trunk/Tomboy/Addins/Tasque/Makefile.am
trunk/Tomboy/Addins/Tasque/RemoteControl.cs
trunk/Tomboy/Addins/Tasque/Tasque.addin.xml
trunk/Tomboy/Addins/Tasque/TasqueNoteAddin.cs
trunk/Tomboy/Addins/Tasque/tasque-22.png (contents, props changed)
Modified:
trunk/ChangeLog
trunk/Tomboy.mdp
trunk/Tomboy/Addins/Makefile.am
trunk/configure.in
Modified: trunk/Tomboy.mdp
==============================================================================
--- trunk/Tomboy.mdp (original)
+++ trunk/Tomboy.mdp Thu Mar 13 04:34:16 2008
@@ -201,6 +201,8 @@
<File name="Tomboy/Addins/Sketching/SketchingNoteAddin.cs" subtype="Code" buildaction="Compile" />
<File name="Tomboy/Addins/Sketching/SketchingTextTag.cs" subtype="Code" buildaction="Compile" />
<File name="Tomboy/Addins/Sketching/Stroke.cs" subtype="Code" buildaction="Compile" />
+ <File name="Tomboy/Addins/Tasque/TasqueNoteAddin.cs" subtype="Code" buildaction="Compile" />
+ <File name="Tomboy/Addins/Tasque/RemoteControl.cs" subtype="Code" buildaction="Compile" />
<File name="Tomboy/Addins/GalagoPresence/GalagoPresenceNoteAddin.cs" subtype="Code" buildaction="Compile" />
<File name="Tomboy/RecentTreeView.cs" subtype="Code" buildaction="Compile" />
<File name="Mono.Addins/Mono.Addins/Mono.Addins/InstanceExtensionNode.cs" subtype="Code" buildaction="Compile" />
Modified: trunk/Tomboy/Addins/Makefile.am
==============================================================================
--- trunk/Tomboy/Addins/Makefile.am (original)
+++ trunk/Tomboy/Addins/Makefile.am Thu Mar 13 04:34:16 2008
@@ -12,5 +12,6 @@
Sketching \
SshSyncService \
StickyNoteImport \
+ Tasque \
WebDavSyncService
Added: trunk/Tomboy/Addins/Tasque/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/Tomboy/Addins/Tasque/Makefile.am Thu Mar 13 04:34:16 2008
@@ -0,0 +1,42 @@
+include $(top_srcdir)/Makefile.include
+
+CSFLAGS = \
+ -debug \
+ -define:DEBUG \
+ -target:library
+
+ASSEMBLIES = \
+ $(LINK_TOMBOY_EXE) \
+ $(TOMBOY_LIBS) \
+ $(LINK_MONO_ADDINS) \
+ $(DBUS_LIBS) \
+ -r:Mono.Posix
+
+# -r:/home/boyd/stage/tasque/lib/tasque/Tasque.exe
+
+ADDIN_NAME = Tasque
+TARGET = $(ADDIN_NAME).Addin.dll
+CSFILES = \
+ $(srcdir)/TasqueNoteAddin.cs \
+ $(srcdir)/RemoteControl.cs
+RESOURCES = \
+ -resource:$(srcdir)/$(ADDIN_NAME).addin.xml \
+ -resource:$(srcdir)/tasque-22.png,tasque.png
+
+$(TARGET): $(CSFILES) $(top_builddir)/Tomboy/Tomboy.exe
+ $(CSC) -out:$@ $(CSFLAGS) $(ASSEMBLIES) $(CSFILES) $(RESOURCES)
+
+
+addinsdir = $(pkglibdir)/addins
+addins_DATA = \
+ $(TARGET)
+
+EXTRA_DIST = \
+ $(CSFILES) \
+ $(srcdir)/$(ADDIN_NAME).addin.xml \
+ $(srcdir)/tasque-22.png
+
+CLEANFILES = \
+ $(TARGET).mdb \
+ $(TARGET)
+
Added: trunk/Tomboy/Addins/Tasque/RemoteControl.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/Addins/Tasque/RemoteControl.cs Thu Mar 13 04:34:16 2008
@@ -0,0 +1,34 @@
+// RemoteControl.cs created with MonoDevelop
+// User: boyd at 9:41 PMÂ2/14/2008
+
+using System;
+using System.Collections.Generic;
+
+using NDesk.DBus;
+using org.freedesktop.DBus;
+
+namespace Tasque
+{
+ [Interface ("org.gnome.Tasque.RemoteControl")]
+ public class RemoteControl : MarshalByRefObject
+ {
+ public RemoteControl()
+ {
+ }
+
+ public string CreateTask (string categoryName, string taskName,
+ bool enterEditMode)
+ {
+ return null;
+ }
+
+ public string[] GetCategoryNames ()
+ {
+ return null;
+ }
+
+ public void ShowTasks ()
+ {
+ }
+ }
+}
Added: trunk/Tomboy/Addins/Tasque/Tasque.addin.xml
==============================================================================
--- (empty file)
+++ trunk/Tomboy/Addins/Tasque/Tasque.addin.xml Thu Mar 13 04:34:16 2008
@@ -0,0 +1,21 @@
+<Addin id="TasqueAddin"
+ namespace="Tomboy"
+ name="Tasque"
+ author="Tomboy Project"
+ description="Create a task from the current line of text in Tasque."
+ category="Tools"
+ defaultEnabled="false"
+ version="0.1">
+
+ <Runtime>
+ <Import assembly="Tasque.Addin.dll" />
+ </Runtime>
+
+ <Dependencies>
+ <Addin id="Tomboy" version="0.7" />
+ </Dependencies>
+
+ <Extension path="/Tomboy/NoteAddins">
+ <NoteAddin type="Tomboy.TasqueAddin.TasqueNoteAddin" />
+ </Extension>
+</Addin>
Added: trunk/Tomboy/Addins/Tasque/TasqueNoteAddin.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/Addins/Tasque/TasqueNoteAddin.cs Thu Mar 13 04:34:16 2008
@@ -0,0 +1,247 @@
+
+using System;
+using System.Collections;
+
+using Mono.Unix;
+
+using Tomboy;
+
+using NDesk.DBus;
+using org.freedesktop.DBus;
+
+namespace Tomboy.TasqueAddin
+{
+ public class TasqueNoteAddin : NoteAddin
+ {
+ static ObjectPath TasquePath =
+ new ObjectPath ("/org/gnome/Tasque/RemoteControl");
+ static string TasqueNamespace = "org.gnome.Tasque";
+
+ static Gdk.Pixbuf tasqueIcon = null;
+
+ static TasqueNoteAddin ()
+ {
+ tasqueIcon =
+ GuiUtils.GetIcon (System.Reflection.Assembly.GetExecutingAssembly (),
+ "tasque", 22);
+ }
+
+ Gtk.MenuToolButton menuToolButton;
+ Gtk.Menu menu;
+ bool submenuBuilt;
+ InterruptableTimeout markSetTimeout;
+
+ public override void Initialize ()
+ {
+ submenuBuilt = false;
+
+ menu = new Gtk.Menu ();
+ menu.Hidden += OnMenuHidden;
+ menu.ShowAll ();
+
+ Gtk.Image tasqueImage = new Gtk.Image (tasqueIcon);
+ tasqueImage.Show ();
+ menuToolButton =
+ new Gtk.MenuToolButton (tasqueImage, Catalog.GetString ("Tasque"));
+ menuToolButton.Menu = menu;
+ menuToolButton.Clicked += OnMenuToolButtonClicked;
+ menuToolButton.ShowMenu += OnMenuItemActivated;
+ menuToolButton.Sensitive = false;
+ menuToolButton.Show ();
+ AddToolItem (menuToolButton, -1);
+
+ // Sensitize the Task button on text selection
+ markSetTimeout = new InterruptableTimeout();
+ markSetTimeout.Timeout += UpdateTaskButtonSensitivity;
+ Note.Buffer.MarkSet += OnSelectionMarkSet;
+ }
+
+ public override void Shutdown ()
+ {
+ // The following two lines are required to prevent the plugin
+ // from leaking references when the plugin is disabled.
+ menu.Hidden -= OnMenuHidden;
+ menuToolButton.Clicked -= OnMenuToolButtonClicked;
+ menuToolButton.ShowMenu -= OnMenuItemActivated;
+ }
+
+ public override void OnNoteOpened ()
+ {
+ }
+
+ void OnMenuToolButtonClicked (object sender, EventArgs args)
+ {
+ string taskName = GetTaskName ();
+ if (taskName == null)
+ return;
+
+Logger.Debug ("\n\n****OnMenuToolButtonClicked****\n\n");
+ CreateTask (string.Empty, taskName);
+ }
+
+ void OnMenuItemActivated (object sender, EventArgs args)
+ {
+ if (submenuBuilt == true)
+ return; // submenu already built. do nothing.
+
+ UpdateMenu ();
+ }
+
+ void OnMenuHidden (object sender, EventArgs args)
+ {
+ // FIXME: Figure out how to have this function be called only when
+ // the whole Tools menu is collapsed so that if a user keeps
+ // toggling over the "What links here?" menu item, it doesn't
+ // keep forcing the submenu to rebuild.
+
+ // Force the submenu to rebuild next time it's supposed to show
+ submenuBuilt = false;
+ }
+
+ void UpdateMenu ()
+ {
+ //
+ // Clear out the old list
+ //
+ foreach (Gtk.MenuItem old_item in menu.Children) {
+ menu.Remove (old_item);
+ }
+
+ Tasque.RemoteControl tasque = GetTasqueRemoteControl ();
+
+ string [] taskCategories = null;
+
+ if (tasque != null) {
+ try {
+ taskCategories = tasque.GetCategoryNames ();
+ } catch (Exception e) {
+ Logger.Debug ("Exception calling Tasque.GetCategoryNames (): {0}",
+ e.Message);
+ }
+ }
+
+ if (taskCategories != null) {
+ //
+ // Build a new list
+ //
+ foreach (string category in taskCategories) {
+ CategoryMenuItem item = new CategoryMenuItem (category);
+ item.Activated += OnCategoryActivated;
+ item.ShowAll ();
+ menu.Append (item);
+ }
+ }
+
+ // If nothing was found, add in a "dummy" item
+ if (menu.Children.Length == 0) {
+ Gtk.MenuItem blankItem =
+ new Gtk.MenuItem (Catalog.GetString ("--- Tasque is not running ---"));
+ blankItem.Sensitive = false;
+ blankItem.ShowAll ();
+ menu.Append (blankItem);
+ }
+
+ submenuBuilt = true;
+ }
+
+ void OnCategoryActivated (object sender, EventArgs args)
+ {
+ CategoryMenuItem item = sender as CategoryMenuItem;
+ if (item == null) {
+ return;
+ }
+
+ string categoryName = item.CategoryName;
+
+ Tasque.RemoteControl tasque = GetTasqueRemoteControl ();
+ if (tasque == null)
+ return;
+
+ string taskName = GetTaskName ();
+ if (taskName == null)
+ return;
+
+ CreateTask (categoryName, taskName);
+ }
+
+ private void CreateTask (string categoryName, string taskName)
+ {
+ Tasque.RemoteControl tasque = GetTasqueRemoteControl ();
+ if (tasque == null)
+ return;
+
+ // Trim and truncate to 100 chars max (this is a
+ // "number out of a hat")...a4gpa protection
+ taskName = taskName.Trim ();
+ if (taskName.Length > 100)
+ taskName = taskName.Substring (0, 100);
+
+ if (taskName == string.Empty)
+ return;
+
+ try {
+ tasque.CreateTask (categoryName, taskName, false);
+ } catch (Exception e) {
+ Logger.Debug ("Exception calling Tasque.CreateTask ()", e.Message);
+ }
+ }
+
+ Tasque.RemoteControl GetTasqueRemoteControl ()
+ {
+ Tasque.RemoteControl remoteControl = null;
+
+ try {
+ if (Bus.Session.NameHasOwner (TasqueNamespace) == false)
+ return null;
+
+ remoteControl =
+ Bus.Session.GetObject<Tasque.RemoteControl> (
+ TasqueNamespace,
+ TasquePath);
+ } catch (Exception e) {
+ Logger.Error ("Exception when getting Tasque.RemoteControl: {0}",
+ e.Message);
+ }
+
+ return remoteControl;
+ }
+
+ string GetTaskName ()
+ {
+ Gtk.TextIter selectionStart;
+ Gtk.TextIter selectionEnd;
+
+ if (Note.Buffer.GetSelectionBounds (out selectionStart,
+ out selectionEnd) == false)
+ return null;
+
+ return Note.Buffer.GetText (selectionStart, selectionEnd, false);
+ }
+
+ void OnSelectionMarkSet (object sender, Gtk.MarkSetArgs args)
+ {
+ // FIXME: Process in a timeout due to GTK+ bug #172050.
+ markSetTimeout.Reset (0);
+ }
+
+ void UpdateTaskButtonSensitivity (object sender, EventArgs args)
+ {
+ menuToolButton.Sensitive = (Note.Buffer.Selection != null);
+ }
+
+ class CategoryMenuItem : Gtk.MenuItem
+ {
+ string name;
+
+ public CategoryMenuItem (string categoryName) : base (categoryName)
+ {
+ this.name = categoryName;
+ }
+
+ public string CategoryName
+ {
+ get { return name; }
+ }
+ }
+ }
+}
Added: trunk/Tomboy/Addins/Tasque/tasque-22.png
==============================================================================
Binary file. No diff available.
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Mar 13 04:34:16 2008
@@ -276,6 +276,7 @@
Tomboy/Addins/Sketching/Makefile
Tomboy/Addins/SshSyncService/Makefile
Tomboy/Addins/StickyNoteImport/Makefile
+Tomboy/Addins/Tasque/Makefile
Tomboy/Addins/WebDavSyncService/Makefile
test/Makefile
po/Makefile.in
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]