Parcourir la source

and some stuff

Getty Ritter il y a 7 mois
Parent
commit
a4557b1a4c
3 fichiers modifiés avec 32 ajouts et 7 suppressions
  1. 7 0
      tools/editor/constants.rs
  2. 12 7
      tools/editor/main.rs
  3. 13 0
      tools/editor/model.rs

+ 7 - 0
tools/editor/constants.rs

@@ -0,0 +1,7 @@
+pub const APP_ID: &str = "org.aysamanra.Thyme";
+pub const NAME: &str = "Thyme";
+
+pub const NEW: &str = "New";
+pub const OPEN: &str = "Open";
+pub const SAVE: &str = "Save";
+pub const SAVE_AS: &str = "Save As";

+ 12 - 7
tools/editor/main.rs

@@ -1,11 +1,14 @@
+mod constants;
+mod model;
+
 use gtk::glib;
 use gtk::prelude::*;
 
-const APP_ID: &str = "org.gtk_rs.HelloWorld1";
-
 fn main() -> glib::ExitCode {
     // Create a new application
-    let app = gtk::Application::builder().application_id(APP_ID).build();
+    let app = gtk::Application::builder()
+        .application_id(constants::APP_ID)
+        .build();
 
     app.connect_activate(build_ui);
 
@@ -42,7 +45,7 @@ impl App {
             .build();
 
         window.set_titlebar(Some(&header.container));
-        window.set_title(Some("Thyme"));
+        window.set_title(Some(constants::NAME));
 
         container.set_start_child(Some(&toolbar));
         container.set_end_child(Some(&center));
@@ -69,12 +72,14 @@ impl Header {
     fn new() -> Header {
         let container = gtk::HeaderBar::new();
 
-        let open_btn = gtk::Button::with_label("open");
-        let save_btn = gtk::Button::with_label("save");
-        let save_as_btn = gtk::Button::with_label("save as");
+        let new_btn = gtk::Button::with_label(constants::NEW);
+        let open_btn = gtk::Button::with_label(constants::OPEN);
+        let save_btn = gtk::Button::with_label(constants::SAVE);
+        let save_as_btn = gtk::Button::with_label(constants::SAVE_AS);
 
         open_btn.connect_clicked(Header::do_open);
 
+        container.pack_start(&new_btn);
         container.pack_start(&open_btn);
         container.pack_end(&save_btn);
         container.pack_end(&save_as_btn);

+ 13 - 0
tools/editor/model.rs

@@ -0,0 +1,13 @@
+use std::path::PathBuf;
+
+#[derive(Debug)]
+pub enum Messages {
+    NewFile { width: u32, height: u32 },
+    OpenFile { path: PathBuf },
+    SaveFile,
+    SaveFileAs { path: PathBuf },
+}
+
+pub struct InternalState {
+    open_file: Option<PathBuf>,
+}