Merge lp:~nico-inattendu/luciole/bug_727165 into lp:luciole

Proposed by NicoInattendu
Status: Merged
Approved by: NicoInattendu
Approved revision: 131
Merged at revision: 129
Proposed branch: lp:~nico-inattendu/luciole/bug_727165
Merge into: lp:luciole
Diff against target: 1177 lines (+331/-232)
8 files modified
luciole/ctrl/ctrl_acq.py (+9/-5)
luciole/ctrl/ctrl_project.py (+66/-41)
luciole/gui/windows/assistant_new_project.py (+7/-6)
luciole/gui/windows/dialog_project_properties.py (+14/-7)
luciole/gui/windows/webcam_detection_widget.py (+84/-162)
test/test_assistant_new_project.py (+6/-1)
test/test_project_properties.py (+21/-10)
test/test_webcam_detection_widget.py (+124/-0)
To merge this branch: bzr merge lp:~nico-inattendu/luciole/bug_727165
Reviewer Review Type Date Requested Status
NicoInattendu Pending
Review via email: mp+52663@code.launchpad.net

Commit message

fix for bug #727165. ow on assistant and webcam properties window, the webcam playback is activated, in viewer window. It's allow a preview of webcam parameters

Description of the change

Bug correction.
Now on assistant and webcam properties window, the webcam plauback is activated, in viewer window. It's allow a preview of webcam parameters

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'luciole/ctrl/ctrl_acq.py'
--- luciole/ctrl/ctrl_acq.py 2011-03-05 14:23:17 +0000
+++ luciole/ctrl/ctrl_acq.py 2011-03-09 11:46:59 +0000
@@ -33,7 +33,7 @@
33import gst33import gst
34from pitivi.signalgroup import SignalGroup34from pitivi.signalgroup import SignalGroup
35from pitivi.action import ViewAction35from pitivi.action import ViewAction
36from pitivi.pipeline import Pipeline36from pitivi.pipeline import Pipeline, PipelineError
3737
38# local application/library specific imports38# local application/library specific imports
39from luciole.media.lgst.webcam_factory import WebcamSourceFactory39from luciole.media.lgst.webcam_factory import WebcamSourceFactory
@@ -157,10 +157,14 @@
157 else :157 else :
158 #self._source_factory.active_mixer(False)158 #self._source_factory.active_mixer(False)
159 self._mode = "ACQUISITION"159 self._mode = "ACQUISITION"
160 160 try :
161 self._pipeline.play()161 self._pipeline.play()
162 self.debug('send acquisition-started - mode : %s', self._mode)162 except PipelineError :
163 self.emit('acquisition-started', with_mixer)163 self.warning('Fail to start pipeline')
164 self._mode = "NO_ACQUISITION"
165 else :
166 self.debug('send acquisition-started - mode : %s', self._mode)
167 self.emit('acquisition-started', with_mixer)
164168
165169
166 else :170 else :
167171
=== modified file 'luciole/ctrl/ctrl_project.py'
--- luciole/ctrl/ctrl_project.py 2011-03-05 13:59:13 +0000
+++ luciole/ctrl/ctrl_project.py 2011-03-09 11:46:59 +0000
@@ -39,15 +39,11 @@
39import luciole.base.exceptions as LEXCEP39import luciole.base.exceptions as LEXCEP
40import luciole.base.tools as LT40import luciole.base.tools as LT
41import luciole.constants as LCONST41import luciole.constants as LCONST
42import luciole.ctrl.constants as CTRL_CONST
43import luciole.ctrl.ctrl_acq as CTRL_ACQ42import luciole.ctrl.ctrl_acq as CTRL_ACQ
44import luciole.ctrl.ctrl_base as CTRL_BASE
45import luciole.ctrl.ctrl_timeline as CTRL_TMLN43import luciole.ctrl.ctrl_timeline as CTRL_TMLN
46import luciole.ctrl.ctrl_no_project as CTRL_NO_PROJECT44import luciole.ctrl.ctrl_no_project as CTRL_NO_PROJECT
47import luciole.ctrl.ctrl_img_vw as CTRL_IMG_VW45import luciole.ctrl.ctrl_img_vw as CTRL_IMG_VW
48import luciole.ctrl.load_rush as LRUSH46import luciole.ctrl.load_rush as LRUSH
49import luciole.gui.constants as GUI_CONST
50import luciole.media.image as LI
51import luciole.project.project_etree as LPF47import luciole.project.project_etree as LPF
5248
53from luciole.gui.windows.assistant_new_project import AssistantNewProject49from luciole.gui.windows.assistant_new_project import AssistantNewProject
@@ -58,7 +54,7 @@
58_NULL_TUPLE = None, None54_NULL_TUPLE = None, None
5955
60class Project(object) :56class Project(object) :
61 57 """ Type class for project data """
62 58
63 def __init__(self) :59 def __init__(self) :
64 self.parser = LPF.ProjectToFile()60 self.parser = LPF.ProjectToFile()
@@ -69,6 +65,7 @@
69 65
70 66
71 def save(self, path) :67 def save(self, path) :
68 """ save to xml file """
72 _project_path = None 69 _project_path = None
73 if path is not None :70 if path is not None :
74 try :71 try :
@@ -83,6 +80,9 @@
83 return _project_path80 return _project_path
84 81
85 def set_non_pjt_dpdt_props(self) :82 def set_non_pjt_dpdt_props(self) :
83 """ set default valus for properties ,
84 who are not stored in xml file
85 """
86 # init props not managed by porject in file86 # init props not managed by porject in file
87 self.props['is_modified'] = False 87 self.props['is_modified'] = False
88 self.props['is-mixer-active'] = False88 self.props['is-mixer-active'] = False
@@ -90,7 +90,8 @@
90 self.props['alpha'] = LCONST.DEFAULT_ALPHA_IMAGE90 self.props['alpha'] = LCONST.DEFAULT_ALPHA_IMAGE
9191
92class CtrlProject(Signallable, Loggable) :92class CtrlProject(Signallable, Loggable) :
93 93 """ High level class who manage a luciole project """
94
94 # CONSTANTS95 # CONSTANTS
95 MODES = ("NO_PROJECT", "ACQUISITION", "TIMELINE", "IMAGE_VIEW", "EXPORT")96 MODES = ("NO_PROJECT", "ACQUISITION", "TIMELINE", "IMAGE_VIEW", "EXPORT")
96 PROJECT_LOADED_MODES = ("ACQUISITION", "TIMELINE", "IMAGE_VIEW", "EXPORT")97 PROJECT_LOADED_MODES = ("ACQUISITION", "TIMELINE", "IMAGE_VIEW", "EXPORT")
@@ -141,6 +142,7 @@
141 Loggable.__init__(self)142 Loggable.__init__(self)
142 143
143 self._mode = None144 self._mode = None
145 self._old_mode = None
144 self.gui = None146 self.gui = None
145 self.project = Project()147 self.project = Project()
146148
@@ -154,6 +156,7 @@
154156
155157
156 def connect_to_gui(self, gui) :158 def connect_to_gui(self, gui) :
159 """ connect project controller with gui """
157 self.gui = gui160 self.gui = gui
158 161
159 self.ctrl_acq.set_viewer(gui.drawarea)162 self.ctrl_acq.set_viewer(gui.drawarea)
@@ -162,6 +165,7 @@
162 self.ctrl_img_vw.set_viewer(gui.drawarea)165 self.ctrl_img_vw.set_viewer(gui.drawarea)
163 166
164 def no_project_mode(self) :167 def no_project_mode(self) :
168 """ activate NO_PROJECT mode """
165 self.debug('No project mode')169 self.debug('No project mode')
166 170
167 if self._mode == 'ACQUISITION' :171 if self._mode == 'ACQUISITION' :
@@ -178,7 +182,7 @@
178 182
179183
180 def acquisition_mode(self, force = False) :184 def acquisition_mode(self, force = False) :
181 """ activate acquisition mode """185 """ activate ACQUISITION mode """
182 self.debug('Acquisition mode')186 self.debug('Acquisition mode')
183 if self._mode in self.PROJECT_LOADED_MODES \187 if self._mode in self.PROJECT_LOADED_MODES \
184 and self._mode != 'ACQUISITION' :188 and self._mode != 'ACQUISITION' :
@@ -195,30 +199,34 @@
195199
196 self.ctrl_acq.active_viewer()200 self.ctrl_acq.active_viewer()
197 self.ctrl_acq.start()201 self.ctrl_acq.start()
198 self.debug('Emit project-mode-changed : %s'%self._mode)202 self.debug('Emit project-mode-changed : %s' % self._mode)
199 self.emit('project-mode-changed',self._mode)203 self.emit('project-mode-changed', self._mode)
200204
201 else :205 else :
202 self.warning("impossible to switch to acquisition mode (%s)",206 self.warning("impossible to switch to acquisition mode (%s)",
203 self._mode )207 self._mode )
204 208
205 def timeline_mode(self) :209 def timeline_mode(self, force = False) :
206 """ activate timeline mode """210 """ activate TIMELINE mode """
211 self.debug('setting timeline mode')
212
207 if self._mode == 'ACQUISITION' :213 if self._mode == 'ACQUISITION' :
208 self.ctrl_acq.stop()214 self.ctrl_acq.stop()
209 215
210 if self._mode in self.PROJECT_LOADED_MODES \216 if (self._mode in self.PROJECT_LOADED_MODES \
211 and self._mode != 'TIMELINE' :217 and self._mode != 'TIMELINE') \
218 or (force == True) :
212219
213 self._mode = 'TIMELINE'220 self._mode = 'TIMELINE'
214 self.ctrl_tmln.active_viewer()221 self.ctrl_tmln.active_viewer()
215 self.debug('Emit project-mode-changed : %s'%self._mode)222 self.debug('Emit project-mode-changed : %s' % self._mode)
216 self.emit('project-mode-changed',self._mode)223 self.emit('project-mode-changed', self._mode)
217 else :224 else :
218 self.warning("impossible to switch to timeline mode")225 self.warning("impossible to switch to timeline mode")
219 226
220227
221 def img_vw_mode(self, origin, image_name, position = 0) :228 def img_vw_mode(self, origin, image_name, position = 0) :
229 """ activate IMAGE_VIEW mode """
222 if self._mode in self.PROJECT_LOADED_MODES : 230 if self._mode in self.PROJECT_LOADED_MODES :
223 if self._mode == 'ACQUISITION' :231 if self._mode == 'ACQUISITION' :
224 self.ctrl_acq.stop()232 self.ctrl_acq.stop()
@@ -274,7 +282,7 @@
274 # close current project282 # close current project
275 self.close()283 self.close()
276 284
277 _ass = AssistantNewProject(self._new_project_cb)285 _ass = AssistantNewProject(self._new_project_cb, self.gui.drawarea)
278 286
279287
280 288
@@ -315,13 +323,14 @@
315 self.project = None323 self.project = None
316 324
317 def save(self, dir_path = None ) :325 def save(self, dir_path = None ) :
326 """ save project """
318 if self._mode not in self.PROJECT_LOADED_MODES :327 if self._mode not in self.PROJECT_LOADED_MODES :
319 self.error('invalid mode for save : %s'%self._mode)328 self.error('invalid mode for save : %s'%self._mode)
320 return329 return
321 if dir_path and not os.path.exists(dir_path) :330 if dir_path and not os.path.exists(dir_path) :
322 self.error('Path %s exists. Impossible to save project', dir_path)331 self.error('Path %s exists. Impossible to save project', dir_path)
323 return332 return
324 self.debug("%s",dir_path) 333 self.debug("%s", dir_path)
325 try :334 try :
326 _project_path = self.project.save(dir_path)335 _project_path = self.project.save(dir_path)
327 except LEXCEP.LucioException, _err_msg :336 except LEXCEP.LucioException, _err_msg :
@@ -332,10 +341,11 @@
332 if dir_path is not None and _project_path is not None :341 if dir_path is not None and _project_path is not None :
333 # reload project is corretcly saved342 # reload project is corretcly saved
334 self.close()343 self.close()
335 self.debug('Opening project with path %s',_project_path)344 self.debug('Opening project with path %s', _project_path)
336 self.open(_project_path)345 self.open(_project_path)
337 346
338 def set_framerate(self, fpi, force = False) :347 def set_framerate(self, fpi, force = False) :
348 """ set project framerate """
339 if self._mode != "TIMELINE" and force == False :349 if self._mode != "TIMELINE" and force == False :
340 self.info('update of fpi only availabe in TIMELINE mode')350 self.info('update of fpi only availabe in TIMELINE mode')
341 return351 return
@@ -347,18 +357,9 @@
347 357
348358
349359
350 def new(self, project_data = None) :
351
352 # create new project
353
354 if project_data :
355 # TODO case with assistant
356 pass
357
358
359
360 def release(self) :360 def release(self) :
361361 """ release project ctrl """
362 # TODO : this fucntion seems unuseful : Ton analyse
362 # release signals between aquirer and project363 # release signals between aquirer and project
363 if self.project.props['hardtype'] in \364 if self.project.props['hardtype'] in \
364 (LCONST.FAKE, LCONST.DVCAM, LCONST.WEBCAM ) : 365 (LCONST.FAKE, LCONST.DVCAM, LCONST.WEBCAM ) :
@@ -374,12 +375,13 @@
374375
375376
376 def import_images(self, paths) :377 def import_images(self, paths) :
378 """ import images """
377 if self._mode not in self.PROJECT_LOADED_MODES :379 if self._mode not in self.PROJECT_LOADED_MODES :
378 self.error('invalid mode for import: %s'%self._mode)380 self.error('invalid mode for import: %s'%self._mode)
379 return381 return
380382
381 if paths != [] :383 if paths != [] :
382 self.debug('Starting image importer for %s',paths)384 self.debug('Starting image importer for %s', paths)
383 importer = ImportController( paths,385 importer = ImportController( paths,
384 self.project.props,386 self.project.props,
385 self.project.rush,387 self.project.rush,
@@ -398,7 +400,7 @@
398 # snapshot tajed, so snapshot-taken signal can400 # snapshot tajed, so snapshot-taken signal can
399 # be emited for each image :401 # be emited for each image :
400 for image in images :402 for image in images :
401 self.ctrl_acq.emit('snapshot-taken',image )403 self.ctrl_acq.emit('snapshot-taken', image )
402 404
403 # update project 405 # update project
404 # get image names406 # get image names
@@ -419,7 +421,7 @@
419 if self._mode not in self.PROJECT_LOADED_MODES :421 if self._mode not in self.PROJECT_LOADED_MODES :
420 self.error('invalid mode for import: %s'%self._mode)422 self.error('invalid mode for import: %s'%self._mode)
421 return423 return
422 self.debug('%s',self.project.props)424 self.debug('%s', self.project.props)
423 self._old_mode = self._mode425 self._old_mode = self._mode
424 if self._mode == 'ACQUISITION' :426 if self._mode == 'ACQUISITION' :
425 # switch to TIMELINE to free the webcam427 # switch to TIMELINE to free the webcam
@@ -427,21 +429,34 @@
427429
428 430
429 _properties = ProjectProperties(self.gui.main_window, 431 _properties = ProjectProperties(self.gui.main_window,
430 self.project.props)432 self.project.props, self.gui.drawarea)
431 _properties.connect('project-changed', self._project_modified_cb)433 _properties.connect('project-changed', self._project_modified_cb)
434 _properties.connect('dialog-closed', self._dialog_pp_closed_cb)
432 _properties.run()435 _properties.run()
433436
434 def _project_modified_cb(self, dialog, project_data) :437 def _project_modified_cb(self, dialog, project_data) :
435 """ callback for modified data from project properties dialog """438 """ callback for modified data from project properties dialog """
436 self.is_modified = True439 self.is_modified = True
440
441 def _dialog_pp_closed_cb(self, dialog) :
442 """ dialog project properties closed callback """
437 if self._old_mode == 'ACQUISITION' :443 if self._old_mode == 'ACQUISITION' :
438 # go back to acqusition mode444 # go back to acqusition mode
439 self.acquisition_mode(True)445 self.acquisition_mode(True)
440 self._old_mode = None446 self._old_mode = None
447 if self._old_mode == 'TIMELINE' :
448 # go back to acqusition mode
449 # trick to force timeline mode reload
450 self.timeline_mode(True)
451 self._old_mode = None
452
441453
442454
443455
444 def _start_project_load(self) :456 def _start_project_load(self) :
457 """ start project load.
458 i.e. execute project controller """
459
445 # start rusher controller460 # start rusher controller
446 _rush_ctrl = LRUSH.ControllerLoadRush( self.project,461 _rush_ctrl = LRUSH.ControllerLoadRush( self.project,
447 self.gui.status_bar )462 self.gui.status_bar )
@@ -449,6 +464,7 @@
449464
450465
451 def _rush_load_finish_cb(self, rush_ctrl, rush_obj) :466 def _rush_load_finish_cb(self, rush_ctrl, rush_obj) :
467 """ image rush load finish callback """
452 self.debug(" Rush Load Finish :%s ", rush_obj.dump_image_name() )468 self.debug(" Rush Load Finish :%s ", rush_obj.dump_image_name() )
453 if rush_obj != None : 469 if rush_obj != None :
454 self._terminate_project_load(rush_obj)470 self._terminate_project_load(rush_obj)
@@ -456,13 +472,14 @@
456 rush_ctrl.disconnect_by_function( self._rush_load_finish_cb)472 rush_ctrl.disconnect_by_function( self._rush_load_finish_cb)
457 473
458 def _terminate_project_load(self, rush_obj) :474 def _terminate_project_load(self, rush_obj) :
475 """ terminate load of a project """
459 self.project.rush = rush_obj476 self.project.rush = rush_obj
460 477
461 # set project as not modified as it is just loaded478 # set project as not modified as it is just loaded
462 self.project.set_non_pjt_dpdt_props()479 self.project.set_non_pjt_dpdt_props()
463 480
464 # set path for image to mix481 # set path for image to mix
465 self.project.props['image2mix'] =\482 self.project.props['image2mix'] = \
466 os.path.join(483 os.path.join(
467 self.project.props['project_dir'],484 self.project.props['project_dir'],
468 LCONST.IMAGE2MIX_NAME485 LCONST.IMAGE2MIX_NAME
@@ -481,15 +498,18 @@
481 self.emit('project-loaded', self.project )498 self.emit('project-loaded', self.project )
482 499
483 def _connect_to_acq(self , ctrl_acq) :500 def _connect_to_acq(self , ctrl_acq) :
501 """ connect to acqusision controller """
484 ctrl_acq.connect('acquirer-ready', self._acquirer_ready_cb)502 ctrl_acq.connect('acquirer-ready', self._acquirer_ready_cb)
485 ctrl_acq.connect('acquirer-error', self._acquirer_error_cb)503 ctrl_acq.connect('acquirer-error', self._acquirer_error_cb)
486504
487 def _disconnect_from_acq(self , ctrl_acq) :505 def _disconnect_from_acq(self , ctrl_acq) :
506 """ disconnect from acqusision controller """
488 ctrl_acq.disconnect_by_function( self._acquirer_ready_cb)507 ctrl_acq.disconnect_by_function( self._acquirer_ready_cb)
489 ctrl_acq.disconnect_by_function( self._acquirer_error_cb)508 ctrl_acq.disconnect_by_function( self._acquirer_error_cb)
490509
491510
492 def _acquirer_ready_cb(self, ctrl_acq ) :511 def _acquirer_ready_cb(self, ctrl_acq ) :
512 """ acquirer ready callback """
493 self.debug('RX acquirer-ready signal')513 self.debug('RX acquirer-ready signal')
494 if self.project.props['hardtype'] in \514 if self.project.props['hardtype'] in \
495 (LCONST.FAKE, LCONST.DVCAM, LCONST.WEBCAM ) : 515 (LCONST.FAKE, LCONST.DVCAM, LCONST.WEBCAM ) :
@@ -504,27 +524,32 @@
504524
505525
506 def _acquirer_error_cb(self, ctrl_acq, msg) :526 def _acquirer_error_cb(self, ctrl_acq, msg) :
527 """ acquirer error callback """
528 # TODO : implementation of acqusition errot
529 # not corectly managed
507 self.error(msg)530 self.error(msg)
508 531
509 def _connect_to_timeline(self, ctrl_tmln) :532 def _connect_to_timeline(self, ctrl_tmln) :
533 """ connect to timeline controller """
510 ctrl_tmln.connect('timeline-ready', self._timeline_ready_cb)534 ctrl_tmln.connect('timeline-ready', self._timeline_ready_cb)
511 535
512 def _disconnect_from_timeline(self, ctrl_tmln) :536 def _disconnect_from_timeline(self, ctrl_tmln) :
537 """ discconnect from timeline controller """
513 ctrl_tmln.disconnect_from_project(self)538 ctrl_tmln.disconnect_from_project(self)
514 ctrl_tmln.disconnect_by_function(self._timeline_loaded_cb)539 ctrl_tmln.disconnect_by_function(self._timeline_ready_cb)
515540
516 def _timeline_ready_cb(self, ctrl_tmln): 541 def _timeline_ready_cb(self, ctrl_tmln):
542 """ timeline ready callback """
543 self.debug('RX timeline-ready signal')
517 if self.project.props['hardtype'] == LCONST.DIGICAM :544 if self.project.props['hardtype'] == LCONST.DIGICAM :
518 # TODO : work around on mode545 # when digicam mode is set force timeline mode
519 # FIXME : set to image to force transtion to acquisition mode546 self.timeline_mode(True)
520 # default mode when project is started
521 self._mode = 'IMAGE_VIEW'
522 self.timeline_mode()
523547
524 548
525 549
526 def _copy_to_image2mix(self, image_name) :550 def _copy_to_image2mix(self, image_name) :
527 551 """ on directory, copy an image to image the image 2 mix path
552 """
528 _source = os.path.join( self.project.props['project_dir'],553 _source = os.path.join( self.project.props['project_dir'],
529 self.project.props['rush_dir'],554 self.project.props['rush_dir'],
530 image_name)555 image_name)
531556
=== modified file 'luciole/gui/windows/assistant_new_project.py'
--- luciole/gui/windows/assistant_new_project.py 2011-02-28 12:58:02 +0000
+++ luciole/gui/windows/assistant_new_project.py 2011-03-09 11:46:59 +0000
@@ -408,8 +408,8 @@
408class PageWebcam(LWDW.WebcamDetectionWidget) :408class PageWebcam(LWDW.WebcamDetectionWidget) :
409 """ Assistant page for webcam detection """409 """ Assistant page for webcam detection """
410 410
411 def __init__(self, assistant, project_data, *args ) :411 def __init__(self, assistant, project_data, viewer_wdg, *args ) :
412 LWDW.WebcamDetectionWidget.__init__(self, project_data, *args )412 LWDW.WebcamDetectionWidget.__init__(self, project_data, viewer_wdg, *args )
413 self.assistant = assistant413 self.assistant = assistant
414414
415 def webcam_detection_prepare(self, page) :415 def webcam_detection_prepare(self, page) :
@@ -517,8 +517,8 @@
517 """ Call back for 'selection-changed' signal """517 """ Call back for 'selection-changed' signal """
518 _filename = widget.get_filename()518 _filename = widget.get_filename()
519 if _filename :519 if _filename :
520 self.project_data['sound']['active'] = 'yes'520 self.project_data['sound']['active'] = 'yes'
521 self.project_data['sound']['input_path'] = _filename521 self.project_data['sound']['input_path'] = _filename
522522
523523
524524
@@ -650,9 +650,10 @@
650 650
651 __LUCIOLE_LOGO = os.path.join(LCONST.IMAGE_DIR,'luciole_logo.png')651 __LUCIOLE_LOGO = os.path.join(LCONST.IMAGE_DIR,'luciole_logo.png')
652652
653 def __init__(self, apply_callback) :653 def __init__(self, apply_callback, viewer_wdg) :
654 """ Initialize assistant window """654 """ Initialize assistant window """
655 self.apply_callback = apply_callback 655 self.apply_callback = apply_callback
656 self.viewer_wdg = viewer_wdg
656 657
657 #658 #
658 # init project datas 659 # init project datas
@@ -696,7 +697,7 @@
696 #697 #
697 # configure page 3698 # configure page 3
698 #699 #
699 self._pg3 = PageWebcam( self.assistant, self.project_data) 700 self._pg3 = PageWebcam( self.assistant, self.project_data, self.viewer_wdg)
700 self.assistant.append_page(self._pg3)701 self.assistant.append_page(self._pg3)
701 self.assistant.set_page_title( self._pg3, _(' Webcam detection '))702 self.assistant.set_page_title( self._pg3, _(' Webcam detection '))
702 self.assistant.set_page_type( self._pg3, gtk.ASSISTANT_PAGE_CONTENT)703 self.assistant.set_page_type( self._pg3, gtk.ASSISTANT_PAGE_CONTENT)
703704
=== modified file 'luciole/gui/windows/dialog_project_properties.py'
--- luciole/gui/windows/dialog_project_properties.py 2011-02-27 18:32:53 +0000
+++ luciole/gui/windows/dialog_project_properties.py 2011-03-09 11:46:59 +0000
@@ -53,6 +53,7 @@
53 """53 """
54 __signals__ = {54 __signals__ = {
55 'project-changed' : ['project'],55 'project-changed' : ['project'],
56 'dialog-closed' : [],
56 }57 }
5758
58 # This tow 2 tables descibes how to display project info59 # This tow 2 tables descibes how to display project info
@@ -130,7 +131,7 @@
130131
131 _title = _('Project properties')132 _title = _('Project properties')
132 133
133 def __init__(self, main_window, project) :134 def __init__(self, main_window, project , viewer_wdg) :
134 """ create a Dialog with project properties and display it"""135 """ create a Dialog with project properties and display it"""
135 Loggable.__init__(self)136 Loggable.__init__(self)
136 Signallable.__init__(self)137 Signallable.__init__(self)
@@ -145,8 +146,8 @@
145 gtk.STOCK_APPLY, gtk.RESPONSE_APPLY146 gtk.STOCK_APPLY, gtk.RESPONSE_APPLY
146 )147 )
147 )148 )
148 print self._dialog.vbox
149 self._project = project149 self._project = project
150 self._viewer_wdg = viewer_wdg
150 # keep framerate list and framerate selected those value can change151 # keep framerate list and framerate selected those value can change
151 #self._framerate_selected = None152 #self._framerate_selected = None
152 #self._framerate_list = None153 #self._framerate_list = None
@@ -204,8 +205,9 @@
204 self._new_webcam_props != self._project['webcam_data'] :205 self._new_webcam_props != self._project['webcam_data'] :
205 self._project['webcam_data'].update(self._new_webcam_props)206 self._project['webcam_data'].update(self._new_webcam_props)
206 self.emit('project-changed', self._project)207 self.emit('project-changed', self._project)
207208
208209 self.debug('emit dialog-closed signal')
210 self.emit('dialog-closed')
209211
210 def _cb_on_exit(self, widget, event) :212 def _cb_on_exit(self, widget, event) :
211 """ on exit callback """213 """ on exit callback """
@@ -530,7 +532,10 @@
530 532
531 def on_button_webcam_clicked(self, widget) :533 def on_button_webcam_clicked(self, widget) :
532 """ Button webcam clicked """534 """ Button webcam clicked """
533 self._widget_webcam = WebcamDetectionDlg(self._dialog, self._cb_webcam_updated)535 self._widget_webcam = WebcamDetectionDlg(
536 self._dialog,
537 self._viewer_wdg,
538 self._cb_webcam_updated)
534539
535540
536 def _cb_webcam_updated(self, webcam_props) :541 def _cb_webcam_updated(self, webcam_props) :
@@ -667,7 +672,7 @@
667class WebcamDetectionDlg(gtk.MessageDialog, Loggable) :672class WebcamDetectionDlg(gtk.MessageDialog, Loggable) :
668 """ Opens Dialog for webcam Detection """673 """ Opens Dialog for webcam Detection """
669 674
670 def __init__(self, parent, cb_ok = None ) :675 def __init__(self, parent, viewer_wdg, cb_ok = None ) :
671 """ create a Dialog with project properties and display it676 """ create a Dialog with project properties and display it
672 parent : The parent window677 parent : The parent window
673 cb_ok : The callback when on button is clicked 678 cb_ok : The callback when on button is clicked
@@ -685,7 +690,9 @@
685 # detected data will be stored here 690 # detected data will be stored here
686 self.project_webcam = dict()691 self.project_webcam = dict()
687 692
688 self.webcam_widget = LWDW.WebcamDetectionWidget(self.project_webcam) 693 self.webcam_widget = \
694 LWDW.WebcamDetectionWidget(self.project_webcam,
695 viewer_wdg)
689 self.webcam_widget.connect('webcam-caps-selected', 696 self.webcam_widget.connect('webcam-caps-selected',
690 self._webcam_caps_selected)697 self._webcam_caps_selected)
691 self.webcam_widget.connect('webcam-caps-selected', 698 self.webcam_widget.connect('webcam-caps-selected',
692699
=== modified file 'luciole/gui/windows/webcam_detection_widget.py'
--- luciole/gui/windows/webcam_detection_widget.py 2011-02-16 13:04:44 +0000
+++ luciole/gui/windows/webcam_detection_widget.py 2011-03-09 11:46:59 +0000
@@ -35,19 +35,13 @@
35import gobject35import gobject
3636
3737
38import gst
39
40
41from pitivi.log.loggable import Loggable38from pitivi.log.loggable import Loggable
42from pitivi.signalinterface import Signallable39from pitivi.signalinterface import Signallable
4340
44# for test41# for test
45from pitivi.encode import RenderSinkFactory, RenderFactory
46from pitivi.action import RenderAction
47from pitivi.factories.base import SinkFactory
48from pitivi.pipeline import Pipeline42from pitivi.pipeline import Pipeline
49from pitivi.settings import StreamEncodeSettings, RenderSettings
5043
44from pitivi.action import ViewAction
51# local application/library specific imports45# local application/library specific imports
52import luciole.media.webcam_detect.webcam_detection as WBCM_DTCT46import luciole.media.webcam_detect.webcam_detection as WBCM_DTCT
5347
@@ -55,6 +49,7 @@
55from luciole.media.lgst.webcam_factory import WebcamSourceFactory49from luciole.media.lgst.webcam_factory import WebcamSourceFactory
5650
57class WebcamField(Loggable, Signallable) :51class WebcamField(Loggable, Signallable) :
52 """ Manage webcam properties/fields """
58 __signals__ = {53 __signals__ = {
59 'combo-changed' : ['field','value'],54 'combo-changed' : ['field','value'],
60 }55 }
@@ -68,9 +63,10 @@
68 self._combo_idx = []63 self._combo_idx = []
69 self._combo = None64 self._combo = None
70 self._range = None65 self._range = None
71 self.widget = self._createUi()66 self.widget = self._create_ui()
7267
73 def _createUi(self) : 68 def _create_ui(self) :
69 """ Gui widgetc creation """
74 _bbox = gtk.HBox()70 _bbox = gtk.HBox()
75 _boxalign = gtk.Alignment(xalign=0.0, yalign=0.0)71 _boxalign = gtk.Alignment(xalign=0.0, yalign=0.0)
76 _boxalign.add(_bbox)72 _boxalign.add(_bbox)
@@ -91,16 +87,18 @@
91 return _boxalign87 return _boxalign
92 88
93 def _create_combo(self, bbox) :89 def _create_combo(self, bbox) :
90 """ create GUI combo box """
94 _combo = gtk.combo_box_new_text()91 _combo = gtk.combo_box_new_text()
95 self.debug('create combobox for field %s', self.field_name)92 self.debug('create combobox for field %s', self.field_name)
96 for _idx, _value in enumerate(self.value) :93 for _idx, _value in enumerate(self.value) :
97 _combo.append_text(str(_value))94 _combo.append_text(str(_value))
98 self._combo_idx.append(str(_value))95 self._combo_idx.append(str(_value))
99 _combo.connect('changed', self.combobox_defintion_changed_cb)96 _combo.connect('changed', self._combobox_defintion_changed_cb)
100 bbox.pack_start(_combo, expand=False)97 bbox.pack_start(_combo, expand=False)
101 return _combo98 return _combo
102 99
103 def _create_range(self, bbox) :100 def _create_range(self, bbox) :
101 """ create GUI range """
104 102
105 _adj = gtk.Adjustment(103 _adj = gtk.Adjustment(
106 float(self.value[0]),104 float(self.value[0]),
@@ -115,19 +113,21 @@
115 _scale.set_value_pos(gtk.POS_RIGHT)113 _scale.set_value_pos(gtk.POS_RIGHT)
116 _scale.set_draw_value(True)114 _scale.set_draw_value(True)
117 _scale.set_size_request(500, 500)115 _scale.set_size_request(500, 500)
118 _scale.connect('value-changed', self.vscale_value_changed_cb)116 _scale.connect('value-changed', self._vscale_value_changed_cb)
119 bbox.pack_start(_scale, expand=True, fill = True )117 bbox.pack_start(_scale, expand=True, fill = True )
120 return _scale118 return _scale
121119
122 def combobox_defintion_changed_cb(self, widget) :120 def _combobox_defintion_changed_cb(self, widget) :
123121 """ combobox change callback"""
124 self.emit('combo-changed', self.field_name, widget.get_active_text() )122 self.emit('combo-changed', self.field_name, widget.get_active_text() )
125 123
126 def vscale_value_changed_cb(self, widget) :124 def _vscale_value_changed_cb(self, widget) :
125 """ scale value changed callback"""
127 self.emit('combo-changed', self.field_name, widget.get_value() )126 self.emit('combo-changed', self.field_name, widget.get_value() )
128127
129128
130 def set_active(self, value) :129 def set_active(self, value) :
130 """ active values on combo """
131 if self._combo is not None :131 if self._combo is not None :
132 try :132 try :
133 _idx = self._combo_idx.index(value)133 _idx = self._combo_idx.index(value)
@@ -138,7 +138,7 @@
138138
139139
140class WebcamPropsWdg(Loggable, Signallable) :140class WebcamPropsWdg(Loggable, Signallable) :
141 """ Webcam Properties """ 141 """ Webcam Properties widget """
142 142
143 __signals__ = {143 __signals__ = {
144 'prop-changed' : ['prop','value'],144 'prop-changed' : ['prop','value'],
@@ -158,46 +158,48 @@
158158
159 parent_wdg.add(self._main_window)159 parent_wdg.add(self._main_window)
160 160
161 self.prepare_ui()
162 161
163 # Show the window and all its children162 # Show the window and all its children
164 self._main_window.show_all()163 self._main_window.show_all()
165164
166
167
168 def prepare_ui(self) :
169 pass
170 165
171 166
172 def set_definitions(self, definitions) :167 def set_definitions(self, definitions) :
168 """ set webcam definitions GUI prop"""
173 self.set_prop('definition', definitions) 169 self.set_prop('definition', definitions)
174 170
175 def set_active_defintion(self, definition) :171 def set_active_defintion(self, definition) :
172 """ set webcam active definition GUI prop"""
176 _wdg = self.prop_widgets['definition']173 _wdg = self.prop_widgets['definition']
177 _wdg.set_active(definition)174 _wdg.set_active(definition)
178175
179176
180 def set_videotypes(self, videotypes) :177 def set_videotypes(self, videotypes) :
178 """ set webcam videotypes GUI prop"""
181 self.set_prop('videotype', videotypes) 179 self.set_prop('videotype', videotypes)
182180
183 def set_active_videotype(self, value) :181 def set_active_videotype(self, value) :
182 """ set webcam active videotype GUI prop"""
184 self.set_active_prop('videotype', value) 183 self.set_active_prop('videotype', value)
185 184
186 185
187 def set_prop(self, prop, prop_values, wdg_type='combo' ) :186 def set_prop(self, prop, prop_values, wdg_type='combo' ) :
187 """ set a webcam GUI prop. Generic method """
188 _wdg = WebcamField(prop, prop_values, wdg_type )188 _wdg = WebcamField(prop, prop_values, wdg_type )
189 if isinstance(prop_values, list) :189 if isinstance(prop_values, list) :
190 _wdg.connect('combo-changed', self.combo_changed_cb)190 _wdg.connect('combo-changed', self._combo_changed_cb)
191 self.prop_widgets[prop] = _wdg191 self.prop_widgets[prop] = _wdg
192 self._main_window.pack_start(_wdg.widget) 192 self._main_window.pack_start(_wdg.widget)
193 _wdg.widget.show_all()193 _wdg.widget.show_all()
194194
195 195
196 def set_active_prop(self, prop, active_value):196 def set_active_prop(self, prop, active_value):
197 """ set a webcam active GUI prop. Generic method """
197 _wdg = self.prop_widgets[prop]198 _wdg = self.prop_widgets[prop]
198 _wdg.set_active(active_value)199 _wdg.set_active(active_value)
199 200
200 def remove_prop(self, prop) :201 def remove_prop(self, prop) :
202 """ remove a webcam property """
201 if prop in self.prop_widgets :203 if prop in self.prop_widgets :
202 204
203 self.debug('remove prop %s', prop)205 self.debug('remove prop %s', prop)
@@ -207,20 +209,23 @@
207 del self.prop_widgets[prop]209 del self.prop_widgets[prop]
208 210
209 def remove_all_props(self) :211 def remove_all_props(self) :
212 """ remove all properties """
210 _props = self.prop_widgets.keys()213 _props = self.prop_widgets.keys()
211 for _prop in _props:214 for _prop in _props:
212 _wdg = self.prop_widgets.pop(_prop)215 _wdg = self.prop_widgets.pop(_prop)
213 self._main_window.remove(_wdg.widget)216 self._main_window.remove(_wdg.widget)
214 _wdg.disconnect_by_function(self.combo_changed_cb)217 _wdg.disconnect_by_function(self._combo_changed_cb)
215 self.debug("remove widget prop %s", _prop)218 self.debug("remove widget prop %s", _prop)
216219
217220
218 def combo_changed_cb(self, widget, prop, value) :221 def _combo_changed_cb(self, widget, prop, value) :
222 """ combobox value changed callback """
219 self.debug('emit prop-changed : %s=%s', prop, value)223 self.debug('emit prop-changed : %s=%s', prop, value)
220 self.emit('prop-changed', prop, value)224 self.emit('prop-changed', prop, value)
221 225
222226
223 def display_webcams(self, _webcams) :227 def display_webcams(self, _webcams) :
228 """ display detected webcams """
224 _wdg = WebcamField('webcam-name', _webcams)229 _wdg = WebcamField('webcam-name', _webcams)
225 if isinstance(_webcams, list) :230 if isinstance(_webcams, list) :
226 _wdg.connect('combo-changed', self._webcam_changed_cb)231 _wdg.connect('combo-changed', self._webcam_changed_cb)
@@ -230,21 +235,15 @@
230 _wdg.widget.show_all()235 _wdg.widget.show_all()
231 236
232 def _webcam_changed_cb(self, widget, prop, value) :237 def _webcam_changed_cb(self, widget, prop, value) :
238 """ webcam selection callback """
233 self.debug('emit webcam-changed : %s=%s', prop, value)239 self.debug('emit webcam-changed : %s=%s', prop, value)
234 240
235 self.emit('webcam-changed', value)241 self.emit('webcam-changed', value)
236242
237243
238class FakeSinkFactory(SinkFactory):
239 def __init__(self, factoryname="fakesink", *args, **kwargs):
240 SinkFactory.__init__(self, *args, **kwargs)
241 self.__factoryname=factoryname
242
243 def _makeBin(self, output_stream=None):
244 return gst.element_factory_make(self.__factoryname)
245
246class WebcamDetectionWidget(gtk.Frame, Loggable) :244class WebcamDetectionWidget(gtk.Frame, Loggable) :
247 """ Assistant page for webcam detection """245 """ Assistant page for webcam detection """
246
248 __gsignals__ = { 247 __gsignals__ = {
249 'webcams-detected' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,248 'webcams-detected' : (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
250 (gobject.TYPE_PYOBJECT,)),249 (gobject.TYPE_PYOBJECT,)),
@@ -260,12 +259,14 @@
260259
261260
262 261
263 def __init__(self, project_data, *args ) :262 def __init__(self, project_data, viewer, *args ) :
264 gtk.Frame.__init__(self, *args )263 gtk.Frame.__init__(self, *args )
265 Signallable.__init__(self)
266 Loggable.__init__(self)264 Loggable.__init__(self)
267 self.wcam_params = {}265 self.wcam_params = {}
268266 self._viewer = viewer
267 self.factory = None
268 self.action = None
269 self.pipeline = None
269 self.set_name('Page_webcam')270 self.set_name('Page_webcam')
270 self.project_data = project_data271 self.project_data = project_data
271 272
@@ -306,57 +307,55 @@
306 self.info('No webcam detected')307 self.info('No webcam detected')
307 self.emit('webcam-not-detetcted')308 self.emit('webcam-not-detetcted')
308309
310 def prepare_viewer(self, wcam_params) :
311 """ prepare viewer and pipeline """
312 self.debug('prepare pipeline/viewer start')
309313
310 def active_webcam(self, device) :314 viewer = self._viewer
311 if self.pipeline is not None :315 if viewer.pipeline is not None :
312 try :316 try :
313 self.pipeline.pause()317 viewer.pause()
314 self.render.deactivate()
315 except :318 except :
316 pass319 self.warning('Impossible to pause viewer')
317
318
319 self.factory = WebcamSourceFactory()320 self.factory = WebcamSourceFactory()
320 self.debug("%s", self.wcam_params)321 self.factory.webcam_params = wcam_params
321 self.factory.webcam_params = self.wcam_params322 self.factory.with_scale = False
323
322 self.pipeline = Pipeline()324 self.pipeline = Pipeline()
323 325 self.action = ViewAction()
324 vsettings = StreamEncodeSettings(encoder="theoraenc")326 self.action.addProducers(self.factory)
325 rsettings = RenderSettings(settings=[vsettings],327 viewer.setPipeline(None)
326 muxer="oggmux")328 #viewer.showSlider()
327 329
328 self.fakesink = FakeSinkFactory()330 # FIXME: why do I have to call viewer.setAction ?
329 rendersink = RenderSinkFactory(RenderFactory(settings=rsettings),331 viewer.setAction(self.action)
330 self.fakesink)332 viewer.setPipeline(self.pipeline)
331 self.render = RenderAction()333 viewer.play()
332 #self.pipeline.connect("eos", self._renderEOSCb)334 self.debug('viewer started')
333 #self.pipeline.connect("error", self._renderErrorCb)335
334 self.pipeline.addAction(self.render)336 def release_viewer(self) :
335 self.render.addConsumers(rendersink)337 """ release pipeline for viewer"""
336 self.render.addProducers(self.factory)338 self.debug(' release pipe %s', self.pipeline)
337 self.render.activate() 339
338 self.pipeline.play()340 viewer = self._viewer
339 gobject.timeout_add(1000, self._deactive_pipeline)341 if self.pipeline is None :
340 return self.factory342 self.debug('No pipeline to release')
341 343 return
342 def _deactive_pipeline(self) :344 if viewer.pipeline is not None :
343 self.debug('Deactive Pipeline')
344 if self.pipeline is not None :
345 try :345 try :
346 print " release ."346 viewer.stop()
347 self.pipeline.stop()
348 self.render.deactivate()
349 self.render.setPipeline(None)
350 self.pipeline.release()
351 self.pipeline = None
352 self.factory = None
353
354 except :347 except :
355 pass348 self.warning('Impossible to stop pipeline')
356 return False349
350 viewer.setPipeline(None)
351 self.pipeline.release()
352 self.pipeline = None
353 self.factory = None
354 self.action = None
357355
358356
359 def _webcam_changed_cb(self, wdg, webcam) :357 def _webcam_changed_cb(self, wdg, webcam) :
358 """ webcam selection changed callback """
360 self.debug('Rx webcam-changed : %s', webcam )359 self.debug('Rx webcam-changed : %s', webcam )
361 self.webcam_props.clear_all()360 self.webcam_props.clear_all()
362 self.wcam_params = {}361 self.wcam_params = {}
@@ -379,8 +378,8 @@
379 'device':_selected_device['device-file'],378 'device':_selected_device['device-file'],
380 }379 }
381 }380 }
382 _factory = self.active_webcam(self.wcam_params)381 self.prepare_viewer(self.wcam_params)
383 self.webcam_props.prepare(_factory.webcam_caps)382 self.webcam_props.prepare(self.factory.webcam_caps)
384383
385384
386 else :385 else :
@@ -388,94 +387,17 @@
388 387
389388
390 def _caps_selected_cb(self, webcam_props, caps) :389 def _caps_selected_cb(self, webcam_props, caps) :
390 """ webcam caps(propeties) selected callback """
391 self.project_data['webcam_data']['caps'] = caps391 self.project_data['webcam_data']['caps'] = caps
392
393 self.wcam_params['wcam_filter'] = {
394 'media_type' : caps,
395 }
396
397 self.prepare_viewer(self.wcam_params)
398
392 self.debug('Rx caps-selected : %s', caps.to_string() )399 self.debug('Rx caps-selected : %s', caps.to_string() )
393 self.emit('webcam-caps-selected', caps)400 self.emit('webcam-caps-selected', caps)
394
395
396
397
398 def _on_webcam_detect_complete(self, webcam_obj) :
399 """ callback , executed when webcam detection is complete
400 Return the number of detected webcams"""
401 _status = 0
402
403 if webcam_obj != None and webcam_obj.webcam_devices != None:
404 _vbox = self._vbox
405 # firt clean childs on the vbox widget
406 for _child in _vbox.get_children() :
407 _vbox.remove(_child)
408 # loop on detected webcams
409 _rd_btn = None
410
411 for (_wbcm_idx, _webcam ) in \
412 enumerate(webcam_obj.webcam_devices) :
413 _rd_btn = gtk.RadioButton(
414 group =_rd_btn,
415 label = _webcam["name"] )
416 _vbox.pack_start(_rd_btn)
417 _rd_btn.show()
418
419 #connect event
420 _rd_btn.connect(
421 "clicked",
422 self.on_webcam_radio_button_clicked,
423 _wbcm_idx,
424 webcam_obj )
425
426 # First set
427 if _wbcm_idx == 0 :
428 # select by default.
429 self.project_data['webcam_data'] = \
430 webcam_obj.get_gst_best_input(_wbcm_idx)
431
432 self.label.set_text(_('Detected webcam(s)'))
433 _status = len(webcam_obj.webcam_devices)
434 else :
435 self.project_data['webcam_data'] = None
436 self.label.set_text(_('No webcam detected'))
437 self.label.show()
438 return _status
439
440 def on_webcam_radio_button_clicked(self, widget, webcam_index, webcam_obj):
441 """ callback for webcam rasdio button.
442 Save info on selected webcam
443 """
444 # when a webcam is selected select webcam data
445 self.project_data['webcam_data'] = \
446 webcam_obj.get_gst_best_input(webcam_index)
447
448 401
449if __name__ == '__main__' :
450 import pygtk
451
452 def init_log() :
453 import os
454 from pitivi.log import log
455 enable_color = os.environ.get('PITIVI_DEBUG_NO_COLOR', '0') in ('', '0')
456 log.init('PITIVI_DEBUG', enable_color)
457 402
458 class Tester(Loggable) :
459
460 def __init__(self) :
461 Loggable.__init__(self)
462 window = gtk.Window()
463 window.connect('destroy', lambda w: gtk.main_quit())
464 self.debug(' starting App')
465 _wdg = WebcamDetectionWidget(project_data = {})
466 _wdg.connect('webcams-detected',self._webcam_detected_cb)
467 window.add(_wdg)
468 window.show_all()
469
470 _wdg.prepare_webcam_detection()
471
472 return
473
474 def _webcam_detected_cb(self, widget, data = None):
475 self.debug('Rx webcam detected %s', data)
476
477 init_log()
478 Tester()
479 gtk.main()
480
481403
482404
=== modified file 'test/test_assistant_new_project.py'
--- test/test_assistant_new_project.py 2011-02-25 08:17:16 +0000
+++ test/test_assistant_new_project.py 2011-03-09 11:46:59 +0000
@@ -42,6 +42,7 @@
42# local application/library specific imports42# local application/library specific imports
43from common import init_log43from common import init_log
4444
45from pitivi.ui.viewer import PitiviViewer
45#tested module46#tested module
46from luciole.gui.windows.assistant_new_project import AssistantNewProject47from luciole.gui.windows.assistant_new_project import AssistantNewProject
4748
@@ -49,6 +50,7 @@
49PROJECT_PATH = '/home/nico/temp/testLuciole'50PROJECT_PATH = '/home/nico/temp/testLuciole'
5051
51class Tester(Loggable) :52class Tester(Loggable) :
53 """ Tester class """
5254
53 def __init__(self) :55 def __init__(self) :
54 Loggable.__init__(self)56 Loggable.__init__(self)
@@ -56,10 +58,13 @@
56 gobject.threads_init() 58 gobject.threads_init()
57 window = gtk.Window()59 window = gtk.Window()
58 window.connect('destroy', lambda w: gtk.main_quit())60 window.connect('destroy', lambda w: gtk.main_quit())
61
62 self.ptv_viewer = PitiviViewer()
63 window.add(self.ptv_viewer)
59 window.show_all()64 window.show_all()
60 65
61 # start assistant66 # start assistant
62 _ass =AssistantNewProject(self._apply_cb)67 _ass =AssistantNewProject(self._apply_cb, self.ptv_viewer)
63 self.prepare_assistant(_ass)68 self.prepare_assistant(_ass)
64 69
65 def _apply_cb(self, project_data) :70 def _apply_cb(self, project_data) :
6671
=== modified file 'test/test_project_properties.py'
--- test/test_project_properties.py 2011-02-27 18:32:53 +0000
+++ test/test_project_properties.py 2011-03-09 11:46:59 +0000
@@ -22,12 +22,10 @@
22#22#
23#23#
24"""24"""
25test_assistant_new_project.py : 25test_project_properties.py :
26 GTK assistant for creation of new projects26 Test project properties
27"""27"""
28# standard library imports28# standard library imports
29import os.path
30import shutil
3129
32# related third party imports30# related third party imports
33import pygtk31import pygtk
@@ -41,11 +39,11 @@
4139
42# local application/library specific imports40# local application/library specific imports
43from common import init_log41from common import init_log
42from pitivi.ui.viewer import PitiviViewer
4443
45#tested module44#tested module
46from luciole.gui.windows.dialog_project_properties import ProjectProperties45from luciole.gui.windows.dialog_project_properties import ProjectProperties
4746
48import gst
4947
50CAPS_STR = ("video/x-raw-yuv, format=(fourcc)I420, width=(int)1280,"48CAPS_STR = ("video/x-raw-yuv, format=(fourcc)I420, width=(int)1280,"
51 "height=(int)1024, interlaced=(boolean)false,"49 "height=(int)1024, interlaced=(boolean)false,"
@@ -63,7 +61,6 @@
63 'v4ldriver': 'v4l2src', 61 'v4ldriver': 'v4l2src',
64 'name': 'Built-in iSight'62 'name': 'Built-in iSight'
65 }, 63 },
66 'project_name': 'test_luciole',
67 'fpi': 5,64 'fpi': 5,
68 'hardtype': 2,65 'hardtype': 2,
69 'resize' : 'no',66 'resize' : 'no',
@@ -71,22 +68,36 @@
71 }68 }
7269
73class Tester(Loggable) :70class Tester(Loggable) :
7471 """ Tester class """
72
75 def __init__(self) :73 def __init__(self) :
76 Loggable.__init__(self)74 Loggable.__init__(self)
77 self.debug('starting tester')75 self.debug('starting tester')
78 gobject.threads_init() 76 gobject.threads_init()
79 window = gtk.Window()77 window = gtk.Window()
80 window.connect('destroy', lambda w: gtk.main_quit())78 window.connect('destroy', lambda w: gtk.main_quit())
79 self.ptv_viewer = PitiviViewer()
80 window.add(self.ptv_viewer)
81
81 window.show_all()82 window.show_all()
82 self.debug("project properties : %s", PROJECT_PROPS)83 self.debug("project properties : %s", PROJECT_PROPS)
83 _properties = ProjectProperties(window, PROJECT_PROPS)84 _properties = ProjectProperties(window, PROJECT_PROPS, self.ptv_viewer)
84 _properties.connect('project-changed', self._project_modified_cb)85 _properties.connect('project-changed', self._project_modified_cb)
86 _properties.connect('dialog-closed', self._dialog_pp_closed_cb)
85 _properties.run()87 _properties.run()
8688
87 def _project_modified_cb(self, gui, project_data) :89 def _project_modified_cb(self, gui, project_data) :
88 self.debug('received aplly cb -- project_data =%s ; %r %r', project_data, project_data, PROJECT_PROPS )90 """ callback for modified data from project properties dialog """
89 91 self.debug( ("received aplly cb"
92 "-- project_data =%s ; %r %r"),
93 project_data,
94 project_data,
95 PROJECT_PROPS)
96
97 def _dialog_pp_closed_cb(self, dialog) :
98 """ dialog project properties closed callback """
99 self.debug('dialog closed')
100 gtk.main_quit()
90101
91102
92if __name__ == '__main__' :103if __name__ == '__main__' :
93104
=== added file 'test/test_webcam_detection_widget.py'
--- test/test_webcam_detection_widget.py 1970-01-01 00:00:00 +0000
+++ test/test_webcam_detection_widget.py 2011-03-09 11:46:59 +0000
@@ -0,0 +1,124 @@
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3# -*- Mode: Python -*-
4# vim:si:ai:et:sw=4:sts=4:ts=4
5#
6# Copyright Nicolas Bertrand (nico@inattendu.org), 2009-2010
7#
8# This file is part of Luciole.
9#
10# Luciole is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# Luciole is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with Luciole. If not, see <http://www.gnu.org/licenses/>.
22#
23#
24"""
25test_webcam_detection_widget.py :
26 test webcam detection widget
27"""
28# standard library imports
29
30# related third party imports
31import pygtk
32pygtk.require('2.0')
33import gtk
34import gobject
35import pygst
36pygst.require('0.10')
37
38from pitivi.log.loggable import Loggable
39from pitivi.action import ViewAction
40from pitivi.ui.viewer import PitiviViewer
41from pitivi.pipeline import Pipeline
42from pitivi.ui.viewer import PitiviViewer
43
44# local application/library specific imports
45from common import init_log
46
47#tested module
48from luciole.gui.windows.webcam_detection_widget import WebcamDetectionWidget
49from luciole.media.lgst.webcam_factory import WebcamSourceFactory
50
51class Tester(Loggable) :
52 """ Test class """
53
54 def __init__(self) :
55 Loggable.__init__(self)
56 self.debug('starting tester')
57 gobject.threads_init()
58 self.wcam_params = {}
59 self.factory = None
60
61 window = gtk.Window()
62 window.connect('destroy', lambda w: gtk.main_quit())
63 bbox = gtk.VBox()
64 boxalign = gtk.Alignment(xalign=0.5, yalign=0.5)
65 boxalign.add(bbox)
66
67 self.ptv_viewer = PitiviViewer()
68
69 # set webcam detection widget
70 self.project_data = {}
71 _wdg = WebcamDetectionWidget(self.project_data, self.ptv_viewer)
72 _wdg.connect('webcam-caps-selected', self._wcam_caps_selected)
73 _wdg.prepare_webcam_detection()
74 bbox.pack_start(_wdg)
75
76 bbox.pack_start(self.ptv_viewer, expand=False)
77
78
79 window.add(boxalign)
80
81 window.show_all()
82
83 def _wcam_caps_selected(self, wdg ,caps) :
84 self.debug('received webcam-caps-selected -- project_data =%s',
85 caps )
86
87 self.wcam_params['wcam_filter'] = {
88 'media_type' : caps,
89 }
90
91 #self.prepare_viewer()
92
93 def prepare_viewer(self) :
94 viewer = self.ptv_viewer
95 if viewer.pipeline is not None :
96 try :
97 viewer.pause()
98 except :
99 pass
100 self.factory = WebcamSourceFactory()
101 self.factory.webcam_params = self.wcam_params
102 self.factory.with_scale = False
103
104 pipeline = Pipeline()
105 action = ViewAction()
106 action.addProducers(self.factory)
107 viewer.setPipeline(None)
108 viewer.showSlider()
109
110 # FIXME: why do I have to call viewer.setAction ?
111 viewer.setAction(action)
112 viewer.setPipeline(pipeline)
113 viewer.play()
114
115 return False
116
117
118
119if __name__ == '__main__' :
120 init_log()
121 Tester()
122 gtk.main()
123
124

Subscribers

People subscribed via source and target branches

to all changes:
to status/vote changes: