tomboy r2045 - in trunk: . Tomboy/Addins/VoiceNotes
- From: nshmyrev svn gnome org
- To: svn-commits-list gnome org
- Subject: tomboy r2045 - in trunk: . Tomboy/Addins/VoiceNotes
- Date: Tue, 29 Jul 2008 22:44:33 +0000 (UTC)
Author: nshmyrev
Date: Tue Jul 29 22:44:33 2008
New Revision: 2045
URL: http://svn.gnome.org/viewvc/tomboy?rev=2045&view=rev
Log:
2008-07-30 Nickolay V. Shmyrev <nshmyrev yandex ru>
* Tomboy/Addins/VoiceNotes/Makefile.am,
Tomboy/Addins/VoiceNotes/VoiceNote.addin.xml,
Tomboy/Addins/VoiceNotes/VoiceNote.cs,
Tomboy/Addins/VoiceNotes/voicenotemedia.c:
Added an initial addin for voice notes by Gabriel Marcondes.
Added:
trunk/Tomboy/Addins/VoiceNotes/
trunk/Tomboy/Addins/VoiceNotes/Makefile.am
trunk/Tomboy/Addins/VoiceNotes/VoiceNote.addin.xml
trunk/Tomboy/Addins/VoiceNotes/VoiceNote.cs
trunk/Tomboy/Addins/VoiceNotes/voicenotemedia.c
Modified:
trunk/ChangeLog
Added: trunk/Tomboy/Addins/VoiceNotes/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/Tomboy/Addins/VoiceNotes/Makefile.am Tue Jul 29 22:44:33 2008
@@ -0,0 +1,67 @@
+include $(top_srcdir)/Makefile.include
+
+CSFLAGS = \
+ -debug \
+ -define:DEBUG \
+ -target:library
+
+ASSEMBLIES = \
+ $(LINK_TOMBOY_EXE) \
+ $(TOMBOY_LIBS) \
+ $(LINK_MONO_ADDINS) \
+ -r:Mono.Posix
+
+if ENABLE_GST
+ADDIN_NAME = VoiceNote
+TARGET = $(ADDIN_NAME).Addin.dll
+CSFILES = \
+ $(srcdir)/VoiceNote.cs
+RESOURCES = \
+ -resource:$(srcdir)/$(ADDIN_NAME).addin.xml
+
+$(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
+
+CLEANFILES = \
+ $(TARGET).mdb \
+ $(TARGET)
+
+##
+## Build libvoicenote
+##
+
+INCLUDES = \
+ -I$(top_srcdir) \
+ -DG_LOG_DOMAIN=\"libvoicenote\" \
+ -DGTK_DISABLE_DEPRECATED \
+ -DGDK_DISABLE_DEPRECATED \
+ -DG_DISABLE_DEPRECATED \
+ $(LIBTOMBOY_CFLAGS) \
+ $(GST_CFLAGS) \
+ $(GTK_CFLAGS)
+
+
+voicenotelibdir = $(pkglibdir)
+voicenotelib_LTLIBRARIES = libvoicenote.la
+
+libvoicenote_la_SOURCES = \
+ voicenotemedia.c
+
+libvoicenote_la_LDFLAGS = \
+ -export-dynamic -module -avoid-version \
+ $(LIBTOMBOY_LIBS) \
+ $(GST_LIBS)
+
+maintainer-clean-local:
+ rm -f Makefile.in
+
+endif
Added: trunk/Tomboy/Addins/VoiceNotes/VoiceNote.addin.xml
==============================================================================
--- (empty file)
+++ trunk/Tomboy/Addins/VoiceNotes/VoiceNote.addin.xml Tue Jul 29 22:44:33 2008
@@ -0,0 +1,21 @@
+<Addin id="VoiceNote"
+ namespace="Tomboy"
+ name="Voice Notes"
+ author="Tomboy Project"
+ description="Records voice notes"
+ category="Tools"
+ defaultEnabled="false"
+ version="0.1">
+
+ <Runtime>
+ <Import assembly="VoiceNote.Addin.dll" />
+ </Runtime>
+
+ <Dependencies>
+ <Addin id="Tomboy" version="0.7" />
+ </Dependencies>
+
+ <Extension path="/Tomboy/NoteAddins">
+ <NoteAddin type="Tomboy.VoiceNote.VoiceNote" />
+ </Extension>
+</Addin>
Added: trunk/Tomboy/Addins/VoiceNotes/VoiceNote.cs
==============================================================================
--- (empty file)
+++ trunk/Tomboy/Addins/VoiceNotes/VoiceNote.cs Tue Jul 29 22:44:33 2008
@@ -0,0 +1,102 @@
+using Tomboy;
+using Mono.Unix;
+using System;
+using System.IO;
+using System.Runtime.InteropServices;
+using Gtk;
+
+namespace Tomboy.VoiceNote
+{
+ public class VoiceNote : NoteAddin
+ {
+ Gtk.ToolButton recordButton;
+ Gtk.ToolButton playButton;
+ Gtk.ToolButton stopButton;
+ Gtk.SeparatorToolItem separator;
+ String voice_note_path;
+ FileStream voice_note_file;
+
+ static VoiceNote ()
+ {
+ }
+
+ [DllImport("libvoicenote")]
+ static extern void initialize ();
+
+ [DllImport("libvoicenote")]
+ static extern void start_play (string uri);
+
+ [DllImport("libvoicenote")]
+ static extern void start_record (string uri);
+
+ [DllImport("libvoicenote")]
+ static extern void stop_stream ();
+
+
+ public override void Initialize ()
+ {
+ separator = new Gtk.SeparatorToolItem ();
+ recordButton = new Gtk.ToolButton (Gtk.Stock.MediaRecord);
+ recordButton.Clicked += OnRecordButtonClicked;
+ playButton = new Gtk.ToolButton (Gtk.Stock.MediaPlay);
+ playButton.Clicked += OnPlayButtonClicked;
+ stopButton = new Gtk.ToolButton (Gtk.Stock.MediaStop);
+ stopButton.Clicked += OnStopButtonClicked;
+ initialize ();
+ }
+
+
+ public override void Shutdown ()
+ {
+ recordButton.Clicked -= OnRecordButtonClicked;
+ playButton.Clicked -= OnPlayButtonClicked;
+ stopButton.Clicked -= OnStopButtonClicked;
+ }
+
+
+ public override void OnNoteOpened ()
+ {
+ voice_note_path = Note.FilePath + ".ogg";
+ separator.Show ();
+ recordButton.Show ();
+ playButton.Show ();
+ stopButton.Show ();
+ AddToolItem (separator, -1);
+ AddToolItem (recordButton, -1);
+ AddToolItem (playButton, -1);
+ AddToolItem (stopButton, -1);
+ }
+
+
+ void OnRecordButtonClicked (object sender, EventArgs args)
+ {
+ start_record (voice_note_path);
+ }
+
+
+ void OnPlayButtonClicked (object sender, EventArgs args)
+ {
+ start_play (voice_note_path);
+ }
+
+ void OnStopButtonClicked (object sender, EventArgs args)
+ {
+ stop_stream ();
+ }
+
+
+ bool voice_note_exists ()
+ {
+ try{
+ /* Not guilty, I presume */
+ voice_note_file = File.Open (voice_note_path, FileMode.Open);
+ }
+ catch (Exception except) {
+ /* Oh, you've disappointed me
+ * I'll do nothing for you */
+ return false;
+ }
+ return true;
+ }
+ }
+}
Added: trunk/Tomboy/Addins/VoiceNotes/voicenotemedia.c
==============================================================================
--- (empty file)
+++ trunk/Tomboy/Addins/VoiceNotes/voicenotemedia.c Tue Jul 29 22:44:33 2008
@@ -0,0 +1,43 @@
+#include <gst/gst.h>
+#include <string.h>
+
+#define PLAY_CMD_START "filesrc location="
+#define PLAY_CMD_END " !oggdemux!vorbisdec!audioconvert!audioresample!gconfaudiosink "
+#define RECORD_CMD "gconfaudiosrc !audioconvert !vorbisenc !oggmux !filesink location="
+
+static GstElement *pipeline;
+static GstBus *bus;
+
+void
+initialize ()
+{
+ gst_init (NULL, NULL);
+ return 0;
+}
+
+void
+start_record (gchar *uri)
+{
+ gchar *gst_command = RECORD_CMD;
+ gst_command = g_strconcat(gst_command, uri, NULL);
+ pipeline = gst_parse_launch (gst_command, NULL);
+ g_free (gst_command);
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
+}
+
+void
+start_play (char *uri)
+{
+ gchar *gst_command = PLAY_CMD_START;
+ gst_command = g_strconcat (gst_command, uri, NULL);
+ gst_command = g_strconcat (gst_command, PLAY_CMD_END);
+ pipeline = gst_parse_launch (gst_command, NULL);
+ g_free (gst_command);
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
+}
+
+void
+stop_stream ()
+{
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]