use glib::object::Cast;
use glib::object::IsA;
use glib::object::ObjectType as ObjectType_;
use glib::translate::*;
use glib::StaticType;
use glib::ToValue;
use std::fmt;
glib::wrapper! {
pub struct Style(Object<ffi::GtkSourceStyle, ffi::GtkSourceStyleClass>);
match fn {
get_type => || ffi::gtk_source_style_get_type(),
}
}
impl Style {
#[doc(alias = "gtk_source_style_apply")]
pub fn apply<P: IsA<gtk::TextTag>>(&self, tag: &P) {
unsafe {
ffi::gtk_source_style_apply(self.to_glib_none().0, tag.as_ref().to_glib_none().0);
}
}
#[doc(alias = "gtk_source_style_copy")]
pub fn copy(&self) -> Option<Style> {
unsafe { from_glib_full(ffi::gtk_source_style_copy(self.to_glib_none().0)) }
}
pub fn get_property_background(&self) -> Option<glib::GString> {
unsafe {
let mut value = glib::Value::from_type(<glib::GString as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"background\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `background` getter")
}
}
pub fn get_property_background_set(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"background-set\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `background-set` getter")
.unwrap()
}
}
pub fn get_property_bold(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"bold\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `bold` getter")
.unwrap()
}
}
pub fn get_property_bold_set(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"bold-set\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `bold-set` getter")
.unwrap()
}
}
pub fn get_property_foreground(&self) -> Option<glib::GString> {
unsafe {
let mut value = glib::Value::from_type(<glib::GString as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"foreground\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `foreground` getter")
}
}
pub fn get_property_foreground_set(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"foreground-set\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `foreground-set` getter")
.unwrap()
}
}
pub fn get_property_italic(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"italic\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `italic` getter")
.unwrap()
}
}
pub fn get_property_italic_set(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"italic-set\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `italic-set` getter")
.unwrap()
}
}
pub fn get_property_line_background(&self) -> Option<glib::GString> {
unsafe {
let mut value = glib::Value::from_type(<glib::GString as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"line-background\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `line-background` getter")
}
}
pub fn get_property_line_background_set(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"line-background-set\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `line-background-set` getter")
.unwrap()
}
}
pub fn get_property_pango_underline(&self) -> pango::Underline {
unsafe {
let mut value = glib::Value::from_type(<pango::Underline as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"pango-underline\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `pango-underline` getter")
.unwrap()
}
}
pub fn get_property_scale(&self) -> Option<glib::GString> {
unsafe {
let mut value = glib::Value::from_type(<glib::GString as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"scale\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `scale` getter")
}
}
pub fn get_property_scale_set(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"scale-set\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `scale-set` getter")
.unwrap()
}
}
pub fn get_property_strikethrough(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"strikethrough\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `strikethrough` getter")
.unwrap()
}
}
pub fn get_property_strikethrough_set(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"strikethrough-set\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `strikethrough-set` getter")
.unwrap()
}
}
pub fn get_property_underline_color(&self) -> Option<glib::GString> {
unsafe {
let mut value = glib::Value::from_type(<glib::GString as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"underline-color\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `underline-color` getter")
}
}
pub fn get_property_underline_color_set(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"underline-color-set\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `underline-color-set` getter")
.unwrap()
}
}
pub fn get_property_underline_set(&self) -> bool {
unsafe {
let mut value = glib::Value::from_type(<bool as StaticType>::static_type());
glib::gobject_ffi::g_object_get_property(
self.as_ptr() as *mut glib::gobject_ffi::GObject,
b"underline-set\0".as_ptr() as *const _,
value.to_glib_none_mut().0,
);
value
.get()
.expect("Return Value for property `underline-set` getter")
.unwrap()
}
}
}
#[derive(Clone, Default)]
pub struct StyleBuilder {
background: Option<String>,
background_set: Option<bool>,
bold: Option<bool>,
bold_set: Option<bool>,
foreground: Option<String>,
foreground_set: Option<bool>,
italic: Option<bool>,
italic_set: Option<bool>,
line_background: Option<String>,
line_background_set: Option<bool>,
pango_underline: Option<pango::Underline>,
scale: Option<String>,
scale_set: Option<bool>,
strikethrough: Option<bool>,
strikethrough_set: Option<bool>,
underline_color: Option<String>,
underline_color_set: Option<bool>,
underline_set: Option<bool>,
}
impl StyleBuilder {
pub fn new() -> Self {
Self::default()
}
pub fn build(self) -> Style {
let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
if let Some(ref background) = self.background {
properties.push(("background", background));
}
if let Some(ref background_set) = self.background_set {
properties.push(("background-set", background_set));
}
if let Some(ref bold) = self.bold {
properties.push(("bold", bold));
}
if let Some(ref bold_set) = self.bold_set {
properties.push(("bold-set", bold_set));
}
if let Some(ref foreground) = self.foreground {
properties.push(("foreground", foreground));
}
if let Some(ref foreground_set) = self.foreground_set {
properties.push(("foreground-set", foreground_set));
}
if let Some(ref italic) = self.italic {
properties.push(("italic", italic));
}
if let Some(ref italic_set) = self.italic_set {
properties.push(("italic-set", italic_set));
}
if let Some(ref line_background) = self.line_background {
properties.push(("line-background", line_background));
}
if let Some(ref line_background_set) = self.line_background_set {
properties.push(("line-background-set", line_background_set));
}
if let Some(ref pango_underline) = self.pango_underline {
properties.push(("pango-underline", pango_underline));
}
if let Some(ref scale) = self.scale {
properties.push(("scale", scale));
}
if let Some(ref scale_set) = self.scale_set {
properties.push(("scale-set", scale_set));
}
if let Some(ref strikethrough) = self.strikethrough {
properties.push(("strikethrough", strikethrough));
}
if let Some(ref strikethrough_set) = self.strikethrough_set {
properties.push(("strikethrough-set", strikethrough_set));
}
if let Some(ref underline_color) = self.underline_color {
properties.push(("underline-color", underline_color));
}
if let Some(ref underline_color_set) = self.underline_color_set {
properties.push(("underline-color-set", underline_color_set));
}
if let Some(ref underline_set) = self.underline_set {
properties.push(("underline-set", underline_set));
}
let ret = glib::Object::new::<Style>(&properties).expect("object new");
ret
}
pub fn background(mut self, background: &str) -> Self {
self.background = Some(background.to_string());
self
}
pub fn background_set(mut self, background_set: bool) -> Self {
self.background_set = Some(background_set);
self
}
pub fn bold(mut self, bold: bool) -> Self {
self.bold = Some(bold);
self
}
pub fn bold_set(mut self, bold_set: bool) -> Self {
self.bold_set = Some(bold_set);
self
}
pub fn foreground(mut self, foreground: &str) -> Self {
self.foreground = Some(foreground.to_string());
self
}
pub fn foreground_set(mut self, foreground_set: bool) -> Self {
self.foreground_set = Some(foreground_set);
self
}
pub fn italic(mut self, italic: bool) -> Self {
self.italic = Some(italic);
self
}
pub fn italic_set(mut self, italic_set: bool) -> Self {
self.italic_set = Some(italic_set);
self
}
pub fn line_background(mut self, line_background: &str) -> Self {
self.line_background = Some(line_background.to_string());
self
}
pub fn line_background_set(mut self, line_background_set: bool) -> Self {
self.line_background_set = Some(line_background_set);
self
}
pub fn pango_underline(mut self, pango_underline: pango::Underline) -> Self {
self.pango_underline = Some(pango_underline);
self
}
pub fn scale(mut self, scale: &str) -> Self {
self.scale = Some(scale.to_string());
self
}
pub fn scale_set(mut self, scale_set: bool) -> Self {
self.scale_set = Some(scale_set);
self
}
pub fn strikethrough(mut self, strikethrough: bool) -> Self {
self.strikethrough = Some(strikethrough);
self
}
pub fn strikethrough_set(mut self, strikethrough_set: bool) -> Self {
self.strikethrough_set = Some(strikethrough_set);
self
}
pub fn underline_color(mut self, underline_color: &str) -> Self {
self.underline_color = Some(underline_color.to_string());
self
}
pub fn underline_color_set(mut self, underline_color_set: bool) -> Self {
self.underline_color_set = Some(underline_color_set);
self
}
pub fn underline_set(mut self, underline_set: bool) -> Self {
self.underline_set = Some(underline_set);
self
}
}
impl fmt::Display for Style {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Style")
}
}