Skip to content

Commit

Permalink
Gresource
Browse files Browse the repository at this point in the history
  • Loading branch information
gr211 committed Jun 24, 2020
1 parent e42ee0c commit e24fe71
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
26 changes: 20 additions & 6 deletions src/main_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ impl MainWindow {
let window: gtk::ApplicationWindow = builder.get_object("main_window").unwrap();
let popup: gtk::Window = builder.get_object("about_popup").unwrap();

builder.connect_signals(|_, handler_name| {
match handler_name {
// handler_name as defined in the glade file
"about_popup_close" => {
let popup = popup.clone();
Box::new(about_popup_close(popup))
}
_ => Box::new(|_| None),
}
});

MainWindow {
window,
popup,
Expand Down Expand Up @@ -108,7 +119,7 @@ impl MainWindow {
self.window.set_application(Some(&application));
}

self.build_system_menu(application, connection);
self.build_system_menu(connection);

self.window.connect_delete_event(|_, _| Inhibit(false));

Expand Down Expand Up @@ -163,11 +174,7 @@ impl MainWindow {
});
}

fn build_system_menu(
&mut self,
application: &gtk::Application,
connection: Arc<Mutex<Connection>>,
) {
fn build_system_menu(&mut self, connection: Arc<Mutex<Connection>>) {
let titlebar = gtk::HeaderBarBuilder::new()
.show_close_button(true)
.title("Authenticator RS")
Expand Down Expand Up @@ -386,3 +393,10 @@ async fn progress_bar_interval(tx: Sender<u8>) {
.expect("Couldn't send data to channel");
}
}

fn about_popup_close(popup: gtk::Window) -> Box<dyn Fn(&[glib::Value]) -> Option<glib::Value>> {
Box::new(move |param: &[glib::Value]| {
popup.hide();
None
})
}
2 changes: 1 addition & 1 deletion src/mainwindow.glade
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@
<property name="width_request">400</property>
<property name="height_request">320</property>
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
Expand Down Expand Up @@ -574,6 +573,7 @@
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="image">about_close_button_image</property>
<signal name="clicked" handler="about_popup_close" swapped="no"/>
</object>
<packing>
<property name="left_attach">0</property>
Expand Down

0 comments on commit e24fe71

Please sign in to comment.