| 1 |
mod canvas;
|
| 2 |
mod picker;
|
| 3 |
|
1 | 4 |
use gdk;
|
2 | 5 |
use gtk::{
|
3 | 6 |
self,
|
|
14 | 17 |
};
|
15 | 18 |
use std::process;
|
16 | 19 |
|
17 | |
mod canvas;
|
| 20 |
use constants;
|
| 21 |
use strings;
|
18 | 22 |
use self::canvas::GridCanvas;
|
19 | |
|
20 | |
mod picker;
|
21 | 23 |
use self::picker::Picker;
|
22 | 24 |
|
| 25 |
|
| 26 |
/// The `App` is the main window that contains everything
|
23 | 27 |
pub struct App {
|
24 | 28 |
pub window: gtk::Window,
|
25 | 29 |
pub canvas: GridCanvas,
|
|
28 | 32 |
pub header: Header,
|
29 | 33 |
}
|
30 | 34 |
|
31 | |
/// The `App` is the main window that contains everything
|
32 | 35 |
impl App {
|
33 | 36 |
fn new() -> App {
|
34 | 37 |
let window = gtk::Window::new(gtk::WindowType::Toplevel);
|
|
38 | 41 |
|
39 | 42 |
window.add_events(gdk::POINTER_MOTION_MASK.bits() as i32);
|
40 | 43 |
window.set_titlebar(&header.container);
|
41 | |
window.set_title("Palladio");
|
42 | |
window.set_wmclass("palladio", "Palladio");
|
| 44 |
window.set_title(constants::PROGRAM_NAME);
|
| 45 |
window.set_wmclass(
|
| 46 |
constants::PROGRAM_SLUG,
|
| 47 |
constants::PROGRAM_NAME,
|
| 48 |
);
|
43 | 49 |
|
44 | 50 |
gtk::Window::set_default_icon_name("iconname");
|
45 | 51 |
|
|
82 | 88 |
impl Header {
|
83 | 89 |
fn new() -> Header {
|
84 | 90 |
let container = gtk::HeaderBar::new();
|
85 | |
container.set_title("Palladio");
|
| 91 |
container.set_title(constants::PROGRAM_NAME);
|
86 | 92 |
container.set_show_close_button(true);
|
87 | 93 |
|
88 | |
let open_btn = gtk::Button::new_with_label("Open");
|
89 | |
let save_btn = gtk::Button::new_with_label("Save");
|
90 | |
let save_as_btn = gtk::Button::new_with_label("Save As");
|
| 94 |
let open_btn = gtk::Button::new_with_label(
|
| 95 |
strings::OPEN_BTN
|
| 96 |
);
|
| 97 |
let save_btn = gtk::Button::new_with_label(
|
| 98 |
strings::SAVE_BTN,
|
| 99 |
);
|
| 100 |
let save_as_btn = gtk::Button::new_with_label(
|
| 101 |
strings::SAVE_AS_BTN,
|
| 102 |
);
|
91 | 103 |
|
92 | 104 |
container.pack_start(&open_btn);
|
93 | 105 |
container.pack_end(&save_btn);
|
|
107 | 119 |
gtk::FileChooserAction::Open,
|
108 | 120 |
);
|
109 | 121 |
|
110 | |
open_dialog.add_button("Cancel", gtk::ResponseType::Cancel.into());
|
111 | |
open_dialog.add_button("Open", gtk::ResponseType::Ok.into());
|
| 122 |
open_dialog.add_button(
|
| 123 |
strings::CANCEL_DIALOG_BTN,
|
| 124 |
gtk::ResponseType::Cancel.into(),
|
| 125 |
);
|
| 126 |
open_dialog.add_button(
|
| 127 |
strings::OPEN_DIALOG_BTN,
|
| 128 |
gtk::ResponseType::Ok.into(),
|
| 129 |
);
|
112 | 130 |
|
113 | 131 |
// if open_dialog.run() == gtk::ResponseType::Ok.into() {
|
114 | 132 |
// println!("got {:?}", open_dialog.get_filename());
|
|
124 | 142 |
gtk::FileChooserAction::Open,
|
125 | 143 |
);
|
126 | 144 |
|
127 | |
save_dialog.add_button("Cancel", gtk::ResponseType::Cancel.into());
|
128 | |
save_dialog.add_button("Open", gtk::ResponseType::Ok.into());
|
| 145 |
open_dialog.add_button(
|
| 146 |
strings::CANCEL_DIALOG_BTN,
|
| 147 |
gtk::ResponseType::Cancel.into(),
|
| 148 |
);
|
| 149 |
open_dialog.add_button(
|
| 150 |
strings::OPEN_DIALOG_BTN,
|
| 151 |
gtk::ResponseType::Ok.into(),
|
| 152 |
);
|
129 | 153 |
|
130 | 154 |
// if save_dialog.run() == gtk::ResponseType::Ok.into() {
|
131 | 155 |
// println!("got {:?}", save_dialog.get_filename());
|
|
150 | 174 |
fn new() -> Toolbar {
|
151 | 175 |
let container = gtk::Box::new(gtk::Orientation::Vertical, 5);
|
152 | 176 |
|
153 | |
let tile_label = gtk::Label::new("Tileset");
|
| 177 |
let tile_label = gtk::Label::new(
|
| 178 |
strings::TILESET_LABEL,
|
| 179 |
);
|
154 | 180 |
|
155 | 181 |
let tile_width = gtk::Entry::new();
|
156 | 182 |
tile_width.set_text("16");
|
157 | 183 |
let tile_height = gtk::Entry::new();
|
158 | 184 |
tile_height.set_text("16");
|
159 | 185 |
|
160 | |
let load_tileset_btn = gtk::Button::new_with_label("Load Tileset Image");
|
| 186 |
let load_tileset_btn = gtk::Button::new_with_label(
|
| 187 |
strings::TILESET_LOAD_BTN,
|
| 188 |
);
|
161 | 189 |
|
162 | 190 |
let picker = Picker::new();
|
163 | 191 |
|