|
@@ -1,21 +1,11 @@
|
|
|
-use anyhow::{Result, bail, anyhow};
|
|
|
+use anyhow::{anyhow, bail, Result};
|
|
|
+use gio::prelude::{ApplicationExt, ApplicationExtManual};
|
|
|
use gtk::{
|
|
|
- Application,
|
|
|
- ApplicationWindow,
|
|
|
- Button,
|
|
|
- GtkWindowExt,
|
|
|
+ Application, ApplicationWindow, BoxExt, Button, ButtonExt, ContainerExt, GtkWindowExt,
|
|
|
WidgetExt,
|
|
|
- ContainerExt,
|
|
|
- ButtonExt,
|
|
|
- BoxExt,
|
|
|
};
|
|
|
-use gio::prelude::{
|
|
|
- ApplicationExt,
|
|
|
- ApplicationExtManual,
|
|
|
-};
|
|
|
-use std::rc::Rc;
|
|
|
use std::cell::RefCell;
|
|
|
-
|
|
|
+use std::rc::Rc;
|
|
|
|
|
|
struct AppData {
|
|
|
symbol: char,
|
|
@@ -25,11 +15,7 @@ struct AppData {
|
|
|
impl AppData {
|
|
|
fn draw_to_file(&self) -> Result<()> {
|
|
|
let f = std::fs::File::create("samp.svg")?;
|
|
|
- let surf = cairo::SvgSurface::for_stream(
|
|
|
- 100.0,
|
|
|
- 100.0,
|
|
|
- f,
|
|
|
- )?;
|
|
|
+ let surf = cairo::SvgSurface::for_stream(100.0, 100.0, f)?;
|
|
|
self.render(&cairo::Context::new(&surf))?;
|
|
|
if let Err(err) = surf.finish_output_stream() {
|
|
|
bail!(err.error);
|
|
@@ -44,7 +30,8 @@ impl AppData {
|
|
|
ctx.set_source_rgb(0., 0., 0.);
|
|
|
|
|
|
ctx.move_to(0.0, -23.0);
|
|
|
- let layout = pangocairo::functions::create_layout(&ctx).ok_or_else(|| anyhow!("Could not create layout"))?;
|
|
|
+ let layout = pangocairo::functions::create_layout(&ctx)
|
|
|
+ .ok_or_else(|| anyhow!("Could not create layout"))?;
|
|
|
layout.set_width(100 * 1024);
|
|
|
layout.set_alignment(pango::Alignment::Center);
|
|
|
let font = pango::FontDescription::from_string("Fira Sans 92");
|
|
@@ -119,10 +106,9 @@ fn mk_icon_choice(choice: char, cell: App) -> gtk::Button {
|
|
|
}
|
|
|
|
|
|
fn main() {
|
|
|
- let application = Application::new(
|
|
|
- Some("com.github.gtk-rs.examples.basic"),
|
|
|
- Default::default(),
|
|
|
- ).expect("failed to initialize GTK application");
|
|
|
+ let application =
|
|
|
+ Application::new(Some("com.github.gtk-rs.examples.basic"), Default::default())
|
|
|
+ .expect("failed to initialize GTK application");
|
|
|
|
|
|
application.connect_activate(|app| {
|
|
|
mk_app(app);
|