Skip to content

Commit

Permalink
Merge pull request gtk-rs#234 from gkoz/translate_refactoring
Browse files Browse the repository at this point in the history
glib::translate refactoring
  • Loading branch information
GuillaumeGomez committed Mar 12, 2015
2 parents d954bba + 16001aa commit c038ae3
Show file tree
Hide file tree
Showing 91 changed files with 629 additions and 805 deletions.
8 changes: 3 additions & 5 deletions glib/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

use ffi::{self, GQuark};
use glib_container::GlibContainer;
use translate::{ToGlibPtr, ToTmp};
use translate::ToGlibPtr;

pub struct Error {
pointer: *mut ffi::C_GError
Expand All @@ -24,8 +24,7 @@ pub struct Error {
impl Error {
pub fn new_literal(domain: GQuark, code: i32, message: &str) -> Option<Error> {
let tmp_pointer = unsafe {
let mut tmp_message = message.to_tmp_for_borrow();
ffi::g_error_new_literal(domain, code, tmp_message.to_glib_ptr())
ffi::g_error_new_literal(domain, code, message.borrow_to_glib().0)
};

if tmp_pointer.is_null() {
Expand All @@ -51,8 +50,7 @@ impl Error {

pub fn set(&mut self, domain: GQuark, code: i32, message: &str) -> () {
unsafe {
let mut tmp_message = message.to_tmp_for_borrow();
ffi::g_set_error_literal(&mut self.pointer, domain, code, tmp_message.to_glib_ptr())
ffi::g_set_error_literal(&mut self.pointer, domain, code, message.borrow_to_glib().0)
}
}

Expand Down
7 changes: 3 additions & 4 deletions glib/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use std::marker::PhantomFn;
use ffi;
use std::any::Any;
use translate::{ToGlibPtr, ToTmp};
use translate::ToGlibPtr;

pub trait FFIGObject {
fn unwrap_gobject(&self) -> *mut ffi::C_GObject;
Expand Down Expand Up @@ -63,13 +63,12 @@ pub trait Connect<'a, T: Signal<'a>>: FFIGObject + PhantomFn<&'a T> {

unsafe {
let trampoline = signal.get_trampoline();
let mut tmp_signal_name = signal.get_signal_name().replace("_", "-")
.to_tmp_for_borrow();
let signal_name = signal.get_signal_name().replace("_", "-");
let user_data_ptr = transmute(Box::new(signal));

ffi::glue_signal_connect(
self.unwrap_gobject(),
tmp_signal_name.to_glib_ptr(),
signal_name.borrow_to_glib().0,
Some(trampoline),
user_data_ptr
);
Expand Down
Loading

0 comments on commit c038ae3

Please sign in to comment.