...
 
Commits (3)
This diff is collapsed.
This diff is collapsed.
GIR = gir/target/bin/gir
GIR_SRC = gir/Cargo.toml gir/Cargo.lock gir/build.rs $(shell find gir/src -name '*.rs')
GIR_FILES = Dazzle-1.0.gir
# Run `gir` generating the bindings
gir: libdazzle/src/auto/mod.rs
libdazzle/src/auto/mod.rs: libdazzle/Gir.toml $(GIR) $(GIR_FILES)
cp $(GIR_FILES) gir-files
$(GIR) -c libdazzle/Gir.toml
$(GIR): $(GIR_SRC)
rm -f gir/target/bin/gir
cargo install --path gir --root gir/target
rm -f gir/target/.crates.toml
$(GIR_SRC) $(GIR_FILES):
git submodule update --init
Subproject commit 251be82a38c777fbb952331399baed63d9ea70b2
Subproject commit 60cbef05401bd73c3e8a0a7c0cbfb793394acfe7
[build-dependencies]
pkg-config = "0.3.7"
system-deps = "1.3"
[dependencies]
cairo-sys-rs = "0.8.0"
gdk = "0.10.0"
gdk-sys = "0.8.0"
gio = "0.6.0"
gio-sys = "0.8.0"
glib-sys = "0.8.0"
gobject-sys = "0.8.0"
gtk-sys = "0.8.0"
cairo-sys-rs = "0.10.0"
gdk = "0.13"
gdk-sys = "0.10.0"
gio = "0.9.0"
gio-sys = "0.10.0"
glib-sys = "0.10.0"
gobject-sys = "0.10.0"
gtk-sys = "0.10.0"
libc = "0.2"
pango-sys = "0.8.0"
pango-sys = "0.10.0"
[dev-dependencies]
shell-words = "0.1.0"
tempdir = "0.3"
tempfile = "3"
[features]
dox = []
......@@ -25,6 +26,8 @@ v3_26 = ["v3_22"]
v3_28 = ["v3_26"]
v3_30 = ["v3_28"]
v3_32 = ["v3_30"]
v3_34 = ["v3_32"]
v3_36 = ["v3_34"]
[package]
authors = ["Christopher Davis <brainblasted@disroot.org>"]
......@@ -32,6 +35,21 @@ build = "build.rs"
edition = "2018"
license = "GPL-3.0-or-later"
name = "libdazzle-sys"
version = "0.1.0"
version = "0.2.0"
description = "FFI bindings for libdazzle"
repository = "https://gitlab.gnome.org/World/Rust/libdazzle-rs"
[package.metadata.system-deps.libdazzle_1_0]
name = "libdazzle-1.0"
version = "1.0"
[package.metadata.system-deps.libdazzle_1_0.feature-versions]
v3_20 = "3.20"
v3_22 = "3.22"
v3_26 = "3.26"
v3_28 = "3.28"
v3_30 = "3.30"
v3_32 = "3.32"
v3_34 = "3.34"
v3_36 = "3.36"
[package.metadata.docs.rs]
features = ["dox"]
// This file was generated by gir (https://github.com/gtk-rs/gir @ 251be82)
// This file was generated by gir (https://github.com/gtk-rs/gir @ 60cbef0)
// from gir-files (https://github.com/gtk-rs/gir-files @ 617a344)
// DO NOT EDIT
extern crate pkg_config;
#[cfg(not(feature = "dox"))]
extern crate system_deps;
use pkg_config::{Config, Error};
use std::env;
#[cfg(not(feature = "dox"))]
use std::io::prelude::*;
#[cfg(not(feature = "dox"))]
use std::io;
#[cfg(not(feature = "dox"))]
use std::process;
#[cfg(feature = "dox")]
fn main() {} // prevent linking libraries to avoid documentation failure
#[cfg(not(feature = "dox"))]
fn main() {
if let Err(s) = find() {
let _ = writeln!(io::stderr(), "{}", s);
if let Err(s) = system_deps::Config::new().probe() {
let _ = eprintln!("{}", s);
process::exit(1);
}
}
fn find() -> Result<(), Error> {
let package_name = "libdazzle-1.0";
let shared_libs = ["dazzle-1.0"];
let version = if cfg!(feature = "v3_32") {
"3.32"
} else if cfg!(feature = "v3_30") {
"3.30"
} else if cfg!(feature = "v3_28") {
"3.28"
} else if cfg!(feature = "v3_26") {
"3.26"
} else if cfg!(feature = "v3_22") {
"3.22"
} else {
"1.0"
};
if let Ok(inc_dir) = env::var("GTK_INCLUDE_DIR") {
println!("cargo:include={}", inc_dir);
}
if let Ok(lib_dir) = env::var("GTK_LIB_DIR") {
for lib_ in shared_libs.iter() {
println!("cargo:rustc-link-lib=dylib={}", lib_);
}
println!("cargo:rustc-link-search=native={}", lib_dir);
return Ok(())
}
let target = env::var("TARGET").expect("TARGET environment variable doesn't exist");
let hardcode_shared_libs = target.contains("windows");
let mut config = Config::new();
config.atleast_version(version);
config.print_system_libs(false);
if hardcode_shared_libs {
config.cargo_metadata(false);
}
match config.probe(package_name) {
Ok(library) => {
if let Ok(paths) = std::env::join_paths(library.include_paths) {
println!("cargo:include={}", paths.to_string_lossy());
}
if hardcode_shared_libs {
for lib_ in shared_libs.iter() {
println!("cargo:rustc-link-lib=dylib={}", lib_);
}
for path in library.link_paths.iter() {
println!("cargo:rustc-link-search=native={}",
path.to_str().expect("library path doesn't exist"));
}
}
Ok(())
}
Err(Error::EnvNoPkgConfig(_)) | Err(Error::Command { .. }) => {
for lib_ in shared_libs.iter() {
println!("cargo:rustc-link-lib=dylib={}", lib_);
}
Ok(())
}
Err(err) => Err(err),
}
}
// This file was generated by gir (https://github.com/gtk-rs/gir @ 251be82)
// This file was generated by gir (https://github.com/gtk-rs/gir @ 60cbef0)
// from gir-files (https://github.com/gtk-rs/gir-files @ 617a344)
// DO NOT EDIT
......@@ -77,9 +77,9 @@ pub const DZL_DOCK_BIN_STYLE_CLASS_PINNED: *const c_char = b"pinned\0" as *const
pub const DZL_ENABLE_TRACE: c_int = 0;
pub const DZL_LOG_LEVEL_TRACE: glib::GLogLevelFlags = 1;
pub const DZL_MAJOR_VERSION: c_int = 3;
pub const DZL_MICRO_VERSION: c_int = 1;
pub const DZL_MINOR_VERSION: c_int = 32;
pub const DZL_VERSION_S: *const c_char = b"3.32.1\0" as *const u8 as *const c_char;
pub const DZL_MICRO_VERSION: c_int = 0;
pub const DZL_MINOR_VERSION: c_int = 36;
pub const DZL_VERSION_S: *const c_char = b"3.36.0\0" as *const u8 as *const c_char;
// Flags
pub type DzlFileTransferFlags = c_uint;
......@@ -544,6 +544,8 @@ pub struct DzlDockItemInterface {
pub minimize: Option<unsafe extern "C" fn(*mut DzlDockItem, *mut DzlDockItem, *mut gtk::GtkPositionType) -> gboolean>,
pub release: Option<unsafe extern "C" fn(*mut DzlDockItem, *mut DzlDockItem)>,
pub presented: Option<unsafe extern "C" fn(*mut DzlDockItem)>,
pub ref_gicon: Option<unsafe extern "C" fn(*mut DzlDockItem) -> *mut gio::GIcon>,
pub needs_attention: Option<unsafe extern "C" fn(*mut DzlDockItem)>,
}
impl ::std::fmt::Debug for DzlDockItemInterface {
......@@ -565,6 +567,8 @@ impl ::std::fmt::Debug for DzlDockItemInterface {
.field("minimize", &self.minimize)
.field("release", &self.release)
.field("presented", &self.presented)
.field("ref_gicon", &self.ref_gicon)
.field("needs_attention", &self.needs_attention)
.finish()
}
}
......@@ -1773,14 +1777,9 @@ impl ::std::fmt::Debug for DzlShortcutChord {
}
#[repr(C)]
pub struct DzlShortcutChordTable(c_void);
pub struct _DzlShortcutChordTable(c_void);
impl ::std::fmt::Debug for DzlShortcutChordTable {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("DzlShortcutChordTable @ {:?}", self as *const _))
.finish()
}
}
pub type DzlShortcutChordTable = *mut _DzlShortcutChordTable;
#[repr(C)]
#[derive(Copy, Clone)]
......@@ -1983,34 +1982,19 @@ impl ::std::fmt::Debug for DzlShortcutTooltipClass {
}
#[repr(C)]
pub struct DzlShortcutsGroupClass(c_void);
pub struct _DzlShortcutsGroupClass(c_void);
impl ::std::fmt::Debug for DzlShortcutsGroupClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("DzlShortcutsGroupClass @ {:?}", self as *const _))
.finish()
}
}
pub type DzlShortcutsGroupClass = *mut _DzlShortcutsGroupClass;
#[repr(C)]
pub struct DzlShortcutsSectionClass(c_void);
pub struct _DzlShortcutsSectionClass(c_void);
impl ::std::fmt::Debug for DzlShortcutsSectionClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("DzlShortcutsSectionClass @ {:?}", self as *const _))
.finish()
}
}
pub type DzlShortcutsSectionClass = *mut _DzlShortcutsSectionClass;
#[repr(C)]
pub struct DzlShortcutsShortcutClass(c_void);
pub struct _DzlShortcutsShortcutClass(c_void);
impl ::std::fmt::Debug for DzlShortcutsShortcutClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("DzlShortcutsShortcutClass @ {:?}", self as *const _))
.finish()
}
}
pub type DzlShortcutsShortcutClass = *mut _DzlShortcutsShortcutClass;
#[repr(C)]
#[derive(Copy, Clone)]
......@@ -2140,6 +2124,21 @@ impl ::std::fmt::Debug for DzlStateMachineClass {
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct DzlSuggestionButtonClass {
pub parent_class: gtk::GtkStackClass,
pub _reserved: [gpointer; 8],
}
impl ::std::fmt::Debug for DzlSuggestionButtonClass {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("DzlSuggestionButtonClass @ {:?}", self as *const _))
.field("parent_class", &self.parent_class)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct DzlSuggestionClass {
......@@ -2148,8 +2147,8 @@ pub struct DzlSuggestionClass {
pub replace_typed_text: Option<unsafe extern "C" fn(*mut DzlSuggestion, *const c_char) -> *mut c_char>,
pub get_icon: Option<unsafe extern "C" fn(*mut DzlSuggestion) -> *mut gio::GIcon>,
pub get_icon_surface: Option<unsafe extern "C" fn(*mut DzlSuggestion, *mut gtk::GtkWidget) -> *mut cairo::cairo_surface_t>,
pub _reserved3: gpointer,
pub _reserved4: gpointer,
pub get_secondary_icon: Option<unsafe extern "C" fn(*mut DzlSuggestion) -> *mut gio::GIcon>,
pub get_secondary_icon_surface: Option<unsafe extern "C" fn(*mut DzlSuggestion, *mut gtk::GtkWidget) -> *mut cairo::cairo_surface_t>,
}
impl ::std::fmt::Debug for DzlSuggestionClass {
......@@ -2160,8 +2159,8 @@ impl ::std::fmt::Debug for DzlSuggestionClass {
.field("replace_typed_text", &self.replace_typed_text)
.field("get_icon", &self.get_icon)
.field("get_icon_surface", &self.get_icon_surface)
.field("_reserved3", &self._reserved3)
.field("_reserved4", &self._reserved4)
.field("get_secondary_icon", &self.get_secondary_icon)
.field("get_secondary_icon_surface", &self.get_secondary_icon_surface)
.finish()
}
}
......@@ -3601,6 +3600,20 @@ impl ::std::fmt::Debug for DzlSuggestion {
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct DzlSuggestionButton {
pub parent_instance: gtk::GtkStack,
}
impl ::std::fmt::Debug for DzlSuggestionButton {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
f.debug_struct(&format!("DzlSuggestionButton @ {:?}", self as *const _))
.field("parent_instance", &self.parent_instance)
.finish()
}
}
#[repr(C)]
#[derive(Copy, Clone)]
pub struct DzlSuggestionEntry {
......@@ -3967,6 +3980,7 @@ extern "C" {
// DzlApplication
//=========================================================================
pub fn dzl_application_get_type() -> GType;
pub fn dzl_application_new(application_id: *const c_char, flags: gio::GApplicationFlags) -> *mut DzlApplication;
pub fn dzl_application_add_resources(self_: *mut DzlApplication, resource_path: *const c_char);
pub fn dzl_application_get_menu_by_id(self_: *mut DzlApplication, menu_id: *const c_char) -> *mut gio::GMenu;
#[cfg(any(feature = "v3_26", feature = "dox"))]
......@@ -4009,6 +4023,8 @@ extern "C" {
// DzlBoldingLabel
//=========================================================================
pub fn dzl_bolding_label_get_type() -> GType;
pub fn dzl_bolding_label_new(str: *const c_char, bold: gboolean) -> *mut DzlBoldingLabel;
pub fn dzl_bolding_label_new_with_mnemonic(str: *const c_char, bold: gboolean) -> *mut DzlBoldingLabel;
pub fn dzl_bolding_label_set_bold(self_: *mut DzlBoldingLabel, bold: gboolean);
pub fn dzl_bolding_label_set_weight(self_: *mut DzlBoldingLabel, weight: pango::PangoWeight);
......@@ -4204,6 +4220,7 @@ extern "C" {
//=========================================================================
pub fn dzl_dock_widget_get_type() -> GType;
pub fn dzl_dock_widget_new() -> *mut gtk::GtkWidget;
pub fn dzl_dock_widget_set_gicon(self_: *mut DzlDockWidget, gicon: *mut gio::GIcon);
pub fn dzl_dock_widget_set_icon_name(self_: *mut DzlDockWidget, icon_name: *const c_char);
pub fn dzl_dock_widget_set_title(self_: *mut DzlDockWidget, title: *const c_char);
......@@ -4386,7 +4403,6 @@ extern "C" {
// DzlListBoxRow
//=========================================================================
pub fn dzl_list_box_row_get_type() -> GType;
pub fn dzl_list_box_row_new() -> *mut gtk::GtkWidget;
//=========================================================================
// DzlListModelFilter
......@@ -4427,6 +4443,7 @@ extern "C" {
//=========================================================================
// DzlMenuManager
//=========================================================================
#[cfg(any(feature = "v3_26", feature = "dox"))]
pub fn dzl_menu_manager_get_type() -> GType;
#[cfg(any(feature = "v3_26", feature = "dox"))]
pub fn dzl_menu_manager_new() -> *mut DzlMenuManager;
......@@ -4739,6 +4756,9 @@ extern "C" {
pub fn dzl_shortcut_controller_get_context_for_phase(self_: *mut DzlShortcutController, phase: DzlShortcutPhase) -> *mut DzlShortcutContext;
pub fn dzl_shortcut_controller_get_current_chord(self_: *mut DzlShortcutController) -> *const DzlShortcutChord;
pub fn dzl_shortcut_controller_get_manager(self_: *mut DzlShortcutController) -> *mut DzlShortcutManager;
#[cfg(any(feature = "v3_34", feature = "dox"))]
pub fn dzl_shortcut_controller_get_widget(self_: *mut DzlShortcutController) -> *mut gtk::GtkWidget;
pub fn dzl_shortcut_controller_remove_accel(self_: *mut DzlShortcutController, accel: *const c_char, phase: DzlShortcutPhase);
#[cfg(any(feature = "v3_26", feature = "dox"))]
pub fn dzl_shortcut_controller_set_context_by_name(self_: *mut DzlShortcutController, name: *const c_char);
pub fn dzl_shortcut_controller_set_manager(self_: *mut DzlShortcutController, manager: *mut DzlShortcutManager);
......@@ -4975,15 +4995,31 @@ extern "C" {
#[cfg(any(feature = "v3_30", feature = "dox"))]
pub fn dzl_suggestion_get_icon_surface(self_: *mut DzlSuggestion, widget: *mut gtk::GtkWidget) -> *mut cairo::cairo_surface_t;
pub fn dzl_suggestion_get_id(self_: *mut DzlSuggestion) -> *const c_char;
#[cfg(any(feature = "v3_36", feature = "dox"))]
pub fn dzl_suggestion_get_secondary_icon(self_: *mut DzlSuggestion) -> *mut gio::GIcon;
pub fn dzl_suggestion_get_secondary_icon_name(self_: *mut DzlSuggestion) -> *const c_char;
#[cfg(any(feature = "v3_36", feature = "dox"))]
pub fn dzl_suggestion_get_secondary_icon_surface(self_: *mut DzlSuggestion, widget: *mut gtk::GtkWidget) -> *mut cairo::cairo_surface_t;
pub fn dzl_suggestion_get_subtitle(self_: *mut DzlSuggestion) -> *const c_char;
pub fn dzl_suggestion_get_title(self_: *mut DzlSuggestion) -> *const c_char;
pub fn dzl_suggestion_replace_typed_text(self_: *mut DzlSuggestion, typed_text: *const c_char) -> *mut c_char;
pub fn dzl_suggestion_set_icon_name(self_: *mut DzlSuggestion, icon_name: *const c_char);
pub fn dzl_suggestion_set_id(self_: *mut DzlSuggestion, id: *const c_char);
pub fn dzl_suggestion_set_secondary_icon_name(self_: *mut DzlSuggestion, icon_name: *const c_char);
pub fn dzl_suggestion_set_subtitle(self_: *mut DzlSuggestion, subtitle: *const c_char);
pub fn dzl_suggestion_set_title(self_: *mut DzlSuggestion, title: *const c_char);
pub fn dzl_suggestion_suggest_suffix(self_: *mut DzlSuggestion, typed_text: *const c_char) -> *mut c_char;
//=========================================================================
// DzlSuggestionButton
//=========================================================================
pub fn dzl_suggestion_button_get_type() -> GType;
pub fn dzl_suggestion_button_new() -> *mut gtk::GtkWidget;
#[cfg(any(feature = "v3_34", feature = "dox"))]
pub fn dzl_suggestion_button_get_button(self_: *mut DzlSuggestionButton) -> *mut gtk::GtkButton;
#[cfg(any(feature = "v3_34", feature = "dox"))]
pub fn dzl_suggestion_button_get_entry(self_: *mut DzlSuggestionButton) -> *mut DzlSuggestionEntry;
//=========================================================================
// DzlSuggestionEntry
//=========================================================================
......@@ -4991,6 +5027,8 @@ extern "C" {
pub fn dzl_suggestion_entry_new() -> *mut gtk::GtkWidget;
pub fn dzl_suggestion_entry_default_position_func(self_: *mut DzlSuggestionEntry, area: *mut gdk::GdkRectangle, is_absolute: *mut gboolean, user_data: gpointer);
pub fn dzl_suggestion_entry_get_activate_on_single_click(self_: *mut DzlSuggestionEntry) -> gboolean;
#[cfg(any(feature = "v3_34", feature = "dox"))]
pub fn dzl_suggestion_entry_get_compact(self_: *mut DzlSuggestionEntry) -> gboolean;
pub fn dzl_suggestion_entry_get_model(self_: *mut DzlSuggestionEntry) -> *mut gio::GListModel;
#[cfg(any(feature = "v3_32", feature = "dox"))]
pub fn dzl_suggestion_entry_get_popover(self_: *mut DzlSuggestionEntry) -> *mut gtk::GtkWidget;
......@@ -4998,6 +5036,8 @@ extern "C" {
pub fn dzl_suggestion_entry_get_typed_text(self_: *mut DzlSuggestionEntry) -> *const c_char;
pub fn dzl_suggestion_entry_hide_suggestions(self_: *mut DzlSuggestionEntry);
pub fn dzl_suggestion_entry_set_activate_on_single_click(self_: *mut DzlSuggestionEntry, activate_on_single_click: gboolean);
#[cfg(any(feature = "v3_34", feature = "dox"))]
pub fn dzl_suggestion_entry_set_compact(self_: *mut DzlSuggestionEntry, compact: gboolean);
pub fn dzl_suggestion_entry_set_model(self_: *mut DzlSuggestionEntry, model: *mut gio::GListModel);
#[cfg(any(feature = "v3_26", feature = "dox"))]
pub fn dzl_suggestion_entry_set_position_func(self_: *mut DzlSuggestionEntry, func: DzlSuggestionPositionFunc, func_data: gpointer, func_data_destroy: glib::GDestroyNotify);
......@@ -5054,6 +5094,7 @@ extern "C" {
pub fn dzl_tab_set_active(self_: *mut DzlTab, active: gboolean);
pub fn dzl_tab_set_can_close(self_: *mut DzlTab, can_close: gboolean);
pub fn dzl_tab_set_edge(self_: *mut DzlTab, edge: gtk::GtkPositionType);
pub fn dzl_tab_set_gicon(self_: *mut DzlTab, gicon: *mut gio::GIcon);
pub fn dzl_tab_set_icon_name(self_: *mut DzlTab, icon_name: *const c_char);
pub fn dzl_tab_set_style(self_: *mut DzlTab, style: DzlTabStyle);
pub fn dzl_tab_set_title(self_: *mut DzlTab, title: *const c_char);
......@@ -5211,8 +5252,12 @@ extern "C" {
pub fn dzl_dock_item_get_title(self_: *mut DzlDockItem) -> *mut c_char;
pub fn dzl_dock_item_has_widgets(self_: *mut DzlDockItem) -> gboolean;
pub fn dzl_dock_item_minimize(self_: *mut DzlDockItem, child: *mut DzlDockItem, position: *mut gtk::GtkPositionType) -> gboolean;
#[cfg(any(feature = "v3_34", feature = "dox"))]
pub fn dzl_dock_item_needs_attention(self_: *mut DzlDockItem);
pub fn dzl_dock_item_present(self_: *mut DzlDockItem);
pub fn dzl_dock_item_present_child(self_: *mut DzlDockItem, child: *mut DzlDockItem);
#[cfg(any(feature = "v3_34", feature = "dox"))]
pub fn dzl_dock_item_ref_gicon(self_: *mut DzlDockItem) -> *mut gio::GIcon;
pub fn dzl_dock_item_release(self_: *mut DzlDockItem, child: *mut DzlDockItem);
pub fn dzl_dock_item_set_child_visible(self_: *mut DzlDockItem, child: *mut DzlDockItem, child_visible: gboolean);
pub fn dzl_dock_item_set_manager(self_: *mut DzlDockItem, manager: *mut DzlDockManager);
......
// This file was generated by gir (https://github.com/gtk-rs/gir @ 251be82)
// This file was generated by gir (https://github.com/gtk-rs/gir @ 60cbef0)
// from gir-files (https://github.com/gtk-rs/gir-files @ 617a344)
// DO NOT EDIT
extern crate libdazzle_sys;
extern crate shell_words;
extern crate tempdir;
extern crate tempfile;
use std::env;
use std::error::Error;
use std::path::Path;
use std::mem::{align_of, size_of};
use std::process::Command;
use std::str;
use tempfile::Builder;
use libdazzle_sys::*;
static PACKAGES: &[&str] = &["libdazzle-1.0"];
......@@ -21,7 +22,7 @@ struct Compiler {
}
impl Compiler {
pub fn new() -> Result<Compiler, Box<Error>> {
pub fn new() -> Result<Compiler, Box<dyn Error>> {
let mut args = get_var("CC", "cc")?;
args.push("-Wno-deprecated-declarations".to_owned());
// For %z support in printf when using MinGW.
......@@ -40,7 +41,7 @@ impl Compiler {
self.args.push(arg);
}
pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box<Error>> {
pub fn compile(&self, src: &Path, out: &Path) -> Result<(), Box<dyn Error>> {
let mut cmd = self.to_command();
cmd.arg(src);
cmd.arg("-o");
......@@ -60,7 +61,7 @@ impl Compiler {
}
}
fn get_var(name: &str, default: &str) -> Result<Vec<String>, Box<Error>> {
fn get_var(name: &str, default: &str) -> Result<Vec<String>, Box<dyn Error>> {
match env::var(name) {
Ok(value) => Ok(shell_words::split(&value)?),
Err(env::VarError::NotPresent) => Ok(shell_words::split(default)?),
......@@ -68,7 +69,7 @@ fn get_var(name: &str, default: &str) -> Result<Vec<String>, Box<Error>> {
}
}
fn pkg_config_cflags(packages: &[&str]) -> Result<Vec<String>, Box<Error>> {
fn pkg_config_cflags(packages: &[&str]) -> Result<Vec<String>, Box<dyn Error>> {
if packages.is_empty() {
return Ok(Vec::new());
}
......@@ -130,7 +131,7 @@ impl Results {
#[test]
fn cross_validate_constants_with_c() {
let tmpdir = tempdir::TempDir::new("abi").expect("temporary directory");
let tmpdir = Builder::new().prefix("abi").tempdir().expect("temporary directory");
let cc = Compiler::new().expect("configured compiler");
assert_eq!("1",
......@@ -163,7 +164,7 @@ fn cross_validate_constants_with_c() {
#[test]
fn cross_validate_layout_with_c() {
let tmpdir = tempdir::TempDir::new("abi").expect("temporary directory");
let tmpdir = Builder::new().prefix("abi").tempdir().expect("temporary directory");
let cc = Compiler::new().expect("configured compiler");
assert_eq!(Layout {size: 1, alignment: 1},
......@@ -194,7 +195,7 @@ fn cross_validate_layout_with_c() {
results.expect_total_success();
}
fn get_c_layout(dir: &Path, cc: &Compiler, name: &str) -> Result<Layout, Box<Error>> {
fn get_c_layout(dir: &Path, cc: &Compiler, name: &str) -> Result<Layout, Box<dyn Error>> {
let exe = dir.join("layout");
let mut cc = cc.clone();
cc.define("ABI_TYPE_NAME", name);
......@@ -214,7 +215,7 @@ fn get_c_layout(dir: &Path, cc: &Compiler, name: &str) -> Result<Layout, Box<Err
Ok(Layout {size, alignment})
}
fn get_c_value(dir: &Path, cc: &Compiler, name: &str) -> Result<String, Box<Error>> {
fn get_c_value(dir: &Path, cc: &Compiler, name: &str) -> Result<String, Box<dyn Error>> {
let exe = dir.join("constant");
let mut cc = cc.clone();
cc.define("ABI_CONSTANT_NAME", name);
......@@ -393,6 +394,8 @@ const RUST_LAYOUTS: &[(&str, Layout)] = &[
("DzlStateMachine", Layout {size: size_of::<DzlStateMachine>(), alignment: align_of::<DzlStateMachine>()}),
("DzlStateMachineClass", Layout {size: size_of::<DzlStateMachineClass>(), alignment: align_of::<DzlStateMachineClass>()}),
("DzlSuggestion", Layout {size: size_of::<DzlSuggestion>(), alignment: align_of::<DzlSuggestion>()}),
("DzlSuggestionButton", Layout {size: size_of::<DzlSuggestionButton>(), alignment: align_of::<DzlSuggestionButton>()}),
("DzlSuggestionButtonClass", Layout {size: size_of::<DzlSuggestionButtonClass>(), alignment: align_of::<DzlSuggestionButtonClass>()}),
("DzlSuggestionClass", Layout {size: size_of::<DzlSuggestionClass>(), alignment: align_of::<DzlSuggestionClass>()}),
("DzlSuggestionEntry", Layout {size: size_of::<DzlSuggestionEntry>(), alignment: align_of::<DzlSuggestionEntry>()}),
("DzlSuggestionEntryBuffer", Layout {size: size_of::<DzlSuggestionEntryBuffer>(), alignment: align_of::<DzlSuggestionEntryBuffer>()}),
......@@ -439,8 +442,8 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[
("(guint) DZL_FILE_TRANSFER_FLAGS_NONE", "0"),
("DZL_LOG_LEVEL_TRACE", "1"),
("DZL_MAJOR_VERSION", "3"),
("DZL_MICRO_VERSION", "1"),
("DZL_MINOR_VERSION", "32"),
("DZL_MICRO_VERSION", "0"),
("DZL_MINOR_VERSION", "36"),
("(guint) DZL_PROPERTIES_FLAGS_NONE", "0"),
("(guint) DZL_PROPERTIES_FLAGS_STATEFUL_BOOLEANS", "1"),
("(gint) DZL_SHORTCUT_ACCELERATOR", "0"),
......@@ -472,7 +475,7 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[
("(gint) DZL_TREE_DROP_AFTER", "2"),
("(gint) DZL_TREE_DROP_BEFORE", "1"),
("(gint) DZL_TREE_DROP_INTO", "0"),
("DZL_VERSION_S", "3.32.1"),
("DZL_VERSION_S", "3.36.0"),
];
// This file was generated by gir (https://github.com/gtk-rs/gir @ 251be82)
// This file was generated by gir (https://github.com/gtk-rs/gir @ 60cbef0)
// from gir-files (https://github.com/gtk-rs/gir-files @ 617a344)
// DO NOT EDIT
......
// This file was generated by gir (https://github.com/gtk-rs/gir @ 251be82)
// This file was generated by gir (https://github.com/gtk-rs/gir @ 60cbef0)
// from gir-files (https://github.com/gtk-rs/gir-files @ 617a344)
// DO NOT EDIT
......
......@@ -2,7 +2,7 @@
name = "libdazzle"
authors = ["Christopher Davis <brainblasted@disroot.org>"]
keywords = [ "dazzle", "libdazzle", "gtk-rs", "gtk", "gnome"]
version = "0.1.0"
version = "0.2.0"
description = "Rust bindings for libdazzle"
license = "GPL-3.0-or-later"
repository = "https://gitlab.gnome.org/World/Rust/libdazzle-rs"
......@@ -15,30 +15,30 @@ exclude = [
name = "dazzle"
[dependencies]
cairo-rs = "0.6.0"
cairo-sys-rs = "0.8.0"
cairo-rs = "0.9.1"
cairo-sys-rs = "0.10.0"
bitflags = "1.0.4"
gdk-sys = "0.8.0"
gio-sys = "0.8.0"
glib = "0.7.1"
glib-sys = "0.8.0"
gobject-sys = "0.8.0"
gtk = "0.6.0"
gtk-sys = "0.8.0"
gdk-sys = "0.10.0"
gio-sys = "0.10.0"
glib = "0.10.1"
glib-sys = "0.10.0"
gobject-sys = "0.10.0"
gtk = "0.9.0"
gtk-sys = "0.10.0"
libc = "0.2.51"
pango = "0.6.0"
pango-sys = "0.8.0"
pango = "0.9.0"
pango-sys = "0.10.0"
[dependencies.gdk]
version = "0.10.0"
version = "0.13"
features = ["v3_22"]
[dependencies.gio]
version = "0.6.0"
version = "0.9"
features = ["v2_44"]
[dependencies.libdazzle-sys]
version = "0.1.0"
version = "0.2.0"
path = "../libdazzle-sys"
[features]
......
[options]
girs_dir = "gir-files"
girs_dir = "../gir-files"
library = "Dazzle"
version = "1.0"
min_cfg_version = "0.0"
......
......@@ -6,8 +6,8 @@ use dazzle_sys;
use gdk;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib_sys;
use std::boxed::Box as Box_;
......@@ -23,38 +23,23 @@ glib_wrapper! {
}
impl Animation {
pub fn calculate_duration<P: IsA<gdk::Monitor>>(monitor: &P, from_value: f64, to_value: f64) -> u32 {
pub fn calculate_duration(monitor: &gdk::Monitor, from_value: f64, to_value: f64) -> u32 {
assert_initialized_main_thread!();
unsafe {
dazzle_sys::dzl_animation_calculate_duration(monitor.as_ref().to_glib_none().0, from_value, to_value)
dazzle_sys::dzl_animation_calculate_duration(monitor.to_glib_none().0, from_value, to_value)
}
}
}
pub const NONE_ANIMATION: Option<&Animation> = None;
/// Trait containing all `Animation` methods.
///
/// # Implementors
///
/// [`Animation`](struct.Animation.html)
pub trait AnimationExt: 'static {
//fn add_property(&self, pspec: /*Ignored*/&glib::ParamSpec, value: &glib::Value);
/// Start the animation. When the animation stops, the internal reference will
/// be dropped and the animation may be finalized.
///
/// Side effects: None.
fn start(&self);
/// Stops a running animation. The internal reference to the animation is
/// dropped and therefore may cause the object to finalize.
///
/// As a convenience, this function accepts `None` for `self` but
/// does nothing if that should occur.
fn stop(&self);
/// The "tick" signal is emitted on each frame in the animation.
fn connect_tick<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
}
......@@ -76,20 +61,20 @@ impl<O: IsA<Animation>> AnimationExt for O {
}
fn connect_tick<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn tick_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlAnimation, f: glib_sys::gpointer)
where P: IsA<Animation>
{
let f: &F = &*(f as *const F);
f(&Animation::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"tick\0".as_ptr() as *const _,
Some(transmute(tick_trampoline::<Self, F> as usize)), Box_::into_raw(f))
Some(transmute::<_, unsafe extern "C" fn()>(tick_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
}
unsafe extern "C" fn tick_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlAnimation, f: glib_sys::gpointer)
where P: IsA<Animation> {
let f: &F = &*(f as *const F);
f(&Animation::from_glib_borrow(this).unsafe_cast())
}
impl fmt::Display for Animation {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Animation")
......
......@@ -2,24 +2,24 @@
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use MenuManager;
use ShortcutManager;
use ThemeManager;
use dazzle_sys;
use gio;
use glib::StaticType;
use glib::Value;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::Value;
use glib_sys;
use gobject_sys;
use gtk;
use std::boxed::Box as Box_;
use std::fmt;
use std::mem::transmute;
use MenuManager;
use ShortcutManager;
use ThemeManager;
glib_wrapper! {
pub struct Application(Object<dazzle_sys::DzlApplication, dazzle_sys::DzlApplicationClass, ApplicationClass>) @extends gtk::Application, @implements gio::ActionGroup;
......@@ -29,65 +29,26 @@ glib_wrapper! {
}
}
impl Application {
//pub fn new(application_id: &str, flags: /*Ignored*/gio::ApplicationFlags) -> Application {
// unsafe { TODO: call dazzle_sys:dzl_application_new() }
//}
}
pub const NONE_APPLICATION: Option<&Application> = None;
/// Trait containing all `Application` methods.
///
/// # Implementors
///
/// [`Application`](struct.Application.html)
pub trait ApplicationExt: 'static {
/// This adds `resource_path` to the list of "automatic resources".
///
/// If `resource_path` starts with "resource://", then the corresponding
/// `GResources` path will be searched for resources. Otherwise, `resource_path`
/// should be a path to a location on disk.
///
/// The `Application` will locate resources such as CSS themes, icons, and
/// keyboard shortcuts using `resource_path`.
/// ## `resource_path`
/// the location of the resources.
fn add_resources(&self, resource_path: &str);
/// Similar to `gtk::ApplicationExt::get_menu_by_id` but takes into account
/// menu merging which could have occurred upon loading plugins.
/// ## `menu_id`
/// the id of the menu to locate
///
/// # Returns
///
/// A `gio::Menu`
fn get_menu_by_id(&self, menu_id: &str) -> Option<gio::Menu>;
/// Gets the menu manager for the application.
///
/// Feature: `v3_26`
///
///
/// # Returns
///
/// A `MenuManager`
#[cfg(any(feature = "v3_26", feature = "dox"))]
fn get_menu_manager(&self) -> Option<MenuManager>;
/// Gets the `ShortcutManager` for the application.
///
/// # Returns
///
/// A `ShortcutManager`
fn get_shortcut_manager(&self) -> Option<ShortcutManager>;
/// Get the theme manager for the application.
///
/// # Returns
///
/// A `ThemeManager`
fn get_theme_manager(&self) -> Option<ThemeManager>;
/// This attempts to undo as many side-effects as possible from a call to
/// `ApplicationExt::add_resources`.
/// ## `resource_path`
/// the location of the resources.
fn remove_resources(&self, resource_path: &str);
fn get_property_menu_manager(&self) -> Option<MenuManager>;
......@@ -141,53 +102,53 @@ impl<O: IsA<Application>> ApplicationExt for O {
unsafe {
let mut value = Value::from_type(<MenuManager as StaticType>::static_type());
gobject_sys::g_object_get_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"menu-manager\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get()
value.get().expect("Return Value for property `menu-manager` getter")
}
}
fn connect_property_menu_manager_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_menu_manager_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<Application>
{
let f: &F = &*(f as *const F);
f(&Application::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::menu-manager\0".as_ptr() as *const _,
Some(transmute(notify_menu_manager_trampoline::<Self, F> as usize)), Box_::into_raw(f))
Some(transmute::<_, unsafe extern "C" fn()>(notify_menu_manager_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
fn connect_property_shortcut_manager_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_shortcut_manager_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<Application>
{
let f: &F = &*(f as *const F);
f(&Application::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::shortcut-manager\0".as_ptr() as *const _,
Some(transmute(notify_shortcut_manager_trampoline::<Self, F> as usize)), Box_::into_raw(f))
Some(transmute::<_, unsafe extern "C" fn()>(notify_shortcut_manager_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
fn connect_property_theme_manager_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_theme_manager_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<Application>
{
let f: &F = &*(f as *const F);
f(&Application::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::theme-manager\0".as_ptr() as *const _,
Some(transmute(notify_theme_manager_trampoline::<Self, F> as usize)), Box_::into_raw(f))
Some(transmute::<_, unsafe extern "C" fn()>(notify_theme_manager_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
}
unsafe extern "C" fn notify_menu_manager_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<Application> {
let f: &F = &*(f as *const F);
f(&Application::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_shortcut_manager_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<Application> {
let f: &F = &*(f as *const F);
f(&Application::from_glib_borrow(this).unsafe_cast())
}
unsafe extern "C" fn notify_theme_manager_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlApplication, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<Application> {
let f: &F = &*(f as *const F);
f(&Application::from_glib_borrow(this).unsafe_cast())
}
impl fmt::Display for Application {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Application")
......
......@@ -4,13 +4,13 @@
use dazzle_sys;
use gio;
use glib::StaticType;
use glib::Value;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::StaticType;
use glib::Value;
use glib_sys;
use gobject_sys;
use gtk;
......@@ -28,76 +28,21 @@ glib_wrapper! {
pub const NONE_APPLICATION_WINDOW: Option<&ApplicationWindow> = None;
/// Trait containing all `ApplicationWindow` methods.
///
/// Feature: `v3_26`
///
/// # Implementors
///
/// [`ApplicationWindow`](struct.ApplicationWindow.html)
pub trait ApplicationWindowExt: 'static {
/// Gets if the window is in the fullscreen state.
///
/// Feature: `v3_26`
///
///
/// # Returns
///
/// `true` if `self` is fullscreen, otherwise `false`.
#[cfg(any(feature = "v3_26", feature = "dox"))]
fn get_fullscreen(&self) -> bool;
/// Gets the titlebar for the window, if there is one.
///
/// Feature: `v3_26`
///
///
/// # Returns
///
/// A `gtk::Widget` or `None`
#[cfg(any(feature = "v3_26", feature = "dox"))]
fn get_titlebar(&self) -> Option<gtk::Widget>;
/// Sets the `ApplicationWindow` into either the fullscreen or unfullscreen
/// state based on `fullscreen`.
///
/// The titlebar for the window is contained within a `gtk::Revealer` which is
/// repurposed as a floating bar when the application is in fullscreen mode.
///
/// See `ApplicationWindowExt::get_fullscreen` to get the current fullscreen
/// state.
///
/// Feature: `v3_26`
///
/// ## `fullscreen`
/// if the window should be in the fullscreen state
#[cfg(any(feature = "v3_26", feature = "dox"))]
fn set_fullscreen(&self, fullscreen: bool);
/// Sets the titlebar for the window.
///
/// Generally, you want to do this from your GTK ui template by setting
/// the &lt;child type="titlebar"&gt;
///
/// Feature: `v3_26`
///
#[cfg(any(feature = "v3_26", feature = "dox"))]
fn set_titlebar<P: IsA<gtk::Widget>>(&self, titlebar: &P);
/// The "fullscreen" property denotes if the window is in the fullscreen
/// state. The titlebar of the `ApplicationWindow` contains a revealer
/// which will be repurposed into a floating bar while the window is in
/// the fullscreen mode.
///
/// Set this property to `false` to unfullscreen.
fn get_property_fullscreen(&self) -> bool;
/// The "fullscreen" property denotes if the window is in the fullscreen
/// state. The titlebar of the `ApplicationWindow` contains a revealer
/// which will be repurposed into a floating bar while the window is in
/// the fullscreen mode.
///
/// Set this property to `false` to unfullscreen.
fn set_property_fullscreen(&self, fullscreen: bool);
fn connect_property_fullscreen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
......@@ -136,7 +81,7 @@ impl<O: IsA<ApplicationWindow>> ApplicationWindowExt for O {
unsafe {
let mut value = Value::from_type(<bool as StaticType>::static_type());
gobject_sys::g_object_get_property(self.to_glib_none().0 as *mut gobject_sys::GObject, b"fullscreen\0".as_ptr() as *const _, value.to_glib_none_mut().0);
value.get().unwrap()
value.get().expect("Return Value for property `fullscreen` getter").unwrap()
}
}
......@@ -147,20 +92,20 @@ impl<O: IsA<ApplicationWindow>> ApplicationWindowExt for O {
}
fn connect_property_fullscreen_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_fullscreen_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlApplicationWindow, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<ApplicationWindow>
{
let f: &F = &*(f as *const F);
f(&ApplicationWindow::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::fullscreen\0".as_ptr() as *const _,
Some(transmute(notify_fullscreen_trampoline::<Self, F> as usize)), Box_::into_raw(f))
Some(transmute::<_, unsafe extern "C" fn()>(notify_fullscreen_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
}
unsafe extern "C" fn notify_fullscreen_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlApplicationWindow, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<ApplicationWindow> {
let f: &F = &*(f as *const F);
f(&ApplicationWindow::from_glib_borrow(this).unsafe_cast())
}
impl fmt::Display for ApplicationWindow {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "ApplicationWindow")
......
......@@ -6,8 +6,8 @@ use dazzle_sys;
use glib;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib_sys;
use std::boxed::Box as Box_;
......@@ -23,11 +23,6 @@ glib_wrapper! {
}
impl BindingGroup {
/// Creates a new `BindingGroup`.
///
/// # Returns
///
/// a new `BindingGroup`
pub fn new() -> BindingGroup {
assert_initialized_main_thread!();
unsafe {
......@@ -44,72 +39,15 @@ impl Default for BindingGroup {
pub const NONE_BINDING_GROUP: Option<&BindingGroup> = None;
/// Trait containing all `BindingGroup` methods.
///
/// # Implementors
///
/// [`BindingGroup`](struct.BindingGroup.html)
pub trait BindingGroupExt: 'static {
/// Creates a binding between `source_property` on the source object
/// and `target_property` on `target`. Whenever the `source_property`
/// is changed the `target_property` is updated using the same value.
/// The binding flags `gobject::BindingFlags::SyncCreate` is automatically specified.
///
/// See: `gobject::ObjectExt::bind_property`.
/// ## `source_property`
/// the property on the source to bind
/// ## `target`
/// the target `gobject::Object`
/// ## `target_property`
/// the property on `target` to bind
/// ## `flags`
/// the flags used to create the `gobject::Binding`
fn bind<P: IsA<glib::Object>>(&self, source_property: &str, target: &P, target_property: &str, flags: glib::BindingFlags);
//fn bind_full<P: IsA<glib::Object>>(&self, source_property: &str, target: &P, target_property: &str, flags: glib::BindingFlags, transform_to: glib::Option<Box<dyn Fn(&glib::Binding, &glib::Value, &glib::Value) -> bool + 'static>>, transform_from: glib::Option<Box<dyn Fn(&glib::Binding, &glib::Value, &glib::Value) -> bool + 'static>>);
/// Creates a binding between `source_property` on the source object and
/// `target_property` on `target`, allowing you to set the transformation
/// functions to be used by the binding. The binding flags
/// `gobject::BindingFlags::SyncCreate` is automatically specified.
///
/// This function is the language bindings friendly version of
/// `dzl_binding_group_bind_property_full`, using `GClosures`
/// instead of function pointers.
///
/// See: `gobject::ObjectExt::bind_property_with_closures`.
/// ## `source_property`
/// the property on the source to bind
/// ## `target`
/// the target `gobject::Object`
/// ## `target_property`
/// the property on `target` to bind
/// ## `flags`
/// the flags used to create the `gobject::Binding`
/// ## `transform_to`
/// a `gobject::Closure` wrapping the
/// transformation function from the source object to the `target`,
/// or `None` to use the default
/// ## `transform_from`
/// a `gobject::Closure` wrapping the
/// transformation function from the `target` to the source object,
/// or `None` to use the default
//fn bind_full<P: IsA<glib::Object>>(&self, source_property: &str, target: &P, target_property: &str, flags: glib::BindingFlags, transform_to: Option<Box_<dyn Fn(&glib::Binding, &glib::Value, &glib::Value) -> bool + 'static>>, transform_from: Option<Box_<dyn Fn(&glib::Binding, &glib::Value, &glib::Value) -> bool + 'static>>);
fn bind_with_closures<P: IsA<glib::Object>>(&self, source_property: &str, target: &P, target_property: &str, flags: glib::BindingFlags, transform_to: Option<&glib::Closure>, transform_from: Option<&glib::Closure>);
/// Gets the source object used for binding properties.
///
/// # Returns
///
/// the source object.
fn get_source(&self) -> Option<glib::Object>;
/// Sets `source` as the source object used for creating property
/// bindings. If there is already a source object all bindings from it
/// will be removed.
///
/// Note: All properties that have been bound must exist on `source`.
/// ## `source`
/// the source `gobject::Object`
fn set_source<P: IsA<glib::Object>>(&self, source: Option<&P>);
fn connect_property_source_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
......@@ -122,7 +60,7 @@ impl<O: IsA<BindingGroup>> BindingGroupExt for O {
}
}
//fn bind_full<P: IsA<glib::Object>>(&self, source_property: &str, target: &P, target_property: &str, flags: glib::BindingFlags, transform_to: glib::Option<Box<dyn Fn(&glib::Binding, &glib::Value, &glib::Value) -> bool + 'static>>, transform_from: glib::Option<Box<dyn Fn(&glib::Binding, &glib::Value, &glib::Value) -> bool + 'static>>) {
//fn bind_full<P: IsA<glib::Object>>(&self, source_property: &str, target: &P, target_property: &str, flags: glib::BindingFlags, transform_to: Option<Box_<dyn Fn(&glib::Binding, &glib::Value, &glib::Value) -> bool + 'static>>, transform_from: Option<Box_<dyn Fn(&glib::Binding, &glib::Value, &glib::Value) -> bool + 'static>>) {
// unsafe { TODO: call dazzle_sys:dzl_binding_group_bind_full() }
//}
......@@ -145,20 +83,20 @@ impl<O: IsA<BindingGroup>> BindingGroupExt for O {
}
fn connect_property_source_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_source_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlBindingGroup, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<BindingGroup>
{
let f: &F = &*(f as *const F);
f(&BindingGroup::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::source\0".as_ptr() as *const _,
Some(transmute(notify_source_trampoline::<Self, F> as usize)), Box_::into_raw(f))
Some(transmute::<_, unsafe extern "C" fn()>(notify_source_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
}
unsafe extern "C" fn notify_source_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlBindingGroup, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<BindingGroup> {
let f: &F = &*(f as *const F);
f(&BindingGroup::from_glib_borrow(this).unsafe_cast())
}
impl fmt::Display for BindingGroup {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "BindingGroup")
......
......@@ -5,8 +5,8 @@
use dazzle_sys;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib_sys;
use gtk;
......@@ -23,13 +23,24 @@ glib_wrapper! {
}
}
impl BoldingLabel {
pub fn new(str: &str, bold: bool) -> BoldingLabel {
assert_initialized_main_thread!();
unsafe {
from_glib_none(dazzle_sys::dzl_bolding_label_new(str.to_glib_none().0, bold.to_glib()))
}
}
pub fn with_mnemonic(str: &str, bold: bool) -> BoldingLabel {
assert_initialized_main_thread!();
unsafe {
from_glib_none(dazzle_sys::dzl_bolding_label_new_with_mnemonic(str.to_glib_none().0, bold.to_glib()))
}
}
}
pub const NONE_BOLDING_LABEL: Option<&BoldingLabel> = None;
/// Trait containing all `BoldingLabel` methods.
///
/// # Implementors
///
/// [`BoldingLabel`](struct.BoldingLabel.html)
pub trait BoldingLabelExt: 'static {
fn set_bold(&self, bold: bool);
......@@ -52,20 +63,20 @@ impl<O: IsA<BoldingLabel>> BoldingLabelExt for O {
}
fn connect_property_bold_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_bold_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlBoldingLabel, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<BoldingLabel>
{
let f: &F = &*(f as *const F);
f(&BoldingLabel::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::bold\0".as_ptr() as *const _,
Some(transmute(notify_bold_trampoline::<Self, F> as usize)), Box_::into_raw(f))
Some(transmute::<_, unsafe extern "C" fn()>(notify_bold_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
}
unsafe extern "C" fn notify_bold_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlBoldingLabel, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<BoldingLabel> {
let f: &F = &*(f as *const F);
f(&BoldingLabel::from_glib_borrow(this).unsafe_cast())
}
impl fmt::Display for BoldingLabel {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "BoldingLabel")
......
......@@ -5,8 +5,8 @@
use dazzle_sys;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib_sys;
use gtk;
......@@ -39,21 +39,9 @@ impl Default for Box {
pub const NONE_BOX: Option<&Box> = None;
/// Trait containing all `Box` methods.
///
/// # Implementors
///
/// [`Box`](struct.Box.html)
pub trait BoxExt: 'static {
fn get_max_width_request(&self) -> i32;
/// Gets the nth child of `self`.
/// ## `nth`
/// the index of the child starting from 0
///
/// # Returns
///
/// A `gtk::Widget` or `None`
fn get_nth_child(&self, nth: u32) -> Option<gtk::Widget>;
fn set_max_width_request(&self, max_width_request: i32);
......@@ -81,20 +69,20 @@ impl<O: IsA<Box>> BoxExt for O {
}
fn connect_property_max_width_request_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
unsafe extern "C" fn notify_max_width_request_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlBox, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<Box>
{
let f: &F = &*(f as *const F);
f(&Box::from_glib_borrow(this).unsafe_cast_ref())
}
unsafe {
let f: Box_<F> = Box_::new(f);
connect_raw(self.as_ptr() as *mut _, b"notify::max-width-request\0".as_ptr() as *const _,
Some(transmute(notify_max_width_request_trampoline::<Self, F> as usize)), Box_::into_raw(f))
Some(transmute::<_, unsafe extern "C" fn()>(notify_max_width_request_trampoline::<Self, F> as *const ())), Box_::into_raw(f))
}
}
}
unsafe extern "C" fn notify_max_width_request_trampoline<P, F: Fn(&P) + 'static>(this: *mut dazzle_sys::DzlBox, _param_spec: glib_sys::gpointer, f: glib_sys::gpointer)
where P: IsA<Box> {
let f: &F = &*(f as *const F);
f(&Box::from_glib_borrow(this).unsafe_cast())
}
impl fmt::Display for Box {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Box")
......
......@@ -4,14 +4,15 @@
use dazzle_sys;
use gio;
use glib::GString;
use glib::StaticType;
use glib::Value;
use glib::object::Cast;
use glib::object::IsA;
use glib::signal::SignalHandlerId;
use glib::signal::connect_raw;
use glib::signal::SignalHandlerId;
use glib::translate::*;
use glib::value::SetValueOptional;
use glib::GString;
use glib::StaticType;
use glib::Value;
use glib_sys;
use gobject_sys;
use gtk;
......@@ -29,11 +30,6 @@ glib_wrapper! {
pub const NONE_BOX_THEATRIC: Option<&BoxTheatric> = None;
/// Trait containing all `BoxTheatric` methods.
///
/// # Implementors
///
/// [`BoxTheatric`](struct.BoxTheatric.html)
pub trait BoxTheatricExt: 'static {