Add rust-alert to the tree and use it to allow a new URL to be navigated to

This commit is contained in:
Patrick Walton 2013-05-17 15:54:48 -07:00
parent 1eb5c4f7b7
commit 4d7f003cd9
6 changed files with 23 additions and 1 deletions

3
.gitmodules vendored
View file

@ -85,3 +85,6 @@
[submodule "src/compiler/rust"]
path = src/compiler/rust
url = https://github.com/mozilla/rust.git
[submodule "src/support/alert/rust-alert"]
path = src/support/alert/rust-alert
url = git://github.com/mozilla-servo/rust-alert.git

1
configure vendored
View file

@ -398,6 +398,7 @@ AUTOCMD="${LIBTOOLIZE} && autoconf && autoheader && automake --add-missing --cop
# Copied from cairo's autogen.sh. Build fails without
CFG_SUBMODULES="\
support/alert/rust-alert \
support/azure/rust-azure \
support/css/rust-css \
support/geom/rust-geom \

View file

@ -103,6 +103,11 @@ DEPS_rust-io-surface += \
rust-core-foundation \
$(NULL)
DEPS_rust-alert += \
rust-core-foundation \
rust-cocoa \
$(NULL)
DEPS_sharegl += \
rust-core-foundation \
rust-io-surface \

View file

@ -10,6 +10,7 @@
use windowing::{ApplicationMethods, CompositeCallback, LoadUrlCallback, ResizeCallback};
use windowing::{WindowMethods};
use alert::{Alert, AlertMethods};
use geom::size::Size2D;
use glut::glut::{DOUBLE, WindowHeight, WindowWidth};
use glut::glut;
@ -116,7 +117,17 @@ impl Window {
fn load_url(&self) {
match self.load_url_callback {
None => error!("no URL callback registered, doing nothing"),
Some(callback) => callback("http://purple.com/"),
Some(callback) => {
let mut alert: Alert = AlertMethods::new("Navigate to:");
alert.add_prompt();
alert.run();
let value = alert.prompt_value();
if "" == value { // To avoid crashing on Linux.
callback("http://purple.com/")
} else {
callback(value)
}
}
}
}
}

View file

@ -11,6 +11,7 @@
#[license = "MPL"];
#[crate_type = "lib"];
extern mod alert;
extern mod azure;
extern mod geom;
extern mod gfx (name = "servo_gfx");

@ -0,0 +1 @@
Subproject commit 0cba81aab4858442e9a995cf3b0149d0d116627c