Cleaned up Gtk::Application a bit.

This commit is contained in:
Jordan Petridis 2017-10-22 07:45:29 +03:00
parent 02cce8b915
commit 6accae0fbe
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
2 changed files with 9 additions and 22 deletions

View File

@ -40,42 +40,35 @@ fn build_ui(app: &gtk::Application) {
// Get the main window
let window = gtk::ApplicationWindow::new(app);
window.set_default_size(1050, 600);
app.add_window(&window);
// Setup the Stack that will magane the switche between podcasts_view and podcast_widget.
let stack = podcasts_view::setup_stack(&db);
window.add(&stack);
// FIXME:
// GLib-GIO-WARNING **: Your application does not implement g_application_activate()
// and has no handlers connected to the 'activate' signal. It should do one of these.
window.connect_delete_event(|_, _| {
gtk::main_quit();
window.connect_delete_event(|w, _| {
w.destroy();
Inhibit(false)
});
// Get the headerbar
let header = headerbar::get_headerbar(&db, &stack);
// TODO: add delay, cause else theres lock contention for the db obj.
// utils::refresh_db(db.clone(), stack.clone());
window.set_titlebar(&header);
window.show_all();
gtk::main();
window.activate();
app.connect_activate(move |_| ());
}
// Copied from:
// https://github.com/GuillaumeGomez/process-viewer/blob/ \
// ddcb30d01631c0083710cf486caf04c831d38cb7/src/process_viewer.rs#L367
fn main() {
// TODO: make the the logger a cli -vv option
loggerv::init_with_level(LogLevel::Info).unwrap();
hammond_data::init().expect("Hammond Initialazation failed.");
// Not sure if needed.
if gtk::init().is_err() {
info!("Failed to initialize GTK.");
return;
}
let application = gtk::Application::new(
"com.gitlab.alatiera.Hammond",
gio::ApplicationFlags::empty(),
@ -85,11 +78,5 @@ fn main() {
build_ui(app);
});
// Not sure if this will be kept.
let original = ::std::env::args().collect::<Vec<_>>();
let mut tmp = Vec::with_capacity(original.len());
for i in 0..original.len() {
tmp.push(original[i].as_str());
}
application.run(&tmp);
application.run(&[]);
}

View File

@ -84,7 +84,7 @@ fn show_empty_view(stack: &gtk::Stack) {
info!("Empty view.");
}
pub fn pop_flowbox_no_store(
pub fn populate_flowbox_no_store(
db: &Arc<Mutex<SqliteConnection>>,
stack: &gtk::Stack,
flowbox: &gtk::FlowBox,
@ -131,7 +131,7 @@ fn setup_podcasts_grid(db: &Arc<Mutex<SqliteConnection>>, stack: &gtk::Stack) {
let flowbox: gtk::FlowBox = builder.get_object("flowbox").unwrap();
// Populate the flowbox with the Podcasts.
// populate_podcasts_flowbox(db, stack, &flowbox);
pop_flowbox_no_store(db, stack, &flowbox);
populate_flowbox_no_store(db, stack, &flowbox);
}
pub fn setup_stack(db: &Arc<Mutex<SqliteConnection>>) -> gtk::Stack {