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

Stub Linux support (untested) and allow the text of the prompt to be retrieved #1

Merged
merged 2 commits into from May 21, 2013
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Stub Linux support (untested) and allow the text of the prompt to be …

…retrieved
  • Loading branch information
pcwalton committed May 17, 2013
commit 729dc48f8094a1987b801ca2ae4917263b5542ed
@@ -0,0 +1,31 @@
VPATH=%VPATH%

CC ?= gcc
CXX ?= g++
CXXFLAGS ?=
AR ?= ar
RUSTC ?= rustc
RUSTFLAGS ?=

RUST_SRC=$(shell find $(VPATH)/. -type f -name '*.rs')

.PHONY: all
all: librustalert.dummy

%.o: %.c
$(CC) $< -o $@ -c $(CFLAGS)

librustalert.dummy: alert.rc $(RUST_SRC)
$(RUSTC) $(RUSTFLAGS) $< -o $@
touch $@

alert-test: alert.rc $(RUST_SRC)
$(RUSTC) $(RUSTFLAGS) $< -o $@ --test

check: alert-test
./alert-test

.PHONY: clean
clean:
rm -f *.o *.a *.so *.dylib *.dll *.dummy *-test

@@ -15,9 +15,13 @@ extern mod core_foundation;
#[cfg(target_os="macos")]
extern mod cocoa;

#[cfg(target_os="linux")]
pub use linux::Alert;
#[cfg(target_os="macos")]
pub use macos::Alert;

#[cfg(target_os="linux")]
mod linux;
#[cfg(target_os="macos")]
mod macos;

@@ -31,7 +35,7 @@ pub trait AlertMethods {
fn add_prompt(&mut self);
/// Runs the alert modally.
fn run(&self);
/// Returns the value of the prompt.
fn prompt_value(&self) -> ~str;
}



@@ -0,0 +1,34 @@
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use AlertMethods;

/// An alert.
pub struct Alert;

impl AlertMethods for Alert {
fn new(_: &str) -> Alert {
// TODO
Alert
}

pub fn add_prompt(&mut self) {
// TODO
}

pub fn run(&self) {
// TODO
}

pub fn prompt_value(&self) -> ~str {
// TODO
~""
}
}

@@ -84,5 +84,19 @@ impl AlertMethods for Alert {
base::msg_send_void(transmute(self.nsalert), selector)
}
}

pub fn prompt_value(&self) -> ~str {
unsafe {
// [nstextfield stringValue]
let selector = sel_registerName(transmute(&"stringValue"[0]));
match self.nstextfield {
None => fail!("No prompt!"),
Some(nstextfield) => {
let string = base::msg_send_id(transmute(nstextfield), selector);
CFString::wrap_shared(transmute(string)).to_str()
}
}
}
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.