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 e24fe71 commit 35b2375
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/main_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ impl MainWindow {
self.window.set_application(Some(&application));
}

self.build_system_menu(connection);
self.build_menus(connection);

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

Expand Down Expand Up @@ -174,25 +174,39 @@ impl MainWindow {
});
}

fn build_system_menu(&mut self, connection: Arc<Mutex<Connection>>) {
fn build_menus(&mut self, connection: Arc<Mutex<Connection>>) {
let titlebar = gtk::HeaderBarBuilder::new()
.show_close_button(true)
.title("Authenticator RS")
.build();

let connection = connection.clone();
{
let connection = connection.clone();
titlebar.pack_start(&self.build_action_menu(connection));
}

titlebar.pack_end(&self.build_system_menu());
self.window.set_titlebar(Some(&titlebar));

titlebar.show_all();
}

fn build_system_menu(&mut self) -> gtk::MenuButton {
let menu_width = 130_i32;

let popover = gtk::PopoverMenuBuilder::new()
.position(PositionType::Bottom)
.build();

let buttons_container = gtk::BoxBuilder::new()
.orientation(Orientation::Vertical)
.width_request(menu_width)
.hexpand(true)
.build();

let about_button = gtk::ButtonBuilder::new()
.label("About")
.hexpand(true)
.hexpand_set(true)
.margin(3)
.build();
Expand Down Expand Up @@ -233,16 +247,12 @@ impl MainWindow {
popup.set_visible(true);
popup.show_all();
});
}
};

titlebar.pack_start(&self.action_menu(connection));
titlebar.pack_end(&system_menu);
self.window.set_titlebar(Some(&titlebar));

titlebar.show_all();
system_menu
}

fn action_menu(&mut self, connection: Arc<Mutex<Connection>>) -> gtk::MenuButton {
fn build_action_menu(&mut self, connection: Arc<Mutex<Connection>>) -> gtk::MenuButton {
let add_image = gtk::ImageBuilder::new().icon_name("list-add").build();

let popover = gtk::PopoverMenuBuilder::new()
Expand Down Expand Up @@ -395,7 +405,7 @@ async fn progress_bar_interval(tx: Sender<u8>) {
}

fn about_popup_close(popup: gtk::Window) -> Box<dyn Fn(&[glib::Value]) -> Option<glib::Value>> {
Box::new(move |param: &[glib::Value]| {
Box::new(move |_param: &[glib::Value]| {
popup.hide();
None
})
Expand Down

0 comments on commit 35b2375

Please sign in to comment.