Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo features fix #99

Merged
merged 2 commits into from
Oct 13, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "rgtk"
version = "0.0.1"
authors = ["letang.jeremy@gmail.com", "mathijs.henquet@gmail.com", "guillaume1.gomez@gmail.com", "bpgarman@fastmail.fm"]
authors = ["letang.jeremy@gmail.com", "mathijs.henquet@gmail.com", "guillaume1.gomez@gmail.com", "bpgarman@fastmail.fm", "me@bstr.eu"]
build = "sh cargobuild.sh"

[features]
Expand Down
4 changes: 2 additions & 2 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ examples: gtktest cairotest
.PHONY: rgtk-build
rgtk-build: src/*
@$(ECHO) "$(OK_COLOR) Building rgtk.rlib $(NO_COLOR)"
$(RUSTC) src/$(LIBNAME).rs --cfg $(GTK_VERSION) -L $(GLUE_DST) --out-dir target/
$(RUSTC) src/$(LIBNAME).rs --cfg feature=\"$(GTK_VERSION)\" -L $(GLUE_DST) --out-dir target/

.PHONY:
glue : $(GLUE_DST)/$(GLUE_LIBNAME).a
Expand Down Expand Up @@ -90,7 +90,7 @@ $(EXAMPLE_DIR)text_viewer: rgtk examples/text_viewer.rs | $(EXAMPLE_DIR)

.PHONY: doc
doc:
rustdoc --cfg $(GTK_VERSION) -o doc/ src/rgtk.rs
rustdoc --cfg feature=\"$(GTK_VERSION)\" -o doc/ src/rgtk.rs
chmod -R 755 doc/

$(GLUE_DST)/ $(EXAMPLE_DIR) target/:
Expand Down
6 changes: 3 additions & 3 deletions src/gtk/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,14 +150,14 @@ pub use self::widgets::{
RecentChooserWidget
};

#[cfg(any(GTK_3_6, GTK_3_8, GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_6", feature = "GTK_3_8", feature = "GTK_3_10", feature = "GTK_3_12"))]
/// GTK Widgets for versions since GTK 3.6
pub use self::widgets::{
MenuButton,
LevelBar,
};

#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
/// GTK Widgets for versions since GTK 3.10
pub use self::widgets::{
SearchEntry,
Expand All @@ -170,7 +170,7 @@ pub use self::widgets::{
ListBoxRow,
};

#[cfg(GTK_3_12)]
#[cfg(feature = "GTK_3_12")]
/// GTK Widgets for versions since GTK 3.12
pub use self::widgets::{
FlowBox,
Expand Down
4 changes: 2 additions & 2 deletions src/gtk/traits/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ pub trait Button: Widget + Container {
}
}

#[cfg(any(GTK_3_6, GTK_3_8, GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_6", feature = "GTK_3_8", feature = "GTK_3_10", feature = "GTK_3_12"))]
fn set_always_show_image(&mut self, always_show: bool) -> () {
match always_show {
true => unsafe { ffi::gtk_button_set_always_show_image(GTK_BUTTON(self.get_widget()), ffi::GTRUE) },
false => unsafe { ffi::gtk_button_set_always_show_image(GTK_BUTTON(self.get_widget()), ffi::GFALSE) }
}
}

#[cfg(any(GTK_3_6, GTK_3_8, GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_6", feature = "GTK_3_8", feature = "GTK_3_10", feature = "GTK_3_12"))]
fn get_always_show_image(&self) -> bool {
match unsafe { ffi::gtk_button_get_always_show_image(GTK_BUTTON(self.get_widget())) } {
ffi::GFALSE => false,
Expand Down
2 changes: 1 addition & 1 deletion src/gtk/traits/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub trait Dialog: traits::Widget + traits::Container + traits::Bin + traits::Win
}
}

#[cfg(GTK_3_12)]
#[cfg(feature = "GTK_3_12")]
fn get_header_bar<T: traits::Widget>(&self) -> Option<T> {
let tmp_pointer = unsafe { ffi::gtk_dialog_get_header_bar(GTK_DIALOG(self.get_widget())) };

Expand Down
4 changes: 2 additions & 2 deletions src/gtk/traits/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ pub trait Label : Widget {
}
}

#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10",feature = "GTK_3_12"))]
fn set_lines(&mut self, lines: i32) -> () {
unsafe {
ffi::gtk_label_set_lines(GTK_LABEL(self.get_widget()), lines as c_int);
}
}

#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10",feature = "GTK_3_12"))]
fn get_lines(&self) -> i32 {
unsafe {
ffi::gtk_label_get_lines(GTK_LABEL(self.get_widget())) as c_int
Expand Down
2 changes: 1 addition & 1 deletion src/gtk/widgets/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl Button {
check_pointer!(tmp_pointer, Button)
}

#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10",feature = "GTK_3_12"))]
pub fn new_from_icon_name(icon_name: &str, size: IconSize) -> Option<Button> {
let tmp_pointer = unsafe {
icon_name.with_c_str(|c_str| {
Expand Down
8 changes: 4 additions & 4 deletions src/gtk/widgets/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,14 @@ impl Grid {
}
}

#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10",feature = "GTK_3_12"))]
pub fn remove_row(&mut self, position: i32) -> () {
unsafe {
ffi::gtk_grid_remove_row(GTK_GRID(self.pointer), position as c_int);
}
}

#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10",feature = "GTK_3_12"))]
pub fn remove_column(&mut self, position: i32) -> () {
unsafe {
ffi::gtk_grid_remove_column(GTK_GRID(self.pointer), position as c_int);
Expand Down Expand Up @@ -149,14 +149,14 @@ impl Grid {
}
}

#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10",feature = "GTK_3_12"))]
pub fn get_baseline_row(&self) -> i32 {
unsafe {
ffi::gtk_grid_get_baseline_row(GTK_GRID(self.pointer)) as i32
}
}

#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10",feature = "GTK_3_12"))]
pub fn set_baseline_row(&mut self, row: i32) -> () {
unsafe {
ffi::gtk_grid_set_baseline_row(GTK_GRID(self.pointer), row as c_int);
Expand Down
4 changes: 2 additions & 2 deletions src/gtk/widgets/infobar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ impl InfoBar {
}
}

#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10",feature = "GTK_3_12"))]
pub fn show_close_button(&mut self, show: bool) -> () {
match show {
true => unsafe { ffi::gtk_info_bar_set_show_close_button(GTK_INFOBAR(self.pointer), ffi::GTRUE) },
false => unsafe { ffi::gtk_info_bar_set_show_close_button(GTK_INFOBAR(self.pointer), ffi::GFALSE) }
}
}

#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10",feature = "GTK_3_12"))]
pub fn get_show_close_button(&self) -> bool {
match unsafe { ffi::gtk_info_bar_get_show_close_button(GTK_INFOBAR(self.pointer)) } {
ffi::GFALSE => false,
Expand Down
4 changes: 2 additions & 2 deletions src/gtk/widgets/levelbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ impl LevelBar {
}
}

#[cfg(any(GTK_3_8, GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_8", feature = "GTK_3_10",feature = "GTK_3_12"))]
pub fn set_inverted(&mut self, inverted: bool) -> () {
match inverted {
true => unsafe { ffi::gtk_level_bar_set_inverted(GTK_LEVELBAR(self.pointer), ffi::GTRUE) },
false => unsafe { ffi::gtk_level_bar_set_inverted(GTK_LEVELBAR(self.pointer), ffi::GFALSE) }
}
}

#[cfg(any(GTK_3_8, GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_8", feature = "GTK_3_10",feature = "GTK_3_12"))]
pub fn get_inverted(&self) -> bool {
match unsafe { ffi::gtk_level_bar_get_inverted(GTK_LEVELBAR(self.pointer)) } {
ffi::GFALSE => false,
Expand Down
44 changes: 22 additions & 22 deletions src/gtk/widgets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub use self::fontbutton::FontButton;
pub use self::togglebutton::ToggleButton;
pub use self::checkbutton::CheckButton;
pub use self::fontchooserdialog::FontChooserDialog;
#[cfg(any(GTK_3_6, GTK_3_8, GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_6", feature = "GTK_3_8", feature = "GTK_3_10", feature = "GTK_3_12"))]
pub use self::menubutton::MenuButton;
pub use self::colorbutton::ColorButton;
pub use self::linkbutton::LinkButton;
Expand All @@ -36,13 +36,13 @@ pub use self::volumebutton::VolumeButton;
pub use self::grid::Grid;
pub use self::entrybuffer::EntryBuffer;
pub use self::entry::Entry;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
pub use self::searchentry::SearchEntry;
pub use self::switch::Switch;
pub use self::scale::Scale;
#[cfg(any(GTK_3_6, GTK_3_8, GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_6", feature = "GTK_3_8", feature = "GTK_3_10", feature = "GTK_3_12"))]
pub use self::levelbar::LevelBar;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
pub use self::searchbar::SearchBar;
pub use self::spinbutton::SpinButton;
pub use self::spinner::Spinner;
Expand All @@ -68,21 +68,21 @@ pub use self::aboutdialog::AboutDialog;
pub use self::messagedialog::MessageDialog;
pub use self::colorchooserdialog::ColorChooserDialog;
pub use self::notebook::NoteBook;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
pub use self::stack::Stack;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
pub use self::stack_switcher::StackSwitcher;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
pub use self::revealer::Revealer;
pub use self::overlay::Overlay;
pub use self::layout::Layout;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
pub use self::header_bar::HeaderBar;
#[cfg(GTK_3_12)]
#[cfg(feature = "GTK_3_12")]
pub use self::flow_box::{FlowBox, FlowBoxChild};
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
pub use self::list_box::{ListBox, ListBoxRow};
#[cfg(GTK_3_12)]
#[cfg(feature = "GTK_3_12")]
pub use self::action_bar::ActionBar;
pub use self::filefilter::FileFilter;
pub use self::filechooserdialog::FileChooserDialog;
Expand Down Expand Up @@ -132,7 +132,7 @@ mod separator;
mod fontbutton;
mod togglebutton;
mod checkbutton;
#[cfg(any(GTK_3_6, GTK_3_8, GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_6", feature = "GTK_3_8", feature = "GTK_3_10", feature = "GTK_3_12"))]
mod menubutton;
mod colorbutton;
mod linkbutton;
Expand All @@ -142,13 +142,13 @@ mod volumebutton;
mod grid;
mod entrybuffer;
mod entry;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
mod searchentry;
mod switch;
mod scale;
#[cfg(any(GTK_3_6, GTK_3_8, GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_6", feature = "GTK_3_8", feature = "GTK_3_10", feature = "GTK_3_12"))]
mod levelbar;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
mod searchbar;
mod spinbutton;
mod spinner;
Expand All @@ -172,21 +172,21 @@ mod colorchooserdialog;
mod fontchooserdialog;
mod messagedialog;
mod notebook;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
mod stack;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
mod stack_switcher;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
mod revealer;
mod overlay;
mod layout;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
mod header_bar;
#[cfg(GTK_3_12)]
#[cfg(feature = "GTK_3_12")]
mod flow_box;
#[cfg(any(GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_10", feature = "GTK_3_12"))]
mod list_box;
#[cfg(GTK_3_12)]
#[cfg(feature = "GTK_3_12")]
mod action_bar;
mod filefilter;
mod filechooserdialog;
Expand Down
6 changes: 3 additions & 3 deletions src/gtk/widgets/treeview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@ impl TreeView {
}
}

#[cfg(any(GTK_3_8, GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_8", feature = "GTK_3_10", feature = "GTK_3_12"))]
pub fn get_activate_on_single_click(&self) -> bool {
unsafe {
ffi::to_bool(ffi::gtk_tree_view_get_activate_on_single_click(GTK_TREE_VIEW(self.pointer)))
}
}

#[cfg(any(GTK_3_8, GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_8", feature = "GTK_3_10", feature = "GTK_3_12"))]
pub fn set_activate_on_single_click(&mut self, setting: bool) {
unsafe {
ffi::gtk_tree_view_set_activate_on_single_click(GTK_TREE_VIEW(self.pointer),
ffi::to_gboolean(setting))
}
}

#[cfg(any(GTK_3_4, GTK_3_6, GTK_3_8, GTK_3_10, GTK_3_12))]
#[cfg(any(feature = "GTK_3_4", feature = "GTK_3_6", feature = "GTK_3_8", feature = "GTK_3_10",feature = "GTK_3_12"))]
pub fn get_n_columns(&self) -> uint {
unsafe {
ffi::gtk_tree_view_get_n_columns(GTK_TREE_VIEW(self.pointer)) as uint
Expand Down