From 4d7f003cd94ad3043f05a8919c6e49fe96947898 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Fri, 17 May 2013 15:54:48 -0700 Subject: [PATCH] Add rust-alert to the tree and use it to allow a new URL to be navigated to --- .gitmodules | 3 +++ configure | 1 + mk/sub.mk | 5 +++++ .../servo/platform/common/glut_windowing.rs | 13 ++++++++++++- src/components/servo/servo.rc | 1 + src/support/alert/rust-alert | 1 + 6 files changed, 23 insertions(+), 1 deletion(-) create mode 160000 src/support/alert/rust-alert diff --git a/.gitmodules b/.gitmodules index e57d923cc2a..38368bc25bf 100644 --- a/.gitmodules +++ b/.gitmodules @@ -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 diff --git a/configure b/configure index 53a0f1eb5a3..27edb45ae41 100755 --- a/configure +++ b/configure @@ -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 \ diff --git a/mk/sub.mk b/mk/sub.mk index 88b9acdc8ca..e8bf4d7c67a 100644 --- a/mk/sub.mk +++ b/mk/sub.mk @@ -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 \ diff --git a/src/components/servo/platform/common/glut_windowing.rs b/src/components/servo/platform/common/glut_windowing.rs index 167eae2dcf0..abb5f4b9591 100644 --- a/src/components/servo/platform/common/glut_windowing.rs +++ b/src/components/servo/platform/common/glut_windowing.rs @@ -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) + } + } } } } diff --git a/src/components/servo/servo.rc b/src/components/servo/servo.rc index 3a124522265..5a832000c7e 100755 --- a/src/components/servo/servo.rc +++ b/src/components/servo/servo.rc @@ -11,6 +11,7 @@ #[license = "MPL"]; #[crate_type = "lib"]; +extern mod alert; extern mod azure; extern mod geom; extern mod gfx (name = "servo_gfx"); diff --git a/src/support/alert/rust-alert b/src/support/alert/rust-alert new file mode 160000 index 00000000000..0cba81aab48 --- /dev/null +++ b/src/support/alert/rust-alert @@ -0,0 +1 @@ +Subproject commit 0cba81aab4858442e9a995cf3b0149d0d116627c