gdritter repos palladio / c991906
Use fewer string literals in view Getty Ritter 5 years ago
2 changed file(s) with 53 addition(s) and 16 deletion(s). Collapse all Expand all
1 static OPEN_BTN: &'static str = "Open";
2 static SAVE_BTN: &'static str = "Save";
3 static SAVE_AS_BTN: &'static str = "Save As";
4
5 static OPEN_DIALOG_BTN: &'static str = "Open";
6 static CANCEL_DIALOG_BTN: &'static str = "Cancel";
7
8 static TILESET_LABEL: &'static str = "Tileset";
9 static TILESET_LOAD_BTN: &'static str = "Load Tileset Image";
1 mod canvas;
2 mod picker;
3
14 use gdk;
25 use gtk::{
36 self,
1417 };
1518 use std::process;
1619
17 mod canvas;
20 use constants;
21 use strings;
1822 use self::canvas::GridCanvas;
19
20 mod picker;
2123 use self::picker::Picker;
2224
25
26 /// The `App` is the main window that contains everything
2327 pub struct App {
2428 pub window: gtk::Window,
2529 pub canvas: GridCanvas,
2832 pub header: Header,
2933 }
3034
31 /// The `App` is the main window that contains everything
3235 impl App {
3336 fn new() -> App {
3437 let window = gtk::Window::new(gtk::WindowType::Toplevel);
3841
3942 window.add_events(gdk::POINTER_MOTION_MASK.bits() as i32);
4043 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 );
4349
4450 gtk::Window::set_default_icon_name("iconname");
4551
8288 impl Header {
8389 fn new() -> Header {
8490 let container = gtk::HeaderBar::new();
85 container.set_title("Palladio");
91 container.set_title(constants::PROGRAM_NAME);
8692 container.set_show_close_button(true);
8793
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 );
91103
92104 container.pack_start(&open_btn);
93105 container.pack_end(&save_btn);
107119 gtk::FileChooserAction::Open,
108120 );
109121
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 );
112130
113131 // if open_dialog.run() == gtk::ResponseType::Ok.into() {
114132 // println!("got {:?}", open_dialog.get_filename());
124142 gtk::FileChooserAction::Open,
125143 );
126144
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 );
129153
130154 // if save_dialog.run() == gtk::ResponseType::Ok.into() {
131155 // println!("got {:?}", save_dialog.get_filename());
150174 fn new() -> Toolbar {
151175 let container = gtk::Box::new(gtk::Orientation::Vertical, 5);
152176
153 let tile_label = gtk::Label::new("Tileset");
177 let tile_label = gtk::Label::new(
178 strings::TILESET_LABEL,
179 );
154180
155181 let tile_width = gtk::Entry::new();
156182 tile_width.set_text("16");
157183 let tile_height = gtk::Entry::new();
158184 tile_height.set_text("16");
159185
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 );
161189
162190 let picker = Picker::new();
163191