[gtk-web: 1/5] code samples: update the rust one per latest bindings changes




commit a970ba2bcdae136ea79a98faf2d1f34693d5c61a
Author: Bilal Elmoussaoui <bil elmoussaoui gmail com>
Date:   Mon May 10 17:11:31 2021 +0200

    code samples: update the rust one per latest bindings changes

 _data/sample_codes.yml | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
---
diff --git a/_data/sample_codes.yml b/_data/sample_codes.yml
index 712c4c9..c26537d 100644
--- a/_data/sample_codes.yml
+++ b/_data/sample_codes.yml
@@ -112,8 +112,9 @@ codes:
     ext: rs
     snippet: |
       ```rust
-      use gio::prelude::*;
       use glib::clone;
+      // glib and other dependencies are re-exported from the gtk crate
+      use gtk::glib;
       use gtk::prelude::*;
 
       // When the application is launched…
@@ -121,20 +122,19 @@ codes:
           // … create a new window …
           let window = gtk::ApplicationWindow::new(application);
           // … with a button in it …
-          let button = gtk::Button::new_with_label("Hello World!");
+          let button = gtk::Button::with_label("Hello World!");
           // … which closes the window when clicked
           button.connect_clicked(clone!(@weak window => move |_| window.close()));
-          window.set_child(&button);
+          window.set_child(Some(&button));
           window.present();
       }
 
       fn main() {
           // Create a new application
-          let app = gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default())
-              .expect("Initialization failed...");
-          app.connect_activate(|app| on_activate(app));
+          let app = gtk::Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default());
+          app.connect_activate(on_activate);
           // Run the application
-          app.run(&std::env::args().collect::<Vec<_>>());
+          app.run();
       }
       ```
   - name: Vala


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]