~timo-jyrinki/ubuntu/trusty/pitivi/backport_utopic_fixes

« back to all changes in this revision

Viewing changes to pitivi/effects.py

  • Committer: Package Import Robot
  • Author(s): Sebastian Dröge
  • Date: 2014-03-29 15:22:50 UTC
  • mto: (3.1.23 experimental)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: package-import@ubuntu.com-20140329152250-flg9onx416bqf3e3
Tags: upstream-0.93
Import upstream version 0.93

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Pitivi video editor
2
2
#
3
 
#       effects.py
 
3
#       pitivi/effects.py
4
4
#
5
5
# Copyright (c) 2010, Thibault Saunier <tsaunier@gnome.org>
6
6
# Copyright (c) 2005, Edward Hervey <bilboed@bilboed.com>
211
211
 
212
212
    def getAllAudioEffects(self):
213
213
        """
214
 
        @returns:  the list off available audio effects elements
 
214
        @return: the list of available audio effects elements
215
215
        """
216
216
        return self.audio_effects
217
217
 
218
218
    def getAllVideoEffects(self):
219
219
        """
220
 
        @returns: the list off available video effects elements
 
220
        @return: the list of available video effects elements
221
221
        """
222
222
        return self.video_effects
223
223
 
226
226
 
227
227
    def getFactoryFromName(self, name):
228
228
        """
229
 
        @ivar name: Factory name.
 
229
        @param name: Factory name.
230
230
        @type name: C{str}
231
 
        @returns: The l{Effect} corresponding to the name
232
 
        @raises: KeyError if the name doesn't  exist
 
231
        @return: The l{Effect} corresponding to the name or None
233
232
        """
234
233
        return self._effect_factories_dict.get(name)
235
234
 
236
235
    def _getEffectDescripton(self, element_factory):
237
236
        """
238
 
        @ivar element_factory: The element factory
 
237
        @param element_factory: The element factory
239
238
        @type element_factory: L{Gst.ElementFactory}
240
 
        @returns: A human description C{str} for the effect
 
239
        @return: A human description C{str} for the effect
241
240
        """
242
241
        return element_factory.get_description()
243
242
 
244
243
    def _getEffectCategories(self, effect_name):
245
244
        """
246
 
        @ivar effect_name: the name of the effect for wich we want the category
 
245
        @param effect_name: the name of the effect for wich we want the category
247
246
        @type effect_name: L{str}
248
 
        @returns: A C{list} of name C{str} of categories corresponding the effect
 
247
        @return: A C{list} of name C{str} of categories corresponding the effect
249
248
        """
250
249
        categories = []
251
250
 
274
273
 
275
274
    def _getEffectName(self, element_factory):
276
275
        """
277
 
        @ivar element_factory: The element factory
 
276
        @param element_factory: The element factory
278
277
        @type element_factory: L{Gst.ElementFactory}
279
 
        @returns: A human readable name C{str} for the effect
 
278
        @return: A human readable name C{str} for the effect
280
279
        """
281
280
        #TODO check if it is the good way to make it translatable
282
281
        #And to filter actually!
289
288
 
290
289
    def getVideoCategories(self, aware=True):
291
290
        """
292
 
        @ivar aware: C{True} if you want it to return only categories on which
293
 
        there are effects on the system, else C{False}
 
291
        @param aware: C{True} if you want it to return only categories on which
 
292
            there are effects on the system, else C{False}
294
293
        @type aware: C{bool}
295
 
        @returns: All video effect categories names C{str} that are available
296
 
        on the system if it has been filled earlier, if it hasen't it will
297
 
        just return all categories
 
294
        @return: All video effect categories names C{str} that are available
 
295
            on the system if it has been filled earlier, if it hasen't it will
 
296
            just return all categories
298
297
        """
299
298
        if not self._video_categories or not aware:
300
299
            for categorie in self._video_categories_effects[1:]:
310
309
 
311
310
    def getAudioCategories(self, aware=True):
312
311
        """
313
 
        @ivar  aware: C{True} if you want it to return only categories on
314
 
        whichs there are effects on the system, else C{False}
 
312
        @param aware: C{True} if you want it to return only categories on
 
313
            which there are effects on the system, else C{False}
315
314
        @type aware: C{bool}
316
 
        @returns: All audio effect categories names C{str}
 
315
        @return: All audio effect categories names C{str}
317
316
        """
318
317
        if not self._audio_categories or not aware:
319
318
            for categorie in self._audio_categories_effects[1:]:
329
328
 
330
329
    def getAllCategories(self):
331
330
        """
332
 
        @returns: All effect categories names C{str}
 
331
        @return: All effect categories names C{str}
333
332
        """
334
333
        effects_categories = []
335
334
        return effects_categories.extended(self.video_categories).extended(
371
370
class EffectListWidget(Gtk.VBox, Loggable):
372
371
    """ Widget for listing effects """
373
372
 
374
 
    def __init__(self, instance, uiman):
 
373
    def __init__(self, instance, unused_uiman):
375
374
        Gtk.VBox.__init__(self)
376
375
        Loggable.__init__(self)
377
376
 
384
383
        builder.add_from_file(os.path.join(get_ui_dir(), "effectslibrary.ui"))
385
384
        builder.connect_signals(self)
386
385
        toolbar = builder.get_object("effectslibrary_toolbar")
387
 
        toolbar.get_style_context().add_class("inline-toolbar")
 
386
        toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_INLINE_TOOLBAR)
388
387
        self.video_togglebutton = builder.get_object("video_togglebutton")
389
388
        self.audio_togglebutton = builder.get_object("audio_togglebutton")
390
389
        self.categoriesWidget = builder.get_object("categories")
393
392
        # Store
394
393
        self.storemodel = Gtk.ListStore(str, str, int, object, object, str, GdkPixbuf.Pixbuf)
395
394
 
396
 
        self.view = Gtk.TreeView(self.storemodel)
 
395
        self.view = Gtk.TreeView(model=self.storemodel)
397
396
        self.view.props.headers_visible = False
398
397
        self.view.get_selection().set_mode(Gtk.SelectionMode.SINGLE)
399
398
 
457
456
        toolbar.show_all()
458
457
 
459
458
    @staticmethod
460
 
    def view_description_cell_data_func(column, cell, model, iter_, data):
461
 
 
 
459
    def view_description_cell_data_func(unused_column, cell, model, iter_, unused_data):
462
460
        name, desc = model.get(iter_, COL_NAME_TEXT, COL_DESC_TEXT)
463
461
        escape = GLib.markup_escape_text
464
462
        cell.props.markup = "<b>%s</b>\n%s" % (escape(name),
509
507
        if pixbuf:
510
508
            Gtk.drag_set_icon_pixbuf(context, pixbuf, 0, 0)
511
509
 
512
 
    def _dndDragEndCb(self, unused_view, context):
 
510
    def _dndDragEndCb(self, unused_view, unused_context):
513
511
        self.info("Drag operation ended")
514
512
 
515
 
    def _dndDragDataGetCb(self, unused_view, context, data, info, timestamp):
 
513
    def _dndDragDataGetCb(self, unused_view, unused_context, data, unused_info, unused_timestamp):
516
514
        data.set_uris([self.getSelectedItems()])
517
515
 
518
516
    def _rowUnderMouseSelected(self, view, event):
524
522
                selection.count_selected_rows() > 0
525
523
        return False
526
524
 
527
 
    def _enterPressEventCb(self, view, event=None):
 
525
    def _enterPressEventCb(self, unused_view, unused_event=None):
528
526
        factory_name = self.getSelectedItems()
529
527
        if factory_name is not None:
530
528
            self.app.gui.clipconfig.effect_expander.addEffectToCurrentSelection(factory_name)
576
574
        self.populate_categories_widget()
577
575
        self.modelFilter.refilter()
578
576
 
579
 
    def _categoryChangedCb(self, combobox):
 
577
    def _categoryChangedCb(self, unused_combobox):
580
578
        self.modelFilter.refilter()
581
579
 
582
 
    def _searchEntryChangedCb(self, entry):
 
580
    def _searchEntryChangedCb(self, unused_entry):
583
581
        self.modelFilter.refilter()
584
582
 
585
583
    def _searchEntryIconClickedCb(self, entry, unused, unused1):
586
584
        entry.set_text("")
587
585
 
588
 
    def _setRowVisible(self, model, iter, data):
 
586
    def _setRowVisible(self, model, iter, unused_data):
589
587
        if self._effectType == model.get_value(iter, COL_EFFECT_TYPE):
590
588
            if model.get_value(iter, COL_EFFECT_CATEGORIES) is None:
591
589
                return False
619
617
        self.app = instance
620
618
 
621
619
    def getEffectConfigurationUI(self, effect):
622
 
        """
623
 
            Permit to get a configuration GUI for the effect
624
 
            @param effect: The effect for which we want the configuration UI
625
 
            @type effect: C{Gst.Element}
626
 
        """
 
620
        """Permit to get a configuration GUI for the effect
627
621
 
 
622
        @param effect: The effect for which we want the configuration UI
 
623
        @type effect: C{Gst.Element}
 
624
        """
628
625
        if effect not in self.cache_dict:
629
 
            #Here we should handle special effects configuration UI
630
 
            effect_set_ui = GstElementSettingsWidget()
631
 
            effect_set_ui.setElement(effect, ignore=PROPS_TO_IGNORE,
632
 
                                     default_btn=True, use_element_props=True)
633
 
            nb_rows = effect_set_ui.get_children()[0].get_property('n-rows')
634
 
            effect_configuration_ui = Gtk.ScrolledWindow()
635
 
            effect_configuration_ui.add_with_viewport(effect_set_ui)
636
 
            effect_configuration_ui.set_policy(Gtk.PolicyType.AUTOMATIC,
637
 
                                               Gtk.PolicyType.AUTOMATIC)
638
 
            self.cache_dict[effect] = effect_configuration_ui
639
 
            self._connectAllWidgetCbs(effect_set_ui, effect)
640
 
            self._postConfiguration(effect, effect_set_ui)
641
 
 
642
 
        effect_set_ui = self._getUiToSetEffect(effect)
643
 
 
644
 
        self._current_effect_setting_ui = effect_set_ui
 
626
            # Here we should handle special effects configuration UI
 
627
            effect_settings_widget = GstElementSettingsWidget()
 
628
            effect_settings_widget.setElement(effect, ignore=PROPS_TO_IGNORE,
 
629
                    default_btn=True, use_element_props=True)
 
630
            scrolled_window = Gtk.ScrolledWindow()
 
631
            scrolled_window.add_with_viewport(effect_settings_widget)
 
632
            scrolled_window.set_policy(Gtk.PolicyType.AUTOMATIC,
 
633
                    Gtk.PolicyType.AUTOMATIC)
 
634
            self.cache_dict[effect] = scrolled_window
 
635
            self._connectAllWidgetCallbacks(effect_settings_widget, effect)
 
636
            self._postConfiguration(effect, effect_settings_widget)
 
637
 
 
638
        self._current_effect_setting_ui = self._getUiToSetEffect(effect)
645
639
        element = self._current_effect_setting_ui.element
646
640
        for prop in element.list_children_properties():
647
641
            self._current_element_values[prop.name] = element.get_child_property(prop.name)
666
660
            effect_set_ui = self.cache_dict[effect].get_children()[0].get_children()[0]
667
661
        else:
668
662
            effect_set_ui = self.cache_dict[effect]
669
 
 
670
663
        return effect_set_ui
671
664
 
672
 
    def _connectAllWidgetCbs(self, effect_configuration_ui, effect):
673
 
        for prop, widget in effect_configuration_ui.properties.iteritems():
 
665
    def _connectAllWidgetCallbacks(self, effect_settings_widget, unused_effect):
 
666
        for prop, widget in effect_settings_widget.properties.iteritems():
674
667
            widget.connectValueChanged(self._onValueChangedCb, widget, prop)
675
668
 
676
 
    def _onSetDefaultCb(self, widget, dynamic):
 
669
    def _onSetDefaultCb(self, unused_widget, dynamic):
677
670
        dynamic.setWidgetToDefault()
678
671
 
679
 
    def _onValueChangedCb(self, widget, dynamic, prop):
 
672
    def _onValueChangedCb(self, unused_widget, dynamic, prop):
680
673
        value = dynamic.getWidgetValue()
681
674
 
682
675
        #FIXME Workaround in order to make aspectratiocrop working