Cleaned up Gtk::Application a bit.
This commit is contained in:
parent
02cce8b915
commit
6accae0fbe
@ -40,42 +40,35 @@ fn build_ui(app: >k::Application) {
|
|||||||
// Get the main window
|
// Get the main window
|
||||||
let window = gtk::ApplicationWindow::new(app);
|
let window = gtk::ApplicationWindow::new(app);
|
||||||
window.set_default_size(1050, 600);
|
window.set_default_size(1050, 600);
|
||||||
app.add_window(&window);
|
|
||||||
// Setup the Stack that will magane the switche between podcasts_view and podcast_widget.
|
// Setup the Stack that will magane the switche between podcasts_view and podcast_widget.
|
||||||
let stack = podcasts_view::setup_stack(&db);
|
let stack = podcasts_view::setup_stack(&db);
|
||||||
window.add(&stack);
|
window.add(&stack);
|
||||||
|
|
||||||
// FIXME:
|
window.connect_delete_event(|w, _| {
|
||||||
// GLib-GIO-WARNING **: Your application does not implement g_application_activate()
|
w.destroy();
|
||||||
// and has no handlers connected to the 'activate' signal. It should do one of these.
|
|
||||||
window.connect_delete_event(|_, _| {
|
|
||||||
gtk::main_quit();
|
|
||||||
Inhibit(false)
|
Inhibit(false)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the headerbar
|
// Get the headerbar
|
||||||
let header = headerbar::get_headerbar(&db, &stack);
|
let header = headerbar::get_headerbar(&db, &stack);
|
||||||
|
|
||||||
// TODO: add delay, cause else theres lock contention for the db obj.
|
// TODO: add delay, cause else theres lock contention for the db obj.
|
||||||
// utils::refresh_db(db.clone(), stack.clone());
|
// utils::refresh_db(db.clone(), stack.clone());
|
||||||
window.set_titlebar(&header);
|
window.set_titlebar(&header);
|
||||||
|
|
||||||
window.show_all();
|
window.show_all();
|
||||||
gtk::main();
|
window.activate();
|
||||||
|
app.connect_activate(move |_| ());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copied from:
|
// Copied from:
|
||||||
// https://github.com/GuillaumeGomez/process-viewer/blob/ \
|
// https://github.com/GuillaumeGomez/process-viewer/blob/ \
|
||||||
// ddcb30d01631c0083710cf486caf04c831d38cb7/src/process_viewer.rs#L367
|
// ddcb30d01631c0083710cf486caf04c831d38cb7/src/process_viewer.rs#L367
|
||||||
fn main() {
|
fn main() {
|
||||||
|
// TODO: make the the logger a cli -vv option
|
||||||
loggerv::init_with_level(LogLevel::Info).unwrap();
|
loggerv::init_with_level(LogLevel::Info).unwrap();
|
||||||
hammond_data::init().expect("Hammond Initialazation failed.");
|
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(
|
let application = gtk::Application::new(
|
||||||
"com.gitlab.alatiera.Hammond",
|
"com.gitlab.alatiera.Hammond",
|
||||||
gio::ApplicationFlags::empty(),
|
gio::ApplicationFlags::empty(),
|
||||||
@ -85,11 +78,5 @@ fn main() {
|
|||||||
build_ui(app);
|
build_ui(app);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Not sure if this will be kept.
|
application.run(&[]);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -84,7 +84,7 @@ fn show_empty_view(stack: >k::Stack) {
|
|||||||
info!("Empty view.");
|
info!("Empty view.");
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pop_flowbox_no_store(
|
pub fn populate_flowbox_no_store(
|
||||||
db: &Arc<Mutex<SqliteConnection>>,
|
db: &Arc<Mutex<SqliteConnection>>,
|
||||||
stack: >k::Stack,
|
stack: >k::Stack,
|
||||||
flowbox: >k::FlowBox,
|
flowbox: >k::FlowBox,
|
||||||
@ -131,7 +131,7 @@ fn setup_podcasts_grid(db: &Arc<Mutex<SqliteConnection>>, stack: >k::Stack) {
|
|||||||
let flowbox: gtk::FlowBox = builder.get_object("flowbox").unwrap();
|
let flowbox: gtk::FlowBox = builder.get_object("flowbox").unwrap();
|
||||||
// Populate the flowbox with the Podcasts.
|
// Populate the flowbox with the Podcasts.
|
||||||
// populate_podcasts_flowbox(db, stack, &flowbox);
|
// 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 {
|
pub fn setup_stack(db: &Arc<Mutex<SqliteConnection>>) -> gtk::Stack {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user