Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/sdroege/gst-plugin-rs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/text
diff options
context:
space:
mode:
authorVivia Nikolaidou <vivia@ahiru.eu>2022-08-18 15:04:15 +0300
committerVivia Nikolaidou <vivia@ahiru.eu>2022-08-22 17:58:43 +0300
commit560611134588f63270a569e92160ecac5ceabc37 (patch)
treeac5f4447c55c1e5dd4d8f15f92c335c36aa5bab8 /text
parent84f6484140098826b3f074d806e0eb052198df43 (diff)
plugins: Simplify code using ParamSpecBuilder
Diffstat (limited to 'text')
-rw-r--r--text/ahead/src/textahead/imp.rs54
-rw-r--r--text/regex/src/gstregex/imp.rs24
-rw-r--r--text/wrap/src/gsttextwrap/imp.rs68
3 files changed, 65 insertions, 81 deletions
diff --git a/text/ahead/src/textahead/imp.rs b/text/ahead/src/textahead/imp.rs
index 1ecf4d3f..226f30c7 100644
--- a/text/ahead/src/textahead/imp.rs
+++ b/text/ahead/src/textahead/imp.rs
@@ -103,37 +103,31 @@ impl ObjectImpl for TextAhead {
let default = Settings::default();
vec![
- glib::ParamSpecUInt::new(
- "n-ahead",
- "n-ahead",
- "The number of ahead text buffers to display along with the current one",
- 0,
- u32::MAX,
- default.n_ahead,
- glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING,
- ),
- glib::ParamSpecString::new(
- "separator",
- "Separator",
- "Text inserted between each text buffers",
- Some(&default.separator),
- glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING,
- ),
+ glib::ParamSpecUInt::builder("n-ahead")
+ .nick("n-ahead")
+ .blurb("The number of ahead text buffers to display along with the current one")
+ .default_value(default.n_ahead)
+ .mutable_playing()
+ .build(),
+ glib::ParamSpecString::builder("separator")
+ .nick("Separator")
+ .blurb("Text inserted between each text buffers")
+ .default_value(Some(&default.separator))
+ .mutable_playing()
+ .build(),
// See https://developer.gimp.org/api/2.0/pango/PangoMarkupFormat.html for pango attributes
- glib::ParamSpecString::new(
- "current-attributes",
- "Current attributes",
- "Pango span attributes to set on the text from the current buffer",
- Some(&default.current_attributes),
- glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING,
- ),
- glib::ParamSpecString::new(
- "ahead-attributes",
- "Ahead attributes",
- "Pango span attributes to set on the ahead text",
- Some(&default.ahead_attributes),
- glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING,
- ),
+ glib::ParamSpecString::builder("current-attributes")
+ .nick("Current attributes")
+ .blurb("Pango span attributes to set on the text from the current buffer")
+ .default_value(Some(&default.current_attributes))
+ .mutable_playing()
+ .build(),
+ glib::ParamSpecString::builder("ahead-attributes")
+ .nick("Ahead attributes")
+ .blurb("Pango span attributes to set on the ahead text")
+ .default_value(Some(&default.ahead_attributes))
+ .mutable_playing()
+ .build(),
]
});
diff --git a/text/regex/src/gstregex/imp.rs b/text/regex/src/gstregex/imp.rs
index 2ef24c1e..6a97bb4c 100644
--- a/text/regex/src/gstregex/imp.rs
+++ b/text/regex/src/gstregex/imp.rs
@@ -141,19 +141,17 @@ impl ObjectSubclass for RegEx {
impl ObjectImpl for RegEx {
fn properties() -> &'static [glib::ParamSpec] {
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
- vec![gst::ParamSpecArray::new(
- "commands",
- "Commands",
- "A set of commands to apply on input text",
- Some(&glib::ParamSpecBoxed::new(
- "command",
- "Command",
- "A command to apply on input text",
- gst::Structure::static_type(),
- glib::ParamFlags::READWRITE,
- )),
- glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING,
- )]
+ vec![gst::ParamSpecArray::builder("commands")
+ .nick("Commands")
+ .blurb("A set of commands to apply on input text")
+ .element_spec(
+ &glib::ParamSpecBoxed::builder("command", gst::Structure::static_type())
+ .nick("Command")
+ .blurb("A command to apply on input text")
+ .build(),
+ )
+ .mutable_playing()
+ .build()]
});
PROPERTIES.as_ref()
diff --git a/text/wrap/src/gsttextwrap/imp.rs b/text/wrap/src/gsttextwrap/imp.rs
index 6520da2f..bbc32c5c 100644
--- a/text/wrap/src/gsttextwrap/imp.rs
+++ b/text/wrap/src/gsttextwrap/imp.rs
@@ -456,45 +456,37 @@ impl ObjectSubclass for TextWrap {
impl ObjectImpl for TextWrap {
fn properties() -> &'static [glib::ParamSpec] {
- static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
- vec![
- glib::ParamSpecString::new(
- "dictionary",
- "Dictionary",
- "Path to a dictionary to load at runtime to perform hyphenation, see \
- <https://docs.rs/crate/hyphenation/0.7.1> for more information",
- None,
- glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING,
- ),
- glib::ParamSpecUInt::new(
- "columns",
- "Columns",
- "Maximum number of columns for any given line",
- 1,
- std::u32::MAX,
- DEFAULT_COLUMNS,
- glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING,
- ),
- glib::ParamSpecUInt::new(
- "lines",
- "Lines",
- "Split input buffer into output buffers with max lines (0=do not split)",
- 0,
- std::u32::MAX,
- DEFAULT_LINES,
- glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING,
- ),
- glib::ParamSpecUInt64::new(
- "accumulate-time",
- "accumulate-time",
- "Cut-off time for input text accumulation (0=do not accumulate)",
- 0,
- u64::MAX - 1,
- DEFAULT_ACCUMULATE.nseconds(),
- glib::ParamFlags::READWRITE | gst::PARAM_FLAG_MUTABLE_PLAYING,
- ),
+ static PROPERTIES: Lazy<Vec<glib::ParamSpec>> =
+ Lazy::new(|| {
+ vec![
+ glib::ParamSpecString::builder("dictionary")
+ .nick("Dictionary")
+ .blurb("Path to a dictionary to load at runtime to perform hyphenation, see \
+ <https://docs.rs/crate/hyphenation/0.7.1> for more information")
+ .mutable_playing()
+ .build(),
+ glib::ParamSpecUInt::builder("columns")
+ .nick("Columns")
+ .blurb("Maximum number of columns for any given line")
+ .minimum(1)
+ .default_value(DEFAULT_COLUMNS)
+ .mutable_playing()
+ .build(),
+ glib::ParamSpecUInt::builder("lines")
+ .nick("Lines")
+ .blurb("Split input buffer into output buffers with max lines (0=do not split)")
+ .default_value(DEFAULT_LINES)
+ .mutable_playing()
+ .build(),
+ glib::ParamSpecUInt64::builder("accumulate-time")
+ .nick("accumulate-time")
+ .blurb("Cut-off time for input text accumulation (0=do not accumulate)")
+ .maximum(u64::MAX - 1)
+ .default_value(DEFAULT_ACCUMULATE.nseconds())
+ .mutable_playing()
+ .build(),
]
- });
+ });
PROPERTIES.as_ref()
}