fix comment style
parent
ad1c4e216b
commit
116d91ef6a
|
@ -60,9 +60,9 @@ pub fn read_bits_l(b: &[u8], cr_bit: usize, width: u8) -> ResultS<u64>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// FIXME: change this to u64::reverse_bits when stabilized
|
||||||
fn reverse_bits(v: u64) -> u64
|
fn reverse_bits(v: u64) -> u64
|
||||||
{
|
{
|
||||||
// TODO: change this to u64::reverse_bits when stabilized
|
|
||||||
let v = v >> 1 & 0x5555_5555_5555_5555 | ((v & 0x5555_5555_5555_5555) << 1);
|
let v = v >> 1 & 0x5555_5555_5555_5555 | ((v & 0x5555_5555_5555_5555) << 1);
|
||||||
let v = v >> 2 & 0x3333_3333_3333_3333 | ((v & 0x3333_3333_3333_3333) << 2);
|
let v = v >> 2 & 0x3333_3333_3333_3333 | ((v & 0x3333_3333_3333_3333) << 2);
|
||||||
let v = v >> 4 & 0x0F0F_0F0F_0F0F_0F0F | ((v & 0x0F0F_0F0F_0F0F_0F0F) << 4);
|
let v = v >> 4 & 0x0F0F_0F0F_0F0F_0F0F | ((v & 0x0F0F_0F0F_0F0F_0F0F) << 4);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
//! Checksum functions.
|
//! Checksum functions.
|
||||||
|
|
||||||
|
// Accumulator for CRC function.
|
||||||
fn crc_accum(a: u32, _: u32) -> u32
|
fn crc_accum(a: u32, _: u32) -> u32
|
||||||
{
|
{
|
||||||
if a & 1 == 1 {
|
if a & 1 == 1 {
|
||||||
|
@ -9,6 +10,8 @@ fn crc_accum(a: u32, _: u32) -> u32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Initializes a CRC array.
|
||||||
|
// FIXME: use const fn when stabilized
|
||||||
fn crc_init() -> [u32; 256]
|
fn crc_init() -> [u32; 256]
|
||||||
{
|
{
|
||||||
let mut t = [0; 256];
|
let mut t = [0; 256];
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::{durandal::{bin::OptU16, err::*, fixed::Unit},
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
|
|
||||||
/// Reads a polygon for either M1 or M2.
|
/// Reads a polygon for either M1 or M2.
|
||||||
fn read_poly_inter(b: &[u8]) -> ResultS<Polygon>
|
pub fn read_poly_inter(b: &[u8]) -> ResultS<Polygon>
|
||||||
{
|
{
|
||||||
read_data! {
|
read_data! {
|
||||||
endian: BIG, buf: b, size: 128, start: 0, data {
|
endian: BIG, buf: b, size: 128, start: 0, data {
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::durandal::{bin::*, err::*, image::*};
|
use crate::durandal::{bin::*, err::*, image::*};
|
||||||
|
|
||||||
/// Reads a `PixMap` header.
|
// Reads a `PixMap` header.
|
||||||
fn read_pm_header<'a>(b: &'a [u8],
|
fn read_pm_header<'a>(b: &'a [u8],
|
||||||
pack: bool,
|
pack: bool,
|
||||||
clip: bool,
|
clip: bool,
|
||||||
|
@ -55,7 +55,7 @@ fn read_pm_header<'a>(b: &'a [u8],
|
||||||
Ok((&b[p..], Header{pitch, pack_t, depth, clut, rle}))
|
Ok((&b[p..], Header{pitch, pack_t, depth, clut, rle}))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads an indexed `PixMap`.
|
// Reads an indexed `PixMap`.
|
||||||
fn read_pm_ind(mut im: Image8, b: &[u8], hdr: Header) -> ResultS<Image8>
|
fn read_pm_ind(mut im: Image8, b: &[u8], hdr: Header) -> ResultS<Image8>
|
||||||
{
|
{
|
||||||
let clut = ok!(hdr.clut, "no CLUT in indexed mode")?;
|
let clut = ok!(hdr.clut, "no CLUT in indexed mode")?;
|
||||||
|
@ -99,7 +99,7 @@ fn read_pm_ind(mut im: Image8, b: &[u8], hdr: Header) -> ResultS<Image8>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads a R5G5B5 `PixMap`.
|
// Reads a R5G5B5 `PixMap`.
|
||||||
fn read_pm_16(mut im: Image8, b: &[u8], hdr: Header) -> ResultS<Image8>
|
fn read_pm_16(mut im: Image8, b: &[u8], hdr: Header) -> ResultS<Image8>
|
||||||
{
|
{
|
||||||
let mut p = 0;
|
let mut p = 0;
|
||||||
|
@ -134,7 +134,7 @@ fn read_pm_16(mut im: Image8, b: &[u8], hdr: Header) -> ResultS<Image8>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads a RGB8 `PixMap`.
|
// Reads a RGB8 `PixMap`.
|
||||||
fn read_pm_32(mut im: Image8, b: &[u8], hdr: Header) -> ResultS<Image8>
|
fn read_pm_32(mut im: Image8, b: &[u8], hdr: Header) -> ResultS<Image8>
|
||||||
{
|
{
|
||||||
let mut p = 0;
|
let mut p = 0;
|
||||||
|
@ -187,7 +187,7 @@ fn read_pm_32(mut im: Image8, b: &[u8], hdr: Header) -> ResultS<Image8>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Process a `CopyBits` operation.
|
// Process a `CopyBits` operation.
|
||||||
fn read_pm_area(im: Image8, b: &[u8], pack: bool, clip: bool)
|
fn read_pm_area(im: Image8, b: &[u8], pack: bool, clip: bool)
|
||||||
-> ResultS<Image8>
|
-> ResultS<Image8>
|
||||||
{
|
{
|
||||||
|
@ -349,7 +349,7 @@ pub fn get_clut(b: &[u8]) -> ResultS<(Vec<Color8>, usize)>
|
||||||
Ok((clut, p))
|
Ok((clut, p))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Read run-length encoded data.
|
// Read run-length encoded data.
|
||||||
fn read_rle<T>(b: &[u8], pitch: usize) -> ResultS<(Vec<T>, usize)>
|
fn read_rle<T>(b: &[u8], pitch: usize) -> ResultS<(Vec<T>, usize)>
|
||||||
where T: ReadRleData
|
where T: ReadRleData
|
||||||
{
|
{
|
||||||
|
@ -382,7 +382,7 @@ fn read_rle<T>(b: &[u8], pitch: usize) -> ResultS<(Vec<T>, usize)>
|
||||||
|
|
||||||
trait ReadRleData: Sized
|
trait ReadRleData: Sized
|
||||||
{
|
{
|
||||||
/// Read a sequence of packed RLE data.
|
// Read a sequence of packed RLE data.
|
||||||
fn read_rle_data(b: &[u8],
|
fn read_rle_data(b: &[u8],
|
||||||
p: &mut usize,
|
p: &mut usize,
|
||||||
cmp: bool,
|
cmp: bool,
|
||||||
|
@ -438,7 +438,7 @@ impl ReadRleData for u8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Expand packed pixel data based on bit depth.
|
// Expand packed pixel data based on bit depth.
|
||||||
fn expand_data(b: Vec<u8>, depth: Depth) -> ResultS<Vec<u8>>
|
fn expand_data(b: Vec<u8>, depth: Depth) -> ResultS<Vec<u8>>
|
||||||
{
|
{
|
||||||
let mut o = Vec::with_capacity(match depth {
|
let mut o = Vec::with_capacity(match depth {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{durandal::{bin::*, err::*, fixed::*, image::*},
|
||||||
marathon::{text::*, xfer::TransferMode}};
|
marathon::{text::*, xfer::TransferMode}};
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
|
|
||||||
/// Reads a color from a color table into `clut`.
|
// Reads a color from a color table into `clut`.
|
||||||
fn read_color(b: &[u8], clut: &mut [ColorShp]) -> ResultS<()>
|
fn read_color(b: &[u8], clut: &mut [ColorShp]) -> ResultS<()>
|
||||||
{
|
{
|
||||||
read_data! {
|
read_data! {
|
||||||
|
@ -30,7 +30,7 @@ fn read_color(b: &[u8], clut: &mut [ColorShp]) -> ResultS<()>
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reads all color tables.
|
// Reads all color tables.
|
||||||
fn color_tables(b: &[u8],
|
fn color_tables(b: &[u8],
|
||||||
tab_ofs: usize,
|
tab_ofs: usize,
|
||||||
tab_num: usize,
|
tab_num: usize,
|
||||||
|
|
|
@ -36,10 +36,10 @@ const IM_NOMAP: ffi::NT = c_str!("/net/greyserv/maraiah/tycho/tycho1.png");
|
||||||
const PATH_BUILDER: ffi::NT = c_str!("/net/greyserv/maraiah/tycho/ui");
|
const PATH_BUILDER: ffi::NT = c_str!("/net/greyserv/maraiah/tycho/ui");
|
||||||
const PATH_CSS: ffi::NT = c_str!("/net/greyserv/maraiah/tycho/css");
|
const PATH_CSS: ffi::NT = c_str!("/net/greyserv/maraiah/tycho/css");
|
||||||
|
|
||||||
/// Called when the application activates in order to set everything up.
|
// Called when the application activates in order to set everything up.
|
||||||
unsafe extern "C" fn app_activate(app: *mut GtkApplication, _: gpointer)
|
unsafe extern "C" fn app_activate(app: *mut GtkApplication, _: gpointer)
|
||||||
{
|
{
|
||||||
/// Callback to finalize the reference.
|
// Callback to finalize the reference.
|
||||||
unsafe extern "C" fn c_done(_: *mut GtkWidget, ptr: gpointer)
|
unsafe extern "C" fn c_done(_: *mut GtkWidget, ptr: gpointer)
|
||||||
{
|
{
|
||||||
let edit = Rc::from_raw(ptr as *const MapEditorRef);
|
let edit = Rc::from_raw(ptr as *const MapEditorRef);
|
||||||
|
@ -64,10 +64,10 @@ unsafe extern "C" fn app_activate(app: *mut GtkApplication, _: gpointer)
|
||||||
connect(app, E_SHUTDOWN, c_done as _, Rc::into_raw(edit));
|
connect(app, E_SHUTDOWN, c_done as _, Rc::into_raw(edit));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets up the map view window's drawing area.
|
// Sets up the map view window's drawing area.
|
||||||
unsafe fn setup_draw_area(b: &Refc<GtkBuilder>, edit: Rc<MapEditorRef>)
|
unsafe fn setup_draw_area(b: &Refc<GtkBuilder>, edit: Rc<MapEditorRef>)
|
||||||
{
|
{
|
||||||
/// All of the state necessary for the drawing area.
|
// All of the state necessary for the drawing area.
|
||||||
struct RenderState
|
struct RenderState
|
||||||
{
|
{
|
||||||
im_nomap: Refc<'static, GdkPixbuf>,
|
im_nomap: Refc<'static, GdkPixbuf>,
|
||||||
|
@ -76,13 +76,13 @@ unsafe fn setup_draw_area(b: &Refc<GtkBuilder>, edit: Rc<MapEditorRef>)
|
||||||
edit: Rc<MapEditorRef>,
|
edit: Rc<MapEditorRef>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Callback to finalize the drawing area.
|
// Callback to finalize the drawing area.
|
||||||
unsafe extern "C" fn c_done(_: *mut GtkWidget, rend: gpointer)
|
unsafe extern "C" fn c_done(_: *mut GtkWidget, rend: gpointer)
|
||||||
{
|
{
|
||||||
Box::from_raw(rend as *mut RenderState);
|
Box::from_raw(rend as *mut RenderState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Callback to draw on the drawing area.
|
// Callback to draw on the drawing area.
|
||||||
unsafe extern "C" fn c_draw(wid: *mut GtkWidget,
|
unsafe extern "C" fn c_draw(wid: *mut GtkWidget,
|
||||||
ctx: *mut cairo_sys::cairo_t,
|
ctx: *mut cairo_sys::cairo_t,
|
||||||
rend: gpointer)
|
rend: gpointer)
|
||||||
|
@ -122,7 +122,7 @@ unsafe fn setup_draw_area(b: &Refc<GtkBuilder>, edit: Rc<MapEditorRef>)
|
||||||
connect(wid, E_DRAW, c_draw as _, rend);
|
connect(wid, E_DRAW, c_draw as _, rend);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets up the map view window.
|
// Sets up the map view window.
|
||||||
unsafe fn setup_win_map_view(b: &Refc<GtkBuilder>)
|
unsafe fn setup_win_map_view(b: &Refc<GtkBuilder>)
|
||||||
{
|
{
|
||||||
let win = get_obj::<GtkWindow >(b, B_WIN_M_VIEW);
|
let win = get_obj::<GtkWindow >(b, B_WIN_M_VIEW);
|
||||||
|
@ -132,7 +132,7 @@ unsafe fn setup_win_map_view(b: &Refc<GtkBuilder>)
|
||||||
connect_show(btn, win);
|
connect_show(btn, win);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets up the map tools window.
|
// Sets up the map tools window.
|
||||||
unsafe fn setup_win_map_tools(b: &Refc<GtkBuilder>)
|
unsafe fn setup_win_map_tools(b: &Refc<GtkBuilder>)
|
||||||
{
|
{
|
||||||
let win = get_obj::<GtkWindow >(b, B_WIN_M_TOOL);
|
let win = get_obj::<GtkWindow >(b, B_WIN_M_TOOL);
|
||||||
|
@ -142,7 +142,7 @@ unsafe fn setup_win_map_tools(b: &Refc<GtkBuilder>)
|
||||||
connect_show(btn, win);
|
connect_show(btn, win);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets up the map properties window.
|
// Sets up the map properties window.
|
||||||
unsafe fn setup_win_map_prop(b: &Refc<GtkBuilder>)
|
unsafe fn setup_win_map_prop(b: &Refc<GtkBuilder>)
|
||||||
{
|
{
|
||||||
let win = get_obj::<GtkWindow >(b, B_WIN_M_PROP);
|
let win = get_obj::<GtkWindow >(b, B_WIN_M_PROP);
|
||||||
|
@ -152,11 +152,11 @@ unsafe fn setup_win_map_prop(b: &Refc<GtkBuilder>)
|
||||||
connect_show(btn, win);
|
connect_show(btn, win);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets up the about dialogue.
|
// Sets up the about dialogue.
|
||||||
unsafe fn setup_about_dlg(b: &Refc<GtkBuilder>)
|
unsafe fn setup_about_dlg(b: &Refc<GtkBuilder>)
|
||||||
{
|
{
|
||||||
/// Callback to show the dialogue when the "About" button is pressed, and
|
// Callback to show the dialogue when the "About" button is pressed, and
|
||||||
/// hide it when the "Close" button is pressed on it.
|
// hide it when the "Close" button is pressed on it.
|
||||||
unsafe extern "C" fn c_show_act(_: *mut GtkWidget, dlg: gpointer)
|
unsafe extern "C" fn c_show_act(_: *mut GtkWidget, dlg: gpointer)
|
||||||
{
|
{
|
||||||
gtk_dialog_run(dlg as _);
|
gtk_dialog_run(dlg as _);
|
||||||
|
@ -179,10 +179,10 @@ unsafe fn setup_about_dlg(b: &Refc<GtkBuilder>)
|
||||||
connect(btn, E_ACTIVATE, c_show_act as _, dlg);
|
connect(btn, E_ACTIVATE, c_show_act as _, dlg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets up explicit window finalization for the main window.
|
// Sets up explicit window finalization for the main window.
|
||||||
unsafe fn setup_explicit_drop(b: &Refc<GtkBuilder>, win: *mut GtkWindow)
|
unsafe fn setup_explicit_drop(b: &Refc<GtkBuilder>, win: *mut GtkWindow)
|
||||||
{
|
{
|
||||||
/// Callback to explicitly finalize all windows on exit.
|
// Callback to explicitly finalize all windows on exit.
|
||||||
unsafe extern "C" fn c_done(_: *mut GtkWidget, exp_del: gpointer)
|
unsafe extern "C" fn c_done(_: *mut GtkWidget, exp_del: gpointer)
|
||||||
{
|
{
|
||||||
let exp_del = Box::from_raw(exp_del as *mut Vec<*mut GtkWindow>);
|
let exp_del = Box::from_raw(exp_del as *mut Vec<*mut GtkWindow>);
|
||||||
|
@ -231,18 +231,18 @@ unsafe fn setup_explicit_drop(b: &Refc<GtkBuilder>, win: *mut GtkWindow)
|
||||||
connect(win, E_DESTROY, c_done as _, exp_del);
|
connect(win, E_DESTROY, c_done as _, exp_del);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets up the main menu window.
|
// Sets up the main menu window.
|
||||||
unsafe fn setup_win_main(b: &Refc<GtkBuilder>,
|
unsafe fn setup_win_main(b: &Refc<GtkBuilder>,
|
||||||
app: *mut GtkApplication,
|
app: *mut GtkApplication,
|
||||||
edit: Rc<MapEditorRef>)
|
edit: Rc<MapEditorRef>)
|
||||||
{
|
{
|
||||||
/// Callback to close the window when the "Quit" button is pressed.
|
// Callback to close the window when the "Quit" button is pressed.
|
||||||
unsafe extern "C" fn c_quit_act(_: *mut GtkWidget, win: gpointer)
|
unsafe extern "C" fn c_quit_act(_: *mut GtkWidget, win: gpointer)
|
||||||
{
|
{
|
||||||
gtk_window_close(win as _);
|
gtk_window_close(win as _);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Callback to create a new map when the "New" button is pressed.
|
// Callback to create a new map when the "New" button is pressed.
|
||||||
unsafe extern "C" fn c_new_act(_: *mut GtkWidget, edit: gpointer)
|
unsafe extern "C" fn c_new_act(_: *mut GtkWidget, edit: gpointer)
|
||||||
{
|
{
|
||||||
let edit = &*(edit as *const MapEditorRef);
|
let edit = &*(edit as *const MapEditorRef);
|
||||||
|
@ -262,7 +262,7 @@ unsafe fn setup_win_main(b: &Refc<GtkBuilder>,
|
||||||
edit.cause_update();
|
edit.cause_update();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Callback to open an existing map when the "Open" button is pressed.
|
// Callback to open an existing map when the "Open" button is pressed.
|
||||||
unsafe extern "C" fn c_open_act(_: *mut GtkWidget, edit: gpointer)
|
unsafe extern "C" fn c_open_act(_: *mut GtkWidget, edit: gpointer)
|
||||||
{
|
{
|
||||||
let edit = &*(edit as *const MapEditorRef);
|
let edit = &*(edit as *const MapEditorRef);
|
||||||
|
@ -306,7 +306,7 @@ unsafe fn setup_win_main(b: &Refc<GtkBuilder>,
|
||||||
connect(btn, E_ACTIVATE, c_open_act as _, connect_ref(btn, edit.clone()));
|
connect(btn, E_ACTIVATE, c_open_act as _, connect_ref(btn, edit.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets up the CSS styling providers.
|
// Sets up the CSS styling providers.
|
||||||
unsafe fn setup_css()
|
unsafe fn setup_css()
|
||||||
{
|
{
|
||||||
let css = Refc::new(gtk_css_provider_new());
|
let css = Refc::new(gtk_css_provider_new());
|
||||||
|
@ -317,7 +317,7 @@ unsafe fn setup_css()
|
||||||
gtk_style_context_add_provider_for_screen(scr, *css as _, pri);
|
gtk_style_context_add_provider_for_screen(scr, *css as _, pri);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs a modal OK/Cancel dialogue.
|
// Runs a modal OK/Cancel dialogue.
|
||||||
unsafe fn run_ok_cancel_dlg(title: ffi::NT, text: ffi::NT) -> bool
|
unsafe fn run_ok_cancel_dlg(title: ffi::NT, text: ffi::NT) -> bool
|
||||||
{
|
{
|
||||||
let flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
|
let flags = GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT;
|
||||||
|
@ -343,7 +343,7 @@ unsafe fn run_ok_cancel_dlg(title: ffi::NT, text: ffi::NT) -> bool
|
||||||
res == GTK_RESPONSE_ACCEPT
|
res == GTK_RESPONSE_ACCEPT
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Runs a modal Open File dialogue.
|
// Runs a modal Open File dialogue.
|
||||||
unsafe fn run_file_chooser_open() -> Option<String>
|
unsafe fn run_file_chooser_open() -> Option<String>
|
||||||
{
|
{
|
||||||
let action = GTK_FILE_CHOOSER_ACTION_OPEN;
|
let action = GTK_FILE_CHOOSER_ACTION_OPEN;
|
||||||
|
@ -376,10 +376,10 @@ unsafe fn run_file_chooser_open() -> Option<String>
|
||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Connects a handler that hides a toplevel widget when deleted.
|
// Connects a handler that hides a toplevel widget when deleted.
|
||||||
unsafe fn connect_hide<T>(wid: *mut T)
|
unsafe fn connect_hide<T>(wid: *mut T)
|
||||||
{
|
{
|
||||||
/// Callback to hide the widget.
|
// Callback to hide the widget.
|
||||||
unsafe extern "C" fn c_hide_del(wid: *mut GtkWidget,
|
unsafe extern "C" fn c_hide_del(wid: *mut GtkWidget,
|
||||||
_: *mut GdkEvent,
|
_: *mut GdkEvent,
|
||||||
_: gpointer)
|
_: gpointer)
|
||||||
|
@ -390,10 +390,10 @@ unsafe fn connect_hide<T>(wid: *mut T)
|
||||||
connect(wid, E_DELETE, c_hide_del as _, ffi::null_void());
|
connect(wid, E_DELETE, c_hide_del as _, ffi::null_void());
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Connects a handler that shows a widget when activated.
|
// Connects a handler that shows a widget when activated.
|
||||||
unsafe fn connect_show<T, U>(btn: *mut T, wid: *mut U)
|
unsafe fn connect_show<T, U>(btn: *mut T, wid: *mut U)
|
||||||
{
|
{
|
||||||
/// Callback to show the widget.
|
// Callback to show the widget.
|
||||||
unsafe extern "C" fn c_show_act(_: *mut GtkWidget, wid: gpointer)
|
unsafe extern "C" fn c_show_act(_: *mut GtkWidget, wid: gpointer)
|
||||||
{
|
{
|
||||||
gtk_widget_show_all(wid as _);
|
gtk_widget_show_all(wid as _);
|
||||||
|
@ -402,11 +402,11 @@ unsafe fn connect_show<T, U>(btn: *mut T, wid: *mut U)
|
||||||
connect(btn, E_ACTIVATE, c_show_act as _, wid);
|
connect(btn, E_ACTIVATE, c_show_act as _, wid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Connects the map editor reference to a widget.
|
// Connects the map editor reference to a widget.
|
||||||
unsafe fn connect_ref<T>(obj: *mut T, rc: Rc<MapEditorRef>)
|
unsafe fn connect_ref<T>(obj: *mut T, rc: Rc<MapEditorRef>)
|
||||||
-> *const MapEditorRef
|
-> *const MapEditorRef
|
||||||
{
|
{
|
||||||
/// Callback to finalize the reference.
|
// Callback to finalize the reference.
|
||||||
unsafe extern "C" fn c_done(_: *mut GtkWidget, ptr: gpointer)
|
unsafe extern "C" fn c_done(_: *mut GtkWidget, ptr: gpointer)
|
||||||
{
|
{
|
||||||
Rc::from_raw(ptr as *const MapEditorRef);
|
Rc::from_raw(ptr as *const MapEditorRef);
|
||||||
|
@ -419,26 +419,26 @@ unsafe fn connect_ref<T>(obj: *mut T, rc: Rc<MapEditorRef>)
|
||||||
ptr
|
ptr
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets an object from a `GtkBuilder`.
|
// Gets an object from a `GtkBuilder`.
|
||||||
unsafe fn get_obj<T>(b: &Refc<GtkBuilder>, name: ffi::NT) -> *mut T
|
unsafe fn get_obj<T>(b: &Refc<GtkBuilder>, name: ffi::NT) -> *mut T
|
||||||
{
|
{
|
||||||
gtk_builder_get_object(**b, name) as _
|
gtk_builder_get_object(**b, name) as _
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Connects a signal handler.
|
// Connects a signal handler.
|
||||||
unsafe fn connect<T, U>(obj: *mut T, name: ffi::NT, cb: gpointer, d: *const U)
|
unsafe fn connect<T, U>(obj: *mut T, name: ffi::NT, cb: gpointer, d: *const U)
|
||||||
{
|
{
|
||||||
let cb = std::mem::transmute(cb);
|
let cb = std::mem::transmute(cb);
|
||||||
g_signal_connect_data(obj as _, name, cb, d as _, None, 0);
|
g_signal_connect_data(obj as _, name, cb, d as _, None, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Loads a `Pixbuf` from a resource.
|
// Loads a `Pixbuf` from a resource.
|
||||||
unsafe fn load_img(path: ffi::NT) -> *mut GdkPixbuf
|
unsafe fn load_img(path: ffi::NT) -> *mut GdkPixbuf
|
||||||
{
|
{
|
||||||
gdk_pixbuf_new_from_resource(path, ffi::null_mut())
|
gdk_pixbuf_new_from_resource(path, ffi::null_mut())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Entry point.
|
// Entry point.
|
||||||
fn main()
|
fn main()
|
||||||
{
|
{
|
||||||
unsafe {
|
unsafe {
|
||||||
|
|
|
@ -10,7 +10,7 @@ fn machdr_must_process()
|
||||||
assert_eq!(machdr::check_macbin(INPUT), Some(128));
|
assert_eq!(machdr::check_macbin(INPUT), Some(128));
|
||||||
assert_eq!(machdr::try_mac_header(INPUT), 128);
|
assert_eq!(machdr::try_mac_header(INPUT), 128);
|
||||||
|
|
||||||
// TODO: missing test data for applesingle
|
// FIXME: missing test data for applesingle
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue