Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Silva <sebastian@sugarlabs.org>2011-10-01 04:44:28 (GMT)
committer Sebastian Silva <sebastian@sugarlabs.org>2011-10-01 04:46:29 (GMT)
commit7893bc88c0ef79167ac4f03427f6ef8fd0050600 (patch)
treeb63b1c6e9a083af57812972d3dd5fd3899ce39ab
parent0c3d5707e2bc3b48fc9d4508042919f00f701902 (diff)
parent7138386b4090c6733cc69193a45a2cdcbc80115c (diff)
Removed pippy code.
Conflicts: activity/activity.info pippy_app.py
-rw-r--r--NEWS4
-rw-r--r--activity/activity.info2
-rw-r--r--screencast_activity.py46
3 files changed, 47 insertions, 5 deletions
diff --git a/NEWS b/NEWS
index db15a21..3d76865 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,7 @@
+5
+
+*Added progress bar for encoding
+
4
*UI fixes (sebastian silva)
diff --git a/activity/activity.info b/activity/activity.info
index 3b719dd..f0ec88c 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -3,4 +3,4 @@ name = Screencast
bundle_id = org.laptop.Screencast
exec = sugar-activity screencast_activity.ScreencastActivity
icon = screencast-icon
-activity_version = 4
+activity_version = 6
diff --git a/screencast_activity.py b/screencast_activity.py
index edffd2e..86cd662 100644
--- a/screencast_activity.py
+++ b/screencast_activity.py
@@ -26,6 +26,7 @@ import popen2
import re
import shutil
import signal
+import sys
from sugar.activity import activity
from sugar.activity.activity import ActivityToolbox, \
@@ -45,6 +46,7 @@ class ScreencastActivity(activity.Activity):
"""Set up the Screencast activity."""
super(ScreencastActivity, self).__init__(handle)
self._logger = logging.getLogger('screencast-activity')
+ self.timed_id2 = None
from sugar.graphics.menuitem import MenuItem
from sugar.graphics.icon import Icon
@@ -95,17 +97,25 @@ class ScreencastActivity(activity.Activity):
# Status label.
self.status = gtk.Label(_("Status: Stopped"))
+
hbox.pack_start(self.record, expand=False, padding=40)
hbox.pack_start(self.stop, expand=False, padding=40)
+ # Encoding progress bar
+ self.progressbar=gtk.ProgressBar(adjustment=None)
+ self.progressbar.set_fraction(0)
+ self.progressbar.set_text("0% complete")
+
valign = gtk.Alignment(0.5, 0.4, 0, 0)
valign.add(vbox)
+ vbox.pack_end(self.progressbar, expand=True, padding=20)
vbox.pack_end(self.status, expand=True, padding=40)
vbox.pack_end(hbox, expand=True, fill=False)
vbox.pack_end(options, expand=True, padding=40)
self.set_canvas(valign)
self.show_all()
+ self.progressbar.hide()
def write_file (self, file_path):
print "Saving file to %s" % file_path
@@ -163,27 +173,54 @@ class ScreencastActivity(activity.Activity):
execargs.append("31")
execargs.append("-o")
execargs.append(OUTFILE)
- print execargs
self.childp = popen2.Popen3(execargs, "t", 0)
flags = fcntl.fcntl(self.childp.childerr, fcntl.F_GETFL)
fcntl.fcntl(self.childp.childerr, fcntl.F_SETFL, flags|os.O_NONBLOCK)
+ flags = fcntl.fcntl(self.childp.fromchild, fcntl.F_GETFL)
+ fcntl.fcntl(self.childp.fromchild, fcntl.F_SETFL, flags|os.O_NONBLOCK)
self.timed_id = gobject.timeout_add(1000, self.check_status_cb)
self.status.set_text("Status: Recording")
def stop_cb(self, stop):
- print "Stop button clicked"
exitret = os.waitpid(self.childp.pid, os.WNOHANG)
if exitret[0] == 0:
os.kill(self.childp.pid, signal.SIGTERM)
self.stop.set_sensitive(False)
+ def update_counter(self):
+ self.progressbar.show()
+ while True:
+ try:
+ strstdout=self.childp.fromchild.read()
+ self.counter_fraction=float(re.search("[0-9][0-9]?[0-9]?", strstdout).group())
+ percentage=self.counter_fraction/100.0
+ if percentage>1.0:
+ percentage=1.0
+ #print "PORCENTAJE %s " % str(percentage)
+ self.progressbar.set_fraction(percentage)
+ self.progressbar.set_text("%d%%"%int(percentage*100)+' complete')
+ except IOError:
+ gtk.main_iteration(block=False)
+ except AttributeError:
+ break
+ except:
+ print "Unexpected error:", sys.exc_info()[0]
+ print "Unexpected error:", sys.exc_info()[1]
+ break
+
def check_status_cb(self):
if self.childp.pid:
exitret = os.waitpid(self.childp.pid, os.WNOHANG)
if exitret[0] != 0:
- print "no more record process"
# The recording process exited
self.status.set_text("Status: Stopped")
+ if self.timed_id2:
+ gobject.source_remove(self.timed_id2)
+ self.timed_id2 = None
+ self.progressbar.hide()
+ self.alert("Success:", "Saved recording to journal")
+ self.progressbar.set_fraction(0)
+ self.progressbar.set_text('0% complete')
self.record.set_sensitive(True)
self.audiocheckbox.set_sensitive(True)
self.qualitycombo.set_sensitive(True)
@@ -198,8 +235,9 @@ class ScreencastActivity(activity.Activity):
while True:
try:
err_line = self.childp.childerr.readline()
- print err_line
if err_line.startswith("STATE:ENCODING"):
+ if not self.timed_id2:
+ self.timed_id2=gobject.timeout_add(300,self.update_counter)
self.status.set_text("Status: Encoding, please wait")
except:
break