Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
Manually implement Coverage
Browse files Browse the repository at this point in the history
Before 1.44 it had no get_type() function and had to be handled like a
shared type, since 1.44 it has a get_type() function and can be handled
as a proper GObject.
  • Loading branch information
sdroege committed Jun 11, 2020
1 parent f78e15f commit e0de5db
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 17 deletions.
12 changes: 1 addition & 11 deletions Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ manual = [
"GLib.Error",
"Pango.Analysis",
"Pango.AttrClass",
"Pango.Coverage",
"Pango.Language",
"Pango.Rectangle",
]
Expand Down Expand Up @@ -162,17 +163,6 @@ status = "generate"
name = "language"
const = true

[[object]]
name = "Pango.Coverage"
status = "generate"
[[object.function]]
name = "new"
[object.function.return]
nullable = false
[[object.function]]
name = "get_type"
version = "1.44"

[[object]]
name = "Pango.Font"
status = "generate"
Expand Down
3 changes: 0 additions & 3 deletions src/auto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
mod context;
pub use self::context::{Context, ContextClass};

mod coverage;
pub use self::coverage::{Coverage, CoverageClass};

mod engine_lang;
pub use self::engine_lang::{EngineLang, EngineLangClass, NONE_ENGINE_LANG};

Expand Down
19 changes: 16 additions & 3 deletions src/auto/coverage.rs → src/coverage.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
// Copyright 2020, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>

use glib::translate::*;
use pango_sys;
Expand All @@ -9,6 +9,7 @@ use std::mem;
use std::ptr;
use CoverageLevel;

#[cfg(any(feature = "v1_44", feature = "dox"))]
glib_wrapper! {
pub struct Coverage(Object<pango_sys::PangoCoverage, CoverageClass>);

Expand All @@ -17,6 +18,18 @@ glib_wrapper! {
}
}

// There was no get_type() function before 1.44
#[cfg(not(any(feature = "v1_44", feature = "dox")))]
glib_wrapper! {
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct Coverage(Shared<pango_sys::PangoCoverage>);

match fn {
ref => |ptr| pango_sys::pango_coverage_ref(ptr),
unref => |ptr| pango_sys::pango_coverage_unref(ptr),
}
}

impl Coverage {
pub fn new() -> Coverage {
unsafe { from_glib_full(pango_sys::pango_coverage_new()) }
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ pub use language::Language;
pub mod rectangle;
pub use rectangle::Rectangle;
pub mod glyph;

mod coverage;
pub use coverage::*;

0 comments on commit e0de5db

Please sign in to comment.