diff --git a/hammond-gtk/src/headerbar.rs b/hammond-gtk/src/headerbar.rs
index f5472b0..58e4a19 100644
--- a/hammond-gtk/src/headerbar.rs
+++ b/hammond-gtk/src/headerbar.rs
@@ -7,24 +7,6 @@ use hammond_data::index_feed::Database;
use podcasts_view::update_podcasts_view;
use utils;
-// http://gtk-rs.org/tuto/closures
-macro_rules! clone {
- (@param _) => ( _ );
- (@param $x:ident) => ( $x );
- ($($n:ident),+ => move || $body:expr) => (
- {
- $( let $n = $n.clone(); )+
- move || $body
- }
- );
- ($($n:ident),+ => move |$($p:tt),+| $body:expr) => (
- {
- $( let $n = $n.clone(); )+
- move |$(clone!(@param $p),)+| $body
- }
- );
-}
-
pub fn get_headerbar(db: &Database, stack: >k::Stack) -> gtk::HeaderBar {
let builder = include_str!("../gtk/headerbar.ui");
let builder = gtk::Builder::new_from_string(builder);
diff --git a/hammond-gtk/src/main.rs b/hammond-gtk/src/main.rs
index 3d19ebb..78b1950 100644
--- a/hammond-gtk/src/main.rs
+++ b/hammond-gtk/src/main.rs
@@ -21,6 +21,25 @@ use std::sync::{Arc, Mutex};
use gtk::prelude::*;
use gio::{ActionMapExt, ApplicationExt, MenuExt, SimpleActionExt};
+// http://gtk-rs.org/tuto/closures
+#[macro_export]
+macro_rules! clone {
+ (@param _) => ( _ );
+ (@param $x:ident) => ( $x );
+ ($($n:ident),+ => move || $body:expr) => (
+ {
+ $( let $n = $n.clone(); )+
+ move || $body
+ }
+ );
+ ($($n:ident),+ => move |$($p:tt),+| $body:expr) => (
+ {
+ $( let $n = $n.clone(); )+
+ move |$(clone!(@param $p),)+| $body
+ }
+ );
+}
+
mod views;
mod widgets;
mod headerbar;
@@ -62,18 +81,15 @@ fn build_ui(app: >k::Application) {
app.add_action(&quit);
// Setup the dbcheckup in the app menu.
- let db2 = Arc::clone(&db);
let check = gio::SimpleAction::new("check", None);
- check.connect_activate(move |_, _| {
- let _ = dbcheckup::run(&db2);
- });
+ check.connect_activate(clone!(db => move |_, _| {
+ let _ = dbcheckup::run(&db);
+ }));
app.add_action(&check);
// Get the headerbar
let header = headerbar::get_headerbar(&db, &stack);
- // TODO: add delay, cause else there's lock contention for the db obj.
- // utils::refresh_db(db.clone(), stack.clone());
window.set_titlebar(&header);
window.show_all();
diff --git a/hammond-gtk/src/utils.rs b/hammond-gtk/src/utils.rs
index ad907fe..cdd6067 100644
--- a/hammond-gtk/src/utils.rs
+++ b/hammond-gtk/src/utils.rs
@@ -13,24 +13,6 @@ use std::sync::mpsc::{channel, Receiver};
use views::podcasts_view;
-// http://gtk-rs.org/tuto/closures
-macro_rules! clone {
- (@param _) => ( _ );
- (@param $x:ident) => ( $x );
- ($($n:ident),+ => move || $body:expr) => (
- {
- $( let $n = $n.clone(); )+
- move || $body
- }
- );
- ($($n:ident),+ => move |$($p:tt),+| $body:expr) => (
- {
- $( let $n = $n.clone(); )+
- move |$(clone!(@param $p),)+| $body
- }
- );
-}
-
// Create a thread local storage that will store the arguments to be transfered.
thread_local!(
static GLOBAL: RefCell