tomboy r2081 - in trunk: . Tomboy/Addins/VoiceNotes
- From: nshmyrev svn gnome org
- To: svn-commits-list gnome org
- Subject: tomboy r2081 - in trunk: . Tomboy/Addins/VoiceNotes
- Date: Wed, 13 Aug 2008 23:02:10 +0000 (UTC)
Author: nshmyrev
Date: Wed Aug 13 23:02:09 2008
New Revision: 2081
URL: http://svn.gnome.org/viewvc/tomboy?rev=2081&view=rev
Log:
2008-08-14 Gabriel Marcondes <gabrielgeraldo gmail com>
* Tomboy/Addins/VoiceNotes/VoiceNote.cs,
Tomboy/Addins/VoiceNotes/voicenotemedia.c:
Cleanup
Modified:
trunk/ChangeLog
trunk/Tomboy/Addins/VoiceNotes/VoiceNote.cs
trunk/Tomboy/Addins/VoiceNotes/voicenotemedia.c
Modified: trunk/Tomboy/Addins/VoiceNotes/VoiceNote.cs
==============================================================================
--- trunk/Tomboy/Addins/VoiceNotes/VoiceNote.cs (original)
+++ trunk/Tomboy/Addins/VoiceNotes/VoiceNote.cs Wed Aug 13 23:02:09 2008
@@ -14,9 +14,9 @@
Gtk.ToolButton stop_button;
Gtk.SeparatorToolItem separator;
InterruptableTimeout button_manager;
+ Gtk.MenuItem delete_item;
String voice_note_path;
bool has_voice_note;
- bool pipeline_set = false;
static Gdk.Pixbuf icon = null;
@@ -45,12 +45,24 @@
public override void Initialize ()
{
separator = new Gtk.SeparatorToolItem ();
+ separator.Show ();
+
record_button = new Gtk.ToolButton (Gtk.Stock.MediaRecord);
record_button.Clicked += OnRecordButtonClicked;
+ record_button.Show ();
+
play_button = new Gtk.ToolButton (Gtk.Stock.MediaPlay);
play_button.Clicked += OnPlayButtonClicked;
+ play_button.Show ();
+
stop_button = new Gtk.ToolButton (Gtk.Stock.MediaStop);
stop_button.Clicked += OnStopButtonClicked;
+ stop_button.Show ();
+
+ delete_item = new Gtk.MenuItem ("Delete Voice Note");
+ delete_item.Activated += OnDeleteItemActivated;
+ delete_item.Show ();
+
initialize ();
}
@@ -60,39 +72,29 @@
record_button.Clicked -= OnRecordButtonClicked;
play_button.Clicked -= OnPlayButtonClicked;
stop_button.Clicked -= OnStopButtonClicked;
-
- // Stop if streaming, and delete the voice note
- if (pipeline_set)
- stop_stream ();
- if (has_voice_note)
- File.Delete (voice_note_path);
+ delete_item.Activated -= OnDeleteItemActivated;
+ stop_stream ();
+ DeleteVoiceNote ();
}
public override void OnNoteOpened ()
{
voice_note_path = Note.FilePath + ".ogg";
- has_voice_note = voice_note_exists ();
- //set the icon if there is a voice note
- if (has_voice_note) {
+ has_voice_note = VoiceNoteExists ();
+
+ if (has_voice_note)
Window.Icon = icon;
- }
- separator.Show ();
- record_button.Show ();
- play_button.Sensitive = has_voice_note;
- play_button.Show ();
- stop_button.Sensitive = false;
- stop_button.Show ();
AddToolItem (separator, -1);
AddToolItem (record_button, -1);
AddToolItem (play_button, -1);
AddToolItem (stop_button, -1);
+ AddPluginMenuItem (delete_item);
- // This has to be done here and not in initialize,
- //otherwise the button's layout becomes disformed
- Window.Hidden += OnNoteClosed;
-
+ play_button.Sensitive = has_voice_note;
+ stop_button.Sensitive = false;
+ Window.Hidden += OnStopButtonClicked;
button_manager = new InterruptableTimeout ();
button_manager.Timeout += UpdateButtons;
}
@@ -101,7 +103,6 @@
void OnRecordButtonClicked (object sender, EventArgs args)
{
start_record (voice_note_path);
- pipeline_set = true;
record_button.Sensitive = false;
play_button.Sensitive = false;
stop_button.Sensitive = true;
@@ -118,26 +119,29 @@
void OnPlayButtonClicked (object sender, EventArgs args)
{
- start_play (voice_note_path);
- pipeline_set = true;
+ start_play (voice_note_path);
record_button.Sensitive = false;
play_button.Sensitive = false;
stop_button.Sensitive = true;
button_manager.Reset (500);
}
+
void OnStopButtonClicked (object sender, EventArgs args)
{
stop_stream ();
}
- void OnNoteClosed (object sender, EventArgs args)
+ void OnDeleteItemActivated (object sender, EventArgs args)
{
- // Stop streaming before hide the window
- if (pipeline_set)
- stop_stream ();
+ stop_stream ();
+ DeleteVoiceNote ();
+ has_voice_note = VoiceNoteExists ();
+ play_button.Sensitive = false;
+ stop_button.Sensitive = false;
}
+
void UpdateButtons (object sender, EventArgs args)
{
int media_state = get_state ();
@@ -154,11 +158,21 @@
break;
}
}
+
+ void DeleteVoiceNote ()
+ {
+ if (has_voice_note)
+ File.Delete (voice_note_path);
+ }
- bool voice_note_exists ()
+ bool VoiceNoteExists ()
{
- try{ File.Open (voice_note_path, FileMode.Open); }
- catch (Exception except) { return false; }
+ try{
+ File.Open (voice_note_path, FileMode.Open);
+ }
+ catch (Exception except) {
+ return false;
+ }
return true;
}
}
Modified: trunk/Tomboy/Addins/VoiceNotes/voicenotemedia.c
==============================================================================
--- trunk/Tomboy/Addins/VoiceNotes/voicenotemedia.c (original)
+++ trunk/Tomboy/Addins/VoiceNotes/voicenotemedia.c Wed Aug 13 23:02:09 2008
@@ -5,7 +5,7 @@
#define PLAY_CMD_END " !oggdemux!vorbisdec!audioconvert!audioresample!gconfaudiosink "
#define RECORD_CMD "gconfaudiosrc !audioconvert !vorbisenc !oggmux !filesink location="
-static GstElement *pipeline;
+static GstElement *pipeline = NULL;
static GstBus *bus;
void
@@ -63,7 +63,8 @@
void
stop_stream ()
{
- gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
+ if (pipeline != NULL)
+ gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_NULL);
}
gint
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]