more code for tycho
parent
d9151a53dd
commit
1371e6c7fa
|
@ -24,12 +24,18 @@ serde_yaml = "0.8"
|
|||
# note: these have to be updated all at once, check the gtk crate for versions
|
||||
atk = "0.6"
|
||||
cairo-rs = "0.6"
|
||||
cairo-sys-rs = "0.8"
|
||||
gdk = "0.10"
|
||||
gdk-pixbuf = "0.6"
|
||||
gtk = "0.6"
|
||||
gio = "0.6"
|
||||
gio-sys = "0.8"
|
||||
glib = "0.7"
|
||||
glib-sys = "0.8"
|
||||
gobject-sys = "0.8"
|
||||
gtk = "0.6"
|
||||
gtk-sys = "0.8"
|
||||
pango = "0.6"
|
||||
pango-sys = "0.8"
|
||||
|
||||
[profile.dev]
|
||||
opt-level = 1
|
||||
|
|
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 226 B |
Binary file not shown.
After Width: | Height: | Size: 205 B |
Binary file not shown.
After Width: | Height: | Size: 538 B |
236
data/tycho.xml
236
data/tycho.xml
|
@ -33,14 +33,131 @@ Author: Alison Sanderson
|
|||
<!-- interface-description Tycho map editor for Maraiah. -->
|
||||
<!-- interface-copyright 2018-2019 Alison Sanderson -->
|
||||
<!-- interface-authors Alison Sanderson -->
|
||||
<object class="GtkImage" id="im_lines">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="resource">/net/greyserv/maraiah/tycho/lines</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="im_points">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="resource">/net/greyserv/maraiah/tycho/points</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="im_polys">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="resource">/net/greyserv/maraiah/tycho/polys</property>
|
||||
</object>
|
||||
<object class="GtkWindow" id="win_tools">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title" translatable="yes">Tool Palette</property>
|
||||
<property name="default_height">250</property>
|
||||
<property name="skip_taskbar_hint">True</property>
|
||||
<property name="has_resize_grip">True</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolPalette">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkToolItemGroup">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Geometry</property>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="btn_point">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Points</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="icon_widget">im_points</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="btn_point-atkobject">
|
||||
<property name="AtkObject::accessible-name" translatable="yes">Points Tool</property>
|
||||
<property name="AtkObject::accessible-description" translatable="yes">The tool that modifies points in the map.</property>
|
||||
<property name="AtkObject::accessible-role" translatable="yes">push-button</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="btn_lines">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Lines</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="icon_widget">im_lines</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="btn_lines-atkobject">
|
||||
<property name="AtkObject::accessible-name" translatable="yes">Lines Tool</property>
|
||||
<property name="AtkObject::accessible-description" translatable="yes">The tool which modifies line segments on the map.</property>
|
||||
<property name="AtkObject::accessible-role" translatable="yes">push-button</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkToolButton" id="btn_polys">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Polygons</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="icon_widget">im_polys</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="btn_polys-atkobject">
|
||||
<property name="AtkObject::accessible-name" translatable="yes">Polygon Tool</property>
|
||||
<property name="AtkObject::accessible-description" translatable="yes">The tool which modifies polygon shapes on the map.</property>
|
||||
<property name="AtkObject::accessible-role" translatable="yes">push-button</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject">
|
||||
<property name="AtkObject::accessible-name" translatable="yes">Geometry Collection</property>
|
||||
<property name="AtkObject::accessible-description" translatable="yes">All of the tools which modify map geometry.</property>
|
||||
<property name="AtkObject::accessible-role" translatable="yes">column-header</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="win_tools-atkobject">
|
||||
<property name="AtkObject::accessible-name" translatable="yes">Tycho Tool Palette</property>
|
||||
<property name="AtkObject::accessible-description" translatable="yes">Tycho's tool palette window.</property>
|
||||
<property name="AtkObject::accessible-role" translatable="yes">window</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkAboutDialog" id="win_about">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="modal">True</property>
|
||||
<property name="destroy_with_parent">True</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<property name="program_name">Tycho</property>
|
||||
<property name="copyright" translatable="yes">2018-2019 Alison Sanderson</property>
|
||||
<property name="program_name">Tycho Map Editor</property>
|
||||
<property name="copyright" translatable="yes">Copyright © 2018-2019 Alison Sanderson</property>
|
||||
<property name="comments" translatable="yes">greetigs i am tico the of superior ai to durdumbal go shoot my soldiers because its funny or ill put you in space</property>
|
||||
<property name="website_label" translatable="yes">Website</property>
|
||||
<property name="logo">resource:///net/greyserv/maraiah/tycho/tycho2.png</property>
|
||||
<property name="website_label" translatable="yes">Home Page</property>
|
||||
<property name="logo_icon_name">image-loading</property>
|
||||
<property name="license_type">mit-x11</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
|
@ -66,23 +183,27 @@ Author: Alison Sanderson
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="win_about-atkobject">
|
||||
<property name="AtkObject::accessible-name" translatable="yes">About Screen</property>
|
||||
<property name="AtkObject::accessible-description" translatable="yes">The about screen for Tycho.</property>
|
||||
<property name="AtkObject::accessible-role" translatable="yes">dialog</property>
|
||||
</object>
|
||||
<object class="GtkWindow" id="win_tycho">
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkWindow" id="win_menus">
|
||||
<property name="can_focus">False</property>
|
||||
<property name="default_width">440</property>
|
||||
<property name="title" translatable="yes">Tycho</property>
|
||||
<property name="default_height">250</property>
|
||||
<property name="has_resize_grip">True</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkMenuBar">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="pack_direction">ttb</property>
|
||||
<child>
|
||||
<object class="GtkMenuItem">
|
||||
<property name="visible">True</property>
|
||||
|
@ -206,11 +327,18 @@ Author: Alison Sanderson
|
|||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkSeparatorMenuItem">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuItem">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">_Help</property>
|
||||
<property name="right_justified">True</property>
|
||||
<property name="label" translatable="yes">_Info</property>
|
||||
<property name="use_underline">True</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu">
|
||||
|
@ -230,90 +358,6 @@ Author: Alison Sanderson
|
|||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkToolPalette">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkToolItemGroup">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkToolButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Points</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="stock_id">gtk-media-play</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkDrawingArea" id="draw_area">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkPaned">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="fill">True</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="win_tycho-atkobject">
|
||||
<property name="AtkObject::accessible-name" translatable="yes">Tycho Map Editor</property>
|
||||
<property name="AtkObject::accessible-description" translatable="yes">The main window of the Tycho map editor.</property>
|
||||
<property name="AtkObject::accessible-role" translatable="yes">window</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/net/greyserv/maraiah/tycho">
|
||||
<file compressed="true" alias="tycho1.png">data/tycho1.png</file>
|
||||
<file compressed="true" alias="tycho2.png">data/tycho2.png</file>
|
||||
<file compressed="true" alias="tycho1">data/tycho1.png</file>
|
||||
<file compressed="true" alias="tycho2">data/tycho2.png</file>
|
||||
<file compressed="true" alias="polys">data/polys.png</file>
|
||||
<file compressed="true" alias="lines">data/lines.png</file>
|
||||
<file compressed="true" alias="points">data/points.png</file>
|
||||
<file compressed="true" preprocess="xml-stripblanks" alias="ui">data/tycho.xml</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
|
|
@ -2,54 +2,101 @@ use gtk::prelude::*;
|
|||
use gio::prelude::*;
|
||||
use maraiah::durandal::err::*;
|
||||
|
||||
// TODO: add detached draw area mode, make everything detachable
|
||||
|
||||
const RESOURCE: &'static [u8] =
|
||||
include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/tycho.res"));
|
||||
|
||||
const XML: &'static str =
|
||||
include_str!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/tycho.xml"));
|
||||
|
||||
fn run_app(app: >k::Application)
|
||||
fn run_app(app: >k::Application) -> ResultS<()>
|
||||
{
|
||||
let b = gtk::Builder::new_from_string(XML);
|
||||
|
||||
let win: gtk::Window = b.get_object("win_tycho").unwrap();
|
||||
let abt: gtk::AboutDialog = b.get_object("win_about").unwrap();
|
||||
let bt_abt: gtk::MenuItem = b.get_object("btn_about").unwrap();
|
||||
|
||||
abt.set_authors(&env!("CARGO_PKG_AUTHORS").split(';').collect::<Vec<_>>());
|
||||
abt.set_version(env!("CARGO_PKG_VERSION"));
|
||||
abt.set_website(env!("CARGO_PKG_HOMEPAGE"));
|
||||
|
||||
fn load_img(path: &'static str) -> ResultS<gdk_pixbuf::Pixbuf>
|
||||
{
|
||||
let abt = abt.clone();
|
||||
bt_abt.connect_activate(move |_| {
|
||||
abt.run();
|
||||
abt.hide();
|
||||
});
|
||||
Ok(gdk_pixbuf::Pixbuf::new_from_resource(path)?)
|
||||
}
|
||||
|
||||
win.set_application(app);
|
||||
win.show_all();
|
||||
fn get_obj<T>(b: >k::Builder, name: &str) -> ResultS<T>
|
||||
where T: glib::object::IsA<glib::object::Object>
|
||||
{
|
||||
match b.get_object(name) {
|
||||
Some(w) => Ok(w),
|
||||
None => Err(err_msg("no object")),
|
||||
}
|
||||
}
|
||||
|
||||
let b = gtk::Builder::new_from_resource("/net/greyserv/maraiah/tycho/ui");
|
||||
|
||||
let win_menus: gtk::Window = get_obj(&b, "win_menus")?;
|
||||
let win_tools: gtk::Window = get_obj(&b, "win_tools")?;
|
||||
let win_about: gtk::AboutDialog = get_obj(&b, "win_about")?;
|
||||
let btn_about: gtk::MenuItem = get_obj(&b, "btn_about")?;
|
||||
//t draw_area: gtk::DrawingArea = get_obj(&b, "draw_area")?;
|
||||
//t btn_point: gtk::ToolButton = get_obj(&b, "btn_point")?;
|
||||
//t btn_lines: gtk::ToolButton = get_obj(&b, "btn_lines")?;
|
||||
//t btn_polys: gtk::ToolButton = get_obj(&b, "btn_polys")?;
|
||||
|
||||
let authors: Vec<_> = env!("CARGO_PKG_AUTHORS").split(';').collect();
|
||||
|
||||
win_about.set_authors(&authors);
|
||||
win_about.set_version(env!("CARGO_PKG_VERSION"));
|
||||
win_about.set_website(env!("CARGO_PKG_HOMEPAGE"));
|
||||
win_about.set_logo(&load_img("/net/greyserv/maraiah/tycho/tycho2")?);
|
||||
|
||||
btn_about.connect_activate(move |_| {
|
||||
win_about.run();
|
||||
win_about.hide();
|
||||
});
|
||||
|
||||
win_tools.set_deletable(false);
|
||||
win_tools.show_all();
|
||||
|
||||
win_menus.set_application(app);
|
||||
win_menus.show_all();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn main() -> ResultS<()>
|
||||
{
|
||||
let rsrc = glib::Bytes::from(&RESOURCE[..]);
|
||||
let rsrc = gio::Resource::new_from_data(&rsrc)?;
|
||||
gio::resources_register(&rsrc);
|
||||
// get jacked, punk. opaque data structures are for nerds.
|
||||
const RESOURCE_DATA: &'static [u8] =
|
||||
include_bytes!(concat!(env!("CARGO_MANIFEST_DIR"), "/data/tycho.res"));
|
||||
|
||||
let mut static_resource =
|
||||
gio_sys::GStaticResource{data: RESOURCE_DATA.as_ptr(),
|
||||
data_len: RESOURCE_DATA.len(),
|
||||
resource: std::ptr::null_mut(),
|
||||
next: std::ptr::null_mut(),
|
||||
padding: std::ptr::null_mut()};
|
||||
|
||||
unsafe {
|
||||
gio_sys::g_static_resource_init(&mut static_resource);
|
||||
}
|
||||
|
||||
let app = gtk::Application::new("net.greyserv.maraiah.tycho",
|
||||
gio::ApplicationFlags::empty())?;
|
||||
|
||||
app.connect_activate(run_app);
|
||||
app.connect_activate(|app| {
|
||||
match run_app(app) {
|
||||
Ok(()) => (),
|
||||
Err(e) => {
|
||||
// print out an error if init failed somehow, otherwise the main
|
||||
// loop will proceed as normal (this is just to prevent panics in
|
||||
// weird circumstances such as breaking the builder while devving)
|
||||
gtk::MessageDialog::new(None::<>k::Window>,
|
||||
gtk::DialogFlags::empty(),
|
||||
gtk::MessageType::Error,
|
||||
gtk::ButtonsType::Ok,
|
||||
&format!("{:?}", e)).run();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
if app.run(&[]) == 0 {
|
||||
let ret = if app.run(&[]) == 0 {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(err_msg("bad return"))
|
||||
};
|
||||
|
||||
unsafe {
|
||||
gio_sys::g_static_resource_fini(&mut static_resource);
|
||||
}
|
||||
|
||||
ret
|
||||
}
|
||||
|
||||
// EOF
|
||||
|
|
Loading…
Reference in New Issue