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

Commit a64bfac

Browse files
Merge pull request #251 from gtk-rs/pending
[release] merging pending into master
2 parents e36340d + d773d14 commit a64bfac

38 files changed

+949
-418
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ language: rust
33
rust:
44
- nightly
55
- beta
6-
- 1.31.0 # stable
6+
- 1.34.0 # stable
77
addons:
88
apt:
99
packages:

CONTRIBUTING.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

Cargo.toml

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,45 @@ autobins = false
77
[dependencies]
88
chrono = "0.4"
99
url = "1.4"
10-
futures-preview = { version = "0.2", optional = true }
11-
atk = "^0"
12-
glib-sys = "^0"
13-
gobject-sys = "^0"
14-
glib = "^0"
15-
gio = "^0"
16-
gdk = "^0"
17-
gdk-pixbuf = "^0"
18-
gtk = "^0"
19-
pango = "^0"
20-
cairo-rs = { version = "^0", features = ["png"] }
10+
futures-preview = { version = "0.3.0-alpha.15", optional = true}
11+
12+
[dependencies.atk]
13+
git = "https://github.com/gtk-rs/atk"
14+
15+
[dependencies.glib-sys]
16+
git = "https://github.com/gtk-rs/sys"
17+
18+
[dependencies.gobject-sys]
19+
git = "https://github.com/gtk-rs/sys"
20+
21+
[dependencies.glib]
22+
git = "https://github.com/gtk-rs/glib"
23+
24+
[dependencies.gio]
25+
git = "https://github.com/gtk-rs/gio"
26+
27+
[dependencies.cairo-rs]
28+
git = "https://github.com/gtk-rs/cairo"
29+
features = ["png"]
30+
31+
[dependencies.pango]
32+
git = "https://github.com/gtk-rs/pango"
33+
34+
[dependencies.gdk-pixbuf]
35+
git = "https://github.com/gtk-rs/gdk-pixbuf"
36+
37+
[dependencies.gdk]
38+
git = "https://github.com/gtk-rs/gdk"
39+
40+
[dependencies.gtk]
41+
git = "https://github.com/gtk-rs/gtk"
2142

2243
[features]
23-
#default = ["gtk_3_22_30", "futures-stable", "subclassing"]
44+
#default = ["gtk_3_22_30", "futures", "subclassing"]
2445
gtk_3_18 = ["gtk/v3_18", "gdk-pixbuf/v2_32", "gdk/v3_18", "gio/v2_46", "glib/v2_46", "pango/v1_38"] #for CI tools
2546
gtk_3_22_30 = ["gtk_3_18", "gtk/v3_22_30", "gdk-pixbuf/v2_36", "gdk/v3_22", "gio/v2_56", "glib/v2_56", "pango/v1_42"] #for CI tools
2647
gtk_3_24 = ["gtk_3_22_30", "gtk/v3_24", "atk/v2_30", "gdk-pixbuf/v2_36_8", "gdk/v3_24", "gio/v2_58", "glib/v2_58"] #for CI tools
27-
futures-stable = ["futures-preview", "glib/futures", "gio/futures"]
48+
futures = ["futures-preview", "glib/futures", "gio/futures"]
2849
subclassing = ["glib/subclassing"]
2950

3051
[[bin]]
@@ -36,6 +57,9 @@ name = "basic"
3657
[[bin]]
3758
name = "builder_basics"
3859

60+
[[bin]]
61+
name = "builders"
62+
3963
[[bin]]
4064
name = "cairo_png"
4165

@@ -48,6 +72,9 @@ name = "cairotest"
4872
[[bin]]
4973
name = "child-properties"
5074

75+
[[bin]]
76+
name = "clipboard_simple"
77+
5178
[[bin]]
5279
name = "clock"
5380

@@ -62,11 +89,12 @@ name = "drag_and_drop_textview"
6289

6390
[[bin]]
6491
name = "gio_futures"
65-
required-features = ["futures-stable"]
92+
required-features = ["futures"]
6693

67-
#[[bin]]
68-
#name = "gio_futures_await"
69-
#required-features = ["futures-nightly"]
94+
[[bin]]
95+
name = "gio_futures_await"
96+
required-features = ["futures"]
97+
edition = "2018"
7098

7199
[[bin]]
72100
name = "grid"
@@ -123,3 +151,6 @@ name = "treeview"
123151

124152
[[bin]]
125153
name = "list_store"
154+
155+
[[bin]]
156+
name = "entry_completion"

build_travis.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ set -e
66
if [ "$GTK" = latest -o "$GTK" = "3.24" ]; then
77
BUNDLE="gtk-3.24.0-1"
88
if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then
9-
FEATURES=gtk_3_24,futures-stable,gio/v2_44,subclassing
9+
FEATURES=gtk_3_24,futures,gio/v2_44,subclassing
1010
else
11-
FEATURES=gtk_3_24,futures-stable,gio/v2_44,subclassing
11+
FEATURES=gtk_3_24,gio/v2_44,subclassing
1212
fi
1313
elif [ "$GTK" = "3.22.30" ]; then
1414
BUNDLE="gtk-3.22.30-1"
1515
if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then
16-
FEATURES=gtk_3_22_30,futures-stable,gio/v2_44,subclassing
16+
FEATURES=gtk_3_22_30,futures,gio/v2_44,subclassing
1717
else
18-
FEATURES=gtk_3_22_30,futures-stable,gio/v2_44,subclassing
18+
FEATURES=gtk_3_22_30,gio/v2_44,subclassing
1919
fi
2020
elif [ "$GTK" = "3.18" ]; then
2121
BUNDLE="gtk-3.18.1-2"
2222
if [ "$TRAVIS_RUST_VERSION" = "nightly" ]; then
23-
FEATURES=gtk_3_18,futures-stable,gio/v2_44,subclassing
23+
FEATURES=gtk_3_18,futures,gio/v2_44,subclassing
2424
else
25-
FEATURES=gtk_3_18,futures-stable,gio/v2_44,subclassing
25+
FEATURES=gtk_3_18,gio/v2_44,subclassing
2626
fi
2727
fi
2828

src/bin/accessibility.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ fn build_ui(application: &gtk::Application) {
2121
window.set_position(gtk::WindowPosition::Center);
2222

2323
let button = gtk::Button::new_with_label("Click me!");
24-
let label = gtk::Label::new("0");
24+
let label = gtk::Label::new(Some("0"));
2525
let vbox = gtk::Box::new(gtk::Orientation::Vertical, 0);
2626

2727
if let (Some(button_obj), Some(label_obj)) = (button.get_accessible(), label.get_accessible()) {
2828
// We set the description
2929
button_obj.set_description("Button to increase label value");
3030

3131
// Then we setup the relation saying that the label is linked to the button.
32-
let relation_set = label_obj.ref_relation_set().expect("Failed to get relation for label");
32+
let relation_set = label_obj
33+
.ref_relation_set()
34+
.expect("Failed to get relation for label");
3335
let relation = atk::Relation::new(&[button_obj], atk::RelationType::LabelFor);
3436

3537
relation_set.add(&relation);
@@ -41,19 +43,23 @@ fn build_ui(application: &gtk::Application) {
4143
window.add(&vbox);
4244

4345
button.connect_clicked(move |_| {
44-
let value = label.get_text()
46+
let value = label
47+
.get_text()
4548
.and_then(|s| u32::from_str_radix(&s, 10).ok())
46-
.unwrap_or(0) + 1;
49+
.unwrap_or(0)
50+
+ 1;
4751
label.set_text(&value.to_string());
4852
});
4953

5054
window.show_all();
5155
}
5256

5357
fn main() {
54-
let application = gtk::Application::new("com.github.accessibility",
55-
gio::ApplicationFlags::empty())
56-
.expect("Initialization failed...");
58+
let application = gtk::Application::new(
59+
Some("com.github.accessibility"),
60+
gio::ApplicationFlags::empty(),
61+
)
62+
.expect("Initialization failed...");
5763

5864
application.connect_activate(|app| {
5965
// We build the application UI.

src/bin/basic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ fn build_ui(application: &gtk::Application) {
2828
}
2929

3030
fn main() {
31-
let application = gtk::Application::new("com.github.gtk-rs.examples.basic",
32-
Default::default())
33-
.expect("Initialization failed...");
31+
let application =
32+
gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default())
33+
.expect("Initialization failed...");
3434

3535
application.connect_activate(|app| {
3636
build_ui(app);

src/bin/builder_basics.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ use gtk::{ApplicationWindow, Builder, Button, MessageDialog};
1212

1313
use std::env::args;
1414

15-
1615
fn build_ui(application: &gtk::Application) {
1716
let glade_src = include_str!("builder_basics.glade");
1817
let builder = Builder::new_from_string(glade_src);
1918

2019
let window: ApplicationWindow = builder.get_object("window1").expect("Couldn't get window1");
21-
window.set_application(application);
20+
window.set_application(Some(application));
2221
let bigbutton: Button = builder.get_object("button1").expect("Couldn't get button1");
23-
let dialog: MessageDialog = builder.get_object("messagedialog1")
22+
let dialog: MessageDialog = builder
23+
.get_object("messagedialog1")
2424
.expect("Couldn't get messagedialog1");
2525

2626
bigbutton.connect_clicked(move |_| {
@@ -32,9 +32,11 @@ fn build_ui(application: &gtk::Application) {
3232
}
3333

3434
fn main() {
35-
let application = gtk::Application::new("com.github.gtk-rs.examples.builder_basics",
36-
Default::default())
37-
.expect("Initialization failed...");
35+
let application = gtk::Application::new(
36+
Some("com.github.gtk-rs.examples.builder_basics"),
37+
Default::default(),
38+
)
39+
.expect("Initialization failed...");
3840

3941
application.connect_activate(|app| {
4042
build_ui(app);

src/bin/builders.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
//! # Builders Sample
2+
//!
3+
//! This sample demonstrates how to create a widget using the builders.
4+
//! These allow to set construct-only properties and other construct
5+
//! properties when creating the widget.
6+
7+
extern crate gio;
8+
extern crate gtk;
9+
10+
use gio::prelude::*;
11+
use gtk::prelude::*;
12+
13+
use std::env::args;
14+
15+
fn build_ui(application: &gtk::Application) {
16+
let window = gtk::ApplicationWindowBuilder::new()
17+
.application(application)
18+
.title("First GTK+ Program")
19+
.border_width(10)
20+
.window_position(gtk::WindowPosition::Center)
21+
.default_width(350)
22+
.default_height(70)
23+
.build();
24+
25+
let button = gtk::LockButtonBuilder::new()
26+
.text_lock("Lock")
27+
.text_unlock("Unlock")
28+
.build();
29+
30+
window.add(&button);
31+
32+
window.show_all();
33+
}
34+
35+
fn main() {
36+
let application =
37+
gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default())
38+
.expect("Initialization failed...");
39+
40+
application.connect_activate(|app| {
41+
build_ui(app);
42+
});
43+
44+
application.run(&args().collect::<Vec<_>>());
45+
}

src/bin/cairo_png.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
77
extern crate cairo;
88

9-
use std::fs::File;
109
use cairo::{Context, Format, ImageSurface};
10+
use std::fs::File;
1111

1212
fn main() {
1313
let surface = ImageSurface::create(Format::ARgb32, 120, 120).expect("Can't create surface");

src/bin/cairo_threads.rs

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
extern crate cairo;
22
extern crate gio;
3-
extern crate gtk;
43
extern crate glib;
4+
extern crate gtk;
55

6-
use std::thread;
6+
use std::cell::RefCell;
77
use std::env::args;
8-
use std::sync::mpsc;
98
use std::rc::Rc;
10-
use std::cell::RefCell;
9+
use std::sync::mpsc;
10+
use std::thread;
1111
use std::time::Duration;
1212

13-
use cairo::prelude::*;
1413
use cairo::{Context, Format, ImageSurface};
1514
use gio::prelude::*;
1615
use gtk::prelude::*;
@@ -67,7 +66,8 @@ impl Image {
6766
// references the pixels anymore
6867
impl Drop for ImageHolder {
6968
fn drop(&mut self) {
70-
*self.return_location.borrow_mut() = Some(self.image.take().expect("Holding no image"));
69+
*self.return_location.borrow_mut() =
70+
Some(self.image.take().expect("Holding no image"));
7171
}
7272
}
7373

@@ -96,14 +96,21 @@ impl Image {
9696
};
9797

9898
// The surface will own the image for the scope of the block below
99-
let surface = ImageSurface::create_for_data(holder, Format::Rgb24, WIDTH, HEIGHT, 4 * WIDTH).expect("Can't create surface");
99+
let surface =
100+
ImageSurface::create_for_data(holder, Format::Rgb24, WIDTH, HEIGHT, 4 * WIDTH)
101+
.expect("Can't create surface");
100102
func(&surface);
101103

102104
// Now the surface will be destroyed and the pixels are stored in the return_location
103105
}
104106

105107
// And here move the pixels back again
106-
self.0 = Some(return_location.borrow_mut().take().expect("Image not returned"));
108+
self.0 = Some(
109+
return_location
110+
.borrow_mut()
111+
.take()
112+
.expect("Image not returned"),
113+
);
107114
}
108115
}
109116

@@ -235,9 +242,11 @@ fn build_ui(application: &gtk::Application) {
235242
}
236243

237244
fn main() {
238-
let application = gtk::Application::new("com.github.gtk-rs.examples.cairo_threads",
239-
Default::default())
240-
.expect("Initialization failed...");
245+
let application = gtk::Application::new(
246+
Some("com.github.gtk-rs.examples.cairo_threads"),
247+
Default::default(),
248+
)
249+
.expect("Initialization failed...");
241250

242251
application.connect_activate(|app| {
243252
build_ui(app);
@@ -272,8 +281,12 @@ fn draw_slow(cr: &Context, delay: Duration, x: f64, y: f64, radius: f64) {
272281
}
273282

274283
// Render the image surface into the context at the given position
275-
fn draw_image_if_dirty(cr: &Context, image: &ImageSurface, origin: (i32, i32),
276-
dimensions: (i32, i32)) {
284+
fn draw_image_if_dirty(
285+
cr: &Context,
286+
image: &ImageSurface,
287+
origin: (i32, i32),
288+
dimensions: (i32, i32),
289+
) {
277290
let x = origin.0 as f64;
278291
let y = origin.1 as f64;
279292
let w = dimensions.0 as f64;
@@ -288,4 +301,3 @@ fn draw_image_if_dirty(cr: &Context, image: &ImageSurface, origin: (i32, i32),
288301
// Release the reference to the surface again
289302
cr.set_source_rgba(0.0, 0.0, 0.0, 0.0);
290303
}
291-

0 commit comments

Comments
 (0)