static gboolean mu_guile_init_instance (const char *muhome) { MuStore *store; MuQuery *query; GError *err; setlocale (LC_ALL, ""); if (!mu_runtime_init (muhome, "guile")) return FALSE; store = mu_store_new_read_only (mu_runtime_path(MU_RUNTIME_PATH_XAPIANDB), &err); if (!store) { mu_guile_g_error (__FUNCTION__, err); g_clear_error (&err); return FALSE; } query = mu_query_new (store, &err); mu_store_unref (store); if (!query) { mu_guile_g_error (__FUNCTION__, err); g_clear_error (&err); return FALSE; } _singleton = g_new0 (MuGuile, 1); _singleton->query = query; return TRUE; }
int main (int argc, char *argv[]) { MugData mugdata; GtkWidget *mugshell; GOptionContext *octx; GOptionEntry entries[] = { {"muhome", 0, 0, G_OPTION_ARG_FILENAME, &mugdata.muhome, "specify an alternative mu directory", NULL}, {NULL, 0, 0, G_OPTION_ARG_NONE, NULL, NULL, NULL} /* sentinel */ }; gtk_init (&argc, &argv); octx = g_option_context_new ("- mug options"); g_option_context_add_main_entries (octx, entries, "Mug"); memset (&mugdata, 0, sizeof (MugData)); if (!g_option_context_parse (octx, &argc, &argv, NULL)) { g_option_context_free (octx); g_printerr ("mug: error in options\n"); return 1; } g_option_context_free (octx); mu_runtime_init (mugdata.muhome, "mug"); mugshell = mug_shell (&mugdata); g_signal_connect (G_OBJECT (mugshell), "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (G_OBJECT (mugshell), "key_release_event", G_CALLBACK ( on_focus_query_bar ), (gpointer)&mugdata ); gtk_widget_show (mugshell); mug_query_bar_grab_focus (MUG_QUERY_BAR (mugdata.querybar)); gtk_main (); g_free (mugdata.muhome); mu_runtime_uninit (); return 0; }