def test_list_properties(self): self.assertTrue(len(GObject.list_properties(Gtk.Window)) >= 70) self.assertTrue(len(GObject.list_properties(Gtk.Editable)) == 0) self.assertRaises(TypeError, GObject.list_properties, None) self.assertRaises(TypeError, GObject.list_properties, 1) self.assertRaises(TypeError, GObject.list_properties, ) self.assertEqual(GObject.list_properties(Gtk.Window.__gtype__), GObject.list_properties(Gtk.Window))
def test_list_properties(self): self.assertTrue(len(GObject.list_properties(Gtk.Window)) >= 70) self.assertTrue(len(GObject.list_properties(Gtk.Editable)) == 0) self.assertRaises(TypeError, GObject.list_properties, None) self.assertRaises(TypeError, GObject.list_properties, 1) self.assertRaises( TypeError, GObject.list_properties, ) self.assertEqual(GObject.list_properties(Gtk.Window.__gtype__), GObject.list_properties(Gtk.Window))
def list_properties(gtype, parent=True): """ Return a list of all properties for GType gtype, excluding properties in parent classes """ pspecs = GObject.list_properties(gtype) if parent: return pspecs parent = GObject.type_parent(gtype) parent_pspecs = GObject.list_properties(parent) return [pspec for pspec in pspecs if pspec not in parent_pspecs]
def __init__(self, options={}): base.Base.__init__(self, options) Gst.Bin.__init__(self) aux = (pipestr.replace('gc-videotest-preview', 'sink-' + self.options['name']) .replace('gc-videotest-enc', self.options['videoencoder']) .replace('gc-videotest-mux', self.options['muxer'])) #bin = Gst.parse_bin_from_description(aux, False) bin = Gst.parse_launch("( {} )".format(aux)) self.add(bin) self.get_by_name('gc-videotest-sink').set_property('location', path.join(self.options['path'], self.options['file'])) #self.get_by_name('gc-videotest-filter').set_property('caps', Gst.Caps(self.options['caps'])) #fr = re.findall("framerate *= *[0-9]+/[0-9]+", self.options['caps']) #if fr: # newcaps = 'video/x-raw,' + fr[0] #self.get_by_name('gc-videotest-vrate').set_property('caps', Gst.Caps(newcaps)) source = self.get_by_name('gc-videotest-src') source.set_property('pattern', int(self.options['pattern'])) coloured = False for properties in GObject.list_properties(source): if properties.name == 'foreground-color': coloured = True if self.options["color1"] and coloured: source.set_property('foreground-color', int(self.options['color1']))
def add_args_from_classifier(group, arg_names): classifier = Gst.ElementFactory.make('classify', 'classify-tmp') prop_lut = {x.name : x for x in GObject.list_properties(classifier)} type_lut = { 'gchararray': str, 'gint': int, 'guint': int, 'guint64': long, 'gfloat': float, 'gdouble': float, 'gboolean': bool, } for args in arg_names: prop_name = args[-1][2:] prop = prop_lut[prop_name] prop_type = type_lut[prop.value_type.name] if prop_type in (float, int, long): prop_type = range_arg(prop.minimum, prop.maximum, prop_type) kwargs = { 'type': prop_type, 'default': None, 'help': prop.blurb } #print args, kwargs if prop_type is bool and not prop.default_value: kwargs['action'] = 'store_true' del kwargs['type'] group.add_argument(*args, **kwargs) return set(prop_lut)
def add_args_from_classifier(group, arg_names): classifier = Gst.ElementFactory.make('classify', 'classify-tmp') prop_lut = {x.name: x for x in GObject.list_properties(classifier)} type_lut = { 'gchararray': str, 'gint': int, 'guint': int, 'guint64': long, 'gfloat': float, 'gdouble': float, 'gboolean': bool, } for args in arg_names: prop_name = args[-1][2:] prop = prop_lut[prop_name] prop_type = type_lut[prop.value_type.name] if prop_type in (float, int, long): prop_type = range_arg(prop.minimum, prop.maximum, prop_type) kwargs = {'type': prop_type, 'default': None, 'help': prop.blurb} #print args, kwargs if prop_type is bool and not prop.default_value: kwargs['action'] = 'store_true' del kwargs['type'] group.add_argument(*args, **kwargs) return set(prop_lut)
def addEffectElement(self, gst_element): properties = {} if gst_element in self._tracked_effects: return for prop in GObject.list_properties(gst_element): gst_element.connect("notify::" + prop.name, self._propertyChangedCb, gst_element) if prop.flags & GObject.PARAM_READABLE: properties[prop.name] = gst_element.get_property(prop.name) self._tracked_effects[gst_element] = properties
def undo(self): element = self.track_element.getElement() props = GObject.list_properties(element) self.effect_props = [(prop.name, element.get_property(prop.name)) for prop in props if prop.flags & GObject.PARAM_WRITABLE and prop.name not in PROPS_TO_IGNORE] gnl_props = GObject.list_properties(self.track_element.gnl_object) gnl_obj = self.track_element.gnl_object self.gnl_obj_props = [(prop.name, gnl_obj.get_property(prop.name)) for prop in gnl_props if prop.flags & GObject.PARAM_WRITABLE] self.clip.removeTrackElement(self.track_element) self.track_element.track.removeTrackElement(self.track_element) self._props_changed =\ self._properties_watcher.getPropChangedFromTrackObj(self.track_element) del self.track_element self.track_element = None self._undone()
def undo(self): element = self.track_element.getElement() props = GObject.list_properties(element) self.effect_props = [ (prop.name, element.get_property(prop.name)) for prop in props if prop.flags & GObject.PARAM_WRITABLE and prop.name not in PROPS_TO_IGNORE ] gnl_props = GObject.list_properties(self.track_element.gnl_object) gnl_obj = self.track_element.gnl_object self.gnl_obj_props = [(prop.name, gnl_obj.get_property(prop.name)) for prop in gnl_props if prop.flags & GObject.PARAM_WRITABLE] self.clip.removeTrackElement(self.track_element) self.track_element.track.removeTrackElement(self.track_element) self._props_changed =\ self._properties_watcher.getPropChangedFromTrackObj(self.track_element) del self.track_element self.track_element = None self._undone()
def addEffectElement(self, gst_element): properties = {} if gst_element in self._tracked_effects: return for prop in GObject.list_properties(gst_element): gst_element.connect('notify::' + prop.name, self._propertyChangedCb, gst_element) if prop.flags & GObject.PARAM_READABLE: properties[prop.name] = gst_element.get_property(prop.name) self._tracked_effects[gst_element] = properties
def unbind_window_settings(self, window_manager, settings, window): if log.query(log.INFO): Gedit.debug_plugin_message(log.format("%s", window)) if not self.is_saving_window_states(): if log.query(log.WARNING): Gedit.debug_plugin_message( log.format("not saving window states")) return state = window_manager.get_window_state(window) if not state: if log.query(log.WARNING): Gedit.debug_plugin_message( log.format("could not get window state")) return if window not in self._window_ids: if log.query(log.WARNING): Gedit.debug_plugin_message( log.format("could not find window id")) return window_id = self._window_ids[window] window_settings = settings.get_window_settings(window_id) if not window_settings: if log.query(log.WARNING): Gedit.debug_plugin_message( log.format("could not get window settings")) return try: params = state.list_properties() except AttributeError: # gedit 3.12 params = GObject.list_properties(state) for param in params: try: window_settings.unbind(state, param.name) except ValueError: # gedit 3.14 pass disconnect_handlers(self, state) settings.remove_window(window_id) del self._window_ids[window]
def element_factory_has_property(element_factory, property_name): """ Check if the given element factory has the given property. @rtype: boolean """ # FIXME: find a better way than instantiating one e = Gst.ElementFactory.make(element_factory,'None') for pspec in GObject.list_properties(e): if pspec.name == property_name: return True return False
def __init__(self, Gst_element, ignore_list=IGNORE_LIST): self._Gst_element = Gst_element _properties_list = GObject.list_properties(self._Gst_element) self.children = [] #print( Gst.Object.get_properties(self._Gst_element)) self.implements_childproxy = GObject.type_from_name( "GstChildProxy") in GObject.type_interfaces(self._Gst_element) if (self.implements_childproxy): for i in range(self._Gst_element.get_children_count()): self.children.append( Element(self._Gst_element.get_child_by_index(i))) if hasattr(self._Gst_element, "get_factory"): self.name = self._Gst_element.get_factory().get_name() else: self.name = self._Gst_element.get_name() self.number_properties = number_properties = [] self.boolean_properties = boolean_properties = [] self.string_properties = string_properties = [] self.enum_properties = enum_properties = [] for property in _properties_list: if property.name in ignore_list: logger.debug("Property {0} is in ignore list, skipping".format( property.name)) elif property.value_type in NUMBER_GTYPES: number_property = NumberProperty(property, self) number_properties.append(number_property) elif property.value_type == GObject.TYPE_BOOLEAN: boolean_property = BooleanProperty(property, self) boolean_properties.append(boolean_property) elif property.value_type in STRING_GTYPES: string_property = StringProperty(property, self) string_properties.append(string_property) elif property.value_type.is_a(GObject.TYPE_ENUM): enum_property = EnumProperty(property, self) enum_properties.append(enum_property) else: logger.error( "Property '{0}' with type {1} has no associated known types, skipping" .format(property.name, property.value_type))
def bind_window_settings(self, window_manager, settings, window): if log.query(log.INFO): Gedit.debug_plugin_message(log.format("%s", window)) if not self.is_saving_window_states(): if log.query(log.WARNING): Gedit.debug_plugin_message( log.format("not saving window states")) return state = window_manager.get_window_state(window) if not state: if log.query(log.WARNING): Gedit.debug_plugin_message( log.format("could not get window state")) return window_id = settings.add_window() self._window_ids[window] = window_id window_settings = settings.get_window_settings(window_id) if not window_settings: if log.query(log.WARNING): Gedit.debug_plugin_message( log.format("could not get window settings")) return try: params = state.list_properties() except AttributeError: # gedit 3.12 params = GObject.list_properties(state) for param in params: # this also immediately sets the settings based on the state values window_settings.bind(param.name, state, param.name, Gio.SettingsBindFlags.SET) connect_handlers(self, state, ['uris-changed', 'notebook-widths-changed'], 'window_state', window_settings) self.on_window_state_uris_changed(state, window_settings) self.on_window_state_notebook_widths_changed(state, window_settings)
def end_quitting(self, settings, do_save): if log.query(log.INFO): Gedit.debug_plugin_message(log.format("do_save=%s", do_save)) if not self.is_quitting(): if log.query(log.WARNING): Gedit.debug_plugin_message( log.format("end quitting without starting")) return if do_save: for window, state in self._quitting.items(): if state.restore_uris: window_id = settings.add_window() window_settings = settings.get_window_settings(window_id) if not window_settings: if log.query(log.WARNING): Gedit.debug_plugin_message( log.format("could not get window settings")) continue try: params = state.list_properties() except AttributeError: # gedit 3.12 params = GObject.list_properties(state) for param in params: window_settings[param.name] = state.get_property( param.name) window_settings['uris'] = state.restore_uris window_settings[ 'notebook-widths'] = state.restore_notebook_widths if log.query(log.MESSAGE): Gedit.debug_plugin_message( log.format("saving %s windows", len(settings.restore_windows))) else: if log.query(log.MESSAGE): Gedit.debug_plugin_message(log.format("not saving windows")) self._quitting = None
def gobject_set_property(object, property, value): """ Set the given property to the given value on the given object. @type object: L{gobject.GObject} @type property: string @param value: value to set property to """ for pspec in GObject.list_properties(object): if pspec.name == property: break else: raise errors.PropertyError( "Property '%s' in element '%s' does not exist" % ( property, object.get_property('name'))) if pspec.value_type in (GObject.TYPE_INT, GObject.TYPE_UINT, GObject.TYPE_INT64, GObject.TYPE_UINT64): try: value = int(value) except ValueError: msg = "Invalid value given for property '%s' in element '%s'" % ( property, object.get_property('name')) raise errors.PropertyError(msg) elif pspec.value_type == GObject.TYPE_BOOLEAN: if value == 'False': value = False elif value == 'True': value = True else: value = bool(value) elif pspec.value_type in (GObject.TYPE_DOUBLE, GObject.TYPE_FLOAT): value = float(value) elif pspec.value_type == GObject.TYPE_STRING: value = str(value) # FIXME: this is superevil ! we really need to find a better way # of checking if this property is a param enum # also, we only allow int for now elif repr(pspec.__gtype__).startswith("<GType GParamEnum"): value = int(value) else: raise errors.PropertyError('Unknown property type: %s' % pspec.value_type) object.set_property(property, value)
def __init__(self, options={}): base.Base.__init__(self, options) Gst.Bin.__init__(self) gcvideosink = get_videosink(videosink=self.options['videosink'], name='sink-' + self.options['name']) aux = (pipestr.replace('gc-vsink', gcvideosink).replace( 'gc-videotest-enc', self.options['videoencoder']).replace('gc-videotest-mux', self.options['muxer'])) if self.options["caps-preview"]: aux = aux.replace( "caps-preview !", "videoscale ! videorate ! " + self.options["caps-preview"] + " !") else: aux = aux.replace("caps-preview !", "") #bin = Gst.parse_bin_from_description(aux, False) bin = Gst.parse_launch("( {} )".format(aux)) self.add(bin) self.get_by_name('gc-videotest-sink').set_property( 'location', path.join(self.options['path'], self.options['file'])) #self.get_by_name('gc-videotest-filter').set_property('caps', Gst.Caps(self.options['caps'])) #fr = re.findall("framerate *= *[0-9]+/[0-9]+", self.options['caps']) #if fr: # newcaps = 'video/x-raw,' + fr[0] #self.get_by_name('gc-videotest-vrate').set_property('caps', Gst.Caps(newcaps)) source = self.get_by_name('gc-videotest-src') source.set_property('pattern', int(self.options['pattern'])) coloured = False for properties in GObject.list_properties(source): if properties.name == 'foreground-color': coloured = True if self.options["color1"] and coloured: source.set_property('foreground-color', int(self.options['color1'])) #if self.options["color2"]: # source.set_property('background-color', int(self.options['color2'])) self.set_option_in_pipeline('caps', 'gc-videotest-filter', 'caps', None)
def __init__(self, Gst_element, ignore_list=IGNORE_LIST): self._Gst_element = Gst_element _properties_list = GObject.list_properties(self._Gst_element) self.children = [] #print( Gst.Object.get_properties(self._Gst_element)) self.implements_childproxy = GObject.type_from_name("GstChildProxy") in GObject.type_interfaces(self._Gst_element) if (self.implements_childproxy): for i in range(self._Gst_element.get_children_count()): self.children.append(Element(self._Gst_element.get_child_by_index(i))) if hasattr(self._Gst_element, "get_factory"): self.name = self._Gst_element.get_factory().get_name() else: self.name = self._Gst_element.get_name() self.number_properties = number_properties = [] self.boolean_properties = boolean_properties = [] self.string_properties = string_properties = [] self.enum_properties = enum_properties = [] for property in _properties_list: if property.name in ignore_list: logger.debug("Property {0} is in ignore list, skipping".format(property.name)) elif property.value_type in NUMBER_GTYPES: number_property = NumberProperty(property, self) number_properties.append(number_property) elif property.value_type == GObject.TYPE_BOOLEAN: boolean_property = BooleanProperty(property, self) boolean_properties.append(boolean_property) elif property.value_type in STRING_GTYPES: string_property = StringProperty(property, self) string_properties.append(string_property) elif property.value_type.is_a(GObject.TYPE_ENUM): enum_property = EnumProperty(property, self) enum_properties.append(enum_property) else: logger.error("Property '{0}' with type {1} has no associated known types, skipping".format(property.name, property.value_type))
def clone(cls, source): clone = cls() try: params = cls.list_properties() except AttributeError: # gedit 3.12 params = GObject.list_properties(cls) for param in params: clone.set_property(param.name, source.get_property(param.name)) clone._notebook_map = dict(source._notebook_map) clone._tab_map = dict(source._tab_map) clone._active_tab = source._active_tab clone.uris = source.uris clone.notebook_widths = source.notebook_widths return clone
def get_controllable_properties(element): """ Returns a list of controllable properties for the given element (and child if it's a container). The list is made of tuples containing: * The GstObject * The GParamspec """ log.debug("utils", "element %r, %d", element, isinstance(element, Gst.Bin)) res = [] if isinstance(element, Gst.Bin): for child in element.elements(): res.extend(get_controllable_properties(child)) else: for prop in GObject.list_properties(element): if prop.flags & Gst.PARAM_CONTROLLABLE: log.debug("utils", "adding property %r", prop) res.append((element, prop)) return res
def get_controllable_properties(element): """ Returns a list of controllable properties for the given element (and child if it's a container). The list is made of tuples containing: * The GstObject * The GParamspec """ log.debug("utils", "element %r, %d", element, isinstance(element, Gst.Bin)) res = [] if isinstance(element, Gst.Bin): for child in element.elements(): res.extend(get_controllable_properties(child)) else: for prop in GObject.list_properties(element): if prop.flags & Gst.PARAM_CONTROLLABLE: log.debug("utils", "adding property %r", prop) res.append((element, prop)) return res
def __init__(self, is_enabled=True): GObject.Object.__init__(self) if log.query(log.INFO): Gedit.debug_plugin_message(log.format("is_enabled=%s", is_enabled)) try: schema_source = Gio.SettingsSchemaSource.new_from_directory( SCHEMAS_PATH, Gio.SettingsSchemaSource.get_default(), False) except: if log.query(log.CRITICAL): Gedit.debug_plugin_message( log.format("could not load settings schema source from %s", SCHEMAS_PATH)) schema_source = None if is_enabled: settings = get_settings( schema_source, 'com.thingsthemselves.gedit.plugins.ex-mortis', '/com/thingsthemselves/gedit/plugins/ex-mortis/') else: settings = None if settings: try: params = self.list_properties() except AttributeError: # gedit 3.12 params = GObject.list_properties(self) for param in params: settings.bind(param.name, self, param.name, Gio.SettingsBindFlags.DEFAULT) self._schema_source = schema_source self._settings = settings self._window_settings = {} for window_id in self.restore_windows: self.init_window_settings(window_id)
def cleanup(self): if log.query(log.INFO): Gedit.debug_plugin_message(log.format("")) settings = self._settings if settings: try: params = self.list_properties() except AttributeError: # gedit 3.12 params = GObject.list_properties(self) for param in params: try: settings.unbind(self, param.name) except ValueError: # gedit 3.14 pass self._schema_source = None self._settings = None self._window_settings = None
def __add_widgets(self, values, with_reset_button): """ Prepare a Gtk.Grid containing the property widgets of an element. Each property is on a separate row. A row is typically a label followed by the widget and a reset button. If there are no properties, returns a "No properties" label. """ self.properties.clear() self.__bindings_by_keyframe_button = {} self.__widgets_by_keyframe_button = {} is_effect = isinstance(self.element, GES.Effect) if is_effect: props = [prop for prop in self.element.list_children_properties() if prop.name not in self.ignore] else: props = [prop for prop in GObject.list_properties(self.element) if prop.name not in self.ignore] if not props: widget = Gtk.Label(label=_("No properties.")) self.pack_start(widget, expand=False, fill=False, padding=0) widget.show() return grid = Gtk.Grid() grid.props.row_spacing = SPACING grid.props.column_spacing = SPACING grid.props.border_width = SPACING for y, prop in enumerate(props): # We do not know how to work with GObjects, so blacklist # them to avoid noise in the UI if (not prop.flags & GObject.PARAM_WRITABLE or not prop.flags & GObject.PARAM_READABLE or GObject.type_is_a(prop.value_type, GObject.Object)): continue if is_effect: result, prop_value = self.element.get_child_property(prop.name) if not result: self.debug( "Could not get value for property: %s", prop.name) else: if not values: # Use the default value. prop_value = self.element.get_property(prop.name) else: prop_value = values.get(prop.name) widget = self._makePropertyWidget(prop, prop_value) if isinstance(widget, ToggleWidget): widget.set_label(prop.nick) grid.attach(widget, 0, y, 2, 1) else: text = _("%(preference_label)s:") % {"preference_label": prop.nick} label = Gtk.Label(label=text) label.set_alignment(0.0, 0.5) grid.attach(label, 0, y, 1, 1) grid.attach(widget, 1, y, 1, 1) if hasattr(prop, 'blurb'): widget.set_tooltip_text(prop.blurb) self.properties[prop] = widget if not self.__controllable or isinstance(widget, DefaultWidget): continue keyframe_button = None if not isinstance(widget, (ToggleWidget, ChoiceWidget)): res, element, pspec = self.element.lookup_child(prop.name) assert(res) binding = GstController.DirectControlBinding.new( element, prop.name, GstController.InterpolationControlSource()) if binding.pspec: # The prop can be controlled (keyframed). keyframe_button = self.__create_keyframe_toggle_button(prop, widget) grid.attach(keyframe_button, 2, y, 1, 1) # The "reset to default" button associated with this property if with_reset_button: button = self.__create_reset_to_default_button(prop, widget, keyframe_button) grid.attach(button, 3, y, 1, 1) self.element.connect('deep-notify', self._propertyChangedCb) self.pack_start(grid, expand=False, fill=False, padding=0) self.show_all()
settings = sorted(settings, key=lambda setting: setting.attrib['{%s}symbol-prefix' % ns_map['c']]) outfile.write("""<?xml version=\"1.0\"?> <!DOCTYPE nm-setting-docs [ <!ENTITY quot """> ]> <nm-setting-docs> """) for settingxml in settings: new_func = NetworkManager.__getattr__(settingxml.attrib['name']) setting = new_func() outfile.write(" <setting name=\"%s\">\n" % setting.props.name) properties = sorted(GObject.list_properties(setting), key=lambda prop: prop.name) for pspec in properties: propxml = settingxml.find('./gi:property[@name="%s"]' % pspec.name, ns_map) if propxml is None: propxml = basexml.find('./gi:property[@name="%s"]' % pspec.name, ns_map) value_type = get_prop_type(setting, pspec, propxml) value_desc = get_docs(setting, pspec, propxml) default_value = get_default_value(setting, pspec, propxml) if default_value is not None: outfile.write(" <property name=\"%s\" type=\"%s\" default=\"%s\" description=\"%s\" />\n" % (pspec.name, value_type, escape(default_value), escape(value_desc))) else: outfile.write(" <property name=\"%s\" type=\"%s\" description=\"%s\" />\n" % (pspec.name, value_type, escape(value_desc)))
def _addWidgets(self, properties, default_btn, use_element_props): """ Prepare a gtk table containing the property widgets of an element. Each property is on a separate row of the table. A row is typically a label followed by the widget and a reset button. If there are no properties, returns a table containing the label "No properties." """ is_effect = False if isinstance(self.element, GES.Effect): is_effect = True props = [ prop for prop in self.element.list_children_properties() if not prop.name in self.ignore ] else: props = [ prop for prop in GObject.list_properties(self.element) if not prop.name in self.ignore ] if not props: table = Gtk.Table(rows=1, columns=1) widget = Gtk.Label(label=_("No properties.")) widget.set_sensitive(False) table.attach(widget, 0, 1, 0, 1, yoptions=Gtk.AttachOptions.FILL) self.pack_start(table, True, True, 0) self.show_all() return if default_btn: table = Gtk.Table(rows=len(props), columns=3) else: table = Gtk.Table(rows=len(props), columns=2) table.set_row_spacings(SPACING) table.set_col_spacings(SPACING) table.set_border_width(SPACING) y = 0 for prop in props: # We do not know how to work with GObjects, so blacklist # them to avoid noise in the UI if (not prop.flags & GObject.PARAM_WRITABLE or not prop.flags & GObject.PARAM_READABLE or GObject.type_is_a(prop.value_type, GObject.Object)): continue if is_effect: result, prop_value = self.element.get_child_property(prop.name) if result is False: self.debug("Could not get property %s value", prop.name) else: if use_element_props: prop_value = self.element.get_property(prop.name) else: prop_value = properties.get(prop.name) widget = make_property_widget(self.element, prop, prop_value) if isinstance(widget, ToggleWidget): widget.set_label(prop.nick) table.attach(widget, 0, 2, y, y + 1, yoptions=Gtk.AttachOptions.FILL) else: label = Gtk.Label(label=prop.nick + ":") label.set_alignment(0.0, 0.5) table.attach(label, 0, 1, y, y + 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) table.attach(widget, 1, 2, y, y + 1, yoptions=Gtk.AttachOptions.FILL) if hasattr(prop, 'blurb'): widget.set_tooltip_text(prop.blurb) self.properties[prop] = widget # The "reset to default" button associated with this property if default_btn: button = self._getResetToDefaultValueButton(prop, widget) table.attach(button, 2, 3, y, y + 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) self.buttons[button] = widget self.element.connect('notify::' + prop.name, self._propertyChangedCb, widget) y += 1 self.pack_start(table, True, True, 0) self.show_all()
continue new_func = NM.__getattr__(settingxml.attrib['name']) setting = new_func() class_desc = get_docs(settingxml) if class_desc is None: raise Exception("%s needs a gtk-doc block with one-line description" % setting.props.name) outfile.write( " <setting name=\"%s\" description=\"%s\" name_upper=\"%s\" >\n" % (setting.props.name, class_desc, get_setting_name_define(settingxml))) setting_properties = { prop.name: prop for prop in GObject.list_properties(setting) if prop.name != 'name' } if args.overrides is None: setting_overrides = {} else: setting_overrides = { override.attrib['name']: override for override in overrides.findall( './setting[@name="%s"]/property' % setting.props.name) } properties = sorted( set.union(set(setting_properties.keys()), set(setting_overrides.keys()))) for prop in properties:
def _addWidgets(self, properties, default_btn, use_element_props): """ Prepare a gtk table containing the property widgets of an element. Each property is on a separate row of the table. A row is typically a label followed by the widget and a reset button. If there are no properties, returns a table containing the label "No properties." """ self.bindings = {} self.keyframeToggleButtons = {} is_effect = False if isinstance(self.element, GES.Effect): is_effect = True props = [ prop for prop in self.element.list_children_properties() if prop.name not in self.ignore] else: props = [prop for prop in GObject.list_properties( self.element) if prop.name not in self.ignore] if not props: table = Gtk.Table(n_rows=1, n_columns=1) widget = Gtk.Label(label=_("No properties.")) widget.set_sensitive(False) table.attach(widget, 0, 1, 0, 1, yoptions=Gtk.AttachOptions.FILL) self.pack_start(table, expand=True, fill=True, padding=0) self.show_all() return if default_btn: table = Gtk.Table(n_rows=len(props), n_columns=4) else: table = Gtk.Table(n_rows=len(props), n_columns=3) table.set_row_spacings(SPACING) table.set_col_spacings(SPACING) table.set_border_width(SPACING) y = 0 for prop in props: # We do not know how to work with GObjects, so blacklist # them to avoid noise in the UI if (not prop.flags & GObject.PARAM_WRITABLE or not prop.flags & GObject.PARAM_READABLE or GObject.type_is_a(prop.value_type, GObject.Object)): continue if is_effect: result, prop_value = self.element.get_child_property(prop.name) if result is False: self.debug( "Could not get value for property: %s", prop.name) else: if use_element_props: prop_value = self.element.get_property(prop.name) else: prop_value = properties.get(prop.name) widget = self._makePropertyWidget(prop, prop_value) if isinstance(widget, ToggleWidget): widget.set_label(prop.nick) table.attach( widget, 0, 2, y, y + 1, yoptions=Gtk.AttachOptions.FILL) else: label = Gtk.Label(label=prop.nick + ":") label.set_alignment(0.0, 0.5) table.attach( label, 0, 1, y, y + 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) table.attach( widget, 1, 2, y, y + 1, yoptions=Gtk.AttachOptions.FILL) if not isinstance(widget, ToggleWidget) and not isinstance(widget, ChoiceWidget) and self.isControllable: button = self._getKeyframeToggleButton(prop) self.keyframeToggleButtons[button] = widget table.attach( button, 3, 4, y, y + 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) if hasattr(prop, 'blurb'): widget.set_tooltip_text(prop.blurb) self.properties[prop] = widget # The "reset to default" button associated with this property if default_btn: widget.propName = prop.name.split("-")[0] if self.isControllable: # If this element is controlled, the value means nothing # anymore. binding = self.element.get_control_binding(prop.name) if binding: widget.set_sensitive(False) self.bindings[widget] = binding button = self._getResetToDefaultValueButton(prop, widget) table.attach( button, 2, 3, y, y + 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) self.buttons[button] = widget y += 1 self.element.connect('deep-notify', self._propertyChangedCb) self.pack_start(table, expand=True, fill=True, padding=0) self.show_all()
def _addWidgets(self, values, default_btn): """ Prepare a Gtk.Grid containing the property widgets of an element. Each property is on a separate row. A row is typically a label followed by the widget and a reset button. If there are no properties, returns a "No properties" label. """ self.properties.clear() self.bindings = {} self.keyframeToggleButtons = {} is_effect = isinstance(self.element, GES.Effect) if is_effect: props = [prop for prop in self.element.list_children_properties() if prop.name not in self.ignore] else: props = [prop for prop in GObject.list_properties(self.element) if prop.name not in self.ignore] if not props: widget = Gtk.Label(label=_("No properties.")) self.pack_start(widget, expand=False, fill=False, padding=0) widget.show() return grid = Gtk.Grid() grid.props.row_spacing = SPACING grid.props.column_spacing = SPACING grid.props.border_width = SPACING for y, prop in enumerate(props): # We do not know how to work with GObjects, so blacklist # them to avoid noise in the UI if ( not prop.flags & GObject.PARAM_WRITABLE or not prop.flags & GObject.PARAM_READABLE or GObject.type_is_a(prop.value_type, GObject.Object) ): continue if is_effect: result, prop_value = self.element.get_child_property(prop.name) if not result: self.debug("Could not get value for property: %s", prop.name) else: if not values: # Use the default value. prop_value = self.element.get_property(prop.name) else: prop_value = values.get(prop.name) widget = self._makePropertyWidget(prop, prop_value) if isinstance(widget, ToggleWidget): widget.set_label(prop.nick) grid.attach(widget, 0, y, 2, 1) else: text = _("%(preference_label)s:") % {"preference_label": prop.nick} label = Gtk.Label(label=text) label.set_alignment(0.0, 0.5) grid.attach(label, 0, y, 1, 1) grid.attach(widget, 1, y, 1, 1) controllable = self.isControllable and not isinstance(widget, DefaultWidget) if controllable and not isinstance(widget, ToggleWidget) and not isinstance(widget, ChoiceWidget): keyframe_toggle_button = self._createKeyframeToggleButton(prop) self.keyframeToggleButtons[keyframe_toggle_button] = widget grid.attach(keyframe_toggle_button, 2, y, 1, 1) if hasattr(prop, "blurb"): widget.set_tooltip_text(prop.blurb) self.properties[prop] = widget # The "reset to default" button associated with this property if controllable and default_btn: # If this element is controlled, the value means nothing # anymore. binding = self.element.get_control_binding(prop.name) if binding: widget.set_sensitive(False) self.bindings[widget] = binding button = self._createResetToDefaultValueButton(prop, widget) grid.attach(button, 3, y, 1, 1) self.buttons[button] = widget self.element.connect("deep-notify", self._propertyChangedCb) self.pack_start(grid, expand=False, fill=False, padding=0) self.show_all()
#pdb.set_trace() # whats the difference between these two items # GncPlugin.Plugin and GncPlugin.PluginClass?? # well GncPlugin.Plugin is the GObject object for subclassing # GncPlugin.PluginClass is the class structure object print(GObject.type_query(GncPlugin.Plugin), file=sys.stderr) typptr = GObject.type_query(GncPlugin.Plugin) print("gtype",typptr.type_name, file=sys.stderr) print("gtype",typptr.type, file=sys.stderr) print("gtype",typptr.class_size, file=sys.stderr) print("gtype",typptr.instance_size, file=sys.stderr) # this lists the properties print(GObject.list_properties(GncPlugin.Plugin), file=sys.stderr) # this lists the signal names print(GObject.signal_list_names(GncPlugin.Plugin), file=sys.stderr) BaseGncPlugin = GncPlugin.Plugin BaseGncPluginClass = GncPlugin.PluginClass # for the moment save the plugins python_plugins = {} # lets not use subclasses of subclasses yet - NO # - switching back to subclass of subclass - using multiple inheritance with # metaclass seems fraught - unless manually merge the various base class attributes
def setup_tests(test_manager, options): print("Setting up tests to validate all elements") pipelines_descriptions = [] test_manager.set_default_blacklist([ ("validate.launch_pipeline.videocrop*", "https://bugzilla.gnome.org/show_bug.cgi?id=743910"), ("validate.launch_pipeline.videobox*", "https://bugzilla.gnome.org/show_bug.cgi?id=743909"), ("validate.launch_pipeline.simplevideomark*", "https://bugzilla.gnome.org/show_bug.cgi?id=743908"), ("validate.launch_pipeline.exclusion*", "https://bugzilla.gnome.org/show_bug.cgi?id=743907"), ("validate.launch_pipeline.frei0r*", "video filter plugins"), ("validate.launch_pipeline.*interleavechannel-positions-from-input=False*", "https://bugzilla.gnome.org/show_bug.cgi?id=744211"), ("validate.launch_pipeline.spectrum*", "https://bugzilla.gnome.org/show_bug.cgi?id=744213"), ("validate.launch_pipeline.smpte*", "smpte cannot be tested with simple pipeline. Hence excluding"), ("validate.launch_pipeline.gleffects_laplacian*", "https://bugzilla.gnome.org/show_bug.cgi?id=748393"), ("validate.launch_pipeline.glfilterbin*", "glfilter bin doesnt launch."), ]) valid_scenarios = ["play_15s"] Gst.init(None) factories = Gst.Registry.get().get_feature_list(Gst.ElementFactory) for element_factory in factories: audiosrc = False audiosink = False videosrc = False videosink = False klass = element_factory.get_metadata("klass") fname = element_factory.get_name() if "Audio" not in klass and "Video" not in klass: continue padstemplates = element_factory.get_static_pad_templates() for padtemplate in padstemplates: if padtemplate.static_caps.string: caps = padtemplate.get_caps() for i in xrange(caps.get_size()): structure = caps.get_structure(i) if "audio/x-raw" in structure.get_name(): if padtemplate.direction == Gst.PadDirection.SRC: audiosrc = True elif padtemplate.direction == Gst.PadDirection.SINK: audiosink = True elif "video/x-raw" in structure.get_name(): if padtemplate.direction == Gst.PadDirection.SRC: videosrc = True elif padtemplate.direction == Gst.PadDirection.SINK: videosink = True if (audiosink is False and videosink is False) or (audiosrc is False and videosrc is False): continue element = Gst.ElementFactory.make(fname, None) if element is None: print("Could not create element: %s" % fname) continue props = GObject.list_properties(element) for prop in props: if "name" in prop.name or "parent" in prop.name or "qos" in prop.name or \ "latency" in prop.name or "message-forward" in prop.name: continue if (prop.flags & GObject.ParamFlags.WRITABLE) and \ (prop.flags & GObject.ParamFlags.READABLE): if prop.value_type == GObject.TYPE_BOOLEAN: loop = 2 elif pspec_is_numeric(prop): loop = 3 else: loop = 0 while loop: loop -= 1 description = get_pipe_and_populate( test_manager, klass, fname, prop, loop) if None is not description: pipelines_descriptions.append(description) # No restriction about scenarios that are potentially used test_manager.add_scenarios(valid_scenarios) test_manager.add_generators( test_manager.GstValidatePipelineTestsGenerator( "validate_elements", test_manager, pipelines_descriptions=pipelines_descriptions, valid_scenarios=valid_scenarios)) return True
def setup_tests(test_manager, options): print("Setting up tests to validate all elements") pipelines_descriptions = [] test_manager.set_default_blacklist([ ("validate.launch_pipeline.videocrop*", "https://bugzilla.gnome.org/show_bug.cgi?id=743910"), ("validate.launch_pipeline.videobox*", "https://bugzilla.gnome.org/show_bug.cgi?id=743909"), ("validate.launch_pipeline.simplevideomark*", "https://bugzilla.gnome.org/show_bug.cgi?id=743908"), ("validate.launch_pipeline.exclusion*", "https://bugzilla.gnome.org/show_bug.cgi?id=743907"), ("validate.launch_pipeline.frei0r*", "video filter plugins"), ("validate.launch_pipeline.*interleavechannel-positions-from-input=False*", "https://bugzilla.gnome.org/show_bug.cgi?id=744211"), ("validate.launch_pipeline.spectrum*", "https://bugzilla.gnome.org/show_bug.cgi?id=744213"), ("validate.launch_pipeline.smpte*", "smpte cannot be tested with simple pipeline. Hence excluding"), ("validate.launch_pipeline.gleffects_laplacian*", "https://bugzilla.gnome.org/show_bug.cgi?id=748393"), ("validate.launch_pipeline.glfilterbin*", "glfilter bin doesnt launch."), ]) valid_scenarios = ["play_15s"] Gst.init(None) factories = Gst.Registry.get().get_feature_list(Gst.ElementFactory) for element_factory in factories: audiosrc = False audiosink = False videosrc = False videosink = False klass = element_factory.get_metadata("klass") fname = element_factory.get_name() if "Audio" not in klass and "Video" not in klass: continue padstemplates = element_factory.get_static_pad_templates() for padtemplate in padstemplates: if padtemplate.static_caps.string: caps = padtemplate.get_caps() for i in range(caps.get_size()): structure = caps.get_structure(i) if "audio/x-raw" in structure.get_name(): if padtemplate.direction == Gst.PadDirection.SRC: audiosrc = True elif padtemplate.direction == Gst.PadDirection.SINK: audiosink = True elif "video/x-raw" in structure.get_name(): if padtemplate.direction == Gst.PadDirection.SRC: videosrc = True elif padtemplate.direction == Gst.PadDirection.SINK: videosink = True if (audiosink is False and videosink is False) or (audiosrc is False and videosrc is False): continue element = Gst.ElementFactory.make(fname, None) if element is None: print("Could not create element: %s" % fname) continue props = GObject.list_properties(element) for prop in props: if "name" in prop.name or "parent" in prop.name or "qos" in prop.name or \ "latency" in prop.name or "message-forward" in prop.name: continue if (prop.flags & GObject.ParamFlags.WRITABLE) and \ (prop.flags & GObject.ParamFlags.READABLE): if prop.value_type == GObject.TYPE_BOOLEAN: loop = 2 elif pspec_is_numeric(prop): loop = 3 else: loop = 0 while loop: loop -= 1 description = get_pipe_and_populate(test_manager, klass, fname, prop, loop) if None is not description: pipelines_descriptions.append(description) # No restriction about scenarios that are potentially used test_manager.add_scenarios(valid_scenarios) test_manager.add_generators(test_manager.GstValidatePipelineTestsGenerator ("validate_elements", test_manager, pipelines_descriptions=pipelines_descriptions, valid_scenarios=valid_scenarios)) return True
def handle_restore_data(self, window_manager, settings, do_restore): if log.query(log.INFO): Gedit.debug_plugin_message(log.format("do_restore=%s", do_restore)) states = [] for window_id in list(settings.restore_windows): if do_restore: state = window_manager.new_window_state() window_settings = settings.get_window_settings(window_id) if not window_settings: if log.query(log.WARNING): Gedit.debug_plugin_message( log.format("could not get window settings")) continue try: params = state.list_properties() except AttributeError: # gedit 3.12 params = GObject.list_properties(state) for param in params: state.set_property(param.name, window_settings[param.name]) state.uris = window_settings['uris'] state.notebook_widths = window_settings['notebook-widths'] if state.restore_uris: states.append(state) settings.remove_window(window_id) if not do_restore: if log.query(log.MESSAGE): Gedit.debug_plugin_message(log.format("not restoring windows")) return if not states: if log.query(log.MESSAGE): Gedit.debug_plugin_message(log.format("no windows to restore")) return if log.query(log.MESSAGE): Gedit.debug_plugin_message( log.format("will restore %s windows", len(states))) screen_width = window_manager.get_screen_width() screen_height = window_manager.get_screen_height() for state in states: # when gedit goes to open the first blank tab, # it tries to find an active window first # but it tests for windows in the current screen/workspace/viewport # which is in part based on the size of the window # so we need to shrink our windows here to fit the screen, # otherwise gedit will think they are in a different viewport # (if the window is too large for the screen, # the window manager will probably resize the window to fit anyway) if state.width > screen_width: state.side_panel_size = round( (state.side_panel_size / state.width) * screen_width) state.width = screen_width if state.height > screen_height: state.bottom_panel_size = round( (state.bottom_panel_size / state.height) * screen_height) state.height = screen_height self._restore_states = states self._restore_windows = {}
def _addWidgets(self, properties, default_btn, use_element_props): """ Prepare a gtk table containing the property widgets of an element. Each property is on a separate row of the table. A row is typically a label followed by the widget and a reset button. If there are no properties, returns a table containing the label "No properties." """ is_effect = False if isinstance(self.element, GES.Effect): is_effect = True props = [prop for prop in self.element.list_children_properties() if not prop.name in self.ignore] else: props = [prop for prop in GObject.list_properties(self.element) if not prop.name in self.ignore] if not props: table = Gtk.Table(rows=1, columns=1) widget = Gtk.Label(label=_("No properties.")) widget.set_sensitive(False) table.attach(widget, 0, 1, 0, 1, yoptions=Gtk.AttachOptions.FILL) self.pack_start(table, True, True, 0) self.show_all() return if default_btn: table = Gtk.Table(rows=len(props), columns=3) else: table = Gtk.Table(rows=len(props), columns=2) table.set_row_spacings(SPACING) table.set_col_spacings(SPACING) table.set_border_width(SPACING) y = 0 for prop in props: # We do not know how to work with GObjects, so blacklist # them to avoid noise in the UI if (not prop.flags & GObject.PARAM_WRITABLE or not prop.flags & GObject.PARAM_READABLE or GObject.type_is_a(prop.value_type, GObject.Object)): continue if is_effect: result, prop_value = self.element.get_child_property(prop.name) if result is False: self.debug("Could not get property %s value", prop.name) else: if use_element_props: prop_value = self.element.get_property(prop.name) else: prop_value = properties.get(prop.name) widget = make_property_widget(self.element, prop, prop_value) if isinstance(widget, ToggleWidget): widget.set_label(prop.nick) table.attach(widget, 0, 2, y, y + 1, yoptions=Gtk.AttachOptions.FILL) else: label = Gtk.Label(label=prop.nick + ":") label.set_alignment(0.0, 0.5) table.attach(label, 0, 1, y, y + 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) table.attach(widget, 1, 2, y, y + 1, yoptions=Gtk.AttachOptions.FILL) if hasattr(prop, 'blurb'): widget.set_tooltip_text(prop.blurb) self.properties[prop] = widget # The "reset to default" button associated with this property if default_btn: button = self._getResetToDefaultValueButton(prop, widget) table.attach(button, 2, 3, y, y + 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) self.buttons[button] = widget self.element.connect('notify::' + prop.name, self._propertyChangedCb, widget) y += 1 self.pack_start(table, True, True, 0) self.show_all()
def __add_widgets(self, values, with_reset_button): """Prepares a Gtk.Grid containing the property widgets of an element. Each property is on a separate row. A row is typically a label followed by the widget and a reset button. If there are no properties, returns a "No properties" label. """ self.properties.clear() self.__bindings_by_keyframe_button = {} self.__widgets_by_keyframe_button = {} is_effect = isinstance(self.element, GES.Effect) if is_effect: props = [ prop for prop in self.element.list_children_properties() if prop.name not in self.ignore ] else: props = [ prop for prop in GObject.list_properties(self.element) if prop.name not in self.ignore ] if not props: widget = Gtk.Label(label=_("No properties.")) self.pack_start(widget, expand=False, fill=False, padding=0) widget.show() return grid = Gtk.Grid() grid.props.row_spacing = SPACING grid.props.column_spacing = SPACING grid.props.border_width = SPACING for y, prop in enumerate(props): # We do not know how to work with GObjects, so blacklist # them to avoid noise in the UI if (not prop.flags & GObject.PARAM_WRITABLE or not prop.flags & GObject.PARAM_READABLE or GObject.type_is_a(prop.value_type, GObject.Object)): continue if is_effect: result, prop_value = self.element.get_child_property(prop.name) if not result: self.debug("Could not get value for property: %s", prop.name) else: if prop.name not in values.keys(): # Use the default value. prop_value = self.element.get_property(prop.name) else: prop_value = values[prop.name] widget = self._makePropertyWidget(prop, prop_value) if isinstance(widget, ToggleWidget): widget.set_label(prop.nick) grid.attach(widget, 0, y, 2, 1) else: text = _("%(preference_label)s:") % { "preference_label": prop.nick } label = Gtk.Label(label=text) label.set_alignment(0.0, 0.5) grid.attach(label, 0, y, 1, 1) grid.attach(widget, 1, y, 1, 1) if hasattr(prop, 'blurb'): widget.set_tooltip_text(prop.blurb) self.properties[prop] = widget if not self.__controllable or isinstance(widget, DefaultWidget): continue keyframe_button = None if not isinstance(widget, (ToggleWidget, ChoiceWidget)): res, element, pspec = self.element.lookup_child(prop.name) assert res binding = GstController.DirectControlBinding.new( element, prop.name, GstController.InterpolationControlSource()) if binding.pspec: # The prop can be controlled (keyframed). keyframe_button = self.__create_keyframe_toggle_button( prop, widget) grid.attach(keyframe_button, 2, y, 1, 1) # The "reset to default" button associated with this property if with_reset_button: button = self.__create_reset_to_default_button( prop, widget, keyframe_button) grid.attach(button, 3, y, 1, 1) self.element.connect('deep-notify', self._propertyChangedCb) self.pack_start(grid, expand=False, fill=False, padding=0) self.show_all()
]> <nm-setting-docs> """) for settingxml in settings: if settingxml.attrib.has_key('abstract'): continue new_func = NM.__getattr__(settingxml.attrib['name']) setting = new_func() outfile.write(" <setting name=\"%s\">\n" % setting.props.name) setting_properties = { prop.name: prop for prop in GObject.list_properties(setting) } if args.overrides is None: setting_overrides = {} else: setting_overrides = { override.attrib['name']: override for override in overrides.findall( './setting[@name="%s"]/property' % setting.props.name) } properties = sorted( set.union( set(setting_properties.keys()), set(setting_overrides.keys()))) for prop in properties:
def _addWidgets(self, properties, default_btn, use_element_props): """ Prepare a gtk table containing the property widgets of an element. Each property is on a separate row of the table. A row is typically a label followed by the widget and a reset button. If there are no properties, returns a table containing the label "No properties." """ self.bindings = {} self.keyframeToggleButtons = {} is_effect = False if isinstance(self.element, GES.Effect): is_effect = True props = [ prop for prop in self.element.list_children_properties() if prop.name not in self.ignore ] else: props = [ prop for prop in GObject.list_properties(self.element) if prop.name not in self.ignore ] if not props: table = Gtk.Table(n_rows=1, n_columns=1) widget = Gtk.Label(label=_("No properties.")) widget.set_sensitive(False) table.attach(widget, 0, 1, 0, 1, yoptions=Gtk.AttachOptions.FILL) self.pack_start(table, expand=True, fill=True, padding=0) self.show_all() return if default_btn: table = Gtk.Table(n_rows=len(props), n_columns=4) else: table = Gtk.Table(n_rows=len(props), n_columns=3) table.set_row_spacings(SPACING) table.set_col_spacings(SPACING) table.set_border_width(SPACING) y = 0 for prop in props: # We do not know how to work with GObjects, so blacklist # them to avoid noise in the UI if (not prop.flags & GObject.PARAM_WRITABLE or not prop.flags & GObject.PARAM_READABLE or GObject.type_is_a(prop.value_type, GObject.Object)): continue if is_effect: result, prop_value = self.element.get_child_property(prop.name) if result is False: self.debug("Could not get value for property: %s", prop.name) else: if use_element_props: prop_value = self.element.get_property(prop.name) else: prop_value = properties.get(prop.name) widget = self._makePropertyWidget(prop, prop_value) if isinstance(widget, ToggleWidget): widget.set_label(prop.nick) table.attach(widget, 0, 2, y, y + 1, yoptions=Gtk.AttachOptions.FILL) else: label = Gtk.Label(label=prop.nick + ":") label.set_alignment(0.0, 0.5) table.attach(label, 0, 1, y, y + 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) table.attach(widget, 1, 2, y, y + 1, yoptions=Gtk.AttachOptions.FILL) if not isinstance(widget, ToggleWidget) and not isinstance( widget, ChoiceWidget) and self.isControllable: button = self._getKeyframeToggleButton(prop) self.keyframeToggleButtons[button] = widget table.attach(button, 3, 4, y, y + 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) if hasattr(prop, 'blurb'): widget.set_tooltip_text(prop.blurb) self.properties[prop] = widget # The "reset to default" button associated with this property if default_btn: widget.propName = prop.name.split("-")[0] if self.isControllable: # If this element is controlled, the value means nothing # anymore. binding = self.element.get_control_binding(prop.name) if binding: widget.set_sensitive(False) self.bindings[widget] = binding button = self._getResetToDefaultValueButton(prop, widget) table.attach(button, 2, 3, y, y + 1, xoptions=Gtk.AttachOptions.FILL, yoptions=Gtk.AttachOptions.FILL) self.buttons[button] = widget y += 1 self.element.connect('deep-notify', self._propertyChangedCb) self.pack_start(table, expand=True, fill=True, padding=0) self.show_all()
def setup_tests(test_manager, options): print("Setting up tests to validate all elements") pipelines_descriptions = [] test_manager.add_expected_issues(KNOWN_ISSUES) test_manager.set_default_blacklist([ ("validateelements.launch_pipeline.videobox*", "Those are broken pipelines."), ("validateelements.launch_pipeline.frei0r*", "video filter plugins"), ("validateelements.launch_pipeline.smpte*", "smpte cannot be tested with simple pipeline. Hence excluding"), ("validateelements.launch_pipeline.glfilterbin*", "glfilter bin doesnt launch."), ("validateelements.launch_pipeline.audiomixmatrix*", "Now deprecated and requires specific properties to be set."), ]) valid_scenarios = ["play_15s"] Gst.init(None) factories = Gst.Registry.get().get_feature_list(Gst.ElementFactory) for element_factory in factories: audiosrc = False audiosink = False videosrc = False videosink = False klass = element_factory.get_metadata("klass") fname = element_factory.get_name() if "Audio" not in klass and "Video" not in klass: continue padstemplates = element_factory.get_static_pad_templates() for padtemplate in padstemplates: if padtemplate.static_caps.string: caps = padtemplate.get_caps() for i in range(caps.get_size()): structure = caps.get_structure(i) if "audio/x-raw" in structure.get_name(): if padtemplate.direction == Gst.PadDirection.SRC: audiosrc = True elif padtemplate.direction == Gst.PadDirection.SINK: audiosink = True elif "video/x-raw" in structure.get_name(): if padtemplate.direction == Gst.PadDirection.SRC: videosrc = True elif padtemplate.direction == Gst.PadDirection.SINK: videosink = True if (audiosink is False and videosink is False) or (audiosrc is False and videosrc is False): continue element = Gst.ElementFactory.make(fname, None) if element is None: print("Could not create element: %s" % fname) continue props = GObject.list_properties(element) for prop in props: if "name" in prop.name or "parent" in prop.name or "qos" in prop.name or \ "latency" in prop.name or "message-forward" in prop.name: continue if (prop.flags & GObject.ParamFlags.WRITABLE) and \ (prop.flags & GObject.ParamFlags.READABLE): if prop.value_type == GObject.TYPE_BOOLEAN: loop = 2 elif pspec_is_numeric(prop): loop = 3 else: loop = 0 while loop: loop -= 1 description = get_pipe_and_populate(test_manager, klass, fname, prop, loop) if None is not description: pipelines_descriptions.append(description) # No restriction about scenarios that are potentially used test_manager.add_scenarios(valid_scenarios) test_manager.add_generators(test_manager.GstValidatePipelineTestsGenerator ("validate_elements", test_manager, pipelines_descriptions=pipelines_descriptions, valid_scenarios=valid_scenarios)) return True
<!DOCTYPE nm-setting-docs [ <!ENTITY quot """> ]> <nm-setting-docs> """) for settingxml in settings: if settingxml.attrib.has_key('abstract'): continue new_func = NM.__getattr__(settingxml.attrib['name']) setting = new_func() outfile.write(" <setting name=\"%s\">\n" % setting.props.name) setting_properties = { prop.name: prop for prop in GObject.list_properties(setting) } if args.overrides is None: setting_overrides = {} else: setting_overrides = { override.attrib['name']: override for override in overrides.findall('./setting[@name="%s"]/property' % setting.props.name) } properties = sorted(set.union(set(setting_properties.keys()), set(setting_overrides.keys()))) for prop in properties: value_type = None value_desc = None default_value = None if prop in setting_properties: pspec = setting_properties[prop] propxml = settingxml.find('./gi:property[@name="%s"]' % pspec.name, ns_map)
]> <nm-setting-docs> """) for settingxml in settings: if settingxml.attrib.has_key('abstract'): continue new_func = NM.__getattr__(settingxml.attrib['name']) setting = new_func() outfile.write(" <setting name=\"%s\">\n" % setting.props.name) setting_properties = { prop.name: prop for prop in GObject.list_properties(setting) } if args.overrides is None: setting_overrides = {} else: setting_overrides = { override.attrib['name']: override for override in overrides.findall( './setting[@name="%s"]/property' % setting.props.name) } properties = sorted( set.union(set(setting_properties.keys()), set(setting_overrides.keys()))) for prop in properties:
<nm-setting-docs> """) for settingxml in settings: if 'abstract' in settingxml.attrib: continue new_func = NM.__getattr__(settingxml.attrib['name']) setting = new_func() class_desc = get_docs(settingxml) if class_desc is None: raise Exception("%s needs a gtk-doc block with one-line description" % setting.props.name) outfile.write(" <setting name=\"%s\" description=\"%s\" name_upper=\"%s\" >\n" % (setting.props.name, class_desc, get_setting_name_define (settingxml))) setting_properties = { prop.name: prop for prop in GObject.list_properties(setting) } if args.overrides is None: setting_overrides = {} else: setting_overrides = { override.attrib['name']: override for override in overrides.findall('./setting[@name="%s"]/property' % setting.props.name) } properties = sorted(set.union(set(setting_properties.keys()), set(setting_overrides.keys()))) for prop in properties: value_type = None value_desc = None default_value = None if prop in setting_properties: pspec = setting_properties[prop] propxml = settingxml.find('./gi:property[@name="%s"]' % pspec.name, ns_map)